@react-aria/tooltip 3.6.2 → 3.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +5 -5
- package/dist/main.js +5 -5
- package/dist/main.js.map +1 -1
- package/dist/module.js +5 -5
- package/dist/module.js.map +1 -1
- package/package.json +8 -8
package/dist/import.mjs
CHANGED
|
@@ -29,7 +29,7 @@ function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
|
|
|
29
29
|
let domProps = (0, $kgVYN$filterDOMProps)(props, {
|
|
30
30
|
labelable: true
|
|
31
31
|
});
|
|
32
|
-
let { hoverProps: hoverProps
|
|
32
|
+
let { hoverProps: hoverProps } = (0, $kgVYN$useHover)({
|
|
33
33
|
onHoverStart: ()=>{
|
|
34
34
|
return state === null || state === void 0 ? void 0 : state.open(true);
|
|
35
35
|
},
|
|
@@ -60,7 +60,7 @@ function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
|
|
63
|
-
let { isDisabled: isDisabled
|
|
63
|
+
let { isDisabled: isDisabled, trigger: trigger } = props;
|
|
64
64
|
let tooltipId = (0, $kgVYN$useId)();
|
|
65
65
|
let isHovered = (0, $kgVYN$useRef)(false);
|
|
66
66
|
let isFocused = (0, $kgVYN$useRef)(false);
|
|
@@ -126,15 +126,15 @@ function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
|
|
|
126
126
|
isHovered.current = false;
|
|
127
127
|
handleHide(true);
|
|
128
128
|
};
|
|
129
|
-
let { hoverProps: hoverProps
|
|
129
|
+
let { hoverProps: hoverProps } = (0, $kgVYN$useHover)({
|
|
130
130
|
isDisabled: isDisabled,
|
|
131
131
|
onHoverStart: onHoverStart,
|
|
132
132
|
onHoverEnd: onHoverEnd
|
|
133
133
|
});
|
|
134
|
-
let { pressProps: pressProps
|
|
134
|
+
let { pressProps: pressProps } = (0, $kgVYN$usePress)({
|
|
135
135
|
onPressStart: onPressStart
|
|
136
136
|
});
|
|
137
|
-
let { focusableProps: focusableProps
|
|
137
|
+
let { focusableProps: focusableProps } = (0, $kgVYN$useFocusable)({
|
|
138
138
|
isDisabled: isDisabled,
|
|
139
139
|
onFocus: onFocus,
|
|
140
140
|
onBlur: onBlur
|
package/dist/main.js
CHANGED
|
@@ -35,7 +35,7 @@ function $199fa2aaa84f20b7$export$1c4b08e0eca38426(props, state) {
|
|
|
35
35
|
let domProps = (0, $aGFp5$reactariautils.filterDOMProps)(props, {
|
|
36
36
|
labelable: true
|
|
37
37
|
});
|
|
38
|
-
let { hoverProps: hoverProps
|
|
38
|
+
let { hoverProps: hoverProps } = (0, $aGFp5$reactariainteractions.useHover)({
|
|
39
39
|
onHoverStart: ()=>{
|
|
40
40
|
return state === null || state === void 0 ? void 0 : state.open(true);
|
|
41
41
|
},
|
|
@@ -66,7 +66,7 @@ function $199fa2aaa84f20b7$export$1c4b08e0eca38426(props, state) {
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
|
|
69
|
-
let { isDisabled: isDisabled
|
|
69
|
+
let { isDisabled: isDisabled, trigger: trigger } = props;
|
|
70
70
|
let tooltipId = (0, $aGFp5$reactariautils.useId)();
|
|
71
71
|
let isHovered = (0, $aGFp5$react.useRef)(false);
|
|
72
72
|
let isFocused = (0, $aGFp5$react.useRef)(false);
|
|
@@ -132,15 +132,15 @@ function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
|
|
|
132
132
|
isHovered.current = false;
|
|
133
133
|
handleHide(true);
|
|
134
134
|
};
|
|
135
|
-
let { hoverProps: hoverProps
|
|
135
|
+
let { hoverProps: hoverProps } = (0, $aGFp5$reactariainteractions.useHover)({
|
|
136
136
|
isDisabled: isDisabled,
|
|
137
137
|
onHoverStart: onHoverStart,
|
|
138
138
|
onHoverEnd: onHoverEnd
|
|
139
139
|
});
|
|
140
|
-
let { pressProps: pressProps
|
|
140
|
+
let { pressProps: pressProps } = (0, $aGFp5$reactariainteractions.usePress)({
|
|
141
141
|
onPressStart: onPressStart
|
|
142
142
|
});
|
|
143
|
-
let { focusableProps: focusableProps
|
|
143
|
+
let { focusableProps: focusableProps } = (0, $aGFp5$reactariafocus.useFocusable)({
|
|
144
144
|
isDisabled: isDisabled,
|
|
145
145
|
onFocus: onFocus,
|
|
146
146
|
onBlur: onBlur
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;AAkBM,SAAS,0CAAW,KAAuB,EAAE,KAA2B;IAC7E,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,IAAI,cAAC,
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;AAkBM,SAAS,0CAAW,KAAuB,EAAE,KAA2B;IAC7E,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QAC1B,cAAc;YAAM,OAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,KAAK;;QAChC,YAAY;YAAM,OAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO;;IAC3B;IAEA,OAAO;QACL,cAAc,CAAA,GAAA,gCAAS,EAAE,UAAU,YAAY;YAC7C,MAAM;QACR;IACF;AACF;;CD/BC;AEVD;;;;;;;;;;CAUC;;;;AA0BM,SAAS,0CAAkB,KAA0B,EAAE,KAA0B,EAAE,GAAgC;IACxH,IAAI,cACF,UAAU,WACV,OAAO,EACR,GAAG;IAEJ,IAAI,YAAY,CAAA,GAAA,2BAAI;IAEpB,IAAI,YAAY,CAAA,GAAA,m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GAAG,CAAA,GAAA,qCAAO,EAAE;sBAAC;IAAY;IAEzC,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW,EAAE;oBAClC;iBACA;gBACA;IACF,GAAG;IAEH,OAAO;QACL,cAAc;YACZ,oBAAoB,MAAM,SAAS,YAAY;YAC/C,GAAG,CAAA,GAAA,gCAAS,EAAE,gBAAgB,YAAY,WAAW;QACvD;QACA,cAAc;YACZ,IAAI;QACN;IACF;AACF;","sources":["packages/@react-aria/tooltip/src/index.ts","packages/@react-aria/tooltip/src/useTooltip.ts","packages/@react-aria/tooltip/src/useTooltipTrigger.ts"],"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 */\nexport {useTooltip} from './useTooltip';\nexport {useTooltipTrigger} from './useTooltipTrigger';\nexport type {AriaTooltipProps, TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipAria} from './useTooltip';\nexport type {TooltipTriggerAria} from './useTooltipTrigger';\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 {AriaTooltipProps} from '@react-types/tooltip';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface TooltipAria {\n /**\n * Props for the tooltip element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a Tooltip component.\n */\nexport function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria {\n let domProps = filterDOMProps(props, {labelable: true});\n\n let {hoverProps} = useHover({\n onHoverStart: () => state?.open(true),\n onHoverEnd: () => state?.close()\n });\n\n return {\n tooltipProps: mergeProps(domProps, hoverProps, {\n role: 'tooltip'\n })\n };\n}\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 {DOMAttributes, FocusableElement, FocusEvents} from '@react-types/shared';\nimport {getInteractionModality, HoverProps, isFocusVisible, PressProps, useHover, usePress} from '@react-aria/interactions';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {TooltipTriggerProps} from '@react-types/tooltip';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useFocusable} from '@react-aria/focus';\n\nexport interface TooltipTriggerAria {\n /**\n * Props for the trigger element.\n */\n triggerProps: DOMAttributes & PressProps & HoverProps & FocusEvents,\n\n /**\n * Props for the overlay container element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button\n * that shows a description when focused or hovered.\n */\nexport function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<FocusableElement>) : TooltipTriggerAria {\n let {\n isDisabled,\n trigger\n } = props;\n\n let tooltipId = useId();\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n\n let handleShow = () => {\n if (isHovered.current || isFocused.current) {\n state.open(isFocused.current);\n }\n };\n\n let handleHide = (immediate?: boolean) => {\n if (!isHovered.current && !isFocused.current) {\n state.close(immediate);\n }\n };\n\n useEffect(() => {\n let onKeyDown = (e) => {\n if (ref && ref.current) {\n // Escape after clicking something can give it keyboard focus\n // dismiss tooltip on esc key press\n if (e.key === 'Escape') {\n e.stopPropagation();\n state.close(true);\n }\n }\n };\n if (state.isOpen) {\n document.addEventListener('keydown', onKeyDown, true);\n return () => {\n document.removeEventListener('keydown', onKeyDown, true);\n };\n }\n }, [ref, state]);\n\n let onHoverStart = () => {\n if (trigger === 'focus') {\n return;\n }\n // In chrome, if you hover a trigger, then another element obscures it, due to keyboard\n // interactions for example, hover will end. When hover is restored after that element disappears,\n // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover\n // is the result of moving the mouse.\n if (getInteractionModality() === 'pointer') {\n isHovered.current = true;\n } else {\n isHovered.current = false;\n }\n handleShow();\n };\n\n let onHoverEnd = () => {\n if (trigger === 'focus') {\n return;\n }\n // no matter how the trigger is left, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide();\n };\n\n let onPressStart = () => {\n // no matter how the trigger is pressed, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\n };\n\n let onFocus = () => {\n let isVisible = isFocusVisible();\n if (isVisible) {\n isFocused.current = true;\n handleShow();\n }\n };\n\n let onBlur = () => {\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\n };\n\n let {hoverProps} = useHover({\n isDisabled,\n onHoverStart,\n onHoverEnd\n });\n\n let {pressProps} = usePress({onPressStart});\n\n let {focusableProps} = useFocusable({\n isDisabled,\n onFocus,\n onBlur\n }, ref);\n\n return {\n triggerProps: {\n 'aria-describedby': state.isOpen ? tooltipId : undefined,\n ...mergeProps(focusableProps, hoverProps, pressProps)\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -29,7 +29,7 @@ function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
|
|
|
29
29
|
let domProps = (0, $kgVYN$filterDOMProps)(props, {
|
|
30
30
|
labelable: true
|
|
31
31
|
});
|
|
32
|
-
let { hoverProps: hoverProps
|
|
32
|
+
let { hoverProps: hoverProps } = (0, $kgVYN$useHover)({
|
|
33
33
|
onHoverStart: ()=>{
|
|
34
34
|
return state === null || state === void 0 ? void 0 : state.open(true);
|
|
35
35
|
},
|
|
@@ -60,7 +60,7 @@ function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
|
|
63
|
-
let { isDisabled: isDisabled
|
|
63
|
+
let { isDisabled: isDisabled, trigger: trigger } = props;
|
|
64
64
|
let tooltipId = (0, $kgVYN$useId)();
|
|
65
65
|
let isHovered = (0, $kgVYN$useRef)(false);
|
|
66
66
|
let isFocused = (0, $kgVYN$useRef)(false);
|
|
@@ -126,15 +126,15 @@ function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
|
|
|
126
126
|
isHovered.current = false;
|
|
127
127
|
handleHide(true);
|
|
128
128
|
};
|
|
129
|
-
let { hoverProps: hoverProps
|
|
129
|
+
let { hoverProps: hoverProps } = (0, $kgVYN$useHover)({
|
|
130
130
|
isDisabled: isDisabled,
|
|
131
131
|
onHoverStart: onHoverStart,
|
|
132
132
|
onHoverEnd: onHoverEnd
|
|
133
133
|
});
|
|
134
|
-
let { pressProps: pressProps
|
|
134
|
+
let { pressProps: pressProps } = (0, $kgVYN$usePress)({
|
|
135
135
|
onPressStart: onPressStart
|
|
136
136
|
});
|
|
137
|
-
let { focusableProps: focusableProps
|
|
137
|
+
let { focusableProps: focusableProps } = (0, $kgVYN$useFocusable)({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cAAc;YACZ,IAAI;QACN;IACF;AACF;","sources":["packages/@react-aria/tooltip/src/index.ts","packages/@react-aria/tooltip/src/useTooltip.ts","packages/@react-aria/tooltip/src/useTooltipTrigger.ts"],"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 */\nexport {useTooltip} from './useTooltip';\nexport {useTooltipTrigger} from './useTooltipTrigger';\nexport type {AriaTooltipProps, TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipAria} from './useTooltip';\nexport type {TooltipTriggerAria} from './useTooltipTrigger';\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 {AriaTooltipProps} from '@react-types/tooltip';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface TooltipAria {\n /**\n * Props for the tooltip element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a Tooltip component.\n */\nexport function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria {\n let domProps = filterDOMProps(props, {labelable: true});\n\n let {hoverProps} = useHover({\n onHoverStart: () => state?.open(true),\n onHoverEnd: () => state?.close()\n });\n\n return {\n tooltipProps: mergeProps(domProps, hoverProps, {\n role: 'tooltip'\n })\n };\n}\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 {DOMAttributes, FocusableElement, FocusEvents} from '@react-types/shared';\nimport {getInteractionModality, HoverProps, isFocusVisible, PressProps, useHover, usePress} from '@react-aria/interactions';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {TooltipTriggerProps} from '@react-types/tooltip';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useFocusable} from '@react-aria/focus';\n\nexport interface TooltipTriggerAria {\n /**\n * Props for the trigger element.\n */\n triggerProps: DOMAttributes & PressProps & HoverProps & FocusEvents,\n\n /**\n * Props for the overlay container element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button\n * that shows a description when focused or hovered.\n */\nexport function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<FocusableElement>) : TooltipTriggerAria {\n let {\n isDisabled,\n trigger\n } = props;\n\n let tooltipId = useId();\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n\n let handleShow = () => {\n if (isHovered.current || isFocused.current) {\n state.open(isFocused.current);\n }\n };\n\n let handleHide = (immediate?: boolean) => {\n if (!isHovered.current && !isFocused.current) {\n state.close(immediate);\n }\n };\n\n useEffect(() => {\n let onKeyDown = (e) => {\n if (ref && ref.current) {\n // Escape after clicking something can give it keyboard focus\n // dismiss tooltip on esc key press\n if (e.key === 'Escape') {\n e.stopPropagation();\n state.close(true);\n }\n }\n };\n if (state.isOpen) {\n document.addEventListener('keydown', onKeyDown, true);\n return () => {\n document.removeEventListener('keydown', onKeyDown, true);\n };\n }\n }, [ref, state]);\n\n let onHoverStart = () => {\n if (trigger === 'focus') {\n return;\n }\n // In chrome, if you hover a trigger, then another element obscures it, due to keyboard\n // interactions for example, hover will end. When hover is restored after that element disappears,\n // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover\n // is the result of moving the mouse.\n if (getInteractionModality() === 'pointer') {\n isHovered.current = true;\n } else {\n isHovered.current = false;\n }\n handleShow();\n };\n\n let onHoverEnd = () => {\n if (trigger === 'focus') {\n return;\n }\n // no matter how the trigger is left, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide();\n };\n\n let onPressStart = () => {\n // no matter how the trigger is pressed, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\n };\n\n let onFocus = () => {\n let isVisible = isFocusVisible();\n if (isVisible) {\n isFocused.current = true;\n handleShow();\n }\n };\n\n let onBlur = () => {\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\n };\n\n let {hoverProps} = useHover({\n isDisabled,\n onHoverStart,\n onHoverEnd\n });\n\n let {pressProps} = usePress({onPressStart});\n\n let {focusableProps} = useFocusable({\n isDisabled,\n onFocus,\n onBlur\n }, ref);\n\n return {\n triggerProps: {\n 'aria-describedby': state.isOpen ? tooltipId : undefined,\n ...mergeProps(focusableProps, hoverProps, pressProps)\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/tooltip",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.3",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/focus": "^3.14.
|
|
26
|
-
"@react-aria/interactions": "^3.
|
|
27
|
-
"@react-aria/utils": "^3.
|
|
28
|
-
"@react-stately/tooltip": "^3.4.
|
|
29
|
-
"@react-types/shared": "^3.
|
|
30
|
-
"@react-types/tooltip": "^3.4.
|
|
25
|
+
"@react-aria/focus": "^3.14.2",
|
|
26
|
+
"@react-aria/interactions": "^3.19.0",
|
|
27
|
+
"@react-aria/utils": "^3.21.0",
|
|
28
|
+
"@react-stately/tooltip": "^3.4.5",
|
|
29
|
+
"@react-types/shared": "^3.21.0",
|
|
30
|
+
"@react-types/tooltip": "^3.4.5",
|
|
31
31
|
"@swc/helpers": "^0.5.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "4122e44d1991c90507d630d35ed297f89db435d3"
|
|
40
40
|
}
|