@workday/canvas-kit-react 5.3.2 → 5.3.6

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.
@@ -32,14 +32,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
32
32
  result["default"] = mod;
33
33
  return result;
34
34
  };
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
36
  var React = __importStar(require("react"));
40
37
  var core_1 = require("@emotion/core");
41
- var styled_1 = __importDefault(require("@emotion/styled"));
42
38
  var tokens_1 = __importStar(require("@workday/canvas-kit-react/tokens"));
39
+ var common_1 = require("@workday/canvas-kit-react/common");
43
40
  /**
44
41
  * Keyframe for the dots loading animation.
45
42
  */
@@ -47,7 +44,7 @@ var keyframesLoading = core_1.keyframes(templateObject_1 || (templateObject_1 =
47
44
  /**
48
45
  * The actual loading dot div.
49
46
  */
50
- var LoadingAnimationDot = styled_1.default('div')({
47
+ var LoadingAnimationDot = common_1.styled('div')({
51
48
  backgroundColor: tokens_1.default.colors.soap400,
52
49
  width: tokens_1.default.space.s,
53
50
  height: tokens_1.default.space.s,
@@ -73,7 +70,7 @@ var LoadingAnimationDot = styled_1.default('div')({
73
70
  /**
74
71
  * A simple container for the loading dots.
75
72
  */
76
- var Container = styled_1.default('div')({
73
+ var Container = common_1.styled('div')({
77
74
  display: 'inline-block',
78
75
  });
79
76
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"PopupCard.d.ts","sourceRoot":"","sources":["../../../../popup/lib/PopupCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAC,IAAI,EAAC,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAOL,YAAY,EACb,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAe,UAAU,EAAoB,MAAM,SAAS,CAAC;AAEpE,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC;IACtE;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AA0CD,eAAO,MAAM,SAAS,gEA0BpB,CAAC"}
1
+ {"version":3,"file":"PopupCard.d.ts","sourceRoot":"","sources":["../../../../popup/lib/PopupCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAC,IAAI,EAAC,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAOL,YAAY,EACb,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAe,UAAU,EAAoB,MAAM,SAAS,CAAC;AAEpE,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC;IACtE;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAmCD,eAAO,MAAM,SAAS,gEAuBpB,CAAC"}
@@ -44,13 +44,7 @@ var popupAnimation = function (transformOrigin) {
44
44
  var translate = common_1.getTranslateFromOrigin(transformOrigin, tokens_1.space.xxs);
45
45
  return core_1.keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% {\n opacity: 0;\n transform: translate(", "px, ", "px);\n }\n 100% {\n opacity: 1;\n transform: translate(0);\n }\n "], ["\n 0% {\n opacity: 0;\n transform: translate(", "px, ", "px);\n }\n 100% {\n opacity: 1;\n transform: translate(0);\n }\n "])), translate.x, translate.y);
46
46
  };
47
- var StyledPopupCard = common_1.styled(card_1.Card)({
48
- position: 'relative',
49
- maxWidth: "calc(100vw - " + tokens_1.space.l + ")",
50
- }, function (_a) {
51
- var width = _a.width;
52
- return width && { width: width };
53
- }, function (_a) {
47
+ var StyledPopupCard = common_1.styled(card_1.Card)(function (_a) {
54
48
  var transformOrigin = _a.transformOrigin;
55
49
  if (transformOrigin == null) {
56
50
  return {};
@@ -69,13 +63,13 @@ var StyledPopupCard = common_1.styled(card_1.Card)({
69
63
  exports.PopupCard = common_1.createComponent('div')({
70
64
  displayName: 'Popup.Card',
71
65
  Component: function (_a, ref, Element) {
72
- var children = _a.children, model = _a.model, _b = _a.padding, padding = _b === void 0 ? 'l' : _b, _c = _a.depth, depth = _c === void 0 ? 2 : _c, width = _a.width, elemProps = __rest(_a, ["children", "model", "padding", "depth", "width"]);
66
+ var children = _a.children, model = _a.model, elemProps = __rest(_a, ["children", "model"]);
73
67
  var localModel = common_1.useModelContext(hooks_1.PopupModelContext, model);
74
68
  var props = hooks_1.usePopupCard(localModel, elemProps, ref);
75
69
  var transformOrigin = React.useMemo(function () {
76
70
  return getTransformFromPlacement_1.getTransformFromPlacement(localModel.state.placement || 'bottom');
77
71
  }, [localModel.state.placement]);
78
- return (React.createElement(StyledPopupCard, __assign({ as: Element, transformOrigin: transformOrigin, depth: depth, width: width, padding: padding }, props),
72
+ return (React.createElement(StyledPopupCard, __assign({ as: Element, transformOrigin: transformOrigin, position: "relative", padding: "l", depth: 2, maxWidth: "calc(100vw - " + tokens_1.space.l + ")" }, props),
79
73
  React.createElement(card_1.Card.Body, null, children)));
80
74
  },
81
75
  });
@@ -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
  }
@@ -26,8 +26,8 @@ var __rest = (this && this.__rest) || function (s, e) {
26
26
  };
27
27
  import * as React from 'react';
28
28
  import { keyframes } from '@emotion/core';
29
- import styled from '@emotion/styled';
30
29
  import canvas, { borderRadius } from '@workday/canvas-kit-react/tokens';
30
+ import { styled } from '@workday/canvas-kit-react/common';
31
31
  /**
32
32
  * Keyframe for the dots loading animation.
33
33
  */
@@ -1 +1 @@
1
- {"version":3,"file":"PopupCard.d.ts","sourceRoot":"","sources":["../../../../popup/lib/PopupCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAC,IAAI,EAAC,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAOL,YAAY,EACb,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAe,UAAU,EAAoB,MAAM,SAAS,CAAC;AAEpE,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC;IACtE;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AA0CD,eAAO,MAAM,SAAS,gEA0BpB,CAAC"}
1
+ {"version":3,"file":"PopupCard.d.ts","sourceRoot":"","sources":["../../../../popup/lib/PopupCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAC,IAAI,EAAC,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAOL,YAAY,EACb,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAe,UAAU,EAAoB,MAAM,SAAS,CAAC;AAEpE,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,IAAI,EAAE,KAAK,CAAC;IACtE;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAmCD,eAAO,MAAM,SAAS,gEAuBpB,CAAC"}
@@ -35,13 +35,7 @@ var popupAnimation = function (transformOrigin) {
35
35
  var translate = getTranslateFromOrigin(transformOrigin, space.xxs);
36
36
  return keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% {\n opacity: 0;\n transform: translate(", "px, ", "px);\n }\n 100% {\n opacity: 1;\n transform: translate(0);\n }\n "], ["\n 0% {\n opacity: 0;\n transform: translate(", "px, ", "px);\n }\n 100% {\n opacity: 1;\n transform: translate(0);\n }\n "])), translate.x, translate.y);
37
37
  };
38
- var StyledPopupCard = styled(Card)({
39
- position: 'relative',
40
- maxWidth: "calc(100vw - " + space.l + ")",
41
- }, function (_a) {
42
- var width = _a.width;
43
- return width && { width: width };
44
- }, function (_a) {
38
+ var StyledPopupCard = styled(Card)(function (_a) {
45
39
  var transformOrigin = _a.transformOrigin;
46
40
  if (transformOrigin == null) {
47
41
  return {};
@@ -60,13 +54,13 @@ var StyledPopupCard = styled(Card)({
60
54
  export var PopupCard = createComponent('div')({
61
55
  displayName: 'Popup.Card',
62
56
  Component: function (_a, ref, Element) {
63
- var children = _a.children, model = _a.model, _b = _a.padding, padding = _b === void 0 ? 'l' : _b, _c = _a.depth, depth = _c === void 0 ? 2 : _c, width = _a.width, elemProps = __rest(_a, ["children", "model", "padding", "depth", "width"]);
57
+ var children = _a.children, model = _a.model, elemProps = __rest(_a, ["children", "model"]);
64
58
  var localModel = useModelContext(PopupModelContext, model);
65
59
  var props = usePopupCard(localModel, elemProps, ref);
66
60
  var transformOrigin = React.useMemo(function () {
67
61
  return getTransformFromPlacement(localModel.state.placement || 'bottom');
68
62
  }, [localModel.state.placement]);
69
- return (React.createElement(StyledPopupCard, __assign({ as: Element, transformOrigin: transformOrigin, depth: depth, width: width, padding: padding }, props),
63
+ return (React.createElement(StyledPopupCard, __assign({ as: Element, transformOrigin: transformOrigin, position: "relative", padding: "l", depth: 2, maxWidth: "calc(100vw - " + space.l + ")" }, props),
70
64
  React.createElement(Card.Body, null, children)));
71
65
  },
72
66
  });
@@ -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
  }
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import {keyframes} from '@emotion/core';
3
- import styled from '@emotion/styled';
4
3
  import canvas, {borderRadius} from '@workday/canvas-kit-react/tokens';
4
+ import {styled} from '@workday/canvas-kit-react/common';
5
5
 
6
6
  /**
7
7
  * Keyframe for the dots loading animation.
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.6",
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",
@@ -38,7 +38,8 @@
38
38
  "build": "npm-run-all --parallel build:cjs build:es6 --sequential build:downlevel-dts",
39
39
  "prepack": "node ../../utils/publish.js pre react",
40
40
  "postpack": "node ../../utils/publish.js post react",
41
- "depcheck": "node ../../utils/check-dependencies-exist.js"
41
+ "depcheck": "node ../../utils/check-dependencies-exist.js",
42
+ "typecheck:src": "tsc -p . --noEmit --incremental false"
42
43
  },
43
44
  "keywords": [
44
45
  "canvas",
@@ -57,9 +58,9 @@
57
58
  "@popperjs/core": "^2.5.4",
58
59
  "@workday/canvas-colors-web": "^2.0.0",
59
60
  "@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",
61
+ "@workday/canvas-kit-labs-react": "^5.3.6",
62
+ "@workday/canvas-kit-popup-stack": "^5.3.6",
63
+ "@workday/canvas-kit-preview-react": "^5.3.6",
63
64
  "@workday/canvas-system-icons-web": "1.0.41",
64
65
  "@workday/design-assets-types": "^0.2.4",
65
66
  "chroma-js": "^2.1.0",
@@ -75,5 +76,5 @@
75
76
  "@workday/canvas-accent-icons-web": "^1.0.0",
76
77
  "@workday/canvas-applet-icons-web": "^0.17.50"
77
78
  },
78
- "gitHead": "b6506c1b24e744ab5e132a16d6f4187be6dc6e2a"
79
+ "gitHead": "067d8895ad8f2e70f7e8f658dc728addc74ddf87"
79
80
  }
@@ -42,36 +42,25 @@ const popupAnimation = (transformOrigin: TransformOrigin) => {
42
42
 
43
43
  const StyledPopupCard = styled(Card)<
44
44
  StyledType & {width?: number | string; transformOrigin?: TransformOrigin}
45
- >(
46
- {
47
- position: 'relative',
48
- maxWidth: `calc(100vw - ${space.l})`,
49
- },
50
- ({width}) => width && {width},
51
- ({transformOrigin}) => {
52
- if (transformOrigin == null) {
53
- return {};
54
- }
55
- return {
56
- animation: popupAnimation(transformOrigin),
57
- animationDuration: '150ms',
58
- animationTimingFunction: 'ease-out',
59
- transformOrigin: `${transformOrigin.vertical} ${transformOrigin.horizontal}`,
60
- // Allow overriding of animation in special cases
61
- '.wd-no-animation &': {
62
- animation: 'none',
63
- },
64
- };
45
+ >(({transformOrigin}) => {
46
+ if (transformOrigin == null) {
47
+ return {};
65
48
  }
66
- );
49
+ return {
50
+ animation: popupAnimation(transformOrigin),
51
+ animationDuration: '150ms',
52
+ animationTimingFunction: 'ease-out',
53
+ transformOrigin: `${transformOrigin.vertical} ${transformOrigin.horizontal}`,
54
+ // Allow overriding of animation in special cases
55
+ '.wd-no-animation &': {
56
+ animation: 'none',
57
+ },
58
+ };
59
+ });
67
60
 
68
61
  export const PopupCard = createComponent('div')({
69
62
  displayName: 'Popup.Card',
70
- Component: (
71
- {children, model, padding = 'l', depth = 2, width, ...elemProps}: PopupCardProps,
72
- ref,
73
- Element
74
- ) => {
63
+ Component: ({children, model, ...elemProps}: PopupCardProps, ref, Element) => {
75
64
  const localModel = useModelContext(PopupModelContext, model);
76
65
  const props = usePopupCard(localModel, elemProps, ref);
77
66
  const transformOrigin = React.useMemo(() => {
@@ -82,9 +71,10 @@ export const PopupCard = createComponent('div')({
82
71
  <StyledPopupCard
83
72
  as={Element}
84
73
  transformOrigin={transformOrigin}
85
- depth={depth}
86
- width={width}
87
- padding={padding}
74
+ position="relative"
75
+ padding="l"
76
+ depth={2}
77
+ maxWidth={`calc(100vw - ${space.l})`}
88
78
  {...props}
89
79
  >
90
80
  <Card.Body>{children}</Card.Body>
@@ -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: {