@react-spectrum/s2 3.0.0-nightly-b3a4d6c11-241119 → 3.0.0-nightly-56e575731-241121
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/CustomDialog.cjs +2 -2
- package/dist/CustomDialog.cjs.map +1 -1
- package/dist/CustomDialog.css.map +1 -1
- package/dist/CustomDialog.mjs +2 -2
- package/dist/CustomDialog.mjs.map +1 -1
- package/dist/Dialog.cjs +6 -6
- package/dist/Dialog.cjs.map +1 -1
- package/dist/Dialog.css.map +1 -1
- package/dist/Dialog.mjs +6 -6
- package/dist/Dialog.mjs.map +1 -1
- package/dist/DialogContainer.cjs +2 -4
- package/dist/DialogContainer.cjs.map +1 -1
- package/dist/DialogContainer.mjs +2 -4
- package/dist/DialogContainer.mjs.map +1 -1
- package/dist/FullscreenDialog.cjs +1 -1
- package/dist/FullscreenDialog.cjs.map +1 -1
- package/dist/FullscreenDialog.css +4 -3
- package/dist/FullscreenDialog.css.map +1 -1
- package/dist/FullscreenDialog.mjs +1 -1
- package/dist/FullscreenDialog.mjs.map +1 -1
- package/dist/Popover.cjs +26 -27
- package/dist/Popover.cjs.map +1 -1
- package/dist/Popover.css +4 -0
- package/dist/Popover.css.map +1 -1
- package/dist/Popover.mjs +28 -29
- package/dist/Popover.mjs.map +1 -1
- package/dist/types.d.ts +6 -8
- package/dist/types.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/CustomDialog.tsx +4 -4
- package/src/Dialog.tsx +8 -8
- package/src/DialogContainer.tsx +3 -5
- package/src/FullscreenDialog.tsx +2 -0
- package/src/Popover.tsx +26 -27
package/dist/Popover.cjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
require("./Popover.css");
|
|
2
2
|
var $914a06b3a1c679bc$exports = require("./Provider.cjs");
|
|
3
3
|
var $308b180f49d82d28$exports = require("../icons/runtime.cjs");
|
|
4
|
-
var $8e678305a8c10028$exports = require("./Modal.cjs");
|
|
5
4
|
var $16fRD$reactjsxruntime = require("react/jsx-runtime");
|
|
6
5
|
var $16fRD$reactariacomponents = require("react-aria-components");
|
|
7
|
-
var $16fRD$reactaria = require("react-aria");
|
|
8
6
|
var $16fRD$react = require("react");
|
|
9
7
|
var $16fRD$reactspectrumutils = require("@react-spectrum/utils");
|
|
10
8
|
|
|
@@ -31,8 +29,6 @@ $parcel$export(module.exports, "Popover", () => $493371ef39bf7a55$export$5b6b194
|
|
|
31
29
|
|
|
32
30
|
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
32
|
const $493371ef39bf7a55$var$fadeKeyframes = "-_1llqja1";
|
|
37
33
|
const $493371ef39bf7a55$var$slideUpKeyframes = "-xohm13";
|
|
38
34
|
const $493371ef39bf7a55$var$slideDownKeyframes = "-_2hjlm";
|
|
@@ -43,7 +39,11 @@ let $493371ef39bf7a55$var$popover = function anonymous(props, overrides) {
|
|
|
43
39
|
let matches = (overrides || '').match(/(?:^|\s)(?:y|z|A|B|_9|_8|h|_5|_4|__A|__c|__d|__a|__b|U|__Q|X|Z|V|W|l|q|r)[^\s]+/g) || [];
|
|
44
40
|
rules += matches.join('');
|
|
45
41
|
let $l = false;
|
|
46
|
-
|
|
42
|
+
let $r = false;
|
|
43
|
+
for (let p of matches){
|
|
44
|
+
if (/^\s*l/.test(p)) $l = true;
|
|
45
|
+
if (/^\s*r/.test(p)) $r = true;
|
|
46
|
+
}
|
|
47
47
|
if (props.colorScheme === "dark") rules += ' _Ab';
|
|
48
48
|
else if (props.colorScheme === "light") rules += ' _Aa';
|
|
49
49
|
else if (props.colorScheme === "light dark") rules += ' _Ac';
|
|
@@ -69,6 +69,8 @@ let $493371ef39bf7a55$var$popover = function anonymous(props, overrides) {
|
|
|
69
69
|
else if (props.size === "M") rules += ' l______6';
|
|
70
70
|
else if (props.size === "S") rules += ' l_____O';
|
|
71
71
|
}
|
|
72
|
+
if (!$r) rules += ' r-rtptky';
|
|
73
|
+
rules += ' __na';
|
|
72
74
|
if (props.placement === "top") {
|
|
73
75
|
if (props.isArrowShown) rules += ' QG';
|
|
74
76
|
} else if (props.placement === "bottom") {
|
|
@@ -126,7 +128,7 @@ let $493371ef39bf7a55$var$arrow = function anonymous(props) {
|
|
|
126
128
|
return rules;
|
|
127
129
|
};
|
|
128
130
|
function $493371ef39bf7a55$var$PopoverBase(props, ref) {
|
|
129
|
-
let { hideArrow: hideArrow = false, UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, styles: styles, size: size
|
|
131
|
+
let { hideArrow: hideArrow = false, UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, styles: styles, size: size } = props;
|
|
130
132
|
let domRef = (0, $16fRD$reactspectrumutils.useDOMRef)(ref);
|
|
131
133
|
let colorScheme = (0, $16fRD$react.useContext)((0, $914a06b3a1c679bc$exports.ColorSchemeContext));
|
|
132
134
|
let { locale: locale, direction: direction } = (0, $16fRD$reactariacomponents.useLocale)();
|
|
@@ -143,27 +145,24 @@ function $493371ef39bf7a55$var$PopoverBase(props, ref) {
|
|
|
143
145
|
domRef
|
|
144
146
|
]);
|
|
145
147
|
// On small devices, show a modal (or eventually a tray) instead of a popover.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}))
|
|
165
|
-
});
|
|
166
|
-
}
|
|
148
|
+
// TODO: reverted this until we have trays.
|
|
149
|
+
// let isMobile = useIsMobileDevice();
|
|
150
|
+
// if (isMobile && process.env.NODE_ENV !== 'test') {
|
|
151
|
+
// let mappedChildren = typeof children === 'function'
|
|
152
|
+
// ? (renderProps: ModalRenderProps) => children({...renderProps, defaultChildren: null, trigger, placement: 'bottom'})
|
|
153
|
+
// : children;
|
|
154
|
+
// return (
|
|
155
|
+
// <Modal size={size} isDismissable>
|
|
156
|
+
// {composeRenderProps(mappedChildren, (children, {state}) => (
|
|
157
|
+
// <>
|
|
158
|
+
// {children}
|
|
159
|
+
// {/* Add additional dismiss button at the end to match popovers. */}
|
|
160
|
+
// <DismissButton onDismiss={state.close} />
|
|
161
|
+
// </>
|
|
162
|
+
// ))}
|
|
163
|
+
// </Modal>
|
|
164
|
+
// );
|
|
165
|
+
// }
|
|
167
166
|
// TODO: this still isn't the final popover 'tip', copying various ones out of the designs files yields different results
|
|
168
167
|
// containerPadding not working as expected
|
|
169
168
|
return /*#__PURE__*/ (0, $16fRD$reactjsxruntime.jsx)((0, $16fRD$reactariacomponents.Popover), {
|
package/dist/Popover.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"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","sources":["packages/@react-spectrum/s2/src/Popover.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {\n Popover as AriaPopover,\n PopoverProps as AriaPopoverProps,\n composeRenderProps,\n Dialog,\n DialogProps,\n ModalRenderProps,\n OverlayArrow,\n OverlayTriggerStateContext,\n useLocale\n} from 'react-aria-components';\nimport {colorScheme, getAllowedOverrides, StyleProps, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {ColorSchemeContext} from './Provider';\nimport {DismissButton} from 'react-aria';\nimport {DOMRef} from '@react-types/shared';\nimport {forwardRef, MutableRefObject, useCallback, useContext} from 'react';\nimport {keyframes} from '../style/style-macro' with {type: 'macro'};\nimport {mergeStyles} from '../style/runtime';\nimport {Modal} from './Modal';\nimport {style} from '../style' with {type: 'macro'};\nimport {StyleString} from '../style/types' with {type: 'macro'};\nimport {useDOMRef, useIsMobileDevice} from '@react-spectrum/utils';\n\nexport interface PopoverProps extends UnsafeStyles, Omit<AriaPopoverProps, 'arrowSize' | 'isNonModal' | 'arrowBoundaryOffset' | 'isKeyboardDismissDisabled' | 'shouldCloseOnInteractOutside' | 'shouldUpdatePosition'> {\n styles?: StyleString,\n /**\n * Whether a popover's arrow should be hidden.\n *\n * @default false\n */\n hideArrow?: boolean,\n /**\n * The size of the Popover. If not specified, the popover fits its contents.\n */\n size?: 'S' | 'M' | 'L',\n /** The type of overlay that should be rendered when on a mobile device. */\n mobileType?: 'modal' | 'fullscreen' | 'fullscreenTakeover' // TODO: add tray back in\n}\n\nconst fadeKeyframes = keyframes(`\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n`);\nconst slideUpKeyframes = keyframes(`\n from {\n transform: translateY(-4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideDownKeyframes = keyframes(`\n from {\n transform: translateY(4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideRightKeyframes = keyframes(`\n from {\n transform: translateX(4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\nconst slideLeftKeyframes = keyframes(`\n from {\n transform: translateX(-4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\n\nlet popover = style({\n ...colorScheme(),\n '--s2-container-bg': {\n type: 'backgroundColor',\n value: 'layer-2'\n },\n backgroundColor: '--s2-container-bg',\n borderRadius: 'lg',\n filter: {\n isArrowShown: 'elevated'\n },\n // Use box-shadow instead of filter when an arrow is not shown.\n // This fixes the shadow stacking problem with submenus.\n boxShadow: {\n default: 'elevated',\n isArrowShown: 'none'\n },\n borderStyle: 'solid',\n borderWidth: 1,\n borderColor: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n },\n width: {\n size: {\n // Copied from designs, not sure if correct.\n S: 336,\n M: 416,\n L: 576\n }\n },\n translateY: {\n placement: {\n bottom: {\n isArrowShown: 8 // TODO: not defined yet should this change with font size? need boolean support for 'hideArrow' prop\n },\n top: {\n isArrowShown: -8\n }\n }\n },\n translateX: {\n placement: {\n left: {\n isArrowShown: -8\n },\n right: {\n isArrowShown: 8\n }\n }\n },\n animation: {\n placement: {\n top: {\n isEntering: `${slideDownKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideDownKeyframes}, ${fadeKeyframes}`\n },\n bottom: {\n isEntering: `${slideUpKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideUpKeyframes}, ${fadeKeyframes}`\n },\n left: {\n isEntering: `${slideRightKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideRightKeyframes}, ${fadeKeyframes}`\n },\n right: {\n isEntering: `${slideLeftKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideLeftKeyframes}, ${fadeKeyframes}`\n }\n },\n isSubmenu: {\n isEntering: fadeKeyframes,\n isExiting: fadeKeyframes\n }\n },\n animationDuration: {\n isEntering: 200,\n isExiting: 200\n },\n animationDirection: {\n isEntering: 'normal',\n isExiting: 'reverse'\n },\n animationTimingFunction: {\n isExiting: 'in'\n },\n transition: '[opacity, transform]',\n willChange: '[opacity, transform]',\n isolation: 'isolate',\n pointerEvents: {\n isExiting: 'none'\n }\n}, getAllowedOverrides());\n// TODO: animations and real Popover Arrow\n\nlet arrow = style({\n display: 'block',\n fill: '--s2-container-bg',\n rotate: {\n default: 180,\n placement: {\n top: 0,\n bottom: 180,\n left: -90,\n right: 90\n }\n },\n translateX: {\n placement: {\n left: -4,\n right: 4\n }\n },\n strokeWidth: 1,\n stroke: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n }\n});\n\nfunction PopoverBase(props: PopoverProps, ref: DOMRef<HTMLDivElement>) {\n let {\n hideArrow = false,\n UNSAFE_className = '',\n UNSAFE_style,\n styles,\n size,\n children,\n trigger = null\n } = props;\n let domRef = useDOMRef(ref);\n let colorScheme = useContext(ColorSchemeContext);\n let {locale, direction} = useLocale();\n\n // TODO: should we pass through lang and dir props in RAC?\n let popoverRef = useCallback((el: HTMLDivElement) => {\n (domRef as MutableRefObject<HTMLDivElement>).current = el;\n if (el) {\n el.lang = locale;\n el.dir = direction;\n }\n }, [locale, direction, domRef]);\n\n // On small devices, show a modal (or eventually a tray) instead of a popover.\n let isMobile = useIsMobileDevice();\n if (isMobile && process.env.NODE_ENV !== 'test') {\n let mappedChildren = typeof children === 'function'\n ? (renderProps: ModalRenderProps) => children({...renderProps, defaultChildren: null, trigger, placement: 'bottom'})\n : children;\n\n return (\n <Modal size={size} isDismissable>\n {composeRenderProps(mappedChildren, (children, {state}) => (\n <>\n {children}\n {/* Add additional dismiss button at the end to match popovers. */}\n <DismissButton onDismiss={state.close} />\n </>\n ))}\n </Modal>\n );\n }\n\n // TODO: this still isn't the final popover 'tip', copying various ones out of the designs files yields different results\n // containerPadding not working as expected\n return (\n <AriaPopover\n {...props}\n ref={popoverRef}\n style={{\n ...UNSAFE_style,\n // Override default z-index from useOverlayPosition. We use isolation: isolate instead.\n zIndex: undefined\n }}\n className={(renderProps) => UNSAFE_className + mergeStyles(popover({...renderProps, size, isArrowShown: !hideArrow, colorScheme, isSubmenu: renderProps.trigger === 'SubmenuTrigger'}), styles)}>\n {composeRenderProps(props.children, (children, renderProps) => (\n <>\n {!hideArrow && (\n <OverlayArrow>\n <svg width={18} height={9} viewBox=\"0 0 18 10\" className={arrow(renderProps)}>\n <path transform=\"translate(0 -1)\" d=\"M1 1L7.93799 8.52588C8.07224 8.67448 8.23607 8.79362 8.41895 8.87524C8.60182 8.95687 8.79973 8.9993 9 9C9.19984 8.99882 9.39724 8.95606 9.57959 8.87427C9.76193 8.79248 9.9253 8.67336 10.0591 8.5249L17 1\" />\n </svg>\n </OverlayArrow>\n )}\n {children}\n </>\n ))}\n </AriaPopover>\n );\n}\n\nlet _PopoverBase = forwardRef(PopoverBase);\nexport {_PopoverBase as PopoverBase};\n\nexport interface PopoverDialogProps extends Pick<PopoverProps, 'size' | 'hideArrow' | 'mobileType' | 'placement' | 'shouldFlip' | 'containerPadding' | 'offset' | 'crossOffset'>, Omit<DialogProps, 'className' | 'style'>, StyleProps {}\n\nconst dialogStyle = style({\n padding: 8,\n boxSizing: 'border-box',\n outlineStyle: 'none',\n borderRadius: '[inherit]',\n overflow: 'auto',\n position: 'relative',\n size: 'full',\n maxSize: '[inherit]'\n}, getAllowedOverrides({height: true}));\n\nfunction Popover(props: PopoverDialogProps, ref: DOMRef) {\n let domRef = useDOMRef(ref);\n\n return (\n <_PopoverBase size={props.size} hideArrow={props.hideArrow} placement={props.placement} shouldFlip={props.shouldFlip} containerPadding={props.containerPadding} offset={props.offset} crossOffset={props.crossOffset}>\n <Dialog\n {...props}\n ref={domRef}\n style={props.UNSAFE_style}\n className={(props.UNSAFE_className || '') + dialogStyle(null, props.styles)}>\n {composeRenderProps(props.children, (children) => (\n // Reset OverlayTriggerStateContext so the buttons inside the dialog don't retain their hover state.\n <OverlayTriggerStateContext.Provider value={null}>\n {children}\n </OverlayTriggerStateContext.Provider>\n ))}\n </Dialog>\n </_PopoverBase>\n );\n}\n\n/**\n * A popover is an overlay element positioned relative to a trigger.\n */\nlet _Popover = forwardRef(Popover);\nexport {_Popover as Popover};\n"],"names":[],"version":3,"file":"Popover.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAsCD,MAAM;AASN,MAAM;AASN,MAAM;AASN,MAAM;AASN,MAAM;AAUN,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGJ,0CAA0C;AAE1C,IAAI;;;;;;;;;;;;;;;;AAyBJ,SAAS,kCAAY,KAAmB,EAAE,GAA2B;IACnE,IAAI,aACF,YAAY,yBACZ,mBAAmB,kBACnB,YAAY,UACZ,MAAM,QACN,IAAI,EACL,GAAG;IACJ,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IACvB,IAAI,cAAc,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,4CAAiB;IAC9C,IAAI,UAAC,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,oCAAQ;IAElC,0DAA0D;IAC1D,IAAI,aAAa,CAAA,GAAA,wBAAU,EAAE,CAAC;QAC3B,OAA4C,OAAO,GAAG;QACvD,IAAI,IAAI;YACN,GAAG,IAAI,GAAG;YACV,GAAG,GAAG,GAAG;QACX;IACF,GAAG;QAAC;QAAQ;QAAW;KAAO;IAE9B,8EAA8E;IAC9E,2CAA2C;IAC3C,sCAAsC;IACtC,qDAAqD;IACrD,wDAAwD;IACxD,2HAA2H;IAC3H,kBAAkB;IAElB,aAAa;IACb,wCAAwC;IACxC,qEAAqE;IACrE,aAAa;IACb,uBAAuB;IACvB,gFAAgF;IAChF,sDAAsD;IACtD,cAAc;IACd,YAAY;IACZ,eAAe;IACf,OAAO;IACP,IAAI;IAEJ,yHAAyH;IACzH,2CAA2C;IAC3C,qBACE,gCAAC,CAAA,GAAA,kCAAU;QACR,GAAG,KAAK;QACT,KAAK;QACL,OAAO;YACL,GAAG,YAAY;YACf,uFAAuF;YACvF,QAAQ;QACV;QACA,WAAW,CAAC,cAAgB,mBAAmB,CAAA,GAAA,qCAAU,EAAE,8BAAQ;gBAAC,GAAG,WAAW;sBAAE;gBAAM,cAAc,CAAC;6BAAW;gBAAa,WAAW,YAAY,OAAO,KAAK;YAAgB,IAAI;kBACvL,CAAA,GAAA,6CAAiB,EAAE,MAAM,QAAQ,EAAE,CAAC,UAAU,4BAC7C;;oBACG,CAAC,2BACA,gCAAC,CAAA,GAAA,uCAAW;kCACV,cAAA,gCAAC;4BAAI,OAAO;4BAAI,QAAQ;4BAAG,SAAQ;4BAAY,WAAW,4BAAM;sCAC9D,cAAA,gCAAC;gCAAK,WAAU;gCAAkB,GAAE;;;;oBAIzC;;;;AAKX;AAEA,IAAI,0DAAe,CAAA,GAAA,uBAAS,EAAE;AAK9B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWN,SAAS,8BAAQ,KAAyB,EAAE,GAAW;IACrD,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IAEvB,qBACE,gCAAC;QAAa,MAAM,MAAM,IAAI;QAAE,WAAW,MAAM,SAAS;QAAE,WAAW,MAAM,SAAS;QAAE,YAAY,MAAM,UAAU;QAAE,kBAAkB,MAAM,gBAAgB;QAAE,QAAQ,MAAM,MAAM;QAAE,aAAa,MAAM,WAAW;kBAClN,cAAA,gCAAC,CAAA,GAAA,iCAAK;YACH,GAAG,KAAK;YACT,KAAK;YACL,OAAO,MAAM,YAAY;YACzB,WAAW,AAAC,CAAA,MAAM,gBAAgB,IAAI,EAAC,IAAK,kCAAY,MAAM,MAAM,MAAM;sBACzE,CAAA,GAAA,6CAAiB,EAAE,MAAM,QAAQ,EAAE,CAAC,WACnC,oGAAoG;8BACpG,gCAAC,CAAA,GAAA,qDAAyB,EAAE,QAAQ;oBAAC,OAAO;8BACzC;;;;AAMb;AAEA;;CAEC,GACD,IAAI,0DAAW,CAAA,GAAA,uBAAS,EAAE","sources":["packages/@react-spectrum/s2/src/Popover.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {\n Popover as AriaPopover,\n PopoverProps as AriaPopoverProps,\n composeRenderProps,\n Dialog,\n DialogProps,\n OverlayArrow,\n OverlayTriggerStateContext,\n useLocale\n} from 'react-aria-components';\nimport {colorScheme, getAllowedOverrides, StyleProps, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {ColorSchemeContext} from './Provider';\nimport {DOMRef} from '@react-types/shared';\nimport {forwardRef, MutableRefObject, useCallback, useContext} from 'react';\nimport {keyframes} from '../style/style-macro' with {type: 'macro'};\nimport {mergeStyles} from '../style/runtime';\nimport {style} from '../style' with {type: 'macro'};\nimport {StyleString} from '../style/types' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\n\nexport interface PopoverProps extends UnsafeStyles, Omit<AriaPopoverProps, 'arrowSize' | 'isNonModal' | 'arrowBoundaryOffset' | 'isKeyboardDismissDisabled' | 'shouldCloseOnInteractOutside' | 'shouldUpdatePosition'> {\n styles?: StyleString,\n /**\n * Whether a popover's arrow should be hidden.\n *\n * @default false\n */\n hideArrow?: boolean,\n /**\n * The size of the Popover. If not specified, the popover fits its contents.\n */\n size?: 'S' | 'M' | 'L'\n /** The type of overlay that should be rendered when on a mobile device. */\n // mobileType?: 'modal' | 'fullscreen' | 'fullscreenTakeover' // TODO: add tray back in\n}\n\nconst fadeKeyframes = keyframes(`\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n`);\nconst slideUpKeyframes = keyframes(`\n from {\n transform: translateY(-4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideDownKeyframes = keyframes(`\n from {\n transform: translateY(4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideRightKeyframes = keyframes(`\n from {\n transform: translateX(4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\nconst slideLeftKeyframes = keyframes(`\n from {\n transform: translateX(-4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\n\nlet popover = style({\n ...colorScheme(),\n '--s2-container-bg': {\n type: 'backgroundColor',\n value: 'layer-2'\n },\n backgroundColor: '--s2-container-bg',\n borderRadius: 'lg',\n filter: {\n isArrowShown: 'elevated'\n },\n // Use box-shadow instead of filter when an arrow is not shown.\n // This fixes the shadow stacking problem with submenus.\n boxShadow: {\n default: 'elevated',\n isArrowShown: 'none'\n },\n borderStyle: 'solid',\n borderWidth: 1,\n borderColor: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n },\n width: {\n size: {\n // Copied from designs, not sure if correct.\n S: 336,\n M: 416,\n L: 576\n }\n },\n // Don't be larger than full screen minus 2 * containerPadding\n maxWidth: '[calc(100vw - 24px)]',\n boxSizing: 'border-box',\n translateY: {\n placement: {\n bottom: {\n isArrowShown: 8 // TODO: not defined yet should this change with font size? need boolean support for 'hideArrow' prop\n },\n top: {\n isArrowShown: -8\n }\n }\n },\n translateX: {\n placement: {\n left: {\n isArrowShown: -8\n },\n right: {\n isArrowShown: 8\n }\n }\n },\n animation: {\n placement: {\n top: {\n isEntering: `${slideDownKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideDownKeyframes}, ${fadeKeyframes}`\n },\n bottom: {\n isEntering: `${slideUpKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideUpKeyframes}, ${fadeKeyframes}`\n },\n left: {\n isEntering: `${slideRightKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideRightKeyframes}, ${fadeKeyframes}`\n },\n right: {\n isEntering: `${slideLeftKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideLeftKeyframes}, ${fadeKeyframes}`\n }\n },\n isSubmenu: {\n isEntering: fadeKeyframes,\n isExiting: fadeKeyframes\n }\n },\n animationDuration: {\n isEntering: 200,\n isExiting: 200\n },\n animationDirection: {\n isEntering: 'normal',\n isExiting: 'reverse'\n },\n animationTimingFunction: {\n isExiting: 'in'\n },\n transition: '[opacity, transform]',\n willChange: '[opacity, transform]',\n isolation: 'isolate',\n pointerEvents: {\n isExiting: 'none'\n }\n}, getAllowedOverrides());\n// TODO: animations and real Popover Arrow\n\nlet arrow = style({\n display: 'block',\n fill: '--s2-container-bg',\n rotate: {\n default: 180,\n placement: {\n top: 0,\n bottom: 180,\n left: -90,\n right: 90\n }\n },\n translateX: {\n placement: {\n left: -4,\n right: 4\n }\n },\n strokeWidth: 1,\n stroke: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n }\n});\n\nfunction PopoverBase(props: PopoverProps, ref: DOMRef<HTMLDivElement>) {\n let {\n hideArrow = false,\n UNSAFE_className = '',\n UNSAFE_style,\n styles,\n size\n } = props;\n let domRef = useDOMRef(ref);\n let colorScheme = useContext(ColorSchemeContext);\n let {locale, direction} = useLocale();\n\n // TODO: should we pass through lang and dir props in RAC?\n let popoverRef = useCallback((el: HTMLDivElement) => {\n (domRef as MutableRefObject<HTMLDivElement>).current = el;\n if (el) {\n el.lang = locale;\n el.dir = direction;\n }\n }, [locale, direction, domRef]);\n\n // On small devices, show a modal (or eventually a tray) instead of a popover.\n // TODO: reverted this until we have trays.\n // let isMobile = useIsMobileDevice();\n // if (isMobile && process.env.NODE_ENV !== 'test') {\n // let mappedChildren = typeof children === 'function'\n // ? (renderProps: ModalRenderProps) => children({...renderProps, defaultChildren: null, trigger, placement: 'bottom'})\n // : children;\n\n // return (\n // <Modal size={size} isDismissable>\n // {composeRenderProps(mappedChildren, (children, {state}) => (\n // <>\n // {children}\n // {/* Add additional dismiss button at the end to match popovers. */}\n // <DismissButton onDismiss={state.close} />\n // </>\n // ))}\n // </Modal>\n // );\n // }\n\n // TODO: this still isn't the final popover 'tip', copying various ones out of the designs files yields different results\n // containerPadding not working as expected\n return (\n <AriaPopover\n {...props}\n ref={popoverRef}\n style={{\n ...UNSAFE_style,\n // Override default z-index from useOverlayPosition. We use isolation: isolate instead.\n zIndex: undefined\n }}\n className={(renderProps) => UNSAFE_className + mergeStyles(popover({...renderProps, size, isArrowShown: !hideArrow, colorScheme, isSubmenu: renderProps.trigger === 'SubmenuTrigger'}), styles)}>\n {composeRenderProps(props.children, (children, renderProps) => (\n <>\n {!hideArrow && (\n <OverlayArrow>\n <svg width={18} height={9} viewBox=\"0 0 18 10\" className={arrow(renderProps)}>\n <path transform=\"translate(0 -1)\" d=\"M1 1L7.93799 8.52588C8.07224 8.67448 8.23607 8.79362 8.41895 8.87524C8.60182 8.95687 8.79973 8.9993 9 9C9.19984 8.99882 9.39724 8.95606 9.57959 8.87427C9.76193 8.79248 9.9253 8.67336 10.0591 8.5249L17 1\" />\n </svg>\n </OverlayArrow>\n )}\n {children}\n </>\n ))}\n </AriaPopover>\n );\n}\n\nlet _PopoverBase = forwardRef(PopoverBase);\nexport {_PopoverBase as PopoverBase};\n\nexport interface PopoverDialogProps extends Pick<PopoverProps, 'size' | 'hideArrow'| 'placement' | 'shouldFlip' | 'containerPadding' | 'offset' | 'crossOffset'>, Omit<DialogProps, 'className' | 'style'>, StyleProps {}\n\nconst dialogStyle = style({\n padding: 8,\n boxSizing: 'border-box',\n outlineStyle: 'none',\n borderRadius: '[inherit]',\n overflow: 'auto',\n position: 'relative',\n size: 'full',\n maxSize: '[inherit]'\n}, getAllowedOverrides({height: true}));\n\nfunction Popover(props: PopoverDialogProps, ref: DOMRef) {\n let domRef = useDOMRef(ref);\n\n return (\n <_PopoverBase size={props.size} hideArrow={props.hideArrow} placement={props.placement} shouldFlip={props.shouldFlip} containerPadding={props.containerPadding} offset={props.offset} crossOffset={props.crossOffset}>\n <Dialog\n {...props}\n ref={domRef}\n style={props.UNSAFE_style}\n className={(props.UNSAFE_className || '') + dialogStyle(null, props.styles)}>\n {composeRenderProps(props.children, (children) => (\n // Reset OverlayTriggerStateContext so the buttons inside the dialog don't retain their hover state.\n <OverlayTriggerStateContext.Provider value={null}>\n {children}\n </OverlayTriggerStateContext.Provider>\n ))}\n </Dialog>\n </_PopoverBase>\n );\n}\n\n/**\n * A popover is an overlay element positioned relative to a trigger.\n */\nlet _Popover = forwardRef(Popover);\nexport {_Popover as Popover};\n"],"names":[],"version":3,"file":"Popover.cjs.map"}
|
package/dist/Popover.css
CHANGED
package/dist/Popover.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"ACmDsB;;;;;;;;;;AASG;;;;;;;;;;AASE;;;;;;;;;;AASC;;;;;;;;;;AASD;;;;;;;;;;AAUb;EAAA;;;;EAAA;;;;;;EAAA;IAAA;;;;;;EAAA;;;;;;EAAA;;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;EAAA;;;;;EAAA;;;;;EAAA;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EA+FF;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;EAAA;;;;;EAAA;;;;EAAA;;;;EAqGQ;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AApMN;;AAAA;EAAA;IAAA;;;;IA+FF;;;;;;AAAA","sources":["6d7a68425d879d5d","packages/@react-spectrum/s2/src/Popover.tsx"],"sourcesContent":["@import \"0dd0ca29757a362f\";\n@import \"81768260922dd838\";\n@import \"1f6a63d51b6d4755\";\n@import \"5d916373626af735\";\n@import \"b7be93ba2a203a5d\";\n@import \"4d2c1c572cefcb8e\";\n@import \"5a3650982696b8cb\";\n@import \"6d02bf82e7eb5c5e\";\n","/*\n * Copyright 2024 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 {\n Popover as AriaPopover,\n PopoverProps as AriaPopoverProps,\n composeRenderProps,\n Dialog,\n DialogProps,\n ModalRenderProps,\n OverlayArrow,\n OverlayTriggerStateContext,\n useLocale\n} from 'react-aria-components';\nimport {colorScheme, getAllowedOverrides, StyleProps, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {ColorSchemeContext} from './Provider';\nimport {DismissButton} from 'react-aria';\nimport {DOMRef} from '@react-types/shared';\nimport {forwardRef, MutableRefObject, useCallback, useContext} from 'react';\nimport {keyframes} from '../style/style-macro' with {type: 'macro'};\nimport {mergeStyles} from '../style/runtime';\nimport {Modal} from './Modal';\nimport {style} from '../style' with {type: 'macro'};\nimport {StyleString} from '../style/types' with {type: 'macro'};\nimport {useDOMRef, useIsMobileDevice} from '@react-spectrum/utils';\n\nexport interface PopoverProps extends UnsafeStyles, Omit<AriaPopoverProps, 'arrowSize' | 'isNonModal' | 'arrowBoundaryOffset' | 'isKeyboardDismissDisabled' | 'shouldCloseOnInteractOutside' | 'shouldUpdatePosition'> {\n styles?: StyleString,\n /**\n * Whether a popover's arrow should be hidden.\n *\n * @default false\n */\n hideArrow?: boolean,\n /**\n * The size of the Popover. If not specified, the popover fits its contents.\n */\n size?: 'S' | 'M' | 'L',\n /** The type of overlay that should be rendered when on a mobile device. */\n mobileType?: 'modal' | 'fullscreen' | 'fullscreenTakeover' // TODO: add tray back in\n}\n\nconst fadeKeyframes = keyframes(`\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n`);\nconst slideUpKeyframes = keyframes(`\n from {\n transform: translateY(-4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideDownKeyframes = keyframes(`\n from {\n transform: translateY(4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideRightKeyframes = keyframes(`\n from {\n transform: translateX(4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\nconst slideLeftKeyframes = keyframes(`\n from {\n transform: translateX(-4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\n\nlet popover = style({\n ...colorScheme(),\n '--s2-container-bg': {\n type: 'backgroundColor',\n value: 'layer-2'\n },\n backgroundColor: '--s2-container-bg',\n borderRadius: 'lg',\n filter: {\n isArrowShown: 'elevated'\n },\n // Use box-shadow instead of filter when an arrow is not shown.\n // This fixes the shadow stacking problem with submenus.\n boxShadow: {\n default: 'elevated',\n isArrowShown: 'none'\n },\n borderStyle: 'solid',\n borderWidth: 1,\n borderColor: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n },\n width: {\n size: {\n // Copied from designs, not sure if correct.\n S: 336,\n M: 416,\n L: 576\n }\n },\n translateY: {\n placement: {\n bottom: {\n isArrowShown: 8 // TODO: not defined yet should this change with font size? need boolean support for 'hideArrow' prop\n },\n top: {\n isArrowShown: -8\n }\n }\n },\n translateX: {\n placement: {\n left: {\n isArrowShown: -8\n },\n right: {\n isArrowShown: 8\n }\n }\n },\n animation: {\n placement: {\n top: {\n isEntering: `${slideDownKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideDownKeyframes}, ${fadeKeyframes}`\n },\n bottom: {\n isEntering: `${slideUpKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideUpKeyframes}, ${fadeKeyframes}`\n },\n left: {\n isEntering: `${slideRightKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideRightKeyframes}, ${fadeKeyframes}`\n },\n right: {\n isEntering: `${slideLeftKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideLeftKeyframes}, ${fadeKeyframes}`\n }\n },\n isSubmenu: {\n isEntering: fadeKeyframes,\n isExiting: fadeKeyframes\n }\n },\n animationDuration: {\n isEntering: 200,\n isExiting: 200\n },\n animationDirection: {\n isEntering: 'normal',\n isExiting: 'reverse'\n },\n animationTimingFunction: {\n isExiting: 'in'\n },\n transition: '[opacity, transform]',\n willChange: '[opacity, transform]',\n isolation: 'isolate',\n pointerEvents: {\n isExiting: 'none'\n }\n}, getAllowedOverrides());\n// TODO: animations and real Popover Arrow\n\nlet arrow = style({\n display: 'block',\n fill: '--s2-container-bg',\n rotate: {\n default: 180,\n placement: {\n top: 0,\n bottom: 180,\n left: -90,\n right: 90\n }\n },\n translateX: {\n placement: {\n left: -4,\n right: 4\n }\n },\n strokeWidth: 1,\n stroke: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n }\n});\n\nfunction PopoverBase(props: PopoverProps, ref: DOMRef<HTMLDivElement>) {\n let {\n hideArrow = false,\n UNSAFE_className = '',\n UNSAFE_style,\n styles,\n size,\n children,\n trigger = null\n } = props;\n let domRef = useDOMRef(ref);\n let colorScheme = useContext(ColorSchemeContext);\n let {locale, direction} = useLocale();\n\n // TODO: should we pass through lang and dir props in RAC?\n let popoverRef = useCallback((el: HTMLDivElement) => {\n (domRef as MutableRefObject<HTMLDivElement>).current = el;\n if (el) {\n el.lang = locale;\n el.dir = direction;\n }\n }, [locale, direction, domRef]);\n\n // On small devices, show a modal (or eventually a tray) instead of a popover.\n let isMobile = useIsMobileDevice();\n if (isMobile && process.env.NODE_ENV !== 'test') {\n let mappedChildren = typeof children === 'function'\n ? (renderProps: ModalRenderProps) => children({...renderProps, defaultChildren: null, trigger, placement: 'bottom'})\n : children;\n\n return (\n <Modal size={size} isDismissable>\n {composeRenderProps(mappedChildren, (children, {state}) => (\n <>\n {children}\n {/* Add additional dismiss button at the end to match popovers. */}\n <DismissButton onDismiss={state.close} />\n </>\n ))}\n </Modal>\n );\n }\n\n // TODO: this still isn't the final popover 'tip', copying various ones out of the designs files yields different results\n // containerPadding not working as expected\n return (\n <AriaPopover\n {...props}\n ref={popoverRef}\n style={{\n ...UNSAFE_style,\n // Override default z-index from useOverlayPosition. We use isolation: isolate instead.\n zIndex: undefined\n }}\n className={(renderProps) => UNSAFE_className + mergeStyles(popover({...renderProps, size, isArrowShown: !hideArrow, colorScheme, isSubmenu: renderProps.trigger === 'SubmenuTrigger'}), styles)}>\n {composeRenderProps(props.children, (children, renderProps) => (\n <>\n {!hideArrow && (\n <OverlayArrow>\n <svg width={18} height={9} viewBox=\"0 0 18 10\" className={arrow(renderProps)}>\n <path transform=\"translate(0 -1)\" d=\"M1 1L7.93799 8.52588C8.07224 8.67448 8.23607 8.79362 8.41895 8.87524C8.60182 8.95687 8.79973 8.9993 9 9C9.19984 8.99882 9.39724 8.95606 9.57959 8.87427C9.76193 8.79248 9.9253 8.67336 10.0591 8.5249L17 1\" />\n </svg>\n </OverlayArrow>\n )}\n {children}\n </>\n ))}\n </AriaPopover>\n );\n}\n\nlet _PopoverBase = forwardRef(PopoverBase);\nexport {_PopoverBase as PopoverBase};\n\nexport interface PopoverDialogProps extends Pick<PopoverProps, 'size' | 'hideArrow' | 'mobileType' | 'placement' | 'shouldFlip' | 'containerPadding' | 'offset' | 'crossOffset'>, Omit<DialogProps, 'className' | 'style'>, StyleProps {}\n\nconst dialogStyle = style({\n padding: 8,\n boxSizing: 'border-box',\n outlineStyle: 'none',\n borderRadius: '[inherit]',\n overflow: 'auto',\n position: 'relative',\n size: 'full',\n maxSize: '[inherit]'\n}, getAllowedOverrides({height: true}));\n\nfunction Popover(props: PopoverDialogProps, ref: DOMRef) {\n let domRef = useDOMRef(ref);\n\n return (\n <_PopoverBase size={props.size} hideArrow={props.hideArrow} placement={props.placement} shouldFlip={props.shouldFlip} containerPadding={props.containerPadding} offset={props.offset} crossOffset={props.crossOffset}>\n <Dialog\n {...props}\n ref={domRef}\n style={props.UNSAFE_style}\n className={(props.UNSAFE_className || '') + dialogStyle(null, props.styles)}>\n {composeRenderProps(props.children, (children) => (\n // Reset OverlayTriggerStateContext so the buttons inside the dialog don't retain their hover state.\n <OverlayTriggerStateContext.Provider value={null}>\n {children}\n </OverlayTriggerStateContext.Provider>\n ))}\n </Dialog>\n </_PopoverBase>\n );\n}\n\n/**\n * A popover is an overlay element positioned relative to a trigger.\n */\nlet _Popover = forwardRef(Popover);\nexport {_Popover as Popover};\n"],"names":[],"version":3,"file":"Popover.css.map"}
|
|
1
|
+
{"mappings":"ACgDsB;;;;;;;;;;AASG;;;;;;;;;;AASE;;;;;;;;;;AASC;;;;;;;;;;AASD;;;;;;;;;;AAUb;EAAA;;;;EAAA;;;;;;EAAA;IAAA;;;;;;EAAA;;;;;;EAAA;;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;EAAA;;;;;EAAA;;;;;EAAA;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAkGF;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;EAAA;;;;;EAAA;;;;EAAA;;;;EAoGQ;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AAtMN;;AAAA;EAAA;IAAA;;;;IAkGF;;;;;;AAAA","sources":["6d7a68425d879d5d","packages/@react-spectrum/s2/src/Popover.tsx"],"sourcesContent":["@import \"0dd0ca29757a362f\";\n@import \"81768260922dd838\";\n@import \"1f6a63d51b6d4755\";\n@import \"5d916373626af735\";\n@import \"b7be93ba2a203a5d\";\n@import \"4d2c1c572cefcb8e\";\n@import \"5a3650982696b8cb\";\n@import \"6d02bf82e7eb5c5e\";\n","/*\n * Copyright 2024 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 {\n Popover as AriaPopover,\n PopoverProps as AriaPopoverProps,\n composeRenderProps,\n Dialog,\n DialogProps,\n OverlayArrow,\n OverlayTriggerStateContext,\n useLocale\n} from 'react-aria-components';\nimport {colorScheme, getAllowedOverrides, StyleProps, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {ColorSchemeContext} from './Provider';\nimport {DOMRef} from '@react-types/shared';\nimport {forwardRef, MutableRefObject, useCallback, useContext} from 'react';\nimport {keyframes} from '../style/style-macro' with {type: 'macro'};\nimport {mergeStyles} from '../style/runtime';\nimport {style} from '../style' with {type: 'macro'};\nimport {StyleString} from '../style/types' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\n\nexport interface PopoverProps extends UnsafeStyles, Omit<AriaPopoverProps, 'arrowSize' | 'isNonModal' | 'arrowBoundaryOffset' | 'isKeyboardDismissDisabled' | 'shouldCloseOnInteractOutside' | 'shouldUpdatePosition'> {\n styles?: StyleString,\n /**\n * Whether a popover's arrow should be hidden.\n *\n * @default false\n */\n hideArrow?: boolean,\n /**\n * The size of the Popover. If not specified, the popover fits its contents.\n */\n size?: 'S' | 'M' | 'L'\n /** The type of overlay that should be rendered when on a mobile device. */\n // mobileType?: 'modal' | 'fullscreen' | 'fullscreenTakeover' // TODO: add tray back in\n}\n\nconst fadeKeyframes = keyframes(`\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n`);\nconst slideUpKeyframes = keyframes(`\n from {\n transform: translateY(-4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideDownKeyframes = keyframes(`\n from {\n transform: translateY(4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideRightKeyframes = keyframes(`\n from {\n transform: translateX(4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\nconst slideLeftKeyframes = keyframes(`\n from {\n transform: translateX(-4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\n\nlet popover = style({\n ...colorScheme(),\n '--s2-container-bg': {\n type: 'backgroundColor',\n value: 'layer-2'\n },\n backgroundColor: '--s2-container-bg',\n borderRadius: 'lg',\n filter: {\n isArrowShown: 'elevated'\n },\n // Use box-shadow instead of filter when an arrow is not shown.\n // This fixes the shadow stacking problem with submenus.\n boxShadow: {\n default: 'elevated',\n isArrowShown: 'none'\n },\n borderStyle: 'solid',\n borderWidth: 1,\n borderColor: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n },\n width: {\n size: {\n // Copied from designs, not sure if correct.\n S: 336,\n M: 416,\n L: 576\n }\n },\n // Don't be larger than full screen minus 2 * containerPadding\n maxWidth: '[calc(100vw - 24px)]',\n boxSizing: 'border-box',\n translateY: {\n placement: {\n bottom: {\n isArrowShown: 8 // TODO: not defined yet should this change with font size? need boolean support for 'hideArrow' prop\n },\n top: {\n isArrowShown: -8\n }\n }\n },\n translateX: {\n placement: {\n left: {\n isArrowShown: -8\n },\n right: {\n isArrowShown: 8\n }\n }\n },\n animation: {\n placement: {\n top: {\n isEntering: `${slideDownKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideDownKeyframes}, ${fadeKeyframes}`\n },\n bottom: {\n isEntering: `${slideUpKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideUpKeyframes}, ${fadeKeyframes}`\n },\n left: {\n isEntering: `${slideRightKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideRightKeyframes}, ${fadeKeyframes}`\n },\n right: {\n isEntering: `${slideLeftKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideLeftKeyframes}, ${fadeKeyframes}`\n }\n },\n isSubmenu: {\n isEntering: fadeKeyframes,\n isExiting: fadeKeyframes\n }\n },\n animationDuration: {\n isEntering: 200,\n isExiting: 200\n },\n animationDirection: {\n isEntering: 'normal',\n isExiting: 'reverse'\n },\n animationTimingFunction: {\n isExiting: 'in'\n },\n transition: '[opacity, transform]',\n willChange: '[opacity, transform]',\n isolation: 'isolate',\n pointerEvents: {\n isExiting: 'none'\n }\n}, getAllowedOverrides());\n// TODO: animations and real Popover Arrow\n\nlet arrow = style({\n display: 'block',\n fill: '--s2-container-bg',\n rotate: {\n default: 180,\n placement: {\n top: 0,\n bottom: 180,\n left: -90,\n right: 90\n }\n },\n translateX: {\n placement: {\n left: -4,\n right: 4\n }\n },\n strokeWidth: 1,\n stroke: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n }\n});\n\nfunction PopoverBase(props: PopoverProps, ref: DOMRef<HTMLDivElement>) {\n let {\n hideArrow = false,\n UNSAFE_className = '',\n UNSAFE_style,\n styles,\n size\n } = props;\n let domRef = useDOMRef(ref);\n let colorScheme = useContext(ColorSchemeContext);\n let {locale, direction} = useLocale();\n\n // TODO: should we pass through lang and dir props in RAC?\n let popoverRef = useCallback((el: HTMLDivElement) => {\n (domRef as MutableRefObject<HTMLDivElement>).current = el;\n if (el) {\n el.lang = locale;\n el.dir = direction;\n }\n }, [locale, direction, domRef]);\n\n // On small devices, show a modal (or eventually a tray) instead of a popover.\n // TODO: reverted this until we have trays.\n // let isMobile = useIsMobileDevice();\n // if (isMobile && process.env.NODE_ENV !== 'test') {\n // let mappedChildren = typeof children === 'function'\n // ? (renderProps: ModalRenderProps) => children({...renderProps, defaultChildren: null, trigger, placement: 'bottom'})\n // : children;\n\n // return (\n // <Modal size={size} isDismissable>\n // {composeRenderProps(mappedChildren, (children, {state}) => (\n // <>\n // {children}\n // {/* Add additional dismiss button at the end to match popovers. */}\n // <DismissButton onDismiss={state.close} />\n // </>\n // ))}\n // </Modal>\n // );\n // }\n\n // TODO: this still isn't the final popover 'tip', copying various ones out of the designs files yields different results\n // containerPadding not working as expected\n return (\n <AriaPopover\n {...props}\n ref={popoverRef}\n style={{\n ...UNSAFE_style,\n // Override default z-index from useOverlayPosition. We use isolation: isolate instead.\n zIndex: undefined\n }}\n className={(renderProps) => UNSAFE_className + mergeStyles(popover({...renderProps, size, isArrowShown: !hideArrow, colorScheme, isSubmenu: renderProps.trigger === 'SubmenuTrigger'}), styles)}>\n {composeRenderProps(props.children, (children, renderProps) => (\n <>\n {!hideArrow && (\n <OverlayArrow>\n <svg width={18} height={9} viewBox=\"0 0 18 10\" className={arrow(renderProps)}>\n <path transform=\"translate(0 -1)\" d=\"M1 1L7.93799 8.52588C8.07224 8.67448 8.23607 8.79362 8.41895 8.87524C8.60182 8.95687 8.79973 8.9993 9 9C9.19984 8.99882 9.39724 8.95606 9.57959 8.87427C9.76193 8.79248 9.9253 8.67336 10.0591 8.5249L17 1\" />\n </svg>\n </OverlayArrow>\n )}\n {children}\n </>\n ))}\n </AriaPopover>\n );\n}\n\nlet _PopoverBase = forwardRef(PopoverBase);\nexport {_PopoverBase as PopoverBase};\n\nexport interface PopoverDialogProps extends Pick<PopoverProps, 'size' | 'hideArrow'| 'placement' | 'shouldFlip' | 'containerPadding' | 'offset' | 'crossOffset'>, Omit<DialogProps, 'className' | 'style'>, StyleProps {}\n\nconst dialogStyle = style({\n padding: 8,\n boxSizing: 'border-box',\n outlineStyle: 'none',\n borderRadius: '[inherit]',\n overflow: 'auto',\n position: 'relative',\n size: 'full',\n maxSize: '[inherit]'\n}, getAllowedOverrides({height: true}));\n\nfunction Popover(props: PopoverDialogProps, ref: DOMRef) {\n let domRef = useDOMRef(ref);\n\n return (\n <_PopoverBase size={props.size} hideArrow={props.hideArrow} placement={props.placement} shouldFlip={props.shouldFlip} containerPadding={props.containerPadding} offset={props.offset} crossOffset={props.crossOffset}>\n <Dialog\n {...props}\n ref={domRef}\n style={props.UNSAFE_style}\n className={(props.UNSAFE_className || '') + dialogStyle(null, props.styles)}>\n {composeRenderProps(props.children, (children) => (\n // Reset OverlayTriggerStateContext so the buttons inside the dialog don't retain their hover state.\n <OverlayTriggerStateContext.Provider value={null}>\n {children}\n </OverlayTriggerStateContext.Provider>\n ))}\n </Dialog>\n </_PopoverBase>\n );\n}\n\n/**\n * A popover is an overlay element positioned relative to a trigger.\n */\nlet _Popover = forwardRef(Popover);\nexport {_Popover as Popover};\n"],"names":[],"version":3,"file":"Popover.css.map"}
|
package/dist/Popover.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import "./Popover.css";
|
|
2
2
|
import {ColorSchemeContext as $9affbfa4e13b9582$export$374e0245597d19a3} from "./Provider.mjs";
|
|
3
3
|
import {mergeStyles as $feb886035e0d4633$export$e618dc39ac9ad607} from "../icons/runtime.mjs";
|
|
4
|
-
import {Modal as $c46d159bd615e407$export$2b77a92f1a5ad772} from "./Modal.mjs";
|
|
5
4
|
import {jsx as $ggIy9$jsx, jsxs as $ggIy9$jsxs, Fragment as $ggIy9$Fragment} from "react/jsx-runtime";
|
|
6
|
-
import {useLocale as $ggIy9$useLocale,
|
|
7
|
-
import {DismissButton as $ggIy9$DismissButton} from "react-aria";
|
|
5
|
+
import {useLocale as $ggIy9$useLocale, Popover as $ggIy9$Popover, composeRenderProps as $ggIy9$composeRenderProps, OverlayArrow as $ggIy9$OverlayArrow, Dialog as $ggIy9$Dialog, OverlayTriggerStateContext as $ggIy9$OverlayTriggerStateContext} from "react-aria-components";
|
|
8
6
|
import {useContext as $ggIy9$useContext, useCallback as $ggIy9$useCallback, forwardRef as $ggIy9$forwardRef} from "react";
|
|
9
|
-
import {useDOMRef as $ggIy9$useDOMRef
|
|
7
|
+
import {useDOMRef as $ggIy9$useDOMRef} from "@react-spectrum/utils";
|
|
10
8
|
|
|
11
9
|
/*
|
|
12
10
|
* Copyright 2024 Adobe. All rights reserved.
|
|
@@ -24,8 +22,6 @@ import {useDOMRef as $ggIy9$useDOMRef, useIsMobileDevice as $ggIy9$useIsMobileDe
|
|
|
24
22
|
|
|
25
23
|
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
25
|
const $88b746eba92c8d0d$var$fadeKeyframes = "-_1llqja1";
|
|
30
26
|
const $88b746eba92c8d0d$var$slideUpKeyframes = "-xohm13";
|
|
31
27
|
const $88b746eba92c8d0d$var$slideDownKeyframes = "-_2hjlm";
|
|
@@ -36,7 +32,11 @@ let $88b746eba92c8d0d$var$popover = function anonymous(props, overrides) {
|
|
|
36
32
|
let matches = (overrides || '').match(/(?:^|\s)(?:y|z|A|B|_9|_8|h|_5|_4|__A|__c|__d|__a|__b|U|__Q|X|Z|V|W|l|q|r)[^\s]+/g) || [];
|
|
37
33
|
rules += matches.join('');
|
|
38
34
|
let $l = false;
|
|
39
|
-
|
|
35
|
+
let $r = false;
|
|
36
|
+
for (let p of matches){
|
|
37
|
+
if (/^\s*l/.test(p)) $l = true;
|
|
38
|
+
if (/^\s*r/.test(p)) $r = true;
|
|
39
|
+
}
|
|
40
40
|
if (props.colorScheme === "dark") rules += ' _Ab';
|
|
41
41
|
else if (props.colorScheme === "light") rules += ' _Aa';
|
|
42
42
|
else if (props.colorScheme === "light dark") rules += ' _Ac';
|
|
@@ -62,6 +62,8 @@ let $88b746eba92c8d0d$var$popover = function anonymous(props, overrides) {
|
|
|
62
62
|
else if (props.size === "M") rules += ' l______6';
|
|
63
63
|
else if (props.size === "S") rules += ' l_____O';
|
|
64
64
|
}
|
|
65
|
+
if (!$r) rules += ' r-rtptky';
|
|
66
|
+
rules += ' __na';
|
|
65
67
|
if (props.placement === "top") {
|
|
66
68
|
if (props.isArrowShown) rules += ' QG';
|
|
67
69
|
} else if (props.placement === "bottom") {
|
|
@@ -119,7 +121,7 @@ let $88b746eba92c8d0d$var$arrow = function anonymous(props) {
|
|
|
119
121
|
return rules;
|
|
120
122
|
};
|
|
121
123
|
function $88b746eba92c8d0d$var$PopoverBase(props, ref) {
|
|
122
|
-
let { hideArrow: hideArrow = false, UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, styles: styles, size: size
|
|
124
|
+
let { hideArrow: hideArrow = false, UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, styles: styles, size: size } = props;
|
|
123
125
|
let domRef = (0, $ggIy9$useDOMRef)(ref);
|
|
124
126
|
let colorScheme = (0, $ggIy9$useContext)((0, $9affbfa4e13b9582$export$374e0245597d19a3));
|
|
125
127
|
let { locale: locale, direction: direction } = (0, $ggIy9$useLocale)();
|
|
@@ -136,27 +138,24 @@ function $88b746eba92c8d0d$var$PopoverBase(props, ref) {
|
|
|
136
138
|
domRef
|
|
137
139
|
]);
|
|
138
140
|
// On small devices, show a modal (or eventually a tray) instead of a popover.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}))
|
|
158
|
-
});
|
|
159
|
-
}
|
|
141
|
+
// TODO: reverted this until we have trays.
|
|
142
|
+
// let isMobile = useIsMobileDevice();
|
|
143
|
+
// if (isMobile && process.env.NODE_ENV !== 'test') {
|
|
144
|
+
// let mappedChildren = typeof children === 'function'
|
|
145
|
+
// ? (renderProps: ModalRenderProps) => children({...renderProps, defaultChildren: null, trigger, placement: 'bottom'})
|
|
146
|
+
// : children;
|
|
147
|
+
// return (
|
|
148
|
+
// <Modal size={size} isDismissable>
|
|
149
|
+
// {composeRenderProps(mappedChildren, (children, {state}) => (
|
|
150
|
+
// <>
|
|
151
|
+
// {children}
|
|
152
|
+
// {/* Add additional dismiss button at the end to match popovers. */}
|
|
153
|
+
// <DismissButton onDismiss={state.close} />
|
|
154
|
+
// </>
|
|
155
|
+
// ))}
|
|
156
|
+
// </Modal>
|
|
157
|
+
// );
|
|
158
|
+
// }
|
|
160
159
|
// TODO: this still isn't the final popover 'tip', copying various ones out of the designs files yields different results
|
|
161
160
|
// containerPadding not working as expected
|
|
162
161
|
return /*#__PURE__*/ (0, $ggIy9$jsx)((0, $ggIy9$Popover), {
|
package/dist/Popover.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"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","sources":["packages/@react-spectrum/s2/src/Popover.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {\n Popover as AriaPopover,\n PopoverProps as AriaPopoverProps,\n composeRenderProps,\n Dialog,\n DialogProps,\n ModalRenderProps,\n OverlayArrow,\n OverlayTriggerStateContext,\n useLocale\n} from 'react-aria-components';\nimport {colorScheme, getAllowedOverrides, StyleProps, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {ColorSchemeContext} from './Provider';\nimport {DismissButton} from 'react-aria';\nimport {DOMRef} from '@react-types/shared';\nimport {forwardRef, MutableRefObject, useCallback, useContext} from 'react';\nimport {keyframes} from '../style/style-macro' with {type: 'macro'};\nimport {mergeStyles} from '../style/runtime';\nimport {Modal} from './Modal';\nimport {style} from '../style' with {type: 'macro'};\nimport {StyleString} from '../style/types' with {type: 'macro'};\nimport {useDOMRef, useIsMobileDevice} from '@react-spectrum/utils';\n\nexport interface PopoverProps extends UnsafeStyles, Omit<AriaPopoverProps, 'arrowSize' | 'isNonModal' | 'arrowBoundaryOffset' | 'isKeyboardDismissDisabled' | 'shouldCloseOnInteractOutside' | 'shouldUpdatePosition'> {\n styles?: StyleString,\n /**\n * Whether a popover's arrow should be hidden.\n *\n * @default false\n */\n hideArrow?: boolean,\n /**\n * The size of the Popover. If not specified, the popover fits its contents.\n */\n size?: 'S' | 'M' | 'L',\n /** The type of overlay that should be rendered when on a mobile device. */\n mobileType?: 'modal' | 'fullscreen' | 'fullscreenTakeover' // TODO: add tray back in\n}\n\nconst fadeKeyframes = keyframes(`\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n`);\nconst slideUpKeyframes = keyframes(`\n from {\n transform: translateY(-4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideDownKeyframes = keyframes(`\n from {\n transform: translateY(4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideRightKeyframes = keyframes(`\n from {\n transform: translateX(4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\nconst slideLeftKeyframes = keyframes(`\n from {\n transform: translateX(-4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\n\nlet popover = style({\n ...colorScheme(),\n '--s2-container-bg': {\n type: 'backgroundColor',\n value: 'layer-2'\n },\n backgroundColor: '--s2-container-bg',\n borderRadius: 'lg',\n filter: {\n isArrowShown: 'elevated'\n },\n // Use box-shadow instead of filter when an arrow is not shown.\n // This fixes the shadow stacking problem with submenus.\n boxShadow: {\n default: 'elevated',\n isArrowShown: 'none'\n },\n borderStyle: 'solid',\n borderWidth: 1,\n borderColor: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n },\n width: {\n size: {\n // Copied from designs, not sure if correct.\n S: 336,\n M: 416,\n L: 576\n }\n },\n translateY: {\n placement: {\n bottom: {\n isArrowShown: 8 // TODO: not defined yet should this change with font size? need boolean support for 'hideArrow' prop\n },\n top: {\n isArrowShown: -8\n }\n }\n },\n translateX: {\n placement: {\n left: {\n isArrowShown: -8\n },\n right: {\n isArrowShown: 8\n }\n }\n },\n animation: {\n placement: {\n top: {\n isEntering: `${slideDownKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideDownKeyframes}, ${fadeKeyframes}`\n },\n bottom: {\n isEntering: `${slideUpKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideUpKeyframes}, ${fadeKeyframes}`\n },\n left: {\n isEntering: `${slideRightKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideRightKeyframes}, ${fadeKeyframes}`\n },\n right: {\n isEntering: `${slideLeftKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideLeftKeyframes}, ${fadeKeyframes}`\n }\n },\n isSubmenu: {\n isEntering: fadeKeyframes,\n isExiting: fadeKeyframes\n }\n },\n animationDuration: {\n isEntering: 200,\n isExiting: 200\n },\n animationDirection: {\n isEntering: 'normal',\n isExiting: 'reverse'\n },\n animationTimingFunction: {\n isExiting: 'in'\n },\n transition: '[opacity, transform]',\n willChange: '[opacity, transform]',\n isolation: 'isolate',\n pointerEvents: {\n isExiting: 'none'\n }\n}, getAllowedOverrides());\n// TODO: animations and real Popover Arrow\n\nlet arrow = style({\n display: 'block',\n fill: '--s2-container-bg',\n rotate: {\n default: 180,\n placement: {\n top: 0,\n bottom: 180,\n left: -90,\n right: 90\n }\n },\n translateX: {\n placement: {\n left: -4,\n right: 4\n }\n },\n strokeWidth: 1,\n stroke: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n }\n});\n\nfunction PopoverBase(props: PopoverProps, ref: DOMRef<HTMLDivElement>) {\n let {\n hideArrow = false,\n UNSAFE_className = '',\n UNSAFE_style,\n styles,\n size,\n children,\n trigger = null\n } = props;\n let domRef = useDOMRef(ref);\n let colorScheme = useContext(ColorSchemeContext);\n let {locale, direction} = useLocale();\n\n // TODO: should we pass through lang and dir props in RAC?\n let popoverRef = useCallback((el: HTMLDivElement) => {\n (domRef as MutableRefObject<HTMLDivElement>).current = el;\n if (el) {\n el.lang = locale;\n el.dir = direction;\n }\n }, [locale, direction, domRef]);\n\n // On small devices, show a modal (or eventually a tray) instead of a popover.\n let isMobile = useIsMobileDevice();\n if (isMobile && process.env.NODE_ENV !== 'test') {\n let mappedChildren = typeof children === 'function'\n ? (renderProps: ModalRenderProps) => children({...renderProps, defaultChildren: null, trigger, placement: 'bottom'})\n : children;\n\n return (\n <Modal size={size} isDismissable>\n {composeRenderProps(mappedChildren, (children, {state}) => (\n <>\n {children}\n {/* Add additional dismiss button at the end to match popovers. */}\n <DismissButton onDismiss={state.close} />\n </>\n ))}\n </Modal>\n );\n }\n\n // TODO: this still isn't the final popover 'tip', copying various ones out of the designs files yields different results\n // containerPadding not working as expected\n return (\n <AriaPopover\n {...props}\n ref={popoverRef}\n style={{\n ...UNSAFE_style,\n // Override default z-index from useOverlayPosition. We use isolation: isolate instead.\n zIndex: undefined\n }}\n className={(renderProps) => UNSAFE_className + mergeStyles(popover({...renderProps, size, isArrowShown: !hideArrow, colorScheme, isSubmenu: renderProps.trigger === 'SubmenuTrigger'}), styles)}>\n {composeRenderProps(props.children, (children, renderProps) => (\n <>\n {!hideArrow && (\n <OverlayArrow>\n <svg width={18} height={9} viewBox=\"0 0 18 10\" className={arrow(renderProps)}>\n <path transform=\"translate(0 -1)\" d=\"M1 1L7.93799 8.52588C8.07224 8.67448 8.23607 8.79362 8.41895 8.87524C8.60182 8.95687 8.79973 8.9993 9 9C9.19984 8.99882 9.39724 8.95606 9.57959 8.87427C9.76193 8.79248 9.9253 8.67336 10.0591 8.5249L17 1\" />\n </svg>\n </OverlayArrow>\n )}\n {children}\n </>\n ))}\n </AriaPopover>\n );\n}\n\nlet _PopoverBase = forwardRef(PopoverBase);\nexport {_PopoverBase as PopoverBase};\n\nexport interface PopoverDialogProps extends Pick<PopoverProps, 'size' | 'hideArrow' | 'mobileType' | 'placement' | 'shouldFlip' | 'containerPadding' | 'offset' | 'crossOffset'>, Omit<DialogProps, 'className' | 'style'>, StyleProps {}\n\nconst dialogStyle = style({\n padding: 8,\n boxSizing: 'border-box',\n outlineStyle: 'none',\n borderRadius: '[inherit]',\n overflow: 'auto',\n position: 'relative',\n size: 'full',\n maxSize: '[inherit]'\n}, getAllowedOverrides({height: true}));\n\nfunction Popover(props: PopoverDialogProps, ref: DOMRef) {\n let domRef = useDOMRef(ref);\n\n return (\n <_PopoverBase size={props.size} hideArrow={props.hideArrow} placement={props.placement} shouldFlip={props.shouldFlip} containerPadding={props.containerPadding} offset={props.offset} crossOffset={props.crossOffset}>\n <Dialog\n {...props}\n ref={domRef}\n style={props.UNSAFE_style}\n className={(props.UNSAFE_className || '') + dialogStyle(null, props.styles)}>\n {composeRenderProps(props.children, (children) => (\n // Reset OverlayTriggerStateContext so the buttons inside the dialog don't retain their hover state.\n <OverlayTriggerStateContext.Provider value={null}>\n {children}\n </OverlayTriggerStateContext.Provider>\n ))}\n </Dialog>\n </_PopoverBase>\n );\n}\n\n/**\n * A popover is an overlay element positioned relative to a trigger.\n */\nlet _Popover = forwardRef(Popover);\nexport {_Popover as Popover};\n"],"names":[],"version":3,"file":"Popover.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAsCD,MAAM;AASN,MAAM;AASN,MAAM;AASN,MAAM;AASN,MAAM;AAUN,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGJ,0CAA0C;AAE1C,IAAI;;;;;;;;;;;;;;;;AAyBJ,SAAS,kCAAY,KAAmB,EAAE,GAA2B;IACnE,IAAI,aACF,YAAY,yBACZ,mBAAmB,kBACnB,YAAY,UACZ,MAAM,QACN,IAAI,EACL,GAAG;IACJ,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,cAAc,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAiB;IAC9C,IAAI,UAAC,MAAM,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAElC,0DAA0D;IAC1D,IAAI,aAAa,CAAA,GAAA,kBAAU,EAAE,CAAC;QAC3B,OAA4C,OAAO,GAAG;QACvD,IAAI,IAAI;YACN,GAAG,IAAI,GAAG;YACV,GAAG,GAAG,GAAG;QACX;IACF,GAAG;QAAC;QAAQ;QAAW;KAAO;IAE9B,8EAA8E;IAC9E,2CAA2C;IAC3C,sCAAsC;IACtC,qDAAqD;IACrD,wDAAwD;IACxD,2HAA2H;IAC3H,kBAAkB;IAElB,aAAa;IACb,wCAAwC;IACxC,qEAAqE;IACrE,aAAa;IACb,uBAAuB;IACvB,gFAAgF;IAChF,sDAAsD;IACtD,cAAc;IACd,YAAY;IACZ,eAAe;IACf,OAAO;IACP,IAAI;IAEJ,yHAAyH;IACzH,2CAA2C;IAC3C,qBACE,gBAAC,CAAA,GAAA,cAAU;QACR,GAAG,KAAK;QACT,KAAK;QACL,OAAO;YACL,GAAG,YAAY;YACf,uFAAuF;YACvF,QAAQ;QACV;QACA,WAAW,CAAC,cAAgB,mBAAmB,CAAA,GAAA,yCAAU,EAAE,8BAAQ;gBAAC,GAAG,WAAW;sBAAE;gBAAM,cAAc,CAAC;6BAAW;gBAAa,WAAW,YAAY,OAAO,KAAK;YAAgB,IAAI;kBACvL,CAAA,GAAA,yBAAiB,EAAE,MAAM,QAAQ,EAAE,CAAC,UAAU,4BAC7C;;oBACG,CAAC,2BACA,gBAAC,CAAA,GAAA,mBAAW;kCACV,cAAA,gBAAC;4BAAI,OAAO;4BAAI,QAAQ;4BAAG,SAAQ;4BAAY,WAAW,4BAAM;sCAC9D,cAAA,gBAAC;gCAAK,WAAU;gCAAkB,GAAE;;;;oBAIzC;;;;AAKX;AAEA,IAAI,0DAAe,CAAA,GAAA,iBAAS,EAAE;AAK9B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWN,SAAS,8BAAQ,KAAyB,EAAE,GAAW;IACrD,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IAEvB,qBACE,gBAAC;QAAa,MAAM,MAAM,IAAI;QAAE,WAAW,MAAM,SAAS;QAAE,WAAW,MAAM,SAAS;QAAE,YAAY,MAAM,UAAU;QAAE,kBAAkB,MAAM,gBAAgB;QAAE,QAAQ,MAAM,MAAM;QAAE,aAAa,MAAM,WAAW;kBAClN,cAAA,gBAAC,CAAA,GAAA,aAAK;YACH,GAAG,KAAK;YACT,KAAK;YACL,OAAO,MAAM,YAAY;YACzB,WAAW,AAAC,CAAA,MAAM,gBAAgB,IAAI,EAAC,IAAK,kCAAY,MAAM,MAAM,MAAM;sBACzE,CAAA,GAAA,yBAAiB,EAAE,MAAM,QAAQ,EAAE,CAAC,WACnC,oGAAoG;8BACpG,gBAAC,CAAA,GAAA,iCAAyB,EAAE,QAAQ;oBAAC,OAAO;8BACzC;;;;AAMb;AAEA;;CAEC,GACD,IAAI,0DAAW,CAAA,GAAA,iBAAS,EAAE","sources":["packages/@react-spectrum/s2/src/Popover.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {\n Popover as AriaPopover,\n PopoverProps as AriaPopoverProps,\n composeRenderProps,\n Dialog,\n DialogProps,\n OverlayArrow,\n OverlayTriggerStateContext,\n useLocale\n} from 'react-aria-components';\nimport {colorScheme, getAllowedOverrides, StyleProps, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {ColorSchemeContext} from './Provider';\nimport {DOMRef} from '@react-types/shared';\nimport {forwardRef, MutableRefObject, useCallback, useContext} from 'react';\nimport {keyframes} from '../style/style-macro' with {type: 'macro'};\nimport {mergeStyles} from '../style/runtime';\nimport {style} from '../style' with {type: 'macro'};\nimport {StyleString} from '../style/types' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\n\nexport interface PopoverProps extends UnsafeStyles, Omit<AriaPopoverProps, 'arrowSize' | 'isNonModal' | 'arrowBoundaryOffset' | 'isKeyboardDismissDisabled' | 'shouldCloseOnInteractOutside' | 'shouldUpdatePosition'> {\n styles?: StyleString,\n /**\n * Whether a popover's arrow should be hidden.\n *\n * @default false\n */\n hideArrow?: boolean,\n /**\n * The size of the Popover. If not specified, the popover fits its contents.\n */\n size?: 'S' | 'M' | 'L'\n /** The type of overlay that should be rendered when on a mobile device. */\n // mobileType?: 'modal' | 'fullscreen' | 'fullscreenTakeover' // TODO: add tray back in\n}\n\nconst fadeKeyframes = keyframes(`\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n`);\nconst slideUpKeyframes = keyframes(`\n from {\n transform: translateY(-4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideDownKeyframes = keyframes(`\n from {\n transform: translateY(4px);\n }\n\n to {\n transform: translateY(0);\n }\n`);\nconst slideRightKeyframes = keyframes(`\n from {\n transform: translateX(4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\nconst slideLeftKeyframes = keyframes(`\n from {\n transform: translateX(-4px);\n }\n\n to {\n transform: translateX(0);\n }\n`);\n\nlet popover = style({\n ...colorScheme(),\n '--s2-container-bg': {\n type: 'backgroundColor',\n value: 'layer-2'\n },\n backgroundColor: '--s2-container-bg',\n borderRadius: 'lg',\n filter: {\n isArrowShown: 'elevated'\n },\n // Use box-shadow instead of filter when an arrow is not shown.\n // This fixes the shadow stacking problem with submenus.\n boxShadow: {\n default: 'elevated',\n isArrowShown: 'none'\n },\n borderStyle: 'solid',\n borderWidth: 1,\n borderColor: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n },\n width: {\n size: {\n // Copied from designs, not sure if correct.\n S: 336,\n M: 416,\n L: 576\n }\n },\n // Don't be larger than full screen minus 2 * containerPadding\n maxWidth: '[calc(100vw - 24px)]',\n boxSizing: 'border-box',\n translateY: {\n placement: {\n bottom: {\n isArrowShown: 8 // TODO: not defined yet should this change with font size? need boolean support for 'hideArrow' prop\n },\n top: {\n isArrowShown: -8\n }\n }\n },\n translateX: {\n placement: {\n left: {\n isArrowShown: -8\n },\n right: {\n isArrowShown: 8\n }\n }\n },\n animation: {\n placement: {\n top: {\n isEntering: `${slideDownKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideDownKeyframes}, ${fadeKeyframes}`\n },\n bottom: {\n isEntering: `${slideUpKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideUpKeyframes}, ${fadeKeyframes}`\n },\n left: {\n isEntering: `${slideRightKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideRightKeyframes}, ${fadeKeyframes}`\n },\n right: {\n isEntering: `${slideLeftKeyframes}, ${fadeKeyframes}`,\n isExiting: `${slideLeftKeyframes}, ${fadeKeyframes}`\n }\n },\n isSubmenu: {\n isEntering: fadeKeyframes,\n isExiting: fadeKeyframes\n }\n },\n animationDuration: {\n isEntering: 200,\n isExiting: 200\n },\n animationDirection: {\n isEntering: 'normal',\n isExiting: 'reverse'\n },\n animationTimingFunction: {\n isExiting: 'in'\n },\n transition: '[opacity, transform]',\n willChange: '[opacity, transform]',\n isolation: 'isolate',\n pointerEvents: {\n isExiting: 'none'\n }\n}, getAllowedOverrides());\n// TODO: animations and real Popover Arrow\n\nlet arrow = style({\n display: 'block',\n fill: '--s2-container-bg',\n rotate: {\n default: 180,\n placement: {\n top: 0,\n bottom: 180,\n left: -90,\n right: 90\n }\n },\n translateX: {\n placement: {\n left: -4,\n right: 4\n }\n },\n strokeWidth: 1,\n stroke: {\n default: 'gray-200',\n forcedColors: 'ButtonBorder'\n }\n});\n\nfunction PopoverBase(props: PopoverProps, ref: DOMRef<HTMLDivElement>) {\n let {\n hideArrow = false,\n UNSAFE_className = '',\n UNSAFE_style,\n styles,\n size\n } = props;\n let domRef = useDOMRef(ref);\n let colorScheme = useContext(ColorSchemeContext);\n let {locale, direction} = useLocale();\n\n // TODO: should we pass through lang and dir props in RAC?\n let popoverRef = useCallback((el: HTMLDivElement) => {\n (domRef as MutableRefObject<HTMLDivElement>).current = el;\n if (el) {\n el.lang = locale;\n el.dir = direction;\n }\n }, [locale, direction, domRef]);\n\n // On small devices, show a modal (or eventually a tray) instead of a popover.\n // TODO: reverted this until we have trays.\n // let isMobile = useIsMobileDevice();\n // if (isMobile && process.env.NODE_ENV !== 'test') {\n // let mappedChildren = typeof children === 'function'\n // ? (renderProps: ModalRenderProps) => children({...renderProps, defaultChildren: null, trigger, placement: 'bottom'})\n // : children;\n\n // return (\n // <Modal size={size} isDismissable>\n // {composeRenderProps(mappedChildren, (children, {state}) => (\n // <>\n // {children}\n // {/* Add additional dismiss button at the end to match popovers. */}\n // <DismissButton onDismiss={state.close} />\n // </>\n // ))}\n // </Modal>\n // );\n // }\n\n // TODO: this still isn't the final popover 'tip', copying various ones out of the designs files yields different results\n // containerPadding not working as expected\n return (\n <AriaPopover\n {...props}\n ref={popoverRef}\n style={{\n ...UNSAFE_style,\n // Override default z-index from useOverlayPosition. We use isolation: isolate instead.\n zIndex: undefined\n }}\n className={(renderProps) => UNSAFE_className + mergeStyles(popover({...renderProps, size, isArrowShown: !hideArrow, colorScheme, isSubmenu: renderProps.trigger === 'SubmenuTrigger'}), styles)}>\n {composeRenderProps(props.children, (children, renderProps) => (\n <>\n {!hideArrow && (\n <OverlayArrow>\n <svg width={18} height={9} viewBox=\"0 0 18 10\" className={arrow(renderProps)}>\n <path transform=\"translate(0 -1)\" d=\"M1 1L7.93799 8.52588C8.07224 8.67448 8.23607 8.79362 8.41895 8.87524C8.60182 8.95687 8.79973 8.9993 9 9C9.19984 8.99882 9.39724 8.95606 9.57959 8.87427C9.76193 8.79248 9.9253 8.67336 10.0591 8.5249L17 1\" />\n </svg>\n </OverlayArrow>\n )}\n {children}\n </>\n ))}\n </AriaPopover>\n );\n}\n\nlet _PopoverBase = forwardRef(PopoverBase);\nexport {_PopoverBase as PopoverBase};\n\nexport interface PopoverDialogProps extends Pick<PopoverProps, 'size' | 'hideArrow'| 'placement' | 'shouldFlip' | 'containerPadding' | 'offset' | 'crossOffset'>, Omit<DialogProps, 'className' | 'style'>, StyleProps {}\n\nconst dialogStyle = style({\n padding: 8,\n boxSizing: 'border-box',\n outlineStyle: 'none',\n borderRadius: '[inherit]',\n overflow: 'auto',\n position: 'relative',\n size: 'full',\n maxSize: '[inherit]'\n}, getAllowedOverrides({height: true}));\n\nfunction Popover(props: PopoverDialogProps, ref: DOMRef) {\n let domRef = useDOMRef(ref);\n\n return (\n <_PopoverBase size={props.size} hideArrow={props.hideArrow} placement={props.placement} shouldFlip={props.shouldFlip} containerPadding={props.containerPadding} offset={props.offset} crossOffset={props.crossOffset}>\n <Dialog\n {...props}\n ref={domRef}\n style={props.UNSAFE_style}\n className={(props.UNSAFE_className || '') + dialogStyle(null, props.styles)}>\n {composeRenderProps(props.children, (children) => (\n // Reset OverlayTriggerStateContext so the buttons inside the dialog don't retain their hover state.\n <OverlayTriggerStateContext.Provider value={null}>\n {children}\n </OverlayTriggerStateContext.Provider>\n ))}\n </Dialog>\n </_PopoverBase>\n );\n}\n\n/**\n * A popover is an overlay element positioned relative to a trigger.\n */\nlet _Popover = forwardRef(Popover);\nexport {_Popover as Popover};\n"],"names":[],"version":3,"file":"Popover.mjs.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -385,10 +385,8 @@ export interface PopoverProps extends UnsafeStyles, Omit<_PopoverProps1, 'arrowS
|
|
|
385
385
|
* The size of the Popover. If not specified, the popover fits its contents.
|
|
386
386
|
*/
|
|
387
387
|
size?: 'S' | 'M' | 'L';
|
|
388
|
-
/** The type of overlay that should be rendered when on a mobile device. */
|
|
389
|
-
mobileType?: 'modal' | 'fullscreen' | 'fullscreenTakeover';
|
|
390
388
|
}
|
|
391
|
-
interface PopoverDialogProps extends Pick<PopoverProps, 'size' | 'hideArrow' | '
|
|
389
|
+
interface PopoverDialogProps extends Pick<PopoverProps, 'size' | 'hideArrow' | 'placement' | 'shouldFlip' | 'containerPadding' | 'offset' | 'crossOffset'>, Omit<_DialogProps1, 'className' | 'style'>, StyleProps {
|
|
392
390
|
}
|
|
393
391
|
/**
|
|
394
392
|
* A popover is an overlay element positioned relative to a trigger.
|
|
@@ -575,9 +573,9 @@ export interface CloseButtonProps extends Pick<_ButtonProps1, 'isDisabled'>, Sty
|
|
|
575
573
|
export let CloseButton: ForwardRefExoticComponent<CloseButtonProps & RefAttributes<FocusableRefValue<HTMLButtonElement, HTMLButtonElement>>>;
|
|
576
574
|
export interface DialogProps extends Omit<_DialogProps1, 'className' | 'style'>, StyleProps {
|
|
577
575
|
/**
|
|
578
|
-
* Whether the Dialog is
|
|
576
|
+
* Whether the Dialog is dismissible.
|
|
579
577
|
*/
|
|
580
|
-
|
|
578
|
+
isDismissible?: boolean;
|
|
581
579
|
/**
|
|
582
580
|
* The size of the Dialog.
|
|
583
581
|
*
|
|
@@ -1003,9 +1001,9 @@ export interface CustomDialogProps extends Omit<_DialogProps1, 'className' | 'st
|
|
|
1003
1001
|
*/
|
|
1004
1002
|
size?: 'S' | 'M' | 'L' | 'fullscreen' | 'fullscreenTakeover';
|
|
1005
1003
|
/**
|
|
1006
|
-
* Whether the Dialog is
|
|
1004
|
+
* Whether the Dialog is dismissible.
|
|
1007
1005
|
*/
|
|
1008
|
-
|
|
1006
|
+
isDismissible?: boolean;
|
|
1009
1007
|
/** Whether pressing the escape key to close the dialog should be disabled. */
|
|
1010
1008
|
isKeyboardDismissDisabled?: boolean;
|
|
1011
1009
|
/**
|
|
@@ -1031,7 +1029,7 @@ export interface FullscreenDialogProps extends Omit<_DialogProps1, 'className' |
|
|
|
1031
1029
|
* Takeover dialogs are large types of dialogs. They use the totality of the screen and should be used for modal experiences with complex workflows.
|
|
1032
1030
|
*/
|
|
1033
1031
|
export let FullscreenDialog: ForwardRefExoticComponent<FullscreenDialogProps & RefAttributes<DOMRefValue<HTMLElement>>>;
|
|
1034
|
-
export interface DialogContainerProps extends Omit<SpectrumDialogContainerProps, 'type'> {
|
|
1032
|
+
export interface DialogContainerProps extends Omit<SpectrumDialogContainerProps, 'type' | 'isDismissable' | 'isKeyboardDismissDisabled'> {
|
|
1035
1033
|
}
|
|
1036
1034
|
/**
|
|
1037
1035
|
* A DialogContainer accepts a single Dialog as a child, and manages showing and hiding
|