@react-spectrum/tooltip 3.6.4 → 3.6.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.
- package/dist/Tooltip.main.js +81 -0
- package/dist/Tooltip.main.js.map +1 -0
- package/dist/Tooltip.mjs +76 -0
- package/dist/Tooltip.module.js +76 -0
- package/dist/Tooltip.module.js.map +1 -0
- package/dist/TooltipTrigger.main.js +122 -0
- package/dist/TooltipTrigger.main.js.map +1 -0
- package/dist/TooltipTrigger.mjs +113 -0
- package/dist/TooltipTrigger.module.js +113 -0
- package/dist/TooltipTrigger.module.js.map +1 -0
- package/dist/context.main.js +27 -0
- package/dist/context.main.js.map +1 -0
- package/dist/context.mjs +18 -0
- package/dist/context.module.js +18 -0
- package/dist/context.module.js.map +1 -0
- package/dist/import.mjs +2 -294
- package/dist/main.js +4 -292
- package/dist/main.js.map +1 -1
- package/dist/module.js +2 -294
- package/dist/module.js.map +1 -1
- package/dist/tooltip_vars_css.main.js +107 -0
- package/dist/tooltip_vars_css.main.js.map +1 -0
- package/dist/tooltip_vars_css.mjs +109 -0
- package/dist/tooltip_vars_css.module.js +109 -0
- package/dist/tooltip_vars_css.module.js.map +1 -0
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/vars.80858477.css +321 -0
- package/dist/vars.80858477.css.map +1 -0
- package/package.json +13 -13
- package/dist/main.css +0 -1
@@ -0,0 +1,81 @@
|
|
1
|
+
require("./vars.80858477.css");
|
2
|
+
var $ba73465d6d9b6556$exports = require("./tooltip_vars_css.main.js");
|
3
|
+
var $ed2e56c8503433b4$exports = require("./context.main.js");
|
4
|
+
var $l0Ry0$spectrumiconsuiAlertSmall = require("@spectrum-icons/ui/AlertSmall");
|
5
|
+
var $l0Ry0$reactspectrumutils = require("@react-spectrum/utils");
|
6
|
+
var $l0Ry0$spectrumiconsuiInfoSmall = require("@spectrum-icons/ui/InfoSmall");
|
7
|
+
var $l0Ry0$reactariautils = require("@react-aria/utils");
|
8
|
+
var $l0Ry0$react = require("react");
|
9
|
+
var $l0Ry0$spectrumiconsuiSuccessSmall = require("@spectrum-icons/ui/SuccessSmall");
|
10
|
+
var $l0Ry0$reactariatooltip = require("@react-aria/tooltip");
|
11
|
+
|
12
|
+
|
13
|
+
function $parcel$interopDefault(a) {
|
14
|
+
return a && a.__esModule ? a.default : a;
|
15
|
+
}
|
16
|
+
|
17
|
+
function $parcel$export(e, n, v, s) {
|
18
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
19
|
+
}
|
20
|
+
|
21
|
+
$parcel$export(module.exports, "Tooltip", () => $55bd11986fcffc6f$export$28c660c63b792dea);
|
22
|
+
/*
|
23
|
+
* Copyright 2020 Adobe. All rights reserved.
|
24
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
25
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
26
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
27
|
+
*
|
28
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
29
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
30
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
31
|
+
* governing permissions and limitations under the License.
|
32
|
+
*/
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
let $55bd11986fcffc6f$var$iconMap = {
|
42
|
+
info: (0, ($parcel$interopDefault($l0Ry0$spectrumiconsuiInfoSmall))),
|
43
|
+
positive: (0, ($parcel$interopDefault($l0Ry0$spectrumiconsuiSuccessSmall))),
|
44
|
+
negative: (0, ($parcel$interopDefault($l0Ry0$spectrumiconsuiAlertSmall)))
|
45
|
+
};
|
46
|
+
function $55bd11986fcffc6f$var$Tooltip(props, ref) {
|
47
|
+
let { ref: overlayRef, arrowProps: arrowProps, state: state, arrowRef: arrowRef, ...tooltipProviderProps } = (0, $l0Ry0$react.useContext)((0, $ed2e56c8503433b4$exports.TooltipContext));
|
48
|
+
let defaultRef = (0, $l0Ry0$react.useRef)();
|
49
|
+
overlayRef = overlayRef || defaultRef;
|
50
|
+
props = (0, $l0Ry0$reactariautils.mergeProps)(props, tooltipProviderProps);
|
51
|
+
let { variant: variant = "neutral", placement: placement = "top", isOpen: isOpen, showIcon: showIcon, ...otherProps } = props;
|
52
|
+
let { styleProps: styleProps } = (0, $l0Ry0$reactspectrumutils.useStyleProps)(otherProps);
|
53
|
+
let { tooltipProps: tooltipProps } = (0, $l0Ry0$reactariatooltip.useTooltip)(props, state);
|
54
|
+
// Sync ref with overlayRef from context.
|
55
|
+
(0, $l0Ry0$react.useImperativeHandle)(ref, ()=>(0, $l0Ry0$reactspectrumutils.createDOMRef)(overlayRef));
|
56
|
+
let Icon = $55bd11986fcffc6f$var$iconMap[variant];
|
57
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($l0Ry0$react))).createElement("div", {
|
58
|
+
...styleProps,
|
59
|
+
...tooltipProps,
|
60
|
+
className: (0, $l0Ry0$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ba73465d6d9b6556$exports))), "spectrum-Tooltip", `spectrum-Tooltip--${variant}`, `spectrum-Tooltip--${placement}`, {
|
61
|
+
"is-open": isOpen,
|
62
|
+
[`is-open--${placement}`]: isOpen
|
63
|
+
}, styleProps.className),
|
64
|
+
ref: overlayRef
|
65
|
+
}, showIcon && variant !== "neutral" && /*#__PURE__*/ (0, ($parcel$interopDefault($l0Ry0$react))).createElement(Icon, {
|
66
|
+
UNSAFE_className: (0, $l0Ry0$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ba73465d6d9b6556$exports))), "spectrum-Tooltip-typeIcon"),
|
67
|
+
"aria-hidden": true
|
68
|
+
}), props.children && /*#__PURE__*/ (0, ($parcel$interopDefault($l0Ry0$react))).createElement("span", {
|
69
|
+
className: (0, $l0Ry0$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ba73465d6d9b6556$exports))), "spectrum-Tooltip-label")
|
70
|
+
}, props.children), /*#__PURE__*/ (0, ($parcel$interopDefault($l0Ry0$react))).createElement("span", {
|
71
|
+
...arrowProps,
|
72
|
+
ref: arrowRef,
|
73
|
+
className: (0, $l0Ry0$reactspectrumutils.classNames)((0, ($parcel$interopDefault($ba73465d6d9b6556$exports))), "spectrum-Tooltip-tip")
|
74
|
+
}));
|
75
|
+
}
|
76
|
+
/**
|
77
|
+
* Display container for Tooltip content. Has a directional arrow dependent on its placement.
|
78
|
+
*/ let $55bd11986fcffc6f$export$28c660c63b792dea = /*#__PURE__*/ (0, ($parcel$interopDefault($l0Ry0$react))).forwardRef($55bd11986fcffc6f$var$Tooltip);
|
79
|
+
|
80
|
+
|
81
|
+
//# sourceMappingURL=Tooltip.main.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAcD,IAAI,gCAAU;IACZ,MAAM,CAAA,GAAA,yDAAQ;IACd,UAAU,CAAA,GAAA,4DAAW;IACrB,UAAU,CAAA,GAAA,0DAAS;AACrB;AAEA,SAAS,8BAAQ,KAA2B,EAAE,GAAW;IACvD,IAAI,EAAC,KAAK,UAAU,cAAE,UAAU,SAAE,KAAK,YAAE,QAAQ,EAAE,GAAG,sBAAqB,GAAG,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,wCAAa;IACtG,IAAI,aAAa,CAAA,GAAA,mBAAK;IACtB,aAAa,cAAc;IAC3B,QAAQ,CAAA,GAAA,gCAAS,EAAE,OAAO;IAC1B,IAAI,WACF,UAAU,sBACV,YAAY,eACZ,MAAM,YACN,QAAQ,EACR,GAAG,YACJ,GAAG;IACJ,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IACjC,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,kCAAS,EAAE,OAAO;IAEvC,yCAAyC;IACzC,CAAA,GAAA,gCAAkB,EAAE,KAAK,IAAM,CAAA,GAAA,sCAAW,EAAE;IAE5C,IAAI,OAAO,6BAAO,CAAC,QAAQ;IAE3B,qBACE,0DAAC;QACE,GAAG,UAAU;QACb,GAAG,YAAY;QAChB,WAAW,CAAA,GAAA,oCAAS,EAClB,CAAA,GAAA,mDAAK,GACL,oBACA,CAAC,kBAAkB,EAAE,QAAQ,CAAC,EAC9B,CAAC,kBAAkB,EAAE,UAAU,CAAC,EAChC;YACE,WAAW;YACX,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,EAAE;QAC7B,GACA,WAAW,SAAS;QAEtB,KAAK;OACJ,YAAY,YAAY,2BAAa,0DAAC;QAAK,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;QAA8B,eAAA;QAC9G,MAAM,QAAQ,kBACb,0DAAC;QAAK,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OACjC,MAAM,QAAQ,iBAGnB,0DAAC;QAAM,GAAG,UAAU;QAAE,KAAK;QAAU,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;;AAGzE;AAEA;;CAEC,GACD,IAAI,0DAAW,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/tooltip/src/Tooltip.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport AlertSmall from '@spectrum-icons/ui/AlertSmall';\nimport {classNames, createDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport InfoSmall from '@spectrum-icons/ui/InfoSmall';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {useContext, useImperativeHandle, useRef} from 'react';\nimport {SpectrumTooltipProps} from '@react-types/tooltip';\nimport styles from '@adobe/spectrum-css-temp/components/tooltip/vars.css';\nimport SuccessSmall from '@spectrum-icons/ui/SuccessSmall';\nimport {TooltipContext} from './context';\nimport {useTooltip} from '@react-aria/tooltip';\n\nlet iconMap = {\n info: InfoSmall,\n positive: SuccessSmall,\n negative: AlertSmall\n};\n\nfunction Tooltip(props: SpectrumTooltipProps, ref: DOMRef) {\n let {ref: overlayRef, arrowProps, state, arrowRef, ...tooltipProviderProps} = useContext(TooltipContext);\n let defaultRef = useRef();\n overlayRef = overlayRef || defaultRef;\n props = mergeProps(props, tooltipProviderProps);\n let {\n variant = 'neutral',\n placement = 'top',\n isOpen,\n showIcon,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps);\n let {tooltipProps} = useTooltip(props, state);\n\n // Sync ref with overlayRef from context.\n useImperativeHandle(ref, () => createDOMRef(overlayRef));\n\n let Icon = iconMap[variant];\n\n return (\n <div\n {...styleProps}\n {...tooltipProps}\n className={classNames(\n styles,\n 'spectrum-Tooltip',\n `spectrum-Tooltip--${variant}`,\n `spectrum-Tooltip--${placement}`,\n {\n 'is-open': isOpen,\n [`is-open--${placement}`]: isOpen\n },\n styleProps.className\n )}\n ref={overlayRef}>\n {showIcon && variant !== 'neutral' && <Icon UNSAFE_className={classNames(styles, 'spectrum-Tooltip-typeIcon')} aria-hidden />}\n {props.children && (\n <span className={classNames(styles, 'spectrum-Tooltip-label')}>\n {props.children}\n </span>\n )}\n <span {...arrowProps} ref={arrowRef} className={classNames(styles, 'spectrum-Tooltip-tip')} />\n </div>\n );\n}\n\n/**\n * Display container for Tooltip content. Has a directional arrow dependent on its placement.\n */\nlet _Tooltip = React.forwardRef(Tooltip);\nexport {_Tooltip as Tooltip};\n"],"names":[],"version":3,"file":"Tooltip.main.js.map"}
|
package/dist/Tooltip.mjs
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
import "./vars.80858477.css";
|
2
|
+
import $dcNtB$tooltip_vars_cssmodulejs from "./tooltip_vars_css.mjs";
|
3
|
+
import {TooltipContext as $b8c00169fae46ac7$export$39ae08fa83328b12} from "./context.mjs";
|
4
|
+
import $dcNtB$spectrumiconsuiAlertSmall from "@spectrum-icons/ui/AlertSmall";
|
5
|
+
import {useStyleProps as $dcNtB$useStyleProps, createDOMRef as $dcNtB$createDOMRef, classNames as $dcNtB$classNames} from "@react-spectrum/utils";
|
6
|
+
import $dcNtB$spectrumiconsuiInfoSmall from "@spectrum-icons/ui/InfoSmall";
|
7
|
+
import {mergeProps as $dcNtB$mergeProps} from "@react-aria/utils";
|
8
|
+
import $dcNtB$react, {useContext as $dcNtB$useContext, useRef as $dcNtB$useRef, useImperativeHandle as $dcNtB$useImperativeHandle} from "react";
|
9
|
+
import $dcNtB$spectrumiconsuiSuccessSmall from "@spectrum-icons/ui/SuccessSmall";
|
10
|
+
import {useTooltip as $dcNtB$useTooltip} from "@react-aria/tooltip";
|
11
|
+
|
12
|
+
|
13
|
+
function $parcel$interopDefault(a) {
|
14
|
+
return a && a.__esModule ? a.default : a;
|
15
|
+
}
|
16
|
+
/*
|
17
|
+
* Copyright 2020 Adobe. All rights reserved.
|
18
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
19
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
20
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
21
|
+
*
|
22
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
23
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
24
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
25
|
+
* governing permissions and limitations under the License.
|
26
|
+
*/
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
let $dc9e2a6f9971fb04$var$iconMap = {
|
36
|
+
info: (0, $dcNtB$spectrumiconsuiInfoSmall),
|
37
|
+
positive: (0, $dcNtB$spectrumiconsuiSuccessSmall),
|
38
|
+
negative: (0, $dcNtB$spectrumiconsuiAlertSmall)
|
39
|
+
};
|
40
|
+
function $dc9e2a6f9971fb04$var$Tooltip(props, ref) {
|
41
|
+
let { ref: overlayRef, arrowProps: arrowProps, state: state, arrowRef: arrowRef, ...tooltipProviderProps } = (0, $dcNtB$useContext)((0, $b8c00169fae46ac7$export$39ae08fa83328b12));
|
42
|
+
let defaultRef = (0, $dcNtB$useRef)();
|
43
|
+
overlayRef = overlayRef || defaultRef;
|
44
|
+
props = (0, $dcNtB$mergeProps)(props, tooltipProviderProps);
|
45
|
+
let { variant: variant = "neutral", placement: placement = "top", isOpen: isOpen, showIcon: showIcon, ...otherProps } = props;
|
46
|
+
let { styleProps: styleProps } = (0, $dcNtB$useStyleProps)(otherProps);
|
47
|
+
let { tooltipProps: tooltipProps } = (0, $dcNtB$useTooltip)(props, state);
|
48
|
+
// Sync ref with overlayRef from context.
|
49
|
+
(0, $dcNtB$useImperativeHandle)(ref, ()=>(0, $dcNtB$createDOMRef)(overlayRef));
|
50
|
+
let Icon = $dc9e2a6f9971fb04$var$iconMap[variant];
|
51
|
+
return /*#__PURE__*/ (0, $dcNtB$react).createElement("div", {
|
52
|
+
...styleProps,
|
53
|
+
...tooltipProps,
|
54
|
+
className: (0, $dcNtB$classNames)((0, ($parcel$interopDefault($dcNtB$tooltip_vars_cssmodulejs))), "spectrum-Tooltip", `spectrum-Tooltip--${variant}`, `spectrum-Tooltip--${placement}`, {
|
55
|
+
"is-open": isOpen,
|
56
|
+
[`is-open--${placement}`]: isOpen
|
57
|
+
}, styleProps.className),
|
58
|
+
ref: overlayRef
|
59
|
+
}, showIcon && variant !== "neutral" && /*#__PURE__*/ (0, $dcNtB$react).createElement(Icon, {
|
60
|
+
UNSAFE_className: (0, $dcNtB$classNames)((0, ($parcel$interopDefault($dcNtB$tooltip_vars_cssmodulejs))), "spectrum-Tooltip-typeIcon"),
|
61
|
+
"aria-hidden": true
|
62
|
+
}), props.children && /*#__PURE__*/ (0, $dcNtB$react).createElement("span", {
|
63
|
+
className: (0, $dcNtB$classNames)((0, ($parcel$interopDefault($dcNtB$tooltip_vars_cssmodulejs))), "spectrum-Tooltip-label")
|
64
|
+
}, props.children), /*#__PURE__*/ (0, $dcNtB$react).createElement("span", {
|
65
|
+
...arrowProps,
|
66
|
+
ref: arrowRef,
|
67
|
+
className: (0, $dcNtB$classNames)((0, ($parcel$interopDefault($dcNtB$tooltip_vars_cssmodulejs))), "spectrum-Tooltip-tip")
|
68
|
+
}));
|
69
|
+
}
|
70
|
+
/**
|
71
|
+
* Display container for Tooltip content. Has a directional arrow dependent on its placement.
|
72
|
+
*/ let $dc9e2a6f9971fb04$export$28c660c63b792dea = /*#__PURE__*/ (0, $dcNtB$react).forwardRef($dc9e2a6f9971fb04$var$Tooltip);
|
73
|
+
|
74
|
+
|
75
|
+
export {$dc9e2a6f9971fb04$export$28c660c63b792dea as Tooltip};
|
76
|
+
//# sourceMappingURL=Tooltip.mjs.map
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import "./vars.80858477.css";
|
2
|
+
import $dcNtB$tooltip_vars_cssmodulejs from "./tooltip_vars_css.module.js";
|
3
|
+
import {TooltipContext as $b8c00169fae46ac7$export$39ae08fa83328b12} from "./context.module.js";
|
4
|
+
import $dcNtB$spectrumiconsuiAlertSmall from "@spectrum-icons/ui/AlertSmall";
|
5
|
+
import {useStyleProps as $dcNtB$useStyleProps, createDOMRef as $dcNtB$createDOMRef, classNames as $dcNtB$classNames} from "@react-spectrum/utils";
|
6
|
+
import $dcNtB$spectrumiconsuiInfoSmall from "@spectrum-icons/ui/InfoSmall";
|
7
|
+
import {mergeProps as $dcNtB$mergeProps} from "@react-aria/utils";
|
8
|
+
import $dcNtB$react, {useContext as $dcNtB$useContext, useRef as $dcNtB$useRef, useImperativeHandle as $dcNtB$useImperativeHandle} from "react";
|
9
|
+
import $dcNtB$spectrumiconsuiSuccessSmall from "@spectrum-icons/ui/SuccessSmall";
|
10
|
+
import {useTooltip as $dcNtB$useTooltip} from "@react-aria/tooltip";
|
11
|
+
|
12
|
+
|
13
|
+
function $parcel$interopDefault(a) {
|
14
|
+
return a && a.__esModule ? a.default : a;
|
15
|
+
}
|
16
|
+
/*
|
17
|
+
* Copyright 2020 Adobe. All rights reserved.
|
18
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
19
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
20
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
21
|
+
*
|
22
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
23
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
24
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
25
|
+
* governing permissions and limitations under the License.
|
26
|
+
*/
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
let $dc9e2a6f9971fb04$var$iconMap = {
|
36
|
+
info: (0, $dcNtB$spectrumiconsuiInfoSmall),
|
37
|
+
positive: (0, $dcNtB$spectrumiconsuiSuccessSmall),
|
38
|
+
negative: (0, $dcNtB$spectrumiconsuiAlertSmall)
|
39
|
+
};
|
40
|
+
function $dc9e2a6f9971fb04$var$Tooltip(props, ref) {
|
41
|
+
let { ref: overlayRef, arrowProps: arrowProps, state: state, arrowRef: arrowRef, ...tooltipProviderProps } = (0, $dcNtB$useContext)((0, $b8c00169fae46ac7$export$39ae08fa83328b12));
|
42
|
+
let defaultRef = (0, $dcNtB$useRef)();
|
43
|
+
overlayRef = overlayRef || defaultRef;
|
44
|
+
props = (0, $dcNtB$mergeProps)(props, tooltipProviderProps);
|
45
|
+
let { variant: variant = "neutral", placement: placement = "top", isOpen: isOpen, showIcon: showIcon, ...otherProps } = props;
|
46
|
+
let { styleProps: styleProps } = (0, $dcNtB$useStyleProps)(otherProps);
|
47
|
+
let { tooltipProps: tooltipProps } = (0, $dcNtB$useTooltip)(props, state);
|
48
|
+
// Sync ref with overlayRef from context.
|
49
|
+
(0, $dcNtB$useImperativeHandle)(ref, ()=>(0, $dcNtB$createDOMRef)(overlayRef));
|
50
|
+
let Icon = $dc9e2a6f9971fb04$var$iconMap[variant];
|
51
|
+
return /*#__PURE__*/ (0, $dcNtB$react).createElement("div", {
|
52
|
+
...styleProps,
|
53
|
+
...tooltipProps,
|
54
|
+
className: (0, $dcNtB$classNames)((0, ($parcel$interopDefault($dcNtB$tooltip_vars_cssmodulejs))), "spectrum-Tooltip", `spectrum-Tooltip--${variant}`, `spectrum-Tooltip--${placement}`, {
|
55
|
+
"is-open": isOpen,
|
56
|
+
[`is-open--${placement}`]: isOpen
|
57
|
+
}, styleProps.className),
|
58
|
+
ref: overlayRef
|
59
|
+
}, showIcon && variant !== "neutral" && /*#__PURE__*/ (0, $dcNtB$react).createElement(Icon, {
|
60
|
+
UNSAFE_className: (0, $dcNtB$classNames)((0, ($parcel$interopDefault($dcNtB$tooltip_vars_cssmodulejs))), "spectrum-Tooltip-typeIcon"),
|
61
|
+
"aria-hidden": true
|
62
|
+
}), props.children && /*#__PURE__*/ (0, $dcNtB$react).createElement("span", {
|
63
|
+
className: (0, $dcNtB$classNames)((0, ($parcel$interopDefault($dcNtB$tooltip_vars_cssmodulejs))), "spectrum-Tooltip-label")
|
64
|
+
}, props.children), /*#__PURE__*/ (0, $dcNtB$react).createElement("span", {
|
65
|
+
...arrowProps,
|
66
|
+
ref: arrowRef,
|
67
|
+
className: (0, $dcNtB$classNames)((0, ($parcel$interopDefault($dcNtB$tooltip_vars_cssmodulejs))), "spectrum-Tooltip-tip")
|
68
|
+
}));
|
69
|
+
}
|
70
|
+
/**
|
71
|
+
* Display container for Tooltip content. Has a directional arrow dependent on its placement.
|
72
|
+
*/ let $dc9e2a6f9971fb04$export$28c660c63b792dea = /*#__PURE__*/ (0, $dcNtB$react).forwardRef($dc9e2a6f9971fb04$var$Tooltip);
|
73
|
+
|
74
|
+
|
75
|
+
export {$dc9e2a6f9971fb04$export$28c660c63b792dea as Tooltip};
|
76
|
+
//# sourceMappingURL=Tooltip.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAcD,IAAI,gCAAU;IACZ,MAAM,CAAA,GAAA,+BAAQ;IACd,UAAU,CAAA,GAAA,kCAAW;IACrB,UAAU,CAAA,GAAA,gCAAS;AACrB;AAEA,SAAS,8BAAQ,KAA2B,EAAE,GAAW;IACvD,IAAI,EAAC,KAAK,UAAU,cAAE,UAAU,SAAE,KAAK,YAAE,QAAQ,EAAE,GAAG,sBAAqB,GAAG,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAa;IACtG,IAAI,aAAa,CAAA,GAAA,aAAK;IACtB,aAAa,cAAc;IAC3B,QAAQ,CAAA,GAAA,iBAAS,EAAE,OAAO;IAC1B,IAAI,WACF,UAAU,sBACV,YAAY,eACZ,MAAM,YACN,QAAQ,EACR,GAAG,YACJ,GAAG;IACJ,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IACjC,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE,OAAO;IAEvC,yCAAyC;IACzC,CAAA,GAAA,0BAAkB,EAAE,KAAK,IAAM,CAAA,GAAA,mBAAW,EAAE;IAE5C,IAAI,OAAO,6BAAO,CAAC,QAAQ;IAE3B,qBACE,gCAAC;QACE,GAAG,UAAU;QACb,GAAG,YAAY;QAChB,WAAW,CAAA,GAAA,iBAAS,EAClB,CAAA,GAAA,yDAAK,GACL,oBACA,CAAC,kBAAkB,EAAE,QAAQ,CAAC,EAC9B,CAAC,kBAAkB,EAAE,UAAU,CAAC,EAChC;YACE,WAAW;YACX,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,EAAE;QAC7B,GACA,WAAW,SAAS;QAEtB,KAAK;OACJ,YAAY,YAAY,2BAAa,gCAAC;QAAK,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yDAAK,GAAG;QAA8B,eAAA;QAC9G,MAAM,QAAQ,kBACb,gCAAC;QAAK,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yDAAK,GAAG;OACjC,MAAM,QAAQ,iBAGnB,gCAAC;QAAM,GAAG,UAAU;QAAE,KAAK;QAAU,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yDAAK,GAAG;;AAGzE;AAEA;;CAEC,GACD,IAAI,0DAAW,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/tooltip/src/Tooltip.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport AlertSmall from '@spectrum-icons/ui/AlertSmall';\nimport {classNames, createDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport InfoSmall from '@spectrum-icons/ui/InfoSmall';\nimport {mergeProps} from '@react-aria/utils';\nimport React, {useContext, useImperativeHandle, useRef} from 'react';\nimport {SpectrumTooltipProps} from '@react-types/tooltip';\nimport styles from '@adobe/spectrum-css-temp/components/tooltip/vars.css';\nimport SuccessSmall from '@spectrum-icons/ui/SuccessSmall';\nimport {TooltipContext} from './context';\nimport {useTooltip} from '@react-aria/tooltip';\n\nlet iconMap = {\n info: InfoSmall,\n positive: SuccessSmall,\n negative: AlertSmall\n};\n\nfunction Tooltip(props: SpectrumTooltipProps, ref: DOMRef) {\n let {ref: overlayRef, arrowProps, state, arrowRef, ...tooltipProviderProps} = useContext(TooltipContext);\n let defaultRef = useRef();\n overlayRef = overlayRef || defaultRef;\n props = mergeProps(props, tooltipProviderProps);\n let {\n variant = 'neutral',\n placement = 'top',\n isOpen,\n showIcon,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps);\n let {tooltipProps} = useTooltip(props, state);\n\n // Sync ref with overlayRef from context.\n useImperativeHandle(ref, () => createDOMRef(overlayRef));\n\n let Icon = iconMap[variant];\n\n return (\n <div\n {...styleProps}\n {...tooltipProps}\n className={classNames(\n styles,\n 'spectrum-Tooltip',\n `spectrum-Tooltip--${variant}`,\n `spectrum-Tooltip--${placement}`,\n {\n 'is-open': isOpen,\n [`is-open--${placement}`]: isOpen\n },\n styleProps.className\n )}\n ref={overlayRef}>\n {showIcon && variant !== 'neutral' && <Icon UNSAFE_className={classNames(styles, 'spectrum-Tooltip-typeIcon')} aria-hidden />}\n {props.children && (\n <span className={classNames(styles, 'spectrum-Tooltip-label')}>\n {props.children}\n </span>\n )}\n <span {...arrowProps} ref={arrowRef} className={classNames(styles, 'spectrum-Tooltip-tip')} />\n </div>\n );\n}\n\n/**\n * Display container for Tooltip content. Has a directional arrow dependent on its placement.\n */\nlet _Tooltip = React.forwardRef(Tooltip);\nexport {_Tooltip as Tooltip};\n"],"names":[],"version":3,"file":"Tooltip.module.js.map"}
|
@@ -0,0 +1,122 @@
|
|
1
|
+
var $ed2e56c8503433b4$exports = require("./context.main.js");
|
2
|
+
var $1fBML$reactariafocus = require("@react-aria/focus");
|
3
|
+
var $1fBML$reactspectrumoverlays = require("@react-spectrum/overlays");
|
4
|
+
var $1fBML$react = require("react");
|
5
|
+
var $1fBML$reactariautils = require("@react-aria/utils");
|
6
|
+
var $1fBML$reactariaoverlays = require("@react-aria/overlays");
|
7
|
+
var $1fBML$reactariatooltip = require("@react-aria/tooltip");
|
8
|
+
var $1fBML$reactstatelytooltip = require("@react-stately/tooltip");
|
9
|
+
|
10
|
+
|
11
|
+
function $parcel$interopDefault(a) {
|
12
|
+
return a && a.__esModule ? a.default : a;
|
13
|
+
}
|
14
|
+
|
15
|
+
function $parcel$export(e, n, v, s) {
|
16
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
17
|
+
}
|
18
|
+
|
19
|
+
$parcel$export(module.exports, "TooltipTrigger", () => $19f06480c1c1a932$export$8c610744efcf8a1d);
|
20
|
+
/*
|
21
|
+
* Copyright 2020 Adobe. All rights reserved.
|
22
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
23
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
24
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
25
|
+
*
|
26
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
27
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
28
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
29
|
+
* governing permissions and limitations under the License.
|
30
|
+
*/
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
const $19f06480c1c1a932$var$DEFAULT_OFFSET = -1; // Offset needed to reach 4px/5px (med/large) distance between tooltip and trigger button
|
39
|
+
const $19f06480c1c1a932$var$DEFAULT_CROSS_OFFSET = 0;
|
40
|
+
function $19f06480c1c1a932$var$TooltipTrigger(props) {
|
41
|
+
let { children: children, crossOffset: crossOffset = $19f06480c1c1a932$var$DEFAULT_CROSS_OFFSET, isDisabled: isDisabled, offset: offset = $19f06480c1c1a932$var$DEFAULT_OFFSET, trigger: triggerAction } = props;
|
42
|
+
let [trigger, tooltip] = (0, ($parcel$interopDefault($1fBML$react))).Children.toArray(children);
|
43
|
+
let state = (0, $1fBML$reactstatelytooltip.useTooltipTriggerState)(props);
|
44
|
+
let tooltipTriggerRef = (0, $1fBML$react.useRef)();
|
45
|
+
let overlayRef = (0, $1fBML$react.useRef)();
|
46
|
+
let { triggerProps: triggerProps, tooltipProps: tooltipProps } = (0, $1fBML$reactariatooltip.useTooltipTrigger)({
|
47
|
+
isDisabled: isDisabled,
|
48
|
+
trigger: triggerAction
|
49
|
+
}, state, tooltipTriggerRef);
|
50
|
+
let [borderRadius, setBorderRadius] = (0, $1fBML$react.useState)(0);
|
51
|
+
(0, $1fBML$reactariautils.useLayoutEffect)(()=>{
|
52
|
+
if (overlayRef.current && state.isOpen) {
|
53
|
+
let spectrumBorderRadius = window.getComputedStyle(overlayRef.current).borderRadius;
|
54
|
+
if (spectrumBorderRadius !== "") setBorderRadius(parseInt(spectrumBorderRadius, 10));
|
55
|
+
}
|
56
|
+
}, [
|
57
|
+
state.isOpen,
|
58
|
+
overlayRef
|
59
|
+
]);
|
60
|
+
let arrowRef = (0, $1fBML$react.useRef)(null);
|
61
|
+
let [arrowWidth, setArrowWidth] = (0, $1fBML$react.useState)(0);
|
62
|
+
(0, $1fBML$reactariautils.useLayoutEffect)(()=>{
|
63
|
+
if (arrowRef.current && state.isOpen) setArrowWidth(arrowRef.current.getBoundingClientRect().width);
|
64
|
+
}, [
|
65
|
+
state.isOpen,
|
66
|
+
arrowRef
|
67
|
+
]);
|
68
|
+
let { overlayProps: overlayProps, arrowProps: arrowProps, placement: placement } = (0, $1fBML$reactariaoverlays.useOverlayPosition)({
|
69
|
+
placement: props.placement || "top",
|
70
|
+
targetRef: tooltipTriggerRef,
|
71
|
+
overlayRef: overlayRef,
|
72
|
+
offset: offset,
|
73
|
+
crossOffset: crossOffset,
|
74
|
+
isOpen: state.isOpen,
|
75
|
+
shouldFlip: props.shouldFlip,
|
76
|
+
containerPadding: props.containerPadding,
|
77
|
+
arrowSize: arrowWidth,
|
78
|
+
arrowBoundaryOffset: borderRadius
|
79
|
+
});
|
80
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($1fBML$react))).createElement((0, $1fBML$reactariafocus.FocusableProvider), {
|
81
|
+
...triggerProps,
|
82
|
+
ref: tooltipTriggerRef
|
83
|
+
}, trigger, /*#__PURE__*/ (0, ($parcel$interopDefault($1fBML$react))).createElement((0, $ed2e56c8503433b4$exports.TooltipContext).Provider, {
|
84
|
+
value: {
|
85
|
+
state: state,
|
86
|
+
placement: placement,
|
87
|
+
ref: overlayRef,
|
88
|
+
UNSAFE_style: overlayProps.style,
|
89
|
+
arrowProps: arrowProps,
|
90
|
+
arrowRef: arrowRef,
|
91
|
+
...tooltipProps
|
92
|
+
}
|
93
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($1fBML$react))).createElement((0, $1fBML$reactspectrumoverlays.Overlay), {
|
94
|
+
isOpen: state.isOpen,
|
95
|
+
nodeRef: overlayRef
|
96
|
+
}, tooltip)));
|
97
|
+
}
|
98
|
+
// Support TooltipTrigger inside components using CollectionBuilder.
|
99
|
+
$19f06480c1c1a932$var$TooltipTrigger.getCollectionNode = function*(props) {
|
100
|
+
// Replaced the use of React.Childern.toArray because it mutates the key prop.
|
101
|
+
let childArray = [];
|
102
|
+
(0, ($parcel$interopDefault($1fBML$react))).Children.forEach(props.children, (child)=>{
|
103
|
+
if (/*#__PURE__*/ (0, ($parcel$interopDefault($1fBML$react))).isValidElement(child)) childArray.push(child);
|
104
|
+
});
|
105
|
+
let [trigger, tooltip] = childArray;
|
106
|
+
yield {
|
107
|
+
element: trigger,
|
108
|
+
wrapper: (element)=>/*#__PURE__*/ (0, ($parcel$interopDefault($1fBML$react))).createElement($19f06480c1c1a932$var$TooltipTrigger, {
|
109
|
+
key: element.key,
|
110
|
+
...props
|
111
|
+
}, element, tooltip)
|
112
|
+
};
|
113
|
+
};
|
114
|
+
/**
|
115
|
+
* TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing
|
116
|
+
* the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip
|
117
|
+
* relative to the trigger.
|
118
|
+
*/ // We don't want getCollectionNode to show up in the type definition
|
119
|
+
let $19f06480c1c1a932$export$8c610744efcf8a1d = $19f06480c1c1a932$var$TooltipTrigger;
|
120
|
+
|
121
|
+
|
122
|
+
//# sourceMappingURL=TooltipTrigger.main.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAYD,MAAM,uCAAiB,IAAI,yFAAyF;AACpH,MAAM,6CAAuB;AAE7B,SAAS,qCAAe,KAAkC;IACxD,IAAI,YACF,QAAQ,eACR,cAAc,wDACd,UAAU,UACV,SAAS,sCACT,SAAS,aAAa,EACvB,GAAG;IAEJ,IAAI,CAAC,SAAS,QAAQ,GAAG,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC;IAChD,IAAI,QAAQ,CAAA,GAAA,iDAAqB,EAAE;IAEnC,IAAI,oBAAoB,CAAA,GAAA,mBAAK;IAC7B,IAAI,aAAa,CAAA,GAAA,mBAAK;IAEtB,IAAI,gBAAC,YAAY,gBAAE,YAAY,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE;oBACnD;QACA,SAAS;IACX,GAAG,OAAO;IAEV,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC/C,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,WAAW,OAAO,IAAI,MAAM,MAAM,EAAE;YACtC,IAAI,uBAAuB,OAAO,gBAAgB,CAAC,WAAW,OAAO,EAAE,YAAY;YACnF,IAAI,yBAAyB,IAC3B,gBAAgB,SAAS,sBAAsB;QAEnD;IACF,GAAG;QAAC,MAAM,MAAM;QAAE;KAAW;IAC7B,IAAI,WAAW,CAAA,GAAA,mBAAK,EAAE;IACtB,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC3C,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,SAAS,OAAO,IAAI,MAAM,MAAM,EAClC,cAAc,SAAS,OAAO,CAAC,qBAAqB,GAAG,KAAK;IAEhE,GAAG;QAAC,MAAM,MAAM;QAAE;KAAS;IAE3B,IAAI,gBAAC,YAAY,cAAE,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,2CAAiB,EAAE;QAC7D,WAAW,MAAM,SAAS,IAAI;QAC9B,WAAW;oBACX;gBACA;qBACA;QACA,QAAQ,MAAM,MAAM;QACpB,YAAY,MAAM,UAAU;QAC5B,kBAAkB,MAAM,gBAAgB;QACxC,WAAW;QACX,qBAAqB;IACvB;IAEA,qBACE,0DAAC,CAAA,GAAA,uCAAgB;QACd,GAAG,YAAY;QAChB,KAAK;OACJ,uBACD,0DAAC,CAAA,GAAA,wCAAa,EAAE,QAAQ;QACtB,OAAO;mBACL;uBACA;YACA,KAAK;YACL,cAAc,aAAa,KAAK;wBAChC;YACA,UAAU;YACV,GAAG,YAAY;QACjB;qBACA,0DAAC,CAAA,GAAA,oCAAM;QAAE,QAAQ,MAAM,MAAM;QAAE,SAAS;OACrC;AAKX;AAEA,oEAAoE;AACpE,qCAAe,iBAAiB,GAAG,UAAW,KAAkC;IAC9E,8EAA8E;IAC9E,IAAI,aAA6B,EAAE;IACnC,CAAA,GAAA,sCAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,QAAQ,EAAE,CAAA;QACrC,kBAAI,CAAA,GAAA,sCAAI,EAAE,cAAc,CAAC,QACvB,WAAW,IAAI,CAAC;IAEpB;IACA,IAAI,CAAC,SAAS,QAAQ,GAAG;IACzB,MAAM;QACJ,SAAS;QACT,SAAS,CAAC,wBACR,0DAAC;gBAAe,KAAK,QAAQ,GAAG;gBAAG,GAAG,KAAK;eACxC,SACA;IAGP;AACF;AAEA;;;;CAIC,GACD,oEAAoE;AACpE,IAAI,4CAAkB","sources":["packages/@react-spectrum/tooltip/src/TooltipTrigger.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableProvider} from '@react-aria/focus';\nimport {Overlay} from '@react-spectrum/overlays';\nimport React, {JSX, ReactElement, useRef, useState} from 'react';\nimport {SpectrumTooltipTriggerProps} from '@react-types/tooltip';\nimport {TooltipContext} from './context';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useOverlayPosition} from '@react-aria/overlays';\nimport {useTooltipTrigger} from '@react-aria/tooltip';\nimport {useTooltipTriggerState} from '@react-stately/tooltip';\n\nconst DEFAULT_OFFSET = -1; // Offset needed to reach 4px/5px (med/large) distance between tooltip and trigger button\nconst DEFAULT_CROSS_OFFSET = 0;\n\nfunction TooltipTrigger(props: SpectrumTooltipTriggerProps) {\n let {\n children,\n crossOffset = DEFAULT_CROSS_OFFSET,\n isDisabled,\n offset = DEFAULT_OFFSET,\n trigger: triggerAction\n } = props;\n\n let [trigger, tooltip] = React.Children.toArray(children) as [ReactElement, ReactElement];\n let state = useTooltipTriggerState(props);\n\n let tooltipTriggerRef = useRef<HTMLElement>();\n let overlayRef = useRef<HTMLDivElement>();\n\n let {triggerProps, tooltipProps} = useTooltipTrigger({\n isDisabled,\n trigger: triggerAction\n }, state, tooltipTriggerRef);\n\n let [borderRadius, setBorderRadius] = useState(0);\n useLayoutEffect(() => {\n if (overlayRef.current && state.isOpen) {\n let spectrumBorderRadius = window.getComputedStyle(overlayRef.current).borderRadius;\n if (spectrumBorderRadius !== '') {\n setBorderRadius(parseInt(spectrumBorderRadius, 10));\n }\n }\n }, [state.isOpen, overlayRef]);\n let arrowRef = useRef(null);\n let [arrowWidth, setArrowWidth] = useState(0);\n useLayoutEffect(() => {\n if (arrowRef.current && state.isOpen) {\n setArrowWidth(arrowRef.current.getBoundingClientRect().width);\n }\n }, [state.isOpen, arrowRef]);\n\n let {overlayProps, arrowProps, placement} = useOverlayPosition({\n placement: props.placement || 'top',\n targetRef: tooltipTriggerRef,\n overlayRef,\n offset,\n crossOffset,\n isOpen: state.isOpen,\n shouldFlip: props.shouldFlip,\n containerPadding: props.containerPadding,\n arrowSize: arrowWidth,\n arrowBoundaryOffset: borderRadius\n });\n\n return (\n <FocusableProvider\n {...triggerProps}\n ref={tooltipTriggerRef}>\n {trigger}\n <TooltipContext.Provider\n value={{\n state,\n placement,\n ref: overlayRef,\n UNSAFE_style: overlayProps.style,\n arrowProps,\n arrowRef: arrowRef,\n ...tooltipProps\n }}>\n <Overlay isOpen={state.isOpen} nodeRef={overlayRef}>\n {tooltip}\n </Overlay>\n </TooltipContext.Provider>\n </FocusableProvider>\n );\n}\n\n// Support TooltipTrigger inside components using CollectionBuilder.\nTooltipTrigger.getCollectionNode = function* (props: SpectrumTooltipTriggerProps) {\n // Replaced the use of React.Childern.toArray because it mutates the key prop.\n let childArray: ReactElement[] = [];\n React.Children.forEach(props.children, child => {\n if (React.isValidElement(child)) {\n childArray.push(child);\n }\n });\n let [trigger, tooltip] = childArray;\n yield {\n element: trigger,\n wrapper: (element) => (\n <TooltipTrigger key={element.key} {...props}>\n {element}\n {tooltip}\n </TooltipTrigger>\n )\n };\n};\n\n/**\n * TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing\n * the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip\n * relative to the trigger.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _TooltipTrigger = TooltipTrigger as (props: SpectrumTooltipTriggerProps) => JSX.Element;\nexport {_TooltipTrigger as TooltipTrigger};\n"],"names":[],"version":3,"file":"TooltipTrigger.main.js.map"}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import {TooltipContext as $b8c00169fae46ac7$export$39ae08fa83328b12} from "./context.mjs";
|
2
|
+
import {FocusableProvider as $cQFGy$FocusableProvider} from "@react-aria/focus";
|
3
|
+
import {Overlay as $cQFGy$Overlay} from "@react-spectrum/overlays";
|
4
|
+
import $cQFGy$react, {useRef as $cQFGy$useRef, useState as $cQFGy$useState} from "react";
|
5
|
+
import {useLayoutEffect as $cQFGy$useLayoutEffect} from "@react-aria/utils";
|
6
|
+
import {useOverlayPosition as $cQFGy$useOverlayPosition} from "@react-aria/overlays";
|
7
|
+
import {useTooltipTrigger as $cQFGy$useTooltipTrigger} from "@react-aria/tooltip";
|
8
|
+
import {useTooltipTriggerState as $cQFGy$useTooltipTriggerState} from "@react-stately/tooltip";
|
9
|
+
|
10
|
+
/*
|
11
|
+
* Copyright 2020 Adobe. All rights reserved.
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
*
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
19
|
+
* governing permissions and limitations under the License.
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
const $019364e6919ef1db$var$DEFAULT_OFFSET = -1; // Offset needed to reach 4px/5px (med/large) distance between tooltip and trigger button
|
29
|
+
const $019364e6919ef1db$var$DEFAULT_CROSS_OFFSET = 0;
|
30
|
+
function $019364e6919ef1db$var$TooltipTrigger(props) {
|
31
|
+
let { children: children, crossOffset: crossOffset = $019364e6919ef1db$var$DEFAULT_CROSS_OFFSET, isDisabled: isDisabled, offset: offset = $019364e6919ef1db$var$DEFAULT_OFFSET, trigger: triggerAction } = props;
|
32
|
+
let [trigger, tooltip] = (0, $cQFGy$react).Children.toArray(children);
|
33
|
+
let state = (0, $cQFGy$useTooltipTriggerState)(props);
|
34
|
+
let tooltipTriggerRef = (0, $cQFGy$useRef)();
|
35
|
+
let overlayRef = (0, $cQFGy$useRef)();
|
36
|
+
let { triggerProps: triggerProps, tooltipProps: tooltipProps } = (0, $cQFGy$useTooltipTrigger)({
|
37
|
+
isDisabled: isDisabled,
|
38
|
+
trigger: triggerAction
|
39
|
+
}, state, tooltipTriggerRef);
|
40
|
+
let [borderRadius, setBorderRadius] = (0, $cQFGy$useState)(0);
|
41
|
+
(0, $cQFGy$useLayoutEffect)(()=>{
|
42
|
+
if (overlayRef.current && state.isOpen) {
|
43
|
+
let spectrumBorderRadius = window.getComputedStyle(overlayRef.current).borderRadius;
|
44
|
+
if (spectrumBorderRadius !== "") setBorderRadius(parseInt(spectrumBorderRadius, 10));
|
45
|
+
}
|
46
|
+
}, [
|
47
|
+
state.isOpen,
|
48
|
+
overlayRef
|
49
|
+
]);
|
50
|
+
let arrowRef = (0, $cQFGy$useRef)(null);
|
51
|
+
let [arrowWidth, setArrowWidth] = (0, $cQFGy$useState)(0);
|
52
|
+
(0, $cQFGy$useLayoutEffect)(()=>{
|
53
|
+
if (arrowRef.current && state.isOpen) setArrowWidth(arrowRef.current.getBoundingClientRect().width);
|
54
|
+
}, [
|
55
|
+
state.isOpen,
|
56
|
+
arrowRef
|
57
|
+
]);
|
58
|
+
let { overlayProps: overlayProps, arrowProps: arrowProps, placement: placement } = (0, $cQFGy$useOverlayPosition)({
|
59
|
+
placement: props.placement || "top",
|
60
|
+
targetRef: tooltipTriggerRef,
|
61
|
+
overlayRef: overlayRef,
|
62
|
+
offset: offset,
|
63
|
+
crossOffset: crossOffset,
|
64
|
+
isOpen: state.isOpen,
|
65
|
+
shouldFlip: props.shouldFlip,
|
66
|
+
containerPadding: props.containerPadding,
|
67
|
+
arrowSize: arrowWidth,
|
68
|
+
arrowBoundaryOffset: borderRadius
|
69
|
+
});
|
70
|
+
return /*#__PURE__*/ (0, $cQFGy$react).createElement((0, $cQFGy$FocusableProvider), {
|
71
|
+
...triggerProps,
|
72
|
+
ref: tooltipTriggerRef
|
73
|
+
}, trigger, /*#__PURE__*/ (0, $cQFGy$react).createElement((0, $b8c00169fae46ac7$export$39ae08fa83328b12).Provider, {
|
74
|
+
value: {
|
75
|
+
state: state,
|
76
|
+
placement: placement,
|
77
|
+
ref: overlayRef,
|
78
|
+
UNSAFE_style: overlayProps.style,
|
79
|
+
arrowProps: arrowProps,
|
80
|
+
arrowRef: arrowRef,
|
81
|
+
...tooltipProps
|
82
|
+
}
|
83
|
+
}, /*#__PURE__*/ (0, $cQFGy$react).createElement((0, $cQFGy$Overlay), {
|
84
|
+
isOpen: state.isOpen,
|
85
|
+
nodeRef: overlayRef
|
86
|
+
}, tooltip)));
|
87
|
+
}
|
88
|
+
// Support TooltipTrigger inside components using CollectionBuilder.
|
89
|
+
$019364e6919ef1db$var$TooltipTrigger.getCollectionNode = function*(props) {
|
90
|
+
// Replaced the use of React.Childern.toArray because it mutates the key prop.
|
91
|
+
let childArray = [];
|
92
|
+
(0, $cQFGy$react).Children.forEach(props.children, (child)=>{
|
93
|
+
if (/*#__PURE__*/ (0, $cQFGy$react).isValidElement(child)) childArray.push(child);
|
94
|
+
});
|
95
|
+
let [trigger, tooltip] = childArray;
|
96
|
+
yield {
|
97
|
+
element: trigger,
|
98
|
+
wrapper: (element)=>/*#__PURE__*/ (0, $cQFGy$react).createElement($019364e6919ef1db$var$TooltipTrigger, {
|
99
|
+
key: element.key,
|
100
|
+
...props
|
101
|
+
}, element, tooltip)
|
102
|
+
};
|
103
|
+
};
|
104
|
+
/**
|
105
|
+
* TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing
|
106
|
+
* the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip
|
107
|
+
* relative to the trigger.
|
108
|
+
*/ // We don't want getCollectionNode to show up in the type definition
|
109
|
+
let $019364e6919ef1db$export$8c610744efcf8a1d = $019364e6919ef1db$var$TooltipTrigger;
|
110
|
+
|
111
|
+
|
112
|
+
export {$019364e6919ef1db$export$8c610744efcf8a1d as TooltipTrigger};
|
113
|
+
//# sourceMappingURL=TooltipTrigger.mjs.map
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import {TooltipContext as $b8c00169fae46ac7$export$39ae08fa83328b12} from "./context.module.js";
|
2
|
+
import {FocusableProvider as $cQFGy$FocusableProvider} from "@react-aria/focus";
|
3
|
+
import {Overlay as $cQFGy$Overlay} from "@react-spectrum/overlays";
|
4
|
+
import $cQFGy$react, {useRef as $cQFGy$useRef, useState as $cQFGy$useState} from "react";
|
5
|
+
import {useLayoutEffect as $cQFGy$useLayoutEffect} from "@react-aria/utils";
|
6
|
+
import {useOverlayPosition as $cQFGy$useOverlayPosition} from "@react-aria/overlays";
|
7
|
+
import {useTooltipTrigger as $cQFGy$useTooltipTrigger} from "@react-aria/tooltip";
|
8
|
+
import {useTooltipTriggerState as $cQFGy$useTooltipTriggerState} from "@react-stately/tooltip";
|
9
|
+
|
10
|
+
/*
|
11
|
+
* Copyright 2020 Adobe. All rights reserved.
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
*
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
19
|
+
* governing permissions and limitations under the License.
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
const $019364e6919ef1db$var$DEFAULT_OFFSET = -1; // Offset needed to reach 4px/5px (med/large) distance between tooltip and trigger button
|
29
|
+
const $019364e6919ef1db$var$DEFAULT_CROSS_OFFSET = 0;
|
30
|
+
function $019364e6919ef1db$var$TooltipTrigger(props) {
|
31
|
+
let { children: children, crossOffset: crossOffset = $019364e6919ef1db$var$DEFAULT_CROSS_OFFSET, isDisabled: isDisabled, offset: offset = $019364e6919ef1db$var$DEFAULT_OFFSET, trigger: triggerAction } = props;
|
32
|
+
let [trigger, tooltip] = (0, $cQFGy$react).Children.toArray(children);
|
33
|
+
let state = (0, $cQFGy$useTooltipTriggerState)(props);
|
34
|
+
let tooltipTriggerRef = (0, $cQFGy$useRef)();
|
35
|
+
let overlayRef = (0, $cQFGy$useRef)();
|
36
|
+
let { triggerProps: triggerProps, tooltipProps: tooltipProps } = (0, $cQFGy$useTooltipTrigger)({
|
37
|
+
isDisabled: isDisabled,
|
38
|
+
trigger: triggerAction
|
39
|
+
}, state, tooltipTriggerRef);
|
40
|
+
let [borderRadius, setBorderRadius] = (0, $cQFGy$useState)(0);
|
41
|
+
(0, $cQFGy$useLayoutEffect)(()=>{
|
42
|
+
if (overlayRef.current && state.isOpen) {
|
43
|
+
let spectrumBorderRadius = window.getComputedStyle(overlayRef.current).borderRadius;
|
44
|
+
if (spectrumBorderRadius !== "") setBorderRadius(parseInt(spectrumBorderRadius, 10));
|
45
|
+
}
|
46
|
+
}, [
|
47
|
+
state.isOpen,
|
48
|
+
overlayRef
|
49
|
+
]);
|
50
|
+
let arrowRef = (0, $cQFGy$useRef)(null);
|
51
|
+
let [arrowWidth, setArrowWidth] = (0, $cQFGy$useState)(0);
|
52
|
+
(0, $cQFGy$useLayoutEffect)(()=>{
|
53
|
+
if (arrowRef.current && state.isOpen) setArrowWidth(arrowRef.current.getBoundingClientRect().width);
|
54
|
+
}, [
|
55
|
+
state.isOpen,
|
56
|
+
arrowRef
|
57
|
+
]);
|
58
|
+
let { overlayProps: overlayProps, arrowProps: arrowProps, placement: placement } = (0, $cQFGy$useOverlayPosition)({
|
59
|
+
placement: props.placement || "top",
|
60
|
+
targetRef: tooltipTriggerRef,
|
61
|
+
overlayRef: overlayRef,
|
62
|
+
offset: offset,
|
63
|
+
crossOffset: crossOffset,
|
64
|
+
isOpen: state.isOpen,
|
65
|
+
shouldFlip: props.shouldFlip,
|
66
|
+
containerPadding: props.containerPadding,
|
67
|
+
arrowSize: arrowWidth,
|
68
|
+
arrowBoundaryOffset: borderRadius
|
69
|
+
});
|
70
|
+
return /*#__PURE__*/ (0, $cQFGy$react).createElement((0, $cQFGy$FocusableProvider), {
|
71
|
+
...triggerProps,
|
72
|
+
ref: tooltipTriggerRef
|
73
|
+
}, trigger, /*#__PURE__*/ (0, $cQFGy$react).createElement((0, $b8c00169fae46ac7$export$39ae08fa83328b12).Provider, {
|
74
|
+
value: {
|
75
|
+
state: state,
|
76
|
+
placement: placement,
|
77
|
+
ref: overlayRef,
|
78
|
+
UNSAFE_style: overlayProps.style,
|
79
|
+
arrowProps: arrowProps,
|
80
|
+
arrowRef: arrowRef,
|
81
|
+
...tooltipProps
|
82
|
+
}
|
83
|
+
}, /*#__PURE__*/ (0, $cQFGy$react).createElement((0, $cQFGy$Overlay), {
|
84
|
+
isOpen: state.isOpen,
|
85
|
+
nodeRef: overlayRef
|
86
|
+
}, tooltip)));
|
87
|
+
}
|
88
|
+
// Support TooltipTrigger inside components using CollectionBuilder.
|
89
|
+
$019364e6919ef1db$var$TooltipTrigger.getCollectionNode = function*(props) {
|
90
|
+
// Replaced the use of React.Childern.toArray because it mutates the key prop.
|
91
|
+
let childArray = [];
|
92
|
+
(0, $cQFGy$react).Children.forEach(props.children, (child)=>{
|
93
|
+
if (/*#__PURE__*/ (0, $cQFGy$react).isValidElement(child)) childArray.push(child);
|
94
|
+
});
|
95
|
+
let [trigger, tooltip] = childArray;
|
96
|
+
yield {
|
97
|
+
element: trigger,
|
98
|
+
wrapper: (element)=>/*#__PURE__*/ (0, $cQFGy$react).createElement($019364e6919ef1db$var$TooltipTrigger, {
|
99
|
+
key: element.key,
|
100
|
+
...props
|
101
|
+
}, element, tooltip)
|
102
|
+
};
|
103
|
+
};
|
104
|
+
/**
|
105
|
+
* TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing
|
106
|
+
* the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip
|
107
|
+
* relative to the trigger.
|
108
|
+
*/ // We don't want getCollectionNode to show up in the type definition
|
109
|
+
let $019364e6919ef1db$export$8c610744efcf8a1d = $019364e6919ef1db$var$TooltipTrigger;
|
110
|
+
|
111
|
+
|
112
|
+
export {$019364e6919ef1db$export$8c610744efcf8a1d as TooltipTrigger};
|
113
|
+
//# sourceMappingURL=TooltipTrigger.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAYD,MAAM,uCAAiB,IAAI,yFAAyF;AACpH,MAAM,6CAAuB;AAE7B,SAAS,qCAAe,KAAkC;IACxD,IAAI,YACF,QAAQ,eACR,cAAc,wDACd,UAAU,UACV,SAAS,sCACT,SAAS,aAAa,EACvB,GAAG;IAEJ,IAAI,CAAC,SAAS,QAAQ,GAAG,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC;IAChD,IAAI,QAAQ,CAAA,GAAA,6BAAqB,EAAE;IAEnC,IAAI,oBAAoB,CAAA,GAAA,aAAK;IAC7B,IAAI,aAAa,CAAA,GAAA,aAAK;IAEtB,IAAI,gBAAC,YAAY,gBAAE,YAAY,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;oBACnD;QACA,SAAS;IACX,GAAG,OAAO;IAEV,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,eAAO,EAAE;IAC/C,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,WAAW,OAAO,IAAI,MAAM,MAAM,EAAE;YACtC,IAAI,uBAAuB,OAAO,gBAAgB,CAAC,WAAW,OAAO,EAAE,YAAY;YACnF,IAAI,yBAAyB,IAC3B,gBAAgB,SAAS,sBAAsB;QAEnD;IACF,GAAG;QAAC,MAAM,MAAM;QAAE;KAAW;IAC7B,IAAI,WAAW,CAAA,GAAA,aAAK,EAAE;IACtB,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,eAAO,EAAE;IAC3C,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,SAAS,OAAO,IAAI,MAAM,MAAM,EAClC,cAAc,SAAS,OAAO,CAAC,qBAAqB,GAAG,KAAK;IAEhE,GAAG;QAAC,MAAM,MAAM;QAAE;KAAS;IAE3B,IAAI,gBAAC,YAAY,cAAE,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,yBAAiB,EAAE;QAC7D,WAAW,MAAM,SAAS,IAAI;QAC9B,WAAW;oBACX;gBACA;qBACA;QACA,QAAQ,MAAM,MAAM;QACpB,YAAY,MAAM,UAAU;QAC5B,kBAAkB,MAAM,gBAAgB;QACxC,WAAW;QACX,qBAAqB;IACvB;IAEA,qBACE,gCAAC,CAAA,GAAA,wBAAgB;QACd,GAAG,YAAY;QAChB,KAAK;OACJ,uBACD,gCAAC,CAAA,GAAA,yCAAa,EAAE,QAAQ;QACtB,OAAO;mBACL;uBACA;YACA,KAAK;YACL,cAAc,aAAa,KAAK;wBAChC;YACA,UAAU;YACV,GAAG,YAAY;QACjB;qBACA,gCAAC,CAAA,GAAA,cAAM;QAAE,QAAQ,MAAM,MAAM;QAAE,SAAS;OACrC;AAKX;AAEA,oEAAoE;AACpE,qCAAe,iBAAiB,GAAG,UAAW,KAAkC;IAC9E,8EAA8E;IAC9E,IAAI,aAA6B,EAAE;IACnC,CAAA,GAAA,YAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,QAAQ,EAAE,CAAA;QACrC,kBAAI,CAAA,GAAA,YAAI,EAAE,cAAc,CAAC,QACvB,WAAW,IAAI,CAAC;IAEpB;IACA,IAAI,CAAC,SAAS,QAAQ,GAAG;IACzB,MAAM;QACJ,SAAS;QACT,SAAS,CAAC,wBACR,gCAAC;gBAAe,KAAK,QAAQ,GAAG;gBAAG,GAAG,KAAK;eACxC,SACA;IAGP;AACF;AAEA;;;;CAIC,GACD,oEAAoE;AACpE,IAAI,4CAAkB","sources":["packages/@react-spectrum/tooltip/src/TooltipTrigger.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableProvider} from '@react-aria/focus';\nimport {Overlay} from '@react-spectrum/overlays';\nimport React, {JSX, ReactElement, useRef, useState} from 'react';\nimport {SpectrumTooltipTriggerProps} from '@react-types/tooltip';\nimport {TooltipContext} from './context';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useOverlayPosition} from '@react-aria/overlays';\nimport {useTooltipTrigger} from '@react-aria/tooltip';\nimport {useTooltipTriggerState} from '@react-stately/tooltip';\n\nconst DEFAULT_OFFSET = -1; // Offset needed to reach 4px/5px (med/large) distance between tooltip and trigger button\nconst DEFAULT_CROSS_OFFSET = 0;\n\nfunction TooltipTrigger(props: SpectrumTooltipTriggerProps) {\n let {\n children,\n crossOffset = DEFAULT_CROSS_OFFSET,\n isDisabled,\n offset = DEFAULT_OFFSET,\n trigger: triggerAction\n } = props;\n\n let [trigger, tooltip] = React.Children.toArray(children) as [ReactElement, ReactElement];\n let state = useTooltipTriggerState(props);\n\n let tooltipTriggerRef = useRef<HTMLElement>();\n let overlayRef = useRef<HTMLDivElement>();\n\n let {triggerProps, tooltipProps} = useTooltipTrigger({\n isDisabled,\n trigger: triggerAction\n }, state, tooltipTriggerRef);\n\n let [borderRadius, setBorderRadius] = useState(0);\n useLayoutEffect(() => {\n if (overlayRef.current && state.isOpen) {\n let spectrumBorderRadius = window.getComputedStyle(overlayRef.current).borderRadius;\n if (spectrumBorderRadius !== '') {\n setBorderRadius(parseInt(spectrumBorderRadius, 10));\n }\n }\n }, [state.isOpen, overlayRef]);\n let arrowRef = useRef(null);\n let [arrowWidth, setArrowWidth] = useState(0);\n useLayoutEffect(() => {\n if (arrowRef.current && state.isOpen) {\n setArrowWidth(arrowRef.current.getBoundingClientRect().width);\n }\n }, [state.isOpen, arrowRef]);\n\n let {overlayProps, arrowProps, placement} = useOverlayPosition({\n placement: props.placement || 'top',\n targetRef: tooltipTriggerRef,\n overlayRef,\n offset,\n crossOffset,\n isOpen: state.isOpen,\n shouldFlip: props.shouldFlip,\n containerPadding: props.containerPadding,\n arrowSize: arrowWidth,\n arrowBoundaryOffset: borderRadius\n });\n\n return (\n <FocusableProvider\n {...triggerProps}\n ref={tooltipTriggerRef}>\n {trigger}\n <TooltipContext.Provider\n value={{\n state,\n placement,\n ref: overlayRef,\n UNSAFE_style: overlayProps.style,\n arrowProps,\n arrowRef: arrowRef,\n ...tooltipProps\n }}>\n <Overlay isOpen={state.isOpen} nodeRef={overlayRef}>\n {tooltip}\n </Overlay>\n </TooltipContext.Provider>\n </FocusableProvider>\n );\n}\n\n// Support TooltipTrigger inside components using CollectionBuilder.\nTooltipTrigger.getCollectionNode = function* (props: SpectrumTooltipTriggerProps) {\n // Replaced the use of React.Childern.toArray because it mutates the key prop.\n let childArray: ReactElement[] = [];\n React.Children.forEach(props.children, child => {\n if (React.isValidElement(child)) {\n childArray.push(child);\n }\n });\n let [trigger, tooltip] = childArray;\n yield {\n element: trigger,\n wrapper: (element) => (\n <TooltipTrigger key={element.key} {...props}>\n {element}\n {tooltip}\n </TooltipTrigger>\n )\n };\n};\n\n/**\n * TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing\n * the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip\n * relative to the trigger.\n */\n// We don't want getCollectionNode to show up in the type definition\nlet _TooltipTrigger = TooltipTrigger as (props: SpectrumTooltipTriggerProps) => JSX.Element;\nexport {_TooltipTrigger as TooltipTrigger};\n"],"names":[],"version":3,"file":"TooltipTrigger.module.js.map"}
|