@react-spectrum/overlays 5.5.4 → 5.6.0
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/Modal.main.js +93 -0
- package/dist/Modal.main.js.map +1 -0
- package/dist/Modal.mjs +88 -0
- package/dist/Modal.module.js +88 -0
- package/dist/Modal.module.js.map +1 -0
- package/dist/OpenTransition.main.js +44 -0
- package/dist/OpenTransition.main.js.map +1 -0
- package/dist/OpenTransition.mjs +35 -0
- package/dist/OpenTransition.module.js +35 -0
- package/dist/OpenTransition.module.js.map +1 -0
- package/dist/Overlay.main.js +75 -0
- package/dist/Overlay.main.js.map +1 -0
- package/dist/Overlay.mjs +66 -0
- package/dist/Overlay.module.js +66 -0
- package/dist/Overlay.module.js.map +1 -0
- package/dist/Popover.main.js +206 -0
- package/dist/Popover.main.js.map +1 -0
- package/dist/Popover.mjs +201 -0
- package/dist/Popover.module.js +201 -0
- package/dist/Popover.module.js.map +1 -0
- package/dist/Tray.main.js +101 -0
- package/dist/Tray.main.js.map +1 -0
- package/dist/Tray.mjs +96 -0
- package/dist/Tray.module.js +96 -0
- package/dist/Tray.module.js.map +1 -0
- package/dist/Underlay.main.js +41 -0
- package/dist/Underlay.main.js.map +1 -0
- package/dist/Underlay.mjs +36 -0
- package/dist/Underlay.module.js +36 -0
- package/dist/Underlay.module.js.map +1 -0
- package/dist/import.mjs +5 -712
- package/dist/main.js +10 -713
- package/dist/main.js.map +1 -1
- package/dist/modal_vars_css.main.js +59 -0
- package/dist/modal_vars_css.main.js.map +1 -0
- package/dist/modal_vars_css.mjs +61 -0
- package/dist/modal_vars_css.module.js +61 -0
- package/dist/modal_vars_css.module.js.map +1 -0
- package/dist/module.js +5 -712
- package/dist/module.js.map +1 -1
- package/dist/overlays.ac5ba32f.css +12 -0
- package/dist/overlays.ac5ba32f.css.map +1 -0
- package/dist/overlays_css.main.js +35 -0
- package/dist/overlays_css.main.js.map +1 -0
- package/dist/overlays_css.mjs +37 -0
- package/dist/overlays_css.module.js +37 -0
- package/dist/overlays_css.module.js.map +1 -0
- package/dist/popover_vars_css.main.js +83 -0
- package/dist/popover_vars_css.main.js.map +1 -0
- package/dist/popover_vars_css.mjs +85 -0
- package/dist/popover_vars_css.module.js +85 -0
- package/dist/popover_vars_css.module.js.map +1 -0
- package/dist/tray_vars_css.main.js +53 -0
- package/dist/tray_vars_css.main.js.map +1 -0
- package/dist/tray_vars_css.mjs +55 -0
- package/dist/tray_vars_css.module.js +55 -0
- package/dist/tray_vars_css.module.js.map +1 -0
- package/dist/types.d.ts +5 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/underlay_vars_css.main.js +50 -0
- package/dist/underlay_vars_css.main.js.map +1 -0
- package/dist/underlay_vars_css.mjs +52 -0
- package/dist/underlay_vars_css.module.js +52 -0
- package/dist/underlay_vars_css.module.js.map +1 -0
- package/dist/vars.28c6b2d1.css +131 -0
- package/dist/vars.28c6b2d1.css.map +1 -0
- package/dist/vars.32d8c84b.css +197 -0
- package/dist/vars.32d8c84b.css.map +1 -0
- package/dist/vars.aa9f4ef9.css +183 -0
- package/dist/vars.aa9f4ef9.css.map +1 -0
- package/dist/vars.e9dc412f.css +210 -0
- package/dist/vars.e9dc412f.css.map +1 -0
- package/package.json +9 -9
- package/src/Overlay.tsx +1 -0
- package/dist/main.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AASD,SAAS,8BAAQ,KAAmB,EAAE,GAA2B;IAC/D,IAAI,YACF,QAAQ,UACR,MAAM,0BACN,sBAAsB,aACtB,SAAS,WACT,OAAO,cACP,UAAU,aACV,SAAS,UACT,MAAM,aACN,SAAS,YACT,QAAQ,WACR,OAAO,EACR,GAAG;IAEJ,IAAI,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,eAAO,EAAE,CAAC;IAEpC,IAAI,gBAAgB,CAAA,GAAA,kBAAU,EAAE;QAC9B,UAAU;QACV,IAAI,WACF;IAEJ,GAAG;QAAC;KAAU;IAEd,IAAI,eAAe,CAAA,GAAA,kBAAU,EAAE;QAC7B,UAAU;QACV,IAAI,UACF;IAEJ,GAAG;QAAC;KAAS;IAEb,4DAA4D;IAC5D,IAAI,eAAe,UAAU,CAAC;IAC9B,IAAI,CAAC,cACH,qDAAqD;IACrD,OAAO;IAGT,qBACE,gCAAC,CAAA,GAAA,cAAe;QAAE,iBAAiB;QAAW,wBAAwB;QAAwB,WAAW,CAAC;qBACxG,gCAAC,CAAA,GAAA,eAAO;QAAE,KAAK;QAAK,cAAc;YAAC,YAAY;YAAe,WAAW;QAAS;QAAG,YAAY;qBAC/F,gCAAC,CAAA,GAAA,yCAAa;QACZ,IAAI;QACJ,QAAA;QACA,QAAQ;QACR,WAAW;QACX,UAAU;QACV,SAAS;QACT,YAAY;QACZ,WAAW;QACX,SAAS;OACR;AAKX;AAEA,IAAI,0DAAW,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/overlays/src/Overlay.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 {DOMRef} from '@react-types/shared';\nimport {OpenTransition} from './OpenTransition';\nimport {OverlayProps} from '@react-types/overlays';\nimport {Provider} from '@react-spectrum/provider';\nimport React, {useCallback, useState} from 'react';\nimport {Overlay as ReactAriaOverlay} from '@react-aria/overlays';\n\nfunction Overlay(props: OverlayProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n isOpen,\n disableFocusManagement,\n container,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n nodeRef\n } = props;\n\n let [exited, setExited] = useState(!isOpen);\n\n let handleEntered = useCallback(() => {\n setExited(false);\n if (onEntered) {\n onEntered();\n }\n }, [onEntered]);\n\n let handleExited = useCallback(() => {\n setExited(true);\n if (onExited) {\n onExited();\n }\n }, [onExited]);\n\n // Don't un-render the overlay while it's transitioning out.\n let mountOverlay = isOpen || !exited;\n if (!mountOverlay) {\n // Don't bother showing anything if we don't have to.\n return null;\n }\n\n return (\n <ReactAriaOverlay portalContainer={container} disableFocusManagement={disableFocusManagement} isExiting={!isOpen}>\n <Provider ref={ref} UNSAFE_style={{background: 'transparent', isolation: 'isolate'}} isDisabled={false}>\n <OpenTransition\n in={isOpen}\n appear\n onExit={onExit}\n onExiting={onExiting}\n onExited={handleExited}\n onEnter={onEnter}\n onEntering={onEntering}\n onEntered={handleEntered}\n nodeRef={nodeRef}>\n {children}\n </OpenTransition>\n </Provider>\n </ReactAriaOverlay>\n );\n}\n\nlet _Overlay = React.forwardRef(Overlay);\nexport {_Overlay as Overlay};\n"],"names":[],"version":3,"file":"Overlay.module.js.map"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
var $2aebdc186fd41e87$exports = require("./Overlay.main.js");
|
|
2
|
+
require("./overlays.ac5ba32f.css");
|
|
3
|
+
var $e9a663ccb19ed1b0$exports = require("./overlays_css.main.js");
|
|
4
|
+
require("./vars.e9dc412f.css");
|
|
5
|
+
var $16e1dca4664d0b1c$exports = require("./popover_vars_css.main.js");
|
|
6
|
+
var $b900e75089bdd9cd$exports = require("./Underlay.main.js");
|
|
7
|
+
var $cgMBg$reactariaoverlays = require("@react-aria/overlays");
|
|
8
|
+
var $cgMBg$reactspectrumutils = require("@react-spectrum/utils");
|
|
9
|
+
var $cgMBg$reactariainteractions = require("@react-aria/interactions");
|
|
10
|
+
var $cgMBg$reactariautils = require("@react-aria/utils");
|
|
11
|
+
var $cgMBg$react = require("react");
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
function $parcel$interopDefault(a) {
|
|
15
|
+
return a && a.__esModule ? a.default : a;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function $parcel$export(e, n, v, s) {
|
|
19
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
$parcel$export(module.exports, "Popover", () => $f02bba55a62f20dd$export$5b6b19405a83ff9d);
|
|
23
|
+
/*
|
|
24
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
25
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
26
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
27
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
30
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
31
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
32
|
+
* governing permissions and limitations under the License.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Arrow placement can be done pointing right or down because those paths start at 0, x or y. Because the
|
|
44
|
+
* other two don't, they start at a fractional pixel value, it introduces rounding differences between browsers and
|
|
45
|
+
* between display types (retina with subpixels vs not retina). By flipping them with CSS we can ensure that
|
|
46
|
+
* the path always starts at 0 so that it perfectly overlaps the popover's border.
|
|
47
|
+
* See bottom of file for more explanation.
|
|
48
|
+
*/ let $f02bba55a62f20dd$var$arrowPlacement = {
|
|
49
|
+
left: "right",
|
|
50
|
+
right: "right",
|
|
51
|
+
top: "bottom",
|
|
52
|
+
bottom: "bottom"
|
|
53
|
+
};
|
|
54
|
+
function $f02bba55a62f20dd$var$Popover(props, ref) {
|
|
55
|
+
let { children: children, state: state, ...otherProps } = props;
|
|
56
|
+
let domRef = (0, $cgMBg$reactspectrumutils.useDOMRef)(ref);
|
|
57
|
+
let wrapperRef = (0, $cgMBg$react.useRef)(null);
|
|
58
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($cgMBg$react))).createElement((0, $2aebdc186fd41e87$exports.Overlay), {
|
|
59
|
+
...otherProps,
|
|
60
|
+
isOpen: state.isOpen,
|
|
61
|
+
nodeRef: wrapperRef
|
|
62
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($cgMBg$react))).createElement($f02bba55a62f20dd$var$PopoverWrapper, {
|
|
63
|
+
ref: domRef,
|
|
64
|
+
...props,
|
|
65
|
+
wrapperRef: wrapperRef
|
|
66
|
+
}, children));
|
|
67
|
+
}
|
|
68
|
+
const $f02bba55a62f20dd$var$PopoverWrapper = /*#__PURE__*/ (0, $cgMBg$react.forwardRef)((props, ref)=>{
|
|
69
|
+
let { children: children, isOpen: isOpen, hideArrow: hideArrow, isNonModal: isNonModal, enableBothDismissButtons: enableBothDismissButtons, state: state, wrapperRef: wrapperRef, onDismissButtonPress: onDismissButtonPress = ()=>state.close() } = props;
|
|
70
|
+
let { styleProps: styleProps } = (0, $cgMBg$reactspectrumutils.useStyleProps)(props);
|
|
71
|
+
let { size: size, borderWidth: borderWidth, arrowRef: arrowRef } = $f02bba55a62f20dd$var$useArrowSize();
|
|
72
|
+
const borderRadius = $f02bba55a62f20dd$var$usePopoverBorderRadius(ref);
|
|
73
|
+
let borderDiagonal = borderWidth * Math.SQRT2;
|
|
74
|
+
let primary = size + borderDiagonal;
|
|
75
|
+
let secondary = primary * 2;
|
|
76
|
+
let { popoverProps: popoverProps, arrowProps: arrowProps, underlayProps: underlayProps, placement: placement } = (0, $cgMBg$reactariaoverlays.usePopover)({
|
|
77
|
+
...props,
|
|
78
|
+
popoverRef: ref,
|
|
79
|
+
maxHeight: null,
|
|
80
|
+
arrowSize: hideArrow ? 0 : secondary,
|
|
81
|
+
arrowBoundaryOffset: borderRadius
|
|
82
|
+
}, state);
|
|
83
|
+
let { focusWithinProps: focusWithinProps } = (0, $cgMBg$reactariainteractions.useFocusWithin)(props);
|
|
84
|
+
// Attach Transition's nodeRef to outermost wrapper for node.reflow: https://github.com/reactjs/react-transition-group/blob/c89f807067b32eea6f68fd6c622190d88ced82e2/src/Transition.js#L231
|
|
85
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($cgMBg$react))).createElement("div", {
|
|
86
|
+
ref: wrapperRef
|
|
87
|
+
}, !isNonModal && /*#__PURE__*/ (0, ($parcel$interopDefault($cgMBg$react))).createElement((0, $b900e75089bdd9cd$exports.Underlay), {
|
|
88
|
+
isTransparent: true,
|
|
89
|
+
...(0, $cgMBg$reactariautils.mergeProps)(underlayProps),
|
|
90
|
+
isOpen: isOpen
|
|
91
|
+
}), /*#__PURE__*/ (0, ($parcel$interopDefault($cgMBg$react))).createElement("div", {
|
|
92
|
+
...styleProps,
|
|
93
|
+
...(0, $cgMBg$reactariautils.mergeProps)(popoverProps, focusWithinProps),
|
|
94
|
+
style: {
|
|
95
|
+
...styleProps.style,
|
|
96
|
+
...popoverProps.style
|
|
97
|
+
},
|
|
98
|
+
ref: ref,
|
|
99
|
+
className: (0, $cgMBg$reactspectrumutils.classNames)((0, ($parcel$interopDefault($16e1dca4664d0b1c$exports))), "spectrum-Popover", `spectrum-Popover--${placement}`, {
|
|
100
|
+
"spectrum-Popover--withTip": !hideArrow,
|
|
101
|
+
"is-open": isOpen,
|
|
102
|
+
[`is-open--${placement}`]: isOpen
|
|
103
|
+
}, (0, $cgMBg$reactspectrumutils.classNames)((0, ($parcel$interopDefault($e9a663ccb19ed1b0$exports))), "spectrum-Popover", "react-spectrum-Popover"), styleProps.className),
|
|
104
|
+
role: "presentation",
|
|
105
|
+
"data-testid": "popover"
|
|
106
|
+
}, (!isNonModal || enableBothDismissButtons) && /*#__PURE__*/ (0, ($parcel$interopDefault($cgMBg$react))).createElement((0, $cgMBg$reactariaoverlays.DismissButton), {
|
|
107
|
+
onDismiss: onDismissButtonPress
|
|
108
|
+
}), children, hideArrow ? null : /*#__PURE__*/ (0, ($parcel$interopDefault($cgMBg$react))).createElement($f02bba55a62f20dd$var$Arrow, {
|
|
109
|
+
arrowProps: arrowProps,
|
|
110
|
+
isLandscape: $f02bba55a62f20dd$var$arrowPlacement[placement] === "bottom",
|
|
111
|
+
arrowRef: arrowRef,
|
|
112
|
+
primary: primary,
|
|
113
|
+
secondary: secondary,
|
|
114
|
+
borderDiagonal: borderDiagonal
|
|
115
|
+
}), /*#__PURE__*/ (0, ($parcel$interopDefault($cgMBg$react))).createElement((0, $cgMBg$reactariaoverlays.DismissButton), {
|
|
116
|
+
onDismiss: onDismissButtonPress
|
|
117
|
+
})));
|
|
118
|
+
});
|
|
119
|
+
function $f02bba55a62f20dd$var$usePopoverBorderRadius(popoverRef) {
|
|
120
|
+
let [borderRadius, setBorderRadius] = (0, $cgMBg$react.useState)(0);
|
|
121
|
+
(0, $cgMBg$reactariautils.useLayoutEffect)(()=>{
|
|
122
|
+
if (popoverRef.current) {
|
|
123
|
+
let spectrumBorderRadius = window.getComputedStyle(popoverRef.current).borderRadius;
|
|
124
|
+
if (spectrumBorderRadius !== "") setBorderRadius(parseInt(spectrumBorderRadius, 10));
|
|
125
|
+
}
|
|
126
|
+
}, [
|
|
127
|
+
popoverRef
|
|
128
|
+
]);
|
|
129
|
+
return borderRadius;
|
|
130
|
+
}
|
|
131
|
+
function $f02bba55a62f20dd$var$useArrowSize() {
|
|
132
|
+
let [size, setSize] = (0, $cgMBg$react.useState)(20);
|
|
133
|
+
let [borderWidth, setBorderWidth] = (0, $cgMBg$react.useState)(1);
|
|
134
|
+
let arrowRef = (0, $cgMBg$react.useRef)(null);
|
|
135
|
+
// get the css value for the tip size and divide it by 2 for this arrow implementation
|
|
136
|
+
(0, $cgMBg$reactariautils.useLayoutEffect)(()=>{
|
|
137
|
+
if (arrowRef.current) {
|
|
138
|
+
let spectrumTipWidth = window.getComputedStyle(arrowRef.current).getPropertyValue("--spectrum-popover-tip-size");
|
|
139
|
+
if (spectrumTipWidth !== "") setSize(parseInt(spectrumTipWidth, 10) / 2);
|
|
140
|
+
let spectrumBorderWidth = window.getComputedStyle(arrowRef.current).getPropertyValue("--spectrum-popover-tip-borderWidth");
|
|
141
|
+
if (spectrumBorderWidth !== "") setBorderWidth(parseInt(spectrumBorderWidth, 10));
|
|
142
|
+
}
|
|
143
|
+
}, []);
|
|
144
|
+
return {
|
|
145
|
+
size: size,
|
|
146
|
+
borderWidth: borderWidth,
|
|
147
|
+
arrowRef: arrowRef
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function $f02bba55a62f20dd$var$Arrow(props) {
|
|
151
|
+
let { primary: primary, secondary: secondary, isLandscape: isLandscape, arrowProps: arrowProps, borderDiagonal: borderDiagonal, arrowRef: arrowRef } = props;
|
|
152
|
+
let halfBorderDiagonal = borderDiagonal / 2;
|
|
153
|
+
let primaryStart = 0;
|
|
154
|
+
let primaryEnd = primary - halfBorderDiagonal;
|
|
155
|
+
let secondaryStart = halfBorderDiagonal;
|
|
156
|
+
let secondaryMiddle = secondary / 2;
|
|
157
|
+
let secondaryEnd = secondary - halfBorderDiagonal;
|
|
158
|
+
let pathData = isLandscape ? [
|
|
159
|
+
"M",
|
|
160
|
+
secondaryStart,
|
|
161
|
+
primaryStart,
|
|
162
|
+
"L",
|
|
163
|
+
secondaryMiddle,
|
|
164
|
+
primaryEnd,
|
|
165
|
+
"L",
|
|
166
|
+
secondaryEnd,
|
|
167
|
+
primaryStart
|
|
168
|
+
] : [
|
|
169
|
+
"M",
|
|
170
|
+
primaryStart,
|
|
171
|
+
secondaryStart,
|
|
172
|
+
"L",
|
|
173
|
+
primaryEnd,
|
|
174
|
+
secondaryMiddle,
|
|
175
|
+
"L",
|
|
176
|
+
primaryStart,
|
|
177
|
+
secondaryEnd
|
|
178
|
+
];
|
|
179
|
+
/* use ceil because the svg needs to always accommodate the path inside it */ return /*#__PURE__*/ (0, ($parcel$interopDefault($cgMBg$react))).createElement("svg", {
|
|
180
|
+
xmlns: "http://www.w3.org/svg/2000",
|
|
181
|
+
width: Math.ceil(isLandscape ? secondary : primary),
|
|
182
|
+
height: Math.ceil(isLandscape ? primary : secondary),
|
|
183
|
+
className: (0, $cgMBg$reactspectrumutils.classNames)((0, ($parcel$interopDefault($16e1dca4664d0b1c$exports))), "spectrum-Popover-tip"),
|
|
184
|
+
ref: arrowRef,
|
|
185
|
+
...arrowProps
|
|
186
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($cgMBg$react))).createElement("path", {
|
|
187
|
+
className: (0, $cgMBg$reactspectrumutils.classNames)((0, ($parcel$interopDefault($16e1dca4664d0b1c$exports))), "spectrum-Popover-tip-triangle"),
|
|
188
|
+
d: pathData.join(" ")
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
let $f02bba55a62f20dd$export$5b6b19405a83ff9d = /*#__PURE__*/ (0, $cgMBg$react.forwardRef)($f02bba55a62f20dd$var$Popover);
|
|
192
|
+
/**
|
|
193
|
+
* More explanation on popover tips.
|
|
194
|
+
* - I tried changing the calculation of the popover placement in an effort to get it squarely onto the pixel grid.
|
|
195
|
+
* This did not work because the problem was in the svg partial pixel end of the path in the popover right and popover bottom.
|
|
196
|
+
* - I tried creating an extra 'bandaid' path that matched the background color and would overlap the popover border.
|
|
197
|
+
* This didn't work because the border on the svg triangle didn't extend all the way to match nicely with the popover border.
|
|
198
|
+
* - I tried getting the client bounding box and setting the svg to that partial pixel value
|
|
199
|
+
* This didn't work because again the issue was inside the svg
|
|
200
|
+
* - I didn't try drawing the svg backwards
|
|
201
|
+
* This could still be tried
|
|
202
|
+
* - I tried changing the calculation of the popover placement AND the svg height/width so that they were all rounded
|
|
203
|
+
* This seems to have done the trick.
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
//# sourceMappingURL=Popover.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;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AC;;AAG7F;AAEA,IAAI,0DAAW,CAAA,GAAA,uBAAS,EAAE;CAG1B;;;;;;;;;;;;CAYC","sources":["packages/@react-spectrum/overlays/src/Popover.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 {AriaPopoverProps, DismissButton, PopoverAria, usePopover} from '@react-aria/overlays';\nimport {classNames, useDOMRef, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef, StyleProps} from '@react-types/shared';\nimport {FocusWithinProps, useFocusWithin} from '@react-aria/interactions';\nimport {mergeProps, useLayoutEffect} from '@react-aria/utils';\nimport {Overlay} from './Overlay';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport overrideStyles from './overlays.css';\nimport React, {forwardRef, MutableRefObject, ReactNode, RefObject, useRef, useState} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/popover/vars.css';\nimport {Underlay} from './Underlay';\n\ninterface PopoverProps extends Omit<AriaPopoverProps, 'popoverRef' | 'maxHeight'>, FocusWithinProps, StyleProps {\n children: ReactNode,\n hideArrow?: boolean,\n state: OverlayTriggerState,\n shouldContainFocus?: boolean,\n onEntering?: () => void,\n onEnter?: () => void,\n onEntered?: () => void,\n onExiting?: () => void,\n onExited?: () => void,\n onExit?: () => void,\n container?: HTMLElement,\n disableFocusManagement?: boolean,\n enableBothDismissButtons?: boolean,\n onDismissButtonPress?: () => void\n}\n\ninterface PopoverWrapperProps extends PopoverProps, FocusWithinProps {\n isOpen?: boolean,\n wrapperRef: MutableRefObject<HTMLDivElement>\n}\n\ninterface ArrowProps {\n arrowProps: PopoverAria['arrowProps'],\n isLandscape: boolean,\n arrowRef?: RefObject<SVGSVGElement>,\n primary: number,\n secondary: number,\n borderDiagonal: number\n}\n\n/**\n * Arrow placement can be done pointing right or down because those paths start at 0, x or y. Because the\n * other two don't, they start at a fractional pixel value, it introduces rounding differences between browsers and\n * between display types (retina with subpixels vs not retina). By flipping them with CSS we can ensure that\n * the path always starts at 0 so that it perfectly overlaps the popover's border.\n * See bottom of file for more explanation.\n */\nlet arrowPlacement = {\n left: 'right',\n right: 'right',\n top: 'bottom',\n bottom: 'bottom'\n};\n\nfunction Popover(props: PopoverProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n state,\n ...otherProps\n } = props;\n let domRef = useDOMRef(ref);\n let wrapperRef = useRef<HTMLDivElement>(null);\n\n return (\n <Overlay {...otherProps} isOpen={state.isOpen} nodeRef={wrapperRef}>\n <PopoverWrapper ref={domRef} {...props} wrapperRef={wrapperRef}>\n {children}\n </PopoverWrapper>\n </Overlay>\n );\n}\n\nconst PopoverWrapper = forwardRef((props: PopoverWrapperProps, ref: RefObject<HTMLDivElement>) => {\n let {\n children,\n isOpen,\n hideArrow,\n isNonModal,\n enableBothDismissButtons,\n state,\n wrapperRef,\n onDismissButtonPress = () => state.close()\n } = props;\n let {styleProps} = useStyleProps(props);\n\n let {size, borderWidth, arrowRef} = useArrowSize();\n const borderRadius = usePopoverBorderRadius(ref);\n let borderDiagonal = borderWidth * Math.SQRT2;\n let primary = size + borderDiagonal;\n let secondary = primary * 2;\n let {\n popoverProps,\n arrowProps,\n underlayProps,\n placement\n } = usePopover({\n ...props,\n popoverRef: ref,\n maxHeight: null,\n arrowSize: hideArrow ? 0 : secondary,\n arrowBoundaryOffset: borderRadius\n }, state);\n let {focusWithinProps} = useFocusWithin(props);\n\n // Attach Transition's nodeRef to outermost wrapper for node.reflow: https://github.com/reactjs/react-transition-group/blob/c89f807067b32eea6f68fd6c622190d88ced82e2/src/Transition.js#L231\n return (\n <div ref={wrapperRef}>\n {!isNonModal && <Underlay isTransparent {...mergeProps(underlayProps)} isOpen={isOpen} /> }\n <div\n {...styleProps}\n {...mergeProps(popoverProps, focusWithinProps)}\n style={{\n ...styleProps.style,\n ...popoverProps.style\n }}\n ref={ref}\n className={\n classNames(\n styles,\n 'spectrum-Popover',\n `spectrum-Popover--${placement}`,\n {\n 'spectrum-Popover--withTip': !hideArrow,\n 'is-open': isOpen,\n [`is-open--${placement}`]: isOpen\n },\n classNames(\n overrideStyles,\n 'spectrum-Popover',\n 'react-spectrum-Popover'\n ),\n styleProps.className\n )\n }\n role=\"presentation\"\n data-testid=\"popover\">\n {(!isNonModal || enableBothDismissButtons) && <DismissButton onDismiss={onDismissButtonPress} />}\n {children}\n {hideArrow ? null : (\n <Arrow\n arrowProps={arrowProps}\n isLandscape={arrowPlacement[placement] === 'bottom'}\n arrowRef={arrowRef}\n primary={primary}\n secondary={secondary}\n borderDiagonal={borderDiagonal} />\n )}\n <DismissButton onDismiss={onDismissButtonPress} />\n </div>\n </div>\n );\n});\n\nfunction usePopoverBorderRadius(popoverRef: RefObject<HTMLDivElement>) {\n let [borderRadius, setBorderRadius] = useState(0);\n useLayoutEffect(() => {\n if (popoverRef.current) {\n let spectrumBorderRadius = window.getComputedStyle(popoverRef.current).borderRadius;\n if (spectrumBorderRadius !== '') {\n setBorderRadius(parseInt(spectrumBorderRadius, 10));\n }\n }\n }, [popoverRef]);\n return borderRadius;\n}\n\nfunction useArrowSize() {\n let [size, setSize] = useState(20);\n let [borderWidth, setBorderWidth] = useState(1);\n let arrowRef = useRef<SVGSVGElement>(null);\n // get the css value for the tip size and divide it by 2 for this arrow implementation\n useLayoutEffect(() => {\n if (arrowRef.current) {\n let spectrumTipWidth = window.getComputedStyle(arrowRef.current)\n .getPropertyValue('--spectrum-popover-tip-size');\n if (spectrumTipWidth !== '') {\n setSize(parseInt(spectrumTipWidth, 10) / 2);\n }\n\n let spectrumBorderWidth = window.getComputedStyle(arrowRef.current)\n .getPropertyValue('--spectrum-popover-tip-borderWidth');\n if (spectrumBorderWidth !== '') {\n setBorderWidth(parseInt(spectrumBorderWidth, 10));\n }\n }\n }, []);\n return {size, borderWidth, arrowRef};\n}\n\nfunction Arrow(props: ArrowProps) {\n let {primary, secondary, isLandscape, arrowProps, borderDiagonal, arrowRef} = props;\n let halfBorderDiagonal = borderDiagonal / 2;\n\n let primaryStart = 0;\n let primaryEnd = primary - halfBorderDiagonal;\n\n let secondaryStart = halfBorderDiagonal;\n let secondaryMiddle = secondary / 2;\n let secondaryEnd = secondary - halfBorderDiagonal;\n\n let pathData = isLandscape ? [\n 'M', secondaryStart, primaryStart,\n 'L', secondaryMiddle, primaryEnd,\n 'L', secondaryEnd, primaryStart\n ] : [\n 'M', primaryStart, secondaryStart,\n 'L', primaryEnd, secondaryMiddle,\n 'L', primaryStart, secondaryEnd\n ];\n\n /* use ceil because the svg needs to always accommodate the path inside it */\n return (\n <svg\n xmlns=\"http://www.w3.org/svg/2000\"\n width={Math.ceil(isLandscape ? secondary : primary)}\n height={Math.ceil(isLandscape ? primary : secondary)}\n className={classNames(styles, 'spectrum-Popover-tip')}\n ref={arrowRef}\n {...arrowProps}>\n <path className={classNames(styles, 'spectrum-Popover-tip-triangle')} d={pathData.join(' ')} />\n </svg>\n );\n}\n\nlet _Popover = forwardRef(Popover);\nexport {_Popover as Popover};\n\n/**\n * More explanation on popover tips.\n * - I tried changing the calculation of the popover placement in an effort to get it squarely onto the pixel grid.\n * This did not work because the problem was in the svg partial pixel end of the path in the popover right and popover bottom.\n * - I tried creating an extra 'bandaid' path that matched the background color and would overlap the popover border.\n * This didn't work because the border on the svg triangle didn't extend all the way to match nicely with the popover border.\n * - I tried getting the client bounding box and setting the svg to that partial pixel value\n * This didn't work because again the issue was inside the svg\n * - I didn't try drawing the svg backwards\n * This could still be tried\n * - I tried changing the calculation of the popover placement AND the svg height/width so that they were all rounded\n * This seems to have done the trick.\n */\n"],"names":[],"version":3,"file":"Popover.main.js.map"}
|
package/dist/Popover.mjs
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import {Overlay as $70305dc5fb729c3b$export$c6fdb837b070b4ff} from "./Overlay.mjs";
|
|
2
|
+
import "./overlays.ac5ba32f.css";
|
|
3
|
+
import $4kQ6h$overlays_cssmodulejs from "./overlays_css.mjs";
|
|
4
|
+
import "./vars.e9dc412f.css";
|
|
5
|
+
import $4kQ6h$popover_vars_cssmodulejs from "./popover_vars_css.mjs";
|
|
6
|
+
import {Underlay as $76a452f4e3df11be$export$f360afc887607b02} from "./Underlay.mjs";
|
|
7
|
+
import {usePopover as $4kQ6h$usePopover, DismissButton as $4kQ6h$DismissButton} from "@react-aria/overlays";
|
|
8
|
+
import {useDOMRef as $4kQ6h$useDOMRef, useStyleProps as $4kQ6h$useStyleProps, classNames as $4kQ6h$classNames} from "@react-spectrum/utils";
|
|
9
|
+
import {useFocusWithin as $4kQ6h$useFocusWithin} from "@react-aria/interactions";
|
|
10
|
+
import {mergeProps as $4kQ6h$mergeProps, useLayoutEffect as $4kQ6h$useLayoutEffect} from "@react-aria/utils";
|
|
11
|
+
import $4kQ6h$react, {useRef as $4kQ6h$useRef, forwardRef as $4kQ6h$forwardRef, useState as $4kQ6h$useState} from "react";
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
function $parcel$interopDefault(a) {
|
|
15
|
+
return a && a.__esModule ? a.default : a;
|
|
16
|
+
}
|
|
17
|
+
/*
|
|
18
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Arrow placement can be done pointing right or down because those paths start at 0, x or y. Because the
|
|
38
|
+
* other two don't, they start at a fractional pixel value, it introduces rounding differences between browsers and
|
|
39
|
+
* between display types (retina with subpixels vs not retina). By flipping them with CSS we can ensure that
|
|
40
|
+
* the path always starts at 0 so that it perfectly overlaps the popover's border.
|
|
41
|
+
* See bottom of file for more explanation.
|
|
42
|
+
*/ let $17b503f7de08fecc$var$arrowPlacement = {
|
|
43
|
+
left: "right",
|
|
44
|
+
right: "right",
|
|
45
|
+
top: "bottom",
|
|
46
|
+
bottom: "bottom"
|
|
47
|
+
};
|
|
48
|
+
function $17b503f7de08fecc$var$Popover(props, ref) {
|
|
49
|
+
let { children: children, state: state, ...otherProps } = props;
|
|
50
|
+
let domRef = (0, $4kQ6h$useDOMRef)(ref);
|
|
51
|
+
let wrapperRef = (0, $4kQ6h$useRef)(null);
|
|
52
|
+
return /*#__PURE__*/ (0, $4kQ6h$react).createElement((0, $70305dc5fb729c3b$export$c6fdb837b070b4ff), {
|
|
53
|
+
...otherProps,
|
|
54
|
+
isOpen: state.isOpen,
|
|
55
|
+
nodeRef: wrapperRef
|
|
56
|
+
}, /*#__PURE__*/ (0, $4kQ6h$react).createElement($17b503f7de08fecc$var$PopoverWrapper, {
|
|
57
|
+
ref: domRef,
|
|
58
|
+
...props,
|
|
59
|
+
wrapperRef: wrapperRef
|
|
60
|
+
}, children));
|
|
61
|
+
}
|
|
62
|
+
const $17b503f7de08fecc$var$PopoverWrapper = /*#__PURE__*/ (0, $4kQ6h$forwardRef)((props, ref)=>{
|
|
63
|
+
let { children: children, isOpen: isOpen, hideArrow: hideArrow, isNonModal: isNonModal, enableBothDismissButtons: enableBothDismissButtons, state: state, wrapperRef: wrapperRef, onDismissButtonPress: onDismissButtonPress = ()=>state.close() } = props;
|
|
64
|
+
let { styleProps: styleProps } = (0, $4kQ6h$useStyleProps)(props);
|
|
65
|
+
let { size: size, borderWidth: borderWidth, arrowRef: arrowRef } = $17b503f7de08fecc$var$useArrowSize();
|
|
66
|
+
const borderRadius = $17b503f7de08fecc$var$usePopoverBorderRadius(ref);
|
|
67
|
+
let borderDiagonal = borderWidth * Math.SQRT2;
|
|
68
|
+
let primary = size + borderDiagonal;
|
|
69
|
+
let secondary = primary * 2;
|
|
70
|
+
let { popoverProps: popoverProps, arrowProps: arrowProps, underlayProps: underlayProps, placement: placement } = (0, $4kQ6h$usePopover)({
|
|
71
|
+
...props,
|
|
72
|
+
popoverRef: ref,
|
|
73
|
+
maxHeight: null,
|
|
74
|
+
arrowSize: hideArrow ? 0 : secondary,
|
|
75
|
+
arrowBoundaryOffset: borderRadius
|
|
76
|
+
}, state);
|
|
77
|
+
let { focusWithinProps: focusWithinProps } = (0, $4kQ6h$useFocusWithin)(props);
|
|
78
|
+
// Attach Transition's nodeRef to outermost wrapper for node.reflow: https://github.com/reactjs/react-transition-group/blob/c89f807067b32eea6f68fd6c622190d88ced82e2/src/Transition.js#L231
|
|
79
|
+
return /*#__PURE__*/ (0, $4kQ6h$react).createElement("div", {
|
|
80
|
+
ref: wrapperRef
|
|
81
|
+
}, !isNonModal && /*#__PURE__*/ (0, $4kQ6h$react).createElement((0, $76a452f4e3df11be$export$f360afc887607b02), {
|
|
82
|
+
isTransparent: true,
|
|
83
|
+
...(0, $4kQ6h$mergeProps)(underlayProps),
|
|
84
|
+
isOpen: isOpen
|
|
85
|
+
}), /*#__PURE__*/ (0, $4kQ6h$react).createElement("div", {
|
|
86
|
+
...styleProps,
|
|
87
|
+
...(0, $4kQ6h$mergeProps)(popoverProps, focusWithinProps),
|
|
88
|
+
style: {
|
|
89
|
+
...styleProps.style,
|
|
90
|
+
...popoverProps.style
|
|
91
|
+
},
|
|
92
|
+
ref: ref,
|
|
93
|
+
className: (0, $4kQ6h$classNames)((0, ($parcel$interopDefault($4kQ6h$popover_vars_cssmodulejs))), "spectrum-Popover", `spectrum-Popover--${placement}`, {
|
|
94
|
+
"spectrum-Popover--withTip": !hideArrow,
|
|
95
|
+
"is-open": isOpen,
|
|
96
|
+
[`is-open--${placement}`]: isOpen
|
|
97
|
+
}, (0, $4kQ6h$classNames)((0, ($parcel$interopDefault($4kQ6h$overlays_cssmodulejs))), "spectrum-Popover", "react-spectrum-Popover"), styleProps.className),
|
|
98
|
+
role: "presentation",
|
|
99
|
+
"data-testid": "popover"
|
|
100
|
+
}, (!isNonModal || enableBothDismissButtons) && /*#__PURE__*/ (0, $4kQ6h$react).createElement((0, $4kQ6h$DismissButton), {
|
|
101
|
+
onDismiss: onDismissButtonPress
|
|
102
|
+
}), children, hideArrow ? null : /*#__PURE__*/ (0, $4kQ6h$react).createElement($17b503f7de08fecc$var$Arrow, {
|
|
103
|
+
arrowProps: arrowProps,
|
|
104
|
+
isLandscape: $17b503f7de08fecc$var$arrowPlacement[placement] === "bottom",
|
|
105
|
+
arrowRef: arrowRef,
|
|
106
|
+
primary: primary,
|
|
107
|
+
secondary: secondary,
|
|
108
|
+
borderDiagonal: borderDiagonal
|
|
109
|
+
}), /*#__PURE__*/ (0, $4kQ6h$react).createElement((0, $4kQ6h$DismissButton), {
|
|
110
|
+
onDismiss: onDismissButtonPress
|
|
111
|
+
})));
|
|
112
|
+
});
|
|
113
|
+
function $17b503f7de08fecc$var$usePopoverBorderRadius(popoverRef) {
|
|
114
|
+
let [borderRadius, setBorderRadius] = (0, $4kQ6h$useState)(0);
|
|
115
|
+
(0, $4kQ6h$useLayoutEffect)(()=>{
|
|
116
|
+
if (popoverRef.current) {
|
|
117
|
+
let spectrumBorderRadius = window.getComputedStyle(popoverRef.current).borderRadius;
|
|
118
|
+
if (spectrumBorderRadius !== "") setBorderRadius(parseInt(spectrumBorderRadius, 10));
|
|
119
|
+
}
|
|
120
|
+
}, [
|
|
121
|
+
popoverRef
|
|
122
|
+
]);
|
|
123
|
+
return borderRadius;
|
|
124
|
+
}
|
|
125
|
+
function $17b503f7de08fecc$var$useArrowSize() {
|
|
126
|
+
let [size, setSize] = (0, $4kQ6h$useState)(20);
|
|
127
|
+
let [borderWidth, setBorderWidth] = (0, $4kQ6h$useState)(1);
|
|
128
|
+
let arrowRef = (0, $4kQ6h$useRef)(null);
|
|
129
|
+
// get the css value for the tip size and divide it by 2 for this arrow implementation
|
|
130
|
+
(0, $4kQ6h$useLayoutEffect)(()=>{
|
|
131
|
+
if (arrowRef.current) {
|
|
132
|
+
let spectrumTipWidth = window.getComputedStyle(arrowRef.current).getPropertyValue("--spectrum-popover-tip-size");
|
|
133
|
+
if (spectrumTipWidth !== "") setSize(parseInt(spectrumTipWidth, 10) / 2);
|
|
134
|
+
let spectrumBorderWidth = window.getComputedStyle(arrowRef.current).getPropertyValue("--spectrum-popover-tip-borderWidth");
|
|
135
|
+
if (spectrumBorderWidth !== "") setBorderWidth(parseInt(spectrumBorderWidth, 10));
|
|
136
|
+
}
|
|
137
|
+
}, []);
|
|
138
|
+
return {
|
|
139
|
+
size: size,
|
|
140
|
+
borderWidth: borderWidth,
|
|
141
|
+
arrowRef: arrowRef
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function $17b503f7de08fecc$var$Arrow(props) {
|
|
145
|
+
let { primary: primary, secondary: secondary, isLandscape: isLandscape, arrowProps: arrowProps, borderDiagonal: borderDiagonal, arrowRef: arrowRef } = props;
|
|
146
|
+
let halfBorderDiagonal = borderDiagonal / 2;
|
|
147
|
+
let primaryStart = 0;
|
|
148
|
+
let primaryEnd = primary - halfBorderDiagonal;
|
|
149
|
+
let secondaryStart = halfBorderDiagonal;
|
|
150
|
+
let secondaryMiddle = secondary / 2;
|
|
151
|
+
let secondaryEnd = secondary - halfBorderDiagonal;
|
|
152
|
+
let pathData = isLandscape ? [
|
|
153
|
+
"M",
|
|
154
|
+
secondaryStart,
|
|
155
|
+
primaryStart,
|
|
156
|
+
"L",
|
|
157
|
+
secondaryMiddle,
|
|
158
|
+
primaryEnd,
|
|
159
|
+
"L",
|
|
160
|
+
secondaryEnd,
|
|
161
|
+
primaryStart
|
|
162
|
+
] : [
|
|
163
|
+
"M",
|
|
164
|
+
primaryStart,
|
|
165
|
+
secondaryStart,
|
|
166
|
+
"L",
|
|
167
|
+
primaryEnd,
|
|
168
|
+
secondaryMiddle,
|
|
169
|
+
"L",
|
|
170
|
+
primaryStart,
|
|
171
|
+
secondaryEnd
|
|
172
|
+
];
|
|
173
|
+
/* use ceil because the svg needs to always accommodate the path inside it */ return /*#__PURE__*/ (0, $4kQ6h$react).createElement("svg", {
|
|
174
|
+
xmlns: "http://www.w3.org/svg/2000",
|
|
175
|
+
width: Math.ceil(isLandscape ? secondary : primary),
|
|
176
|
+
height: Math.ceil(isLandscape ? primary : secondary),
|
|
177
|
+
className: (0, $4kQ6h$classNames)((0, ($parcel$interopDefault($4kQ6h$popover_vars_cssmodulejs))), "spectrum-Popover-tip"),
|
|
178
|
+
ref: arrowRef,
|
|
179
|
+
...arrowProps
|
|
180
|
+
}, /*#__PURE__*/ (0, $4kQ6h$react).createElement("path", {
|
|
181
|
+
className: (0, $4kQ6h$classNames)((0, ($parcel$interopDefault($4kQ6h$popover_vars_cssmodulejs))), "spectrum-Popover-tip-triangle"),
|
|
182
|
+
d: pathData.join(" ")
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
let $17b503f7de08fecc$export$5b6b19405a83ff9d = /*#__PURE__*/ (0, $4kQ6h$forwardRef)($17b503f7de08fecc$var$Popover);
|
|
186
|
+
/**
|
|
187
|
+
* More explanation on popover tips.
|
|
188
|
+
* - I tried changing the calculation of the popover placement in an effort to get it squarely onto the pixel grid.
|
|
189
|
+
* This did not work because the problem was in the svg partial pixel end of the path in the popover right and popover bottom.
|
|
190
|
+
* - I tried creating an extra 'bandaid' path that matched the background color and would overlap the popover border.
|
|
191
|
+
* This didn't work because the border on the svg triangle didn't extend all the way to match nicely with the popover border.
|
|
192
|
+
* - I tried getting the client bounding box and setting the svg to that partial pixel value
|
|
193
|
+
* This didn't work because again the issue was inside the svg
|
|
194
|
+
* - I didn't try drawing the svg backwards
|
|
195
|
+
* This could still be tried
|
|
196
|
+
* - I tried changing the calculation of the popover placement AND the svg height/width so that they were all rounded
|
|
197
|
+
* This seems to have done the trick.
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
export {$17b503f7de08fecc$export$5b6b19405a83ff9d as Popover};
|
|
201
|
+
//# sourceMappingURL=Popover.mjs.map
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import {Overlay as $70305dc5fb729c3b$export$c6fdb837b070b4ff} from "./Overlay.module.js";
|
|
2
|
+
import "./overlays.ac5ba32f.css";
|
|
3
|
+
import $4kQ6h$overlays_cssmodulejs from "./overlays_css.module.js";
|
|
4
|
+
import "./vars.e9dc412f.css";
|
|
5
|
+
import $4kQ6h$popover_vars_cssmodulejs from "./popover_vars_css.module.js";
|
|
6
|
+
import {Underlay as $76a452f4e3df11be$export$f360afc887607b02} from "./Underlay.module.js";
|
|
7
|
+
import {usePopover as $4kQ6h$usePopover, DismissButton as $4kQ6h$DismissButton} from "@react-aria/overlays";
|
|
8
|
+
import {useDOMRef as $4kQ6h$useDOMRef, useStyleProps as $4kQ6h$useStyleProps, classNames as $4kQ6h$classNames} from "@react-spectrum/utils";
|
|
9
|
+
import {useFocusWithin as $4kQ6h$useFocusWithin} from "@react-aria/interactions";
|
|
10
|
+
import {mergeProps as $4kQ6h$mergeProps, useLayoutEffect as $4kQ6h$useLayoutEffect} from "@react-aria/utils";
|
|
11
|
+
import $4kQ6h$react, {useRef as $4kQ6h$useRef, forwardRef as $4kQ6h$forwardRef, useState as $4kQ6h$useState} from "react";
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
function $parcel$interopDefault(a) {
|
|
15
|
+
return a && a.__esModule ? a.default : a;
|
|
16
|
+
}
|
|
17
|
+
/*
|
|
18
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Arrow placement can be done pointing right or down because those paths start at 0, x or y. Because the
|
|
38
|
+
* other two don't, they start at a fractional pixel value, it introduces rounding differences between browsers and
|
|
39
|
+
* between display types (retina with subpixels vs not retina). By flipping them with CSS we can ensure that
|
|
40
|
+
* the path always starts at 0 so that it perfectly overlaps the popover's border.
|
|
41
|
+
* See bottom of file for more explanation.
|
|
42
|
+
*/ let $17b503f7de08fecc$var$arrowPlacement = {
|
|
43
|
+
left: "right",
|
|
44
|
+
right: "right",
|
|
45
|
+
top: "bottom",
|
|
46
|
+
bottom: "bottom"
|
|
47
|
+
};
|
|
48
|
+
function $17b503f7de08fecc$var$Popover(props, ref) {
|
|
49
|
+
let { children: children, state: state, ...otherProps } = props;
|
|
50
|
+
let domRef = (0, $4kQ6h$useDOMRef)(ref);
|
|
51
|
+
let wrapperRef = (0, $4kQ6h$useRef)(null);
|
|
52
|
+
return /*#__PURE__*/ (0, $4kQ6h$react).createElement((0, $70305dc5fb729c3b$export$c6fdb837b070b4ff), {
|
|
53
|
+
...otherProps,
|
|
54
|
+
isOpen: state.isOpen,
|
|
55
|
+
nodeRef: wrapperRef
|
|
56
|
+
}, /*#__PURE__*/ (0, $4kQ6h$react).createElement($17b503f7de08fecc$var$PopoverWrapper, {
|
|
57
|
+
ref: domRef,
|
|
58
|
+
...props,
|
|
59
|
+
wrapperRef: wrapperRef
|
|
60
|
+
}, children));
|
|
61
|
+
}
|
|
62
|
+
const $17b503f7de08fecc$var$PopoverWrapper = /*#__PURE__*/ (0, $4kQ6h$forwardRef)((props, ref)=>{
|
|
63
|
+
let { children: children, isOpen: isOpen, hideArrow: hideArrow, isNonModal: isNonModal, enableBothDismissButtons: enableBothDismissButtons, state: state, wrapperRef: wrapperRef, onDismissButtonPress: onDismissButtonPress = ()=>state.close() } = props;
|
|
64
|
+
let { styleProps: styleProps } = (0, $4kQ6h$useStyleProps)(props);
|
|
65
|
+
let { size: size, borderWidth: borderWidth, arrowRef: arrowRef } = $17b503f7de08fecc$var$useArrowSize();
|
|
66
|
+
const borderRadius = $17b503f7de08fecc$var$usePopoverBorderRadius(ref);
|
|
67
|
+
let borderDiagonal = borderWidth * Math.SQRT2;
|
|
68
|
+
let primary = size + borderDiagonal;
|
|
69
|
+
let secondary = primary * 2;
|
|
70
|
+
let { popoverProps: popoverProps, arrowProps: arrowProps, underlayProps: underlayProps, placement: placement } = (0, $4kQ6h$usePopover)({
|
|
71
|
+
...props,
|
|
72
|
+
popoverRef: ref,
|
|
73
|
+
maxHeight: null,
|
|
74
|
+
arrowSize: hideArrow ? 0 : secondary,
|
|
75
|
+
arrowBoundaryOffset: borderRadius
|
|
76
|
+
}, state);
|
|
77
|
+
let { focusWithinProps: focusWithinProps } = (0, $4kQ6h$useFocusWithin)(props);
|
|
78
|
+
// Attach Transition's nodeRef to outermost wrapper for node.reflow: https://github.com/reactjs/react-transition-group/blob/c89f807067b32eea6f68fd6c622190d88ced82e2/src/Transition.js#L231
|
|
79
|
+
return /*#__PURE__*/ (0, $4kQ6h$react).createElement("div", {
|
|
80
|
+
ref: wrapperRef
|
|
81
|
+
}, !isNonModal && /*#__PURE__*/ (0, $4kQ6h$react).createElement((0, $76a452f4e3df11be$export$f360afc887607b02), {
|
|
82
|
+
isTransparent: true,
|
|
83
|
+
...(0, $4kQ6h$mergeProps)(underlayProps),
|
|
84
|
+
isOpen: isOpen
|
|
85
|
+
}), /*#__PURE__*/ (0, $4kQ6h$react).createElement("div", {
|
|
86
|
+
...styleProps,
|
|
87
|
+
...(0, $4kQ6h$mergeProps)(popoverProps, focusWithinProps),
|
|
88
|
+
style: {
|
|
89
|
+
...styleProps.style,
|
|
90
|
+
...popoverProps.style
|
|
91
|
+
},
|
|
92
|
+
ref: ref,
|
|
93
|
+
className: (0, $4kQ6h$classNames)((0, ($parcel$interopDefault($4kQ6h$popover_vars_cssmodulejs))), "spectrum-Popover", `spectrum-Popover--${placement}`, {
|
|
94
|
+
"spectrum-Popover--withTip": !hideArrow,
|
|
95
|
+
"is-open": isOpen,
|
|
96
|
+
[`is-open--${placement}`]: isOpen
|
|
97
|
+
}, (0, $4kQ6h$classNames)((0, ($parcel$interopDefault($4kQ6h$overlays_cssmodulejs))), "spectrum-Popover", "react-spectrum-Popover"), styleProps.className),
|
|
98
|
+
role: "presentation",
|
|
99
|
+
"data-testid": "popover"
|
|
100
|
+
}, (!isNonModal || enableBothDismissButtons) && /*#__PURE__*/ (0, $4kQ6h$react).createElement((0, $4kQ6h$DismissButton), {
|
|
101
|
+
onDismiss: onDismissButtonPress
|
|
102
|
+
}), children, hideArrow ? null : /*#__PURE__*/ (0, $4kQ6h$react).createElement($17b503f7de08fecc$var$Arrow, {
|
|
103
|
+
arrowProps: arrowProps,
|
|
104
|
+
isLandscape: $17b503f7de08fecc$var$arrowPlacement[placement] === "bottom",
|
|
105
|
+
arrowRef: arrowRef,
|
|
106
|
+
primary: primary,
|
|
107
|
+
secondary: secondary,
|
|
108
|
+
borderDiagonal: borderDiagonal
|
|
109
|
+
}), /*#__PURE__*/ (0, $4kQ6h$react).createElement((0, $4kQ6h$DismissButton), {
|
|
110
|
+
onDismiss: onDismissButtonPress
|
|
111
|
+
})));
|
|
112
|
+
});
|
|
113
|
+
function $17b503f7de08fecc$var$usePopoverBorderRadius(popoverRef) {
|
|
114
|
+
let [borderRadius, setBorderRadius] = (0, $4kQ6h$useState)(0);
|
|
115
|
+
(0, $4kQ6h$useLayoutEffect)(()=>{
|
|
116
|
+
if (popoverRef.current) {
|
|
117
|
+
let spectrumBorderRadius = window.getComputedStyle(popoverRef.current).borderRadius;
|
|
118
|
+
if (spectrumBorderRadius !== "") setBorderRadius(parseInt(spectrumBorderRadius, 10));
|
|
119
|
+
}
|
|
120
|
+
}, [
|
|
121
|
+
popoverRef
|
|
122
|
+
]);
|
|
123
|
+
return borderRadius;
|
|
124
|
+
}
|
|
125
|
+
function $17b503f7de08fecc$var$useArrowSize() {
|
|
126
|
+
let [size, setSize] = (0, $4kQ6h$useState)(20);
|
|
127
|
+
let [borderWidth, setBorderWidth] = (0, $4kQ6h$useState)(1);
|
|
128
|
+
let arrowRef = (0, $4kQ6h$useRef)(null);
|
|
129
|
+
// get the css value for the tip size and divide it by 2 for this arrow implementation
|
|
130
|
+
(0, $4kQ6h$useLayoutEffect)(()=>{
|
|
131
|
+
if (arrowRef.current) {
|
|
132
|
+
let spectrumTipWidth = window.getComputedStyle(arrowRef.current).getPropertyValue("--spectrum-popover-tip-size");
|
|
133
|
+
if (spectrumTipWidth !== "") setSize(parseInt(spectrumTipWidth, 10) / 2);
|
|
134
|
+
let spectrumBorderWidth = window.getComputedStyle(arrowRef.current).getPropertyValue("--spectrum-popover-tip-borderWidth");
|
|
135
|
+
if (spectrumBorderWidth !== "") setBorderWidth(parseInt(spectrumBorderWidth, 10));
|
|
136
|
+
}
|
|
137
|
+
}, []);
|
|
138
|
+
return {
|
|
139
|
+
size: size,
|
|
140
|
+
borderWidth: borderWidth,
|
|
141
|
+
arrowRef: arrowRef
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function $17b503f7de08fecc$var$Arrow(props) {
|
|
145
|
+
let { primary: primary, secondary: secondary, isLandscape: isLandscape, arrowProps: arrowProps, borderDiagonal: borderDiagonal, arrowRef: arrowRef } = props;
|
|
146
|
+
let halfBorderDiagonal = borderDiagonal / 2;
|
|
147
|
+
let primaryStart = 0;
|
|
148
|
+
let primaryEnd = primary - halfBorderDiagonal;
|
|
149
|
+
let secondaryStart = halfBorderDiagonal;
|
|
150
|
+
let secondaryMiddle = secondary / 2;
|
|
151
|
+
let secondaryEnd = secondary - halfBorderDiagonal;
|
|
152
|
+
let pathData = isLandscape ? [
|
|
153
|
+
"M",
|
|
154
|
+
secondaryStart,
|
|
155
|
+
primaryStart,
|
|
156
|
+
"L",
|
|
157
|
+
secondaryMiddle,
|
|
158
|
+
primaryEnd,
|
|
159
|
+
"L",
|
|
160
|
+
secondaryEnd,
|
|
161
|
+
primaryStart
|
|
162
|
+
] : [
|
|
163
|
+
"M",
|
|
164
|
+
primaryStart,
|
|
165
|
+
secondaryStart,
|
|
166
|
+
"L",
|
|
167
|
+
primaryEnd,
|
|
168
|
+
secondaryMiddle,
|
|
169
|
+
"L",
|
|
170
|
+
primaryStart,
|
|
171
|
+
secondaryEnd
|
|
172
|
+
];
|
|
173
|
+
/* use ceil because the svg needs to always accommodate the path inside it */ return /*#__PURE__*/ (0, $4kQ6h$react).createElement("svg", {
|
|
174
|
+
xmlns: "http://www.w3.org/svg/2000",
|
|
175
|
+
width: Math.ceil(isLandscape ? secondary : primary),
|
|
176
|
+
height: Math.ceil(isLandscape ? primary : secondary),
|
|
177
|
+
className: (0, $4kQ6h$classNames)((0, ($parcel$interopDefault($4kQ6h$popover_vars_cssmodulejs))), "spectrum-Popover-tip"),
|
|
178
|
+
ref: arrowRef,
|
|
179
|
+
...arrowProps
|
|
180
|
+
}, /*#__PURE__*/ (0, $4kQ6h$react).createElement("path", {
|
|
181
|
+
className: (0, $4kQ6h$classNames)((0, ($parcel$interopDefault($4kQ6h$popover_vars_cssmodulejs))), "spectrum-Popover-tip-triangle"),
|
|
182
|
+
d: pathData.join(" ")
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
let $17b503f7de08fecc$export$5b6b19405a83ff9d = /*#__PURE__*/ (0, $4kQ6h$forwardRef)($17b503f7de08fecc$var$Popover);
|
|
186
|
+
/**
|
|
187
|
+
* More explanation on popover tips.
|
|
188
|
+
* - I tried changing the calculation of the popover placement in an effort to get it squarely onto the pixel grid.
|
|
189
|
+
* This did not work because the problem was in the svg partial pixel end of the path in the popover right and popover bottom.
|
|
190
|
+
* - I tried creating an extra 'bandaid' path that matched the background color and would overlap the popover border.
|
|
191
|
+
* This didn't work because the border on the svg triangle didn't extend all the way to match nicely with the popover border.
|
|
192
|
+
* - I tried getting the client bounding box and setting the svg to that partial pixel value
|
|
193
|
+
* This didn't work because again the issue was inside the svg
|
|
194
|
+
* - I didn't try drawing the svg backwards
|
|
195
|
+
* This could still be tried
|
|
196
|
+
* - I tried changing the calculation of the popover placement AND the svg height/width so that they were all rounded
|
|
197
|
+
* This seems to have done the trick.
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
export {$17b503f7de08fecc$export$5b6b19405a83ff9d as Popover};
|
|
201
|
+
//# sourceMappingURL=Popover.module.js.map
|