@react-spectrum/tooltip 3.5.1 → 3.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js.map +1 -1
- package/dist/module.js.map +1 -1
- package/package.json +15 -15
package/dist/main.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C;ACZ1C;;;;;;;;;;CAUC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;ACZA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAjBA,4CAAqC;AACrC,4CAA4B;AAC5B,4CAA6C;AAC7C,4CAA0C;AAC1C,4CAA4C;AAC5C,4CAA2C;AAC3C,2CAAyC;AACzC,4CAA8C;AAC9C,4CAA2C;AAC3C,4CAA0C;AAC1C,4CAA+B;AAC/B,4CAA+B;AAC/B,4CAA+C;AAC/C,4CAA4C;AAC5C,4CAA2C;AAC3C,4CAA2C;AAC3C,4CAA+C;AAC/C,4CAA8C;;;;ACjB9C;;;;;;;;;;CAUC,GAED;AAaO,MAAM,4CAAiB,CAAA,GAAA,sCAAK,AAAD,EAAE,aAAa,CAAsB,CAAC;;;;AFDxE,IAAI,gCAAU;IACZ,MAAM,CAAA,GAAA,yDAAS,AAAD;IACd,UAAU,CAAA,GAAA,yDAAY,GAAD;IACrB,UAAU,CAAA,GAAA,yDAAU,CAAD;AACrB;AAEA,SAAS,8BAAQ,KAA2B,EAAE,GAAW,EAAE;IACzD,IAAI,EAAC,KAAK,WAAU,cAAE,WAAU,SAAE,MAAK,YAAE,SAAQ,EAAE,GAAG,sBAAqB,GAAG,CAAA,GAAA,uBAAS,EAAE,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AAE;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,uCAAiB,AAAD;QACd,GAAG,YAAY;QAChB,KAAK;OACJ,uBACD,0DAAC,CAAA,GAAA,yCAAa,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,EAAE;IAChF,8EAA8E;IAC9E,IAAI,aAA6B,EAAE;IACnC,CAAA,GAAA,sCAAK,AAAD,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,QAAQ,EAAE,CAAA,QAAS;QAC9C,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/index.ts","packages/@react-spectrum/tooltip/src/Tooltip.tsx","packages/@adobe/spectrum-css-temp/components/tooltip/vars.css","packages/@react-spectrum/tooltip/src/context.ts","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\n/// <reference types=\"css-module-types\" />\n\nexport {Tooltip} from './Tooltip';\nexport {TooltipTrigger} from './TooltipTrigger';\nexport type {SpectrumTooltipProps, SpectrumTooltipTriggerProps} from '@react-types/tooltip';\n","/*\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 },\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","/*\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\n@import './index.css';\n@import './skin.css';\n","/*\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 {PlacementAxis} from '@react-types/overlays';\nimport React, {HTMLAttributes, RefObject} from 'react';\nimport {StyleProps} from '@react-types/shared';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\n\ninterface TooltipContextProps extends StyleProps {\n state?: TooltipTriggerState,\n ref?: RefObject<HTMLDivElement>,\n placement?: PlacementAxis,\n arrowProps?: HTMLAttributes<HTMLElement>,\n arrowRef?: RefObject<HTMLElement>\n}\n\nexport const TooltipContext = React.createContext<TooltipContextProps>({});\n","/*\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, {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":"main.js.map"}
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C;ACZ1C;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;;;;;ACVD,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAjBA,4CAAqC;AACrC,4CAA4B;AAC5B,4CAA6C;AAC7C,4CAA0C;AAC1C,4CAA4C;AAC5C,4CAA2C;AAC3C,2CAAyC;AACzC,4CAA8C;AAC9C,4CAA2C;AAC3C,4CAA0C;AAC1C,4CAA+B;AAC/B,4CAA+B;AAC/B,4CAA+C;AAC/C,4CAA4C;AAC5C,4CAA2C;AAC3C,4CAA2C;AAC3C,4CAA+C;AAC/C,4CAA8C;;;;ACjB9C;;;;;;;;;;CAUC;AAeM,MAAM,4CAAiB,CAAA,GAAA,sCAAI,EAAE,cAAmC,CAAC;;;;AFDxE,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,WAAU,cAAE,WAAU,SAAE,MAAK,YAAE,SAAQ,EAAE,GAAG,s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OACJ,uBACD,0DAAC,CAAA,GAAA,yCAAa,EAAE;QACd,OAAO;mBACL;uBACA;YACA,KAAK;YACL,cAAc,aAAa;wBAC3B;YACA,UAAU;YACV,GAAG,YAAY;QACjB;qBACA,0DAAC,CAAA,GAAA,oCAAM;QAAE,QAAQ,MAAM;QAAQ,SAAS;OACrC;AAKX;AAEA,oEAAoE;AACpE,qCAAe,oBAAoB,UAAW,KAAkC;IAC9E,8EAA8E;IAC9E,IAAI,aAA6B,EAAE;IACnC,CAAA,GAAA,sCAAI,EAAE,SAAS,QAAQ,MAAM,UAAU,CAAA;QACrC,kBAAI,CAAA,GAAA,sCAAI,EAAE,eAAe,QACvB,WAAW,KAAK;IAEpB;IACA,IAAI,CAAC,SAAS,QAAQ,GAAG;IACzB,MAAM;QACJ,SAAS;QACT,SAAS,CAAC,wBACR,0DAAC;gBAAe,KAAK,QAAQ;gBAAM,GAAG,KAAK;eACxC,SACA;IAGP;AACF;AAEA;;;;CAIC,GACD,oEAAoE;AACpE,IAAI,4CAAkB;;","sources":["packages/@react-spectrum/tooltip/src/index.ts","packages/@react-spectrum/tooltip/src/Tooltip.tsx","packages/@adobe/spectrum-css-temp/components/tooltip/vars.css","packages/@react-spectrum/tooltip/src/context.ts","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\n/// <reference types=\"css-module-types\" />\n\nexport {Tooltip} from './Tooltip';\nexport {TooltipTrigger} from './TooltipTrigger';\nexport type {SpectrumTooltipProps, SpectrumTooltipTriggerProps} from '@react-types/tooltip';\n","/*\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 },\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","/*\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\n@import './index.css';\n@import './skin.css';\n","/*\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 {PlacementAxis} from '@react-types/overlays';\nimport React, {HTMLAttributes, RefObject} from 'react';\nimport {StyleProps} from '@react-types/shared';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\n\ninterface TooltipContextProps extends StyleProps {\n state?: TooltipTriggerState,\n ref?: RefObject<HTMLDivElement>,\n placement?: PlacementAxis,\n arrowProps?: HTMLAttributes<HTMLElement>,\n arrowRef?: RefObject<HTMLElement>\n}\n\nexport const TooltipContext = React.createContext<TooltipContextProps>({});\n","/*\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, {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":"main.js.map"}
|
package/dist/module.js.map
CHANGED
@@ -1 +1 @@
|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;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,EAAE;IAChF,8EAA8E;IAC9E,IAAI,aAA6B,EAAE;IACnC,CAAA,GAAA,YAAK,AAAD,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,QAAQ,EAAE,CAAA,QAAS;QAC9C,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/index.ts","packages/@react-spectrum/tooltip/src/Tooltip.tsx","packages/@adobe/spectrum-css-temp/components/tooltip/vars.css","packages/@react-spectrum/tooltip/src/context.ts","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\n/// <reference types=\"css-module-types\" />\n\nexport {Tooltip} from './Tooltip';\nexport {TooltipTrigger} from './TooltipTrigger';\nexport type {SpectrumTooltipProps, SpectrumTooltipTriggerProps} from '@react-types/tooltip';\n","/*\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 },\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","/*\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\n@import './index.css';\n@import './skin.css';\n","/*\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 {PlacementAxis} from '@react-types/overlays';\nimport React, {HTMLAttributes, RefObject} from 'react';\nimport {StyleProps} from '@react-types/shared';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\n\ninterface TooltipContextProps extends StyleProps {\n state?: TooltipTriggerState,\n ref?: RefObject<HTMLDivElement>,\n placement?: PlacementAxis,\n arrowProps?: HTMLAttributes<HTMLElement>,\n arrowRef?: RefObject<HTMLElement>\n}\n\nexport const TooltipContext = React.createContext<TooltipContextProps>({});\n","/*\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, {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 {_Toolt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AAkC;IAC9E,8EAA8E;IAC9E,IAAI,aAA6B,EAAE;IACnC,CAAA,GAAA,YAAI,EAAE,SAAS,QAAQ,MAAM,UAAU,CAAA;QACrC,kBAAI,CAAA,GAAA,YAAI,EAAE,eAAe,QACvB,WAAW,KAAK;IAEpB;IACA,IAAI,CAAC,SAAS,QAAQ,GAAG;IACzB,MAAM;QACJ,SAAS;QACT,SAAS,CAAC,wBACR,gCAAC;gBAAe,KAAK,QAAQ;gBAAM,GAAG,KAAK;eACxC,SACA;IAGP;AACF;AAEA;;;;CAIC,GACD,oEAAoE;AACpE,IAAI,4CAAkB;;","sources":["packages/@react-spectrum/tooltip/src/index.ts","packages/@react-spectrum/tooltip/src/Tooltip.tsx","packages/@adobe/spectrum-css-temp/components/tooltip/vars.css","packages/@react-spectrum/tooltip/src/context.ts","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\n/// <reference types=\"css-module-types\" />\n\nexport {Tooltip} from './Tooltip';\nexport {TooltipTrigger} from './TooltipTrigger';\nexport type {SpectrumTooltipProps, SpectrumTooltipTriggerProps} from '@react-types/tooltip';\n","/*\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 },\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","/*\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\n@import './index.css';\n@import './skin.css';\n","/*\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 {PlacementAxis} from '@react-types/overlays';\nimport React, {HTMLAttributes, RefObject} from 'react';\nimport {StyleProps} from '@react-types/shared';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\n\ninterface TooltipContextProps extends StyleProps {\n state?: TooltipTriggerState,\n ref?: RefObject<HTMLDivElement>,\n placement?: PlacementAxis,\n arrowProps?: HTMLAttributes<HTMLElement>,\n arrowRef?: RefObject<HTMLElement>\n}\n\nexport const TooltipContext = React.createContext<TooltipContextProps>({});\n","/*\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, {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":"module.js.map"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-spectrum/tooltip",
|
3
|
-
"version": "3.5.
|
3
|
+
"version": "3.5.2",
|
4
4
|
"description": "Spectrum UI components in React",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "dist/main.js",
|
@@ -36,20 +36,20 @@
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@react-aria/focus": "^3.
|
40
|
-
"@react-aria/interactions": "^3.
|
41
|
-
"@react-aria/overlays": "^3.
|
42
|
-
"@react-aria/tooltip": "^3.
|
43
|
-
"@react-aria/utils": "^3.
|
44
|
-
"@react-spectrum/overlays": "^5.
|
45
|
-
"@react-spectrum/utils": "^3.
|
46
|
-
"@react-stately/tooltip": "^3.4.
|
47
|
-
"@react-stately/utils": "^3.
|
48
|
-
"@react-types/overlays": "^3.
|
39
|
+
"@react-aria/focus": "^3.13.0",
|
40
|
+
"@react-aria/interactions": "^3.16.0",
|
41
|
+
"@react-aria/overlays": "^3.15.0",
|
42
|
+
"@react-aria/tooltip": "^3.6.0",
|
43
|
+
"@react-aria/utils": "^3.18.0",
|
44
|
+
"@react-spectrum/overlays": "^5.2.0",
|
45
|
+
"@react-spectrum/utils": "^3.10.0",
|
46
|
+
"@react-stately/tooltip": "^3.4.2",
|
47
|
+
"@react-stately/utils": "^3.7.0",
|
48
|
+
"@react-types/overlays": "^3.8.0",
|
49
49
|
"@react-types/shared": "^3.18.1",
|
50
|
-
"@react-types/tooltip": "^3.4.
|
51
|
-
"@spectrum-icons/ui": "^3.5.
|
52
|
-
"@swc/helpers": "^0.
|
50
|
+
"@react-types/tooltip": "^3.4.2",
|
51
|
+
"@spectrum-icons/ui": "^3.5.3",
|
52
|
+
"@swc/helpers": "^0.5.0"
|
53
53
|
},
|
54
54
|
"devDependencies": {
|
55
55
|
"@adobe/spectrum-css-temp": "3.0.0-alpha.1"
|
@@ -62,5 +62,5 @@
|
|
62
62
|
"publishConfig": {
|
63
63
|
"access": "public"
|
64
64
|
},
|
65
|
-
"gitHead": "
|
65
|
+
"gitHead": "504e40e0a50c1b20ed0fb3ba9561a263b6d5565e"
|
66
66
|
}
|