@workday/canvas-kit-react 5.3.2 → 5.3.3

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.
@@ -37,6 +37,14 @@ export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
37
37
  * @default 'label'
38
38
  */
39
39
  type?: 'label' | 'describe' | 'muted';
40
+ /**
41
+ * Amount of time (in ms) to delay before showing the tooltip
42
+ */
43
+ showDelay?: number;
44
+ /**
45
+ * Amount of time (in ms) to delay before hiding the tooltip
46
+ */
47
+ hideDelay?: number;
40
48
  }
41
- export declare const Tooltip: ({ type, placement, title, children, ...elemProps }: TooltipProps) => JSX.Element;
49
+ export declare const Tooltip: ({ type, placement, title, children, showDelay, hideDelay, ...elemProps }: TooltipProps) => JSX.Element;
42
50
  //# sourceMappingURL=Tooltip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../tooltip/lib/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAA4B,SAAS,EAAS,MAAM,iCAAiC,CAAC;AAM7F,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IACvF;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB;;;;;;;OAOG;IACH,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;CACvC;AAiBD,eAAO,MAAM,OAAO,mFA+BnB,CAAC"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../tooltip/lib/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAA4B,SAAS,EAAS,MAAM,iCAAiC,CAAC;AAM7F,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IACvF;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB;;;;;;;OAOG;IACH,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;IACtC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAiBD,eAAO,MAAM,OAAO,yGAsCnB,CAAC"}
@@ -51,9 +51,14 @@ function mergeCallbacks(elemProps, componentProps, keys) {
51
51
  }, {});
52
52
  }
53
53
  exports.Tooltip = function (_a) {
54
- var _b = _a.type, type = _b === void 0 ? 'label' : _b, _c = _a.placement, placement = _c === void 0 ? 'top' : _c, title = _a.title, children = _a.children, elemProps = __rest(_a, ["type", "placement", "title", "children"]);
54
+ var _b = _a.type, type = _b === void 0 ? 'label' : _b, _c = _a.placement, placement = _c === void 0 ? 'top' : _c, title = _a.title, children = _a.children, _d = _a.showDelay, showDelay = _d === void 0 ? 300 : _d, _e = _a.hideDelay, hideDelay = _e === void 0 ? 100 : _e, elemProps = __rest(_a, ["type", "placement", "title", "children", "showDelay", "hideDelay"]);
55
55
  var titleText = react_innertext_1.default(title);
56
- var _d = useTooltip_1.useTooltip({ type: type, titleText: titleText }), targetProps = _d.targetProps, popperProps = _d.popperProps, tooltipProps = _d.tooltipProps;
56
+ var _f = useTooltip_1.useTooltip({
57
+ type: type,
58
+ titleText: titleText,
59
+ showDelay: showDelay,
60
+ hideDelay: hideDelay,
61
+ }), targetProps = _f.targetProps, popperProps = _f.popperProps, tooltipProps = _f.tooltipProps;
57
62
  return (React.createElement(React.Fragment, null,
58
63
  React.cloneElement(children, __assign(__assign(__assign({}, targetProps), mergeCallbacks(children.props, targetProps)), (type === 'muted' && children.props['aria-label']
59
64
  ? { 'aria-label': children.props['aria-label'] }
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  * Convenience hook for creating components with tooltips. It will return an object of properties to mix
4
4
  * into a target, popper and tooltip
5
5
  */
6
- export declare function useTooltip<T extends Element = Element>({ type, titleText, }?: {
6
+ export declare function useTooltip<T extends Element = Element>({ type, titleText, showDelay, hideDelay, }?: {
7
7
  /**
8
8
  * Determines the tooltip type for accessibility.
9
9
  *
@@ -25,6 +25,14 @@ export declare function useTooltip<T extends Element = Element>({ type, titleTex
25
25
  * The content of the `aria-label` if `type` is `label.
26
26
  */
27
27
  titleText?: string;
28
+ /**
29
+ * Amount of time (in ms) to delay before showing the tooltip
30
+ */
31
+ showDelay?: number;
32
+ /**
33
+ * Amount of time (in ms) to delay before hiding the tooltip
34
+ */
35
+ hideDelay?: number;
28
36
  }): {
29
37
  /** Mix these properties into the target element. **Must be an Element** */
30
38
  targetProps: {
@@ -1 +1 @@
1
- {"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../../../tooltip/lib/useTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAiD/B;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,EACtD,IAAc,EACd,SAAc,GACf,GAAE;IACD;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;IACtC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACf;IAuCF,2EAA2E;;;;;;;;;;IAY3E,uDAAuD;;;;;;IAMvD,iEAAiE;;;;;;;EAQpE"}
1
+ {"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../../../tooltip/lib/useTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAiD/B;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,EACtD,IAAc,EACd,SAAc,EACd,SAAe,EACf,SAAe,GAChB,GAAE;IACD;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;IACtC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACf;IA4CF,2EAA2E;;;;;;;;;;IAY3E,uDAAuD;;;;;;IAMvD,iEAAiE;;;;;;;EAQpE"}
@@ -53,15 +53,20 @@ var isInteractiveElement = function (element) {
53
53
  * into a target, popper and tooltip
54
54
  */
55
55
  function useTooltip(_a) {
56
- var _b = _a === void 0 ? {} : _a, _c = _b.type, type = _c === void 0 ? 'label' : _c, _d = _b.titleText, titleText = _d === void 0 ? '' : _d;
56
+ var _b = _a === void 0 ? {} : _a, _c = _b.type, type = _c === void 0 ? 'label' : _c, _d = _b.titleText, titleText = _d === void 0 ? '' : _d, _e = _b.showDelay, showDelay = _e === void 0 ? 300 : _e, _f = _b.hideDelay, hideDelay = _f === void 0 ? 100 : _f;
57
57
  var mouseDownRef = React.useRef(false); // use to prevent newly focused from making tooltip flash
58
58
  var popupModel = popup_1.usePopupModel();
59
- var _e = React.useState(null), anchorElement = _e[0], setAnchorElement = _e[1];
59
+ var _g = React.useState(null), anchorElement = _g[0], setAnchorElement = _g[1];
60
60
  var id = React.useState(function () { return v4_1.default(); })[0];
61
- var intentTimer = useIntentTimer(popupModel.events.hide, 100);
61
+ var intentTimerHide = useIntentTimer(popupModel.events.hide, hideDelay);
62
+ var intentTimerShow = useIntentTimer(popupModel.events.show, showDelay);
63
+ var onHide = function () {
64
+ intentTimerHide.start();
65
+ intentTimerShow.clear();
66
+ };
62
67
  var onOpen = function () {
63
- popupModel.events.show();
64
- intentTimer.clear();
68
+ intentTimerShow.start();
69
+ intentTimerHide.clear();
65
70
  };
66
71
  var onOpenFromTarget = function (event) {
67
72
  setAnchorElement(event.currentTarget);
@@ -90,10 +95,10 @@ function useTooltip(_a) {
90
95
  // This will replace the accessible name of the target element
91
96
  'aria-label': type === 'label' ? titleText : undefined,
92
97
  onMouseEnter: onOpenFromTarget,
93
- onMouseLeave: intentTimer.start,
98
+ onMouseLeave: onHide,
94
99
  onMouseDown: onMouseDown,
95
100
  onFocus: onFocus,
96
- onBlur: intentTimer.start,
101
+ onBlur: onHide,
97
102
  },
98
103
  /** Mix these properties into the `Popper` component */
99
104
  popperProps: {
@@ -106,7 +111,7 @@ function useTooltip(_a) {
106
111
  id: type === 'describe' && visible ? id : undefined,
107
112
  role: 'tooltip',
108
113
  onMouseEnter: onOpen,
109
- onMouseLeave: intentTimer.start,
114
+ onMouseLeave: onHide,
110
115
  },
111
116
  };
112
117
  }
@@ -37,6 +37,14 @@ export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
37
37
  * @default 'label'
38
38
  */
39
39
  type?: 'label' | 'describe' | 'muted';
40
+ /**
41
+ * Amount of time (in ms) to delay before showing the tooltip
42
+ */
43
+ showDelay?: number;
44
+ /**
45
+ * Amount of time (in ms) to delay before hiding the tooltip
46
+ */
47
+ hideDelay?: number;
40
48
  }
41
- export declare const Tooltip: ({ type, placement, title, children, ...elemProps }: TooltipProps) => JSX.Element;
49
+ export declare const Tooltip: ({ type, placement, title, children, showDelay, hideDelay, ...elemProps }: TooltipProps) => JSX.Element;
42
50
  //# sourceMappingURL=Tooltip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../tooltip/lib/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAA4B,SAAS,EAAS,MAAM,iCAAiC,CAAC;AAM7F,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IACvF;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB;;;;;;;OAOG;IACH,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;CACvC;AAiBD,eAAO,MAAM,OAAO,mFA+BnB,CAAC"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../tooltip/lib/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAA4B,SAAS,EAAS,MAAM,iCAAiC,CAAC;AAM7F,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IACvF;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB;;;;;;;OAOG;IACH,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;IACtC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAiBD,eAAO,MAAM,OAAO,yGAsCnB,CAAC"}
@@ -39,9 +39,14 @@ function mergeCallbacks(elemProps, componentProps, keys) {
39
39
  }, {});
40
40
  }
41
41
  export var Tooltip = function (_a) {
42
- var _b = _a.type, type = _b === void 0 ? 'label' : _b, _c = _a.placement, placement = _c === void 0 ? 'top' : _c, title = _a.title, children = _a.children, elemProps = __rest(_a, ["type", "placement", "title", "children"]);
42
+ var _b = _a.type, type = _b === void 0 ? 'label' : _b, _c = _a.placement, placement = _c === void 0 ? 'top' : _c, title = _a.title, children = _a.children, _d = _a.showDelay, showDelay = _d === void 0 ? 300 : _d, _e = _a.hideDelay, hideDelay = _e === void 0 ? 100 : _e, elemProps = __rest(_a, ["type", "placement", "title", "children", "showDelay", "hideDelay"]);
43
43
  var titleText = innerText(title);
44
- var _d = useTooltip({ type: type, titleText: titleText }), targetProps = _d.targetProps, popperProps = _d.popperProps, tooltipProps = _d.tooltipProps;
44
+ var _f = useTooltip({
45
+ type: type,
46
+ titleText: titleText,
47
+ showDelay: showDelay,
48
+ hideDelay: hideDelay,
49
+ }), targetProps = _f.targetProps, popperProps = _f.popperProps, tooltipProps = _f.tooltipProps;
45
50
  return (React.createElement(React.Fragment, null,
46
51
  React.cloneElement(children, __assign(__assign(__assign({}, targetProps), mergeCallbacks(children.props, targetProps)), (type === 'muted' && children.props['aria-label']
47
52
  ? { 'aria-label': children.props['aria-label'] }
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  * Convenience hook for creating components with tooltips. It will return an object of properties to mix
4
4
  * into a target, popper and tooltip
5
5
  */
6
- export declare function useTooltip<T extends Element = Element>({ type, titleText, }?: {
6
+ export declare function useTooltip<T extends Element = Element>({ type, titleText, showDelay, hideDelay, }?: {
7
7
  /**
8
8
  * Determines the tooltip type for accessibility.
9
9
  *
@@ -25,6 +25,14 @@ export declare function useTooltip<T extends Element = Element>({ type, titleTex
25
25
  * The content of the `aria-label` if `type` is `label.
26
26
  */
27
27
  titleText?: string;
28
+ /**
29
+ * Amount of time (in ms) to delay before showing the tooltip
30
+ */
31
+ showDelay?: number;
32
+ /**
33
+ * Amount of time (in ms) to delay before hiding the tooltip
34
+ */
35
+ hideDelay?: number;
28
36
  }): {
29
37
  /** Mix these properties into the target element. **Must be an Element** */
30
38
  targetProps: {
@@ -1 +1 @@
1
- {"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../../../tooltip/lib/useTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAiD/B;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,EACtD,IAAc,EACd,SAAc,GACf,GAAE;IACD;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;IACtC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACf;IAuCF,2EAA2E;;;;;;;;;;IAY3E,uDAAuD;;;;;;IAMvD,iEAAiE;;;;;;;EAQpE"}
1
+ {"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../../../tooltip/lib/useTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAiD/B;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,EACtD,IAAc,EACd,SAAc,EACd,SAAe,EACf,SAAe,GAChB,GAAE;IACD;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;IACtC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACf;IA4CF,2EAA2E;;;;;;;;;;IAY3E,uDAAuD;;;;;;IAMvD,iEAAiE;;;;;;;EAQpE"}
@@ -41,15 +41,20 @@ var isInteractiveElement = function (element) {
41
41
  * into a target, popper and tooltip
42
42
  */
43
43
  export function useTooltip(_a) {
44
- var _b = _a === void 0 ? {} : _a, _c = _b.type, type = _c === void 0 ? 'label' : _c, _d = _b.titleText, titleText = _d === void 0 ? '' : _d;
44
+ var _b = _a === void 0 ? {} : _a, _c = _b.type, type = _c === void 0 ? 'label' : _c, _d = _b.titleText, titleText = _d === void 0 ? '' : _d, _e = _b.showDelay, showDelay = _e === void 0 ? 300 : _e, _f = _b.hideDelay, hideDelay = _f === void 0 ? 100 : _f;
45
45
  var mouseDownRef = React.useRef(false); // use to prevent newly focused from making tooltip flash
46
46
  var popupModel = usePopupModel();
47
- var _e = React.useState(null), anchorElement = _e[0], setAnchorElement = _e[1];
47
+ var _g = React.useState(null), anchorElement = _g[0], setAnchorElement = _g[1];
48
48
  var id = React.useState(function () { return uuid(); })[0];
49
- var intentTimer = useIntentTimer(popupModel.events.hide, 100);
49
+ var intentTimerHide = useIntentTimer(popupModel.events.hide, hideDelay);
50
+ var intentTimerShow = useIntentTimer(popupModel.events.show, showDelay);
51
+ var onHide = function () {
52
+ intentTimerHide.start();
53
+ intentTimerShow.clear();
54
+ };
50
55
  var onOpen = function () {
51
- popupModel.events.show();
52
- intentTimer.clear();
56
+ intentTimerShow.start();
57
+ intentTimerHide.clear();
53
58
  };
54
59
  var onOpenFromTarget = function (event) {
55
60
  setAnchorElement(event.currentTarget);
@@ -78,10 +83,10 @@ export function useTooltip(_a) {
78
83
  // This will replace the accessible name of the target element
79
84
  'aria-label': type === 'label' ? titleText : undefined,
80
85
  onMouseEnter: onOpenFromTarget,
81
- onMouseLeave: intentTimer.start,
86
+ onMouseLeave: onHide,
82
87
  onMouseDown: onMouseDown,
83
88
  onFocus: onFocus,
84
- onBlur: intentTimer.start,
89
+ onBlur: onHide,
85
90
  },
86
91
  /** Mix these properties into the `Popper` component */
87
92
  popperProps: {
@@ -94,7 +99,7 @@ export function useTooltip(_a) {
94
99
  id: type === 'describe' && visible ? id : undefined,
95
100
  role: 'tooltip',
96
101
  onMouseEnter: onOpen,
97
- onMouseLeave: intentTimer.start,
102
+ onMouseLeave: onHide,
98
103
  },
99
104
  };
100
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "5.3.2",
3
+ "version": "5.3.3",
4
4
  "description": "The parent module that contains all Workday Canvas Kit React components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -57,9 +57,9 @@
57
57
  "@popperjs/core": "^2.5.4",
58
58
  "@workday/canvas-colors-web": "^2.0.0",
59
59
  "@workday/canvas-depth-web": "^0.16.4",
60
- "@workday/canvas-kit-labs-react": "^5.3.2",
61
- "@workday/canvas-kit-popup-stack": "^5.3.2",
62
- "@workday/canvas-kit-preview-react": "^5.3.2",
60
+ "@workday/canvas-kit-labs-react": "^5.3.3",
61
+ "@workday/canvas-kit-popup-stack": "^5.3.3",
62
+ "@workday/canvas-kit-preview-react": "^5.3.3",
63
63
  "@workday/canvas-system-icons-web": "1.0.41",
64
64
  "@workday/design-assets-types": "^0.2.4",
65
65
  "chroma-js": "^2.1.0",
@@ -75,5 +75,5 @@
75
75
  "@workday/canvas-accent-icons-web": "^1.0.0",
76
76
  "@workday/canvas-applet-icons-web": "^0.17.50"
77
77
  },
78
- "gitHead": "b6506c1b24e744ab5e132a16d6f4187be6dc6e2a"
78
+ "gitHead": "a7a2e0b0ba0e84487df0113fba21b4f22dcd38e9"
79
79
  }
@@ -44,6 +44,14 @@ export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
44
44
  * @default 'label'
45
45
  */
46
46
  type?: 'label' | 'describe' | 'muted';
47
+ /**
48
+ * Amount of time (in ms) to delay before showing the tooltip
49
+ */
50
+ showDelay?: number;
51
+ /**
52
+ * Amount of time (in ms) to delay before hiding the tooltip
53
+ */
54
+ hideDelay?: number;
47
55
  }
48
56
 
49
57
  function mergeCallbacks<T extends {[key: string]: any}>(
@@ -66,10 +74,17 @@ export const Tooltip = ({
66
74
  placement = 'top',
67
75
  title,
68
76
  children,
77
+ showDelay = 300,
78
+ hideDelay = 100,
69
79
  ...elemProps
70
80
  }: TooltipProps) => {
71
81
  const titleText = innerText(title);
72
- const {targetProps, popperProps, tooltipProps} = useTooltip({type, titleText});
82
+ const {targetProps, popperProps, tooltipProps} = useTooltip({
83
+ type,
84
+ titleText,
85
+ showDelay,
86
+ hideDelay,
87
+ });
73
88
 
74
89
  return (
75
90
  <React.Fragment>
@@ -54,6 +54,8 @@ const isInteractiveElement = (element: Element) => {
54
54
  export function useTooltip<T extends Element = Element>({
55
55
  type = 'label',
56
56
  titleText = '',
57
+ showDelay = 300,
58
+ hideDelay = 100,
57
59
  }: {
58
60
  /**
59
61
  * Determines the tooltip type for accessibility.
@@ -76,17 +78,30 @@ export function useTooltip<T extends Element = Element>({
76
78
  * The content of the `aria-label` if `type` is `label.
77
79
  */
78
80
  titleText?: string;
81
+ /**
82
+ * Amount of time (in ms) to delay before showing the tooltip
83
+ */
84
+ showDelay?: number;
85
+ /**
86
+ * Amount of time (in ms) to delay before hiding the tooltip
87
+ */
88
+ hideDelay?: number;
79
89
  } = {}) {
80
90
  const mouseDownRef = React.useRef(false); // use to prevent newly focused from making tooltip flash
81
91
  const popupModel = usePopupModel();
82
92
  const [anchorElement, setAnchorElement] = React.useState<T | null>(null);
83
93
  const [id] = React.useState(() => uuid());
94
+ const intentTimerHide = useIntentTimer(popupModel.events.hide, hideDelay);
95
+ const intentTimerShow = useIntentTimer(popupModel.events.show, showDelay);
84
96
 
85
- const intentTimer = useIntentTimer(popupModel.events.hide, 100);
97
+ const onHide = () => {
98
+ intentTimerHide.start();
99
+ intentTimerShow.clear();
100
+ };
86
101
 
87
102
  const onOpen = () => {
88
- popupModel.events.show();
89
- intentTimer.clear();
103
+ intentTimerShow.start();
104
+ intentTimerHide.clear();
90
105
  };
91
106
 
92
107
  const onOpenFromTarget = (event: React.SyntheticEvent) => {
@@ -122,10 +137,10 @@ export function useTooltip<T extends Element = Element>({
122
137
  // This will replace the accessible name of the target element
123
138
  'aria-label': type === 'label' ? titleText : undefined,
124
139
  onMouseEnter: onOpenFromTarget,
125
- onMouseLeave: intentTimer.start,
140
+ onMouseLeave: onHide,
126
141
  onMouseDown,
127
142
  onFocus,
128
- onBlur: intentTimer.start,
143
+ onBlur: onHide,
129
144
  },
130
145
  /** Mix these properties into the `Popper` component */
131
146
  popperProps: {
@@ -138,7 +153,7 @@ export function useTooltip<T extends Element = Element>({
138
153
  id: type === 'describe' && visible ? id : undefined,
139
154
  role: 'tooltip',
140
155
  onMouseEnter: onOpen,
141
- onMouseLeave: intentTimer.start,
156
+ onMouseLeave: onHide,
142
157
  },
143
158
  };
144
159
  }
@@ -37,6 +37,14 @@ export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
37
37
  * @default 'label'
38
38
  */
39
39
  type?: 'label' | 'describe' | 'muted';
40
+ /**
41
+ * Amount of time (in ms) to delay before showing the tooltip
42
+ */
43
+ showDelay?: number;
44
+ /**
45
+ * Amount of time (in ms) to delay before hiding the tooltip
46
+ */
47
+ hideDelay?: number;
40
48
  }
41
- export declare const Tooltip: ({ type, placement, title, children, ...elemProps }: TooltipProps) => JSX.Element;
49
+ export declare const Tooltip: ({ type, placement, title, children, showDelay, hideDelay, ...elemProps }: TooltipProps) => JSX.Element;
42
50
  //# sourceMappingURL=Tooltip.d.ts.map
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  * Convenience hook for creating components with tooltips. It will return an object of properties to mix
4
4
  * into a target, popper and tooltip
5
5
  */
6
- export declare function useTooltip<T extends Element = Element>({ type, titleText, }?: {
6
+ export declare function useTooltip<T extends Element = Element>({ type, titleText, showDelay, hideDelay, }?: {
7
7
  /**
8
8
  * Determines the tooltip type for accessibility.
9
9
  *
@@ -25,6 +25,14 @@ export declare function useTooltip<T extends Element = Element>({ type, titleTex
25
25
  * The content of the `aria-label` if `type` is `label.
26
26
  */
27
27
  titleText?: string;
28
+ /**
29
+ * Amount of time (in ms) to delay before showing the tooltip
30
+ */
31
+ showDelay?: number;
32
+ /**
33
+ * Amount of time (in ms) to delay before hiding the tooltip
34
+ */
35
+ hideDelay?: number;
28
36
  }): {
29
37
  /** Mix these properties into the target element. **Must be an Element** */
30
38
  targetProps: {
@@ -37,6 +37,14 @@ export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
37
37
  * @default 'label'
38
38
  */
39
39
  type?: 'label' | 'describe' | 'muted';
40
+ /**
41
+ * Amount of time (in ms) to delay before showing the tooltip
42
+ */
43
+ showDelay?: number;
44
+ /**
45
+ * Amount of time (in ms) to delay before hiding the tooltip
46
+ */
47
+ hideDelay?: number;
40
48
  }
41
- export declare const Tooltip: ({ type, placement, title, children, ...elemProps }: TooltipProps) => JSX.Element;
49
+ export declare const Tooltip: ({ type, placement, title, children, showDelay, hideDelay, ...elemProps }: TooltipProps) => JSX.Element;
42
50
  //# sourceMappingURL=Tooltip.d.ts.map
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  * Convenience hook for creating components with tooltips. It will return an object of properties to mix
4
4
  * into a target, popper and tooltip
5
5
  */
6
- export declare function useTooltip<T extends Element = Element>({ type, titleText, }?: {
6
+ export declare function useTooltip<T extends Element = Element>({ type, titleText, showDelay, hideDelay, }?: {
7
7
  /**
8
8
  * Determines the tooltip type for accessibility.
9
9
  *
@@ -25,6 +25,14 @@ export declare function useTooltip<T extends Element = Element>({ type, titleTex
25
25
  * The content of the `aria-label` if `type` is `label.
26
26
  */
27
27
  titleText?: string;
28
+ /**
29
+ * Amount of time (in ms) to delay before showing the tooltip
30
+ */
31
+ showDelay?: number;
32
+ /**
33
+ * Amount of time (in ms) to delay before hiding the tooltip
34
+ */
35
+ hideDelay?: number;
28
36
  }): {
29
37
  /** Mix these properties into the target element. **Must be an Element** */
30
38
  targetProps: {