@razorpay/blade 12.66.0 → 12.67.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/build/lib/native/components/Popover/Popover.native.js +1 -1
- package/build/lib/native/components/Popover/Popover.native.js.map +1 -1
- package/build/lib/native/components/Popover/PopoverContent.js +1 -1
- package/build/lib/native/components/Popover/PopoverContent.js.map +1 -1
- package/build/lib/native/components/Popover/PopoverContext.js.map +1 -1
- package/build/lib/web/development/components/Popover/Popover.web.js +13 -7
- package/build/lib/web/development/components/Popover/Popover.web.js.map +1 -1
- package/build/lib/web/development/components/Popover/PopoverContent.js +8 -3
- package/build/lib/web/development/components/Popover/PopoverContent.js.map +1 -1
- package/build/lib/web/development/components/Popover/PopoverContext.js.map +1 -1
- package/build/lib/web/development/components/SpotlightPopoverTour/TourPopover.web.js +2 -1
- package/build/lib/web/development/components/SpotlightPopoverTour/TourPopover.web.js.map +1 -1
- package/build/lib/web/development/components/Toast/ToastContainer.web.js +15 -5
- package/build/lib/web/development/components/Toast/ToastContainer.web.js.map +1 -1
- package/build/lib/web/development/components/Toast/constants.js +1 -1
- package/build/lib/web/development/components/Toast/constants.js.map +1 -1
- package/build/lib/web/production/components/Popover/Popover.web.js +13 -7
- package/build/lib/web/production/components/Popover/Popover.web.js.map +1 -1
- package/build/lib/web/production/components/Popover/PopoverContent.js +8 -3
- package/build/lib/web/production/components/Popover/PopoverContent.js.map +1 -1
- package/build/lib/web/production/components/Popover/PopoverContext.js.map +1 -1
- package/build/lib/web/production/components/SpotlightPopoverTour/TourPopover.web.js +2 -1
- package/build/lib/web/production/components/SpotlightPopoverTour/TourPopover.web.js.map +1 -1
- package/build/lib/web/production/components/Toast/ToastContainer.web.js +15 -5
- package/build/lib/web/production/components/Toast/ToastContainer.web.js.map +1 -1
- package/build/lib/web/production/components/Toast/constants.js +1 -1
- package/build/lib/web/production/components/Toast/constants.js.map +1 -1
- package/build/types/components/index.d.ts +15 -2
- package/build/types/components/index.native.d.ts +6 -0
- package/package.json +2 -2
|
@@ -19,7 +19,7 @@ import { PopupArrow } from '../PopupArrow/PopupArrow.native.js';
|
|
|
19
19
|
import { getFloatingPlacementParts } from '../../utils/getFloatingPlacementParts.js';
|
|
20
20
|
import { componentZIndices } from '../../utils/componentZIndices.js';
|
|
21
21
|
|
|
22
|
-
var Popover=function Popover(_ref){var content=_ref.content,children=_ref.children,_ref$placement=_ref.placement,placement=_ref$placement===void 0?'top':_ref$placement,onOpenChange=_ref.onOpenChange,_ref$zIndex=_ref.zIndex,zIndex=_ref$zIndex===void 0?componentZIndices.popover:_ref$zIndex,title=_ref.title,titleLeading=_ref.titleLeading,footer=_ref.footer,isOpen=_ref.isOpen,defaultIsOpen=_ref.defaultIsOpen;var _useTheme=useTheme(),theme=_useTheme.theme;var defaultInitialFocusRef=React__default.useRef(null);var _useControllableState=useControllableState({value:isOpen,defaultValue:defaultIsOpen,onChange:function onChange(isOpen){return onOpenChange==null?void 0:onOpenChange({isOpen:isOpen});}}),_useControllableState2=_slicedToArray(_useControllableState,2),controllableIsOpen=_useControllableState2[0],controllableSetIsOpen=_useControllableState2[1];var gap=theme.spacing[2];var _getFloatingPlacement=getFloatingPlacementParts(placement),_getFloatingPlacement2=_slicedToArray(_getFloatingPlacement,1),side=_getFloatingPlacement2[0];var isHorizontal=side==='left'||side==='right';var arrowRef=React__default.useRef();var context=useFloating({sameScrollView:false,placement:placement,middleware:[shift({crossAxis:false,padding:gap}),flip({padding:gap,fallbackAxisSideDirection:'start'}),offset(gap+ARROW_HEIGHT),arrow({element:arrowRef,padding:isHorizontal?0:ARROW_WIDTH})]});var refs=context.refs,floatingStyles=context.floatingStyles;var _getFloatingPlacement3=getFloatingPlacementParts(context.placement),_getFloatingPlacement4=_slicedToArray(_getFloatingPlacement3,1),computedSide=_getFloatingPlacement4[0];var handleOpen=React__default.useCallback(function(){controllableSetIsOpen(function(){return true;});onOpenChange==null?void 0:onOpenChange({isOpen:true});},[controllableSetIsOpen,onOpenChange]);var handleClose=React__default.useCallback(function(){controllableSetIsOpen(function(){return false;});onOpenChange==null?void 0:onOpenChange({isOpen:false});},[controllableSetIsOpen,onOpenChange]);var _React$useState=React__default.useState(function(){return controllableIsOpen;}),_React$useState2=_slicedToArray(_React$useState,2),isVisible=_React$useState2[0],setIsVisible=_React$useState2[1];React__default.useEffect(function(){var id=setTimeout(function(){if(!controllableIsOpen){setIsVisible(false);}},theme.motion.duration.gentle);if(controllableIsOpen){setIsVisible(true);}return function(){return clearTimeout(id);};},[controllableIsOpen]);var contextValue=React__default.useMemo(function(){return {close:handleClose,defaultInitialFocusRef:defaultInitialFocusRef,titleId:undefined};},[handleClose]);return jsxs(PopoverContext.Provider,{value:contextValue,children:[React__default.cloneElement(children,Object.assign({},mergeProps({onTouchEnd:children.props.onTouchEnd},{onTouchEnd:handleOpen}),{ref:refs.setReference})),jsxs(Modal,Object.assign({collapsable:false,transparent:true,visible:Boolean(isVisible)},metaAttribute({testID:'popover-modal'}),{children:[jsx(TouchableOpacity,Object.assign({style:{position:'absolute',top:0,bottom:0,left:0,right:0},onPress:handleClose,activeOpacity:1,testID:"popover-modal-backdrop"},metaAttribute({name:MetaConstants.Popover}))),jsx(PopoverContent,{titleLeading:titleLeading,title:title,footer:footer,isVisible:controllableIsOpen,ref:refs.setFloating,side:computedSide,style:Object.assign({},floatingStyles,{zIndex:zIndex}),arrow:jsx(PopupArrow,{ref:arrowRef,context:context,width:ARROW_WIDTH,height:ARROW_HEIGHT,fillColor:theme.colors.popup.background.subtle,strokeColor:theme.colors.popup.border.subtle}),children:content})]}))]});};
|
|
22
|
+
var Popover=function Popover(_ref){var content=_ref.content,children=_ref.children,_ref$placement=_ref.placement,placement=_ref$placement===void 0?'top':_ref$placement,onOpenChange=_ref.onOpenChange,_ref$zIndex=_ref.zIndex,zIndex=_ref$zIndex===void 0?componentZIndices.popover:_ref$zIndex,title=_ref.title,titleLeading=_ref.titleLeading,footer=_ref.footer,isOpen=_ref.isOpen,defaultIsOpen=_ref.defaultIsOpen;var _useTheme=useTheme(),theme=_useTheme.theme;var defaultInitialFocusRef=React__default.useRef(null);var _useControllableState=useControllableState({value:isOpen,defaultValue:defaultIsOpen,onChange:function onChange(isOpen){return onOpenChange==null?void 0:onOpenChange({isOpen:isOpen});}}),_useControllableState2=_slicedToArray(_useControllableState,2),controllableIsOpen=_useControllableState2[0],controllableSetIsOpen=_useControllableState2[1];var gap=theme.spacing[2];var _getFloatingPlacement=getFloatingPlacementParts(placement),_getFloatingPlacement2=_slicedToArray(_getFloatingPlacement,1),side=_getFloatingPlacement2[0];var isHorizontal=side==='left'||side==='right';var arrowRef=React__default.useRef();var context=useFloating({sameScrollView:false,placement:placement,middleware:[shift({crossAxis:false,padding:gap}),flip({padding:gap,fallbackAxisSideDirection:'start'}),offset(gap+ARROW_HEIGHT),arrow({element:arrowRef,padding:isHorizontal?0:ARROW_WIDTH})]});var refs=context.refs,floatingStyles=context.floatingStyles;var _getFloatingPlacement3=getFloatingPlacementParts(context.placement),_getFloatingPlacement4=_slicedToArray(_getFloatingPlacement3,1),computedSide=_getFloatingPlacement4[0];var handleOpen=React__default.useCallback(function(){controllableSetIsOpen(function(){return true;});onOpenChange==null?void 0:onOpenChange({isOpen:true});},[controllableSetIsOpen,onOpenChange]);var handleClose=React__default.useCallback(function(){controllableSetIsOpen(function(){return false;});onOpenChange==null?void 0:onOpenChange({isOpen:false});},[controllableSetIsOpen,onOpenChange]);var _React$useState=React__default.useState(function(){return controllableIsOpen;}),_React$useState2=_slicedToArray(_React$useState,2),isVisible=_React$useState2[0],setIsVisible=_React$useState2[1];React__default.useEffect(function(){var id=setTimeout(function(){if(!controllableIsOpen){setIsVisible(false);}},theme.motion.duration.gentle);if(controllableIsOpen){setIsVisible(true);}return function(){return clearTimeout(id);};},[controllableIsOpen]);var contextValue=React__default.useMemo(function(){return {close:handleClose,defaultInitialFocusRef:defaultInitialFocusRef,titleId:undefined,openInteraction:'click'};},[handleClose]);return jsxs(PopoverContext.Provider,{value:contextValue,children:[React__default.cloneElement(children,Object.assign({},mergeProps({onTouchEnd:children.props.onTouchEnd},{onTouchEnd:handleOpen}),{ref:refs.setReference})),jsxs(Modal,Object.assign({collapsable:false,transparent:true,visible:Boolean(isVisible)},metaAttribute({testID:'popover-modal'}),{children:[jsx(TouchableOpacity,Object.assign({style:{position:'absolute',top:0,bottom:0,left:0,right:0},onPress:handleClose,activeOpacity:1,testID:"popover-modal-backdrop"},metaAttribute({name:MetaConstants.Popover}))),jsx(PopoverContent,{titleLeading:titleLeading,title:title,footer:footer,isVisible:controllableIsOpen,ref:refs.setFloating,side:computedSide,style:Object.assign({},floatingStyles,{zIndex:zIndex}),arrow:jsx(PopupArrow,{ref:arrowRef,context:context,width:ARROW_WIDTH,height:ARROW_HEIGHT,fillColor:theme.colors.popup.background.subtle,strokeColor:theme.colors.popup.border.subtle}),children:content})]}))]});};
|
|
23
23
|
|
|
24
24
|
export { Popover };
|
|
25
25
|
//# sourceMappingURL=Popover.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.native.js","sources":["../../../../../src/components/Popover/Popover.native.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\nimport { arrow, shift, useFloating, flip, offset } from '@floating-ui/react-native';\nimport React from 'react';\nimport { Modal, TouchableOpacity } from 'react-native';\nimport { PopoverContent } from './PopoverContent';\nimport type { PopoverProps } from './types';\nimport { ARROW_HEIGHT, ARROW_WIDTH } from './constants';\nimport { PopoverContext } from './PopoverContext';\nimport { useTheme } from '~components/BladeProvider';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { mergeProps } from '~utils/mergeProps';\nimport { useControllableState } from '~utils/useControllable';\nimport { PopupArrow } from '~components/PopupArrow';\nimport { getFloatingPlacementParts } from '~utils/getFloatingPlacementParts';\nimport { componentZIndices } from '~utils/componentZIndices';\n\nconst Popover = ({\n content,\n children,\n placement = 'top',\n onOpenChange,\n zIndex = componentZIndices.popover,\n title,\n titleLeading,\n footer,\n isOpen,\n defaultIsOpen,\n}: PopoverProps): React.ReactElement => {\n const { theme } = useTheme();\n const defaultInitialFocusRef = React.useRef(null);\n const [controllableIsOpen, controllableSetIsOpen] = useControllableState({\n value: isOpen,\n defaultValue: defaultIsOpen,\n onChange: (isOpen) => onOpenChange?.({ isOpen }),\n });\n\n const gap = theme.spacing[2];\n const [side] = getFloatingPlacementParts(placement);\n const isHorizontal = side === 'left' || side === 'right';\n const arrowRef = React.useRef();\n const context = useFloating({\n sameScrollView: false,\n placement,\n middleware: [\n shift({ crossAxis: false, padding: gap }),\n flip({ padding: gap, fallbackAxisSideDirection: 'start' }),\n offset(gap + ARROW_HEIGHT),\n arrow({\n element: arrowRef,\n padding: isHorizontal ? 0 : ARROW_WIDTH,\n }),\n ],\n });\n\n const { refs, floatingStyles } = context;\n const [computedSide] = getFloatingPlacementParts(context.placement);\n\n const handleOpen = React.useCallback(() => {\n controllableSetIsOpen(() => true);\n onOpenChange?.({ isOpen: true });\n }, [controllableSetIsOpen, onOpenChange]);\n\n const handleClose = React.useCallback(() => {\n controllableSetIsOpen(() => false);\n onOpenChange?.({ isOpen: false });\n }, [controllableSetIsOpen, onOpenChange]);\n\n // wait for animation to finish before unmounting modal\n const [isVisible, setIsVisible] = React.useState(() => controllableIsOpen);\n React.useEffect(() => {\n const id = setTimeout(() => {\n if (!controllableIsOpen) {\n setIsVisible(false);\n }\n }, theme.motion.duration.gentle);\n\n if (controllableIsOpen) {\n setIsVisible(true);\n }\n return () => clearTimeout(id);\n }, [controllableIsOpen]);\n\n const contextValue = React.useMemo(() => {\n return {\n close: handleClose,\n defaultInitialFocusRef,\n titleId: undefined,\n };\n }, [handleClose]);\n\n return (\n <PopoverContext.Provider value={contextValue}>\n {/* Cloning the trigger children to enhance it with ref and event handler */}\n {React.cloneElement(children, {\n ...mergeProps(\n {\n onTouchEnd: children.props.onTouchEnd,\n },\n { onTouchEnd: handleOpen },\n ),\n ref: refs.setReference,\n })}\n <Modal\n collapsable={false}\n transparent\n visible={Boolean(isVisible)}\n {...metaAttribute({ testID: 'popover-modal' })}\n >\n <TouchableOpacity\n style={{\n position: 'absolute',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n }}\n onPress={handleClose}\n activeOpacity={1}\n testID=\"popover-modal-backdrop\"\n {...metaAttribute({ name: MetaConstants.Popover })}\n />\n <PopoverContent\n titleLeading={titleLeading}\n title={title}\n footer={footer}\n isVisible={controllableIsOpen}\n ref={refs.setFloating}\n side={computedSide}\n style={{\n ...floatingStyles,\n // TODO: Tokenize zIndex values\n zIndex,\n }}\n arrow={\n <PopupArrow\n ref={arrowRef as never}\n context={context}\n width={ARROW_WIDTH}\n height={ARROW_HEIGHT}\n fillColor={theme.colors.popup.background.subtle}\n strokeColor={theme.colors.popup.border.subtle}\n />\n }\n >\n {content}\n </PopoverContent>\n </Modal>\n </PopoverContext.Provider>\n );\n};\n\nexport { Popover };\n"],"names":["Popover","_ref","content","children","_ref$placement","placement","onOpenChange","_ref$zIndex","zIndex","componentZIndices","popover","title","titleLeading","footer","isOpen","defaultIsOpen","_useTheme","useTheme","theme","defaultInitialFocusRef","React","useRef","_useControllableState","useControllableState","value","defaultValue","onChange","_useControllableState2","_slicedToArray","controllableIsOpen","controllableSetIsOpen","gap","spacing","_getFloatingPlacement","getFloatingPlacementParts","_getFloatingPlacement2","side","isHorizontal","arrowRef","context","useFloating","sameScrollView","middleware","shift","crossAxis","padding","flip","fallbackAxisSideDirection","offset","ARROW_HEIGHT","arrow","element","ARROW_WIDTH","refs","floatingStyles","_getFloatingPlacement3","_getFloatingPlacement4","computedSide","handleOpen","useCallback","handleClose","_React$useState","useState","_React$useState2","isVisible","setIsVisible","useEffect","id","setTimeout","motion","duration","gentle","clearTimeout","contextValue","useMemo","close","titleId","undefined","_jsxs","PopoverContext","Provider","cloneElement","Object","assign","mergeProps","onTouchEnd","props","ref","setReference","Modal","collapsable","transparent","visible","Boolean","metaAttribute","testID","_jsx","TouchableOpacity","style","position","top","bottom","left","right","onPress","activeOpacity","name","MetaConstants","PopoverContent","setFloating","PopupArrow","width","height","fillColor","colors","popup","background","subtle","strokeColor","border"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBM,IAAAA,OAAO,CAAG,SAAVA,OAAOA,CAAAC,IAAA,CAW2B,KAVtCC,OAAO,CAAAD,IAAA,CAAPC,OAAO,CACPC,QAAQ,CAAAF,IAAA,CAARE,QAAQ,CAAAC,cAAA,CAAAH,IAAA,CACRI,SAAS,CAATA,SAAS,CAAAD,cAAA,UAAG,KAAK,CAAAA,cAAA,CACjBE,YAAY,CAAAL,IAAA,CAAZK,YAAY,CAAAC,WAAA,CAAAN,IAAA,CACZO,MAAM,CAANA,MAAM,CAAAD,WAAA,GAAA,KAAA,CAAA,CAAGE,iBAAiB,CAACC,OAAO,CAAAH,WAAA,CAClCI,KAAK,CAAAV,IAAA,CAALU,KAAK,CACLC,YAAY,CAAAX,IAAA,CAAZW,YAAY,CACZC,MAAM,CAAAZ,IAAA,CAANY,MAAM,CACNC,MAAM,CAAAb,IAAA,CAANa,MAAM,CACNC,aAAa,CAAAd,IAAA,CAAbc,aAAa,CAEb,IAAAC,SAAA,CAAkBC,QAAQ,EAAE,CAApBC,KAAK,CAAAF,SAAA,CAALE,KAAK,CACb,IAAMC,sBAAsB,CAAGC,cAAK,CAACC,MAAM,CAAC,IAAI,CAAC,CACjD,IAAAC,qBAAA,CAAoDC,oBAAoB,CAAC,CACvEC,KAAK,CAAEV,MAAM,CACbW,YAAY,CAAEV,aAAa,CAC3BW,QAAQ,CAAE,SAAAA,QAAAA,CAACZ,MAAM,CAAA,CAAA,OAAKR,YAAY,cAAZA,YAAY,CAAG,CAAEQ,MAAM,CAANA,MAAO,CAAC,CAAC,EAClD,CAAC,CAAC,CAAAa,sBAAA,CAAAC,cAAA,CAAAN,qBAAA,IAJKO,kBAAkB,CAAAF,sBAAA,CAAA,CAAA,CAAA,CAAEG,qBAAqB,CAAAH,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CACA7B,EAAAA,CAAAA,cAAc,CAEjB9C,CAAAA,MAAM,CAANA,MAAM,EACN,CACF0C,KAAK,CACH8C,GAAA,CAACc,UAAU,CACTvB,CAAAA,GAAG,CAAEjD,QAAkB,CACvBC,OAAO,CAAEA,OAAQ,CACjBwE,KAAK,CAAE3D,WAAY,CACnB4D,MAAM,CAAE/D,YAAa,CACrBgE,SAAS,CAAE/F,KAAK,CAACgG,MAAM,CAACC,KAAK,CAACC,UAAU,CAACC,MAAO,CAChDC,WAAW,CAAEpG,KAAK,CAACgG,MAAM,CAACC,KAAK,CAACI,MAAM,CAACF,MAAO,CAC/C,CACF,CAAAlH,QAAA,CAEAD,OAAO,CACM,CAAC,GACZ,CAAC,CAAA,CACe,CAAC,CAE9B;;;;"}
|
|
1
|
+
{"version":3,"file":"Popover.native.js","sources":["../../../../../src/components/Popover/Popover.native.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\nimport { arrow, shift, useFloating, flip, offset } from '@floating-ui/react-native';\nimport React from 'react';\nimport { Modal, TouchableOpacity } from 'react-native';\nimport { PopoverContent } from './PopoverContent';\nimport type { PopoverProps } from './types';\nimport { ARROW_HEIGHT, ARROW_WIDTH } from './constants';\nimport { PopoverContext } from './PopoverContext';\nimport { useTheme } from '~components/BladeProvider';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { mergeProps } from '~utils/mergeProps';\nimport { useControllableState } from '~utils/useControllable';\nimport { PopupArrow } from '~components/PopupArrow';\nimport { getFloatingPlacementParts } from '~utils/getFloatingPlacementParts';\nimport { componentZIndices } from '~utils/componentZIndices';\n\nconst Popover = ({\n content,\n children,\n placement = 'top',\n onOpenChange,\n zIndex = componentZIndices.popover,\n title,\n titleLeading,\n footer,\n isOpen,\n defaultIsOpen,\n}: PopoverProps): React.ReactElement => {\n const { theme } = useTheme();\n const defaultInitialFocusRef = React.useRef(null);\n const [controllableIsOpen, controllableSetIsOpen] = useControllableState({\n value: isOpen,\n defaultValue: defaultIsOpen,\n onChange: (isOpen) => onOpenChange?.({ isOpen }),\n });\n\n const gap = theme.spacing[2];\n const [side] = getFloatingPlacementParts(placement);\n const isHorizontal = side === 'left' || side === 'right';\n const arrowRef = React.useRef();\n const context = useFloating({\n sameScrollView: false,\n placement,\n middleware: [\n shift({ crossAxis: false, padding: gap }),\n flip({ padding: gap, fallbackAxisSideDirection: 'start' }),\n offset(gap + ARROW_HEIGHT),\n arrow({\n element: arrowRef,\n padding: isHorizontal ? 0 : ARROW_WIDTH,\n }),\n ],\n });\n\n const { refs, floatingStyles } = context;\n const [computedSide] = getFloatingPlacementParts(context.placement);\n\n const handleOpen = React.useCallback(() => {\n controllableSetIsOpen(() => true);\n onOpenChange?.({ isOpen: true });\n }, [controllableSetIsOpen, onOpenChange]);\n\n const handleClose = React.useCallback(() => {\n controllableSetIsOpen(() => false);\n onOpenChange?.({ isOpen: false });\n }, [controllableSetIsOpen, onOpenChange]);\n\n // wait for animation to finish before unmounting modal\n const [isVisible, setIsVisible] = React.useState(() => controllableIsOpen);\n React.useEffect(() => {\n const id = setTimeout(() => {\n if (!controllableIsOpen) {\n setIsVisible(false);\n }\n }, theme.motion.duration.gentle);\n\n if (controllableIsOpen) {\n setIsVisible(true);\n }\n return () => clearTimeout(id);\n }, [controllableIsOpen]);\n\n const contextValue = React.useMemo(() => {\n return {\n close: handleClose,\n defaultInitialFocusRef,\n titleId: undefined,\n openInteraction: 'click' as const,\n };\n }, [handleClose]);\n\n return (\n <PopoverContext.Provider value={contextValue}>\n {/* Cloning the trigger children to enhance it with ref and event handler */}\n {React.cloneElement(children, {\n ...mergeProps(\n {\n onTouchEnd: children.props.onTouchEnd,\n },\n { onTouchEnd: handleOpen },\n ),\n ref: refs.setReference,\n })}\n <Modal\n collapsable={false}\n transparent\n visible={Boolean(isVisible)}\n {...metaAttribute({ testID: 'popover-modal' })}\n >\n <TouchableOpacity\n style={{\n position: 'absolute',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n }}\n onPress={handleClose}\n activeOpacity={1}\n testID=\"popover-modal-backdrop\"\n {...metaAttribute({ name: MetaConstants.Popover })}\n />\n <PopoverContent\n titleLeading={titleLeading}\n title={title}\n footer={footer}\n isVisible={controllableIsOpen}\n ref={refs.setFloating}\n side={computedSide}\n style={{\n ...floatingStyles,\n // TODO: Tokenize zIndex values\n zIndex,\n }}\n arrow={\n <PopupArrow\n ref={arrowRef as never}\n context={context}\n width={ARROW_WIDTH}\n height={ARROW_HEIGHT}\n fillColor={theme.colors.popup.background.subtle}\n strokeColor={theme.colors.popup.border.subtle}\n />\n }\n >\n {content}\n </PopoverContent>\n </Modal>\n </PopoverContext.Provider>\n );\n};\n\nexport { Popover };\n"],"names":["Popover","_ref","content","children","_ref$placement","placement","onOpenChange","_ref$zIndex","zIndex","componentZIndices","popover","title","titleLeading","footer","isOpen","defaultIsOpen","_useTheme","useTheme","theme","defaultInitialFocusRef","React","useRef","_useControllableState","useControllableState","value","defaultValue","onChange","_useControllableState2","_slicedToArray","controllableIsOpen","controllableSetIsOpen","gap","spacing","_getFloatingPlacement","getFloatingPlacementParts","_getFloatingPlacement2","side","isHorizontal","arrowRef","context","useFloating","sameScrollView","middleware","shift","crossAxis","padding","flip","fallbackAxisSideDirection","offset","ARROW_HEIGHT","arrow","element","ARROW_WIDTH","refs","floatingStyles","_getFloatingPlacement3","_getFloatingPlacement4","computedSide","handleOpen","useCallback","handleClose","_React$useState","useState","_React$useState2","isVisible","setIsVisible","useEffect","id","setTimeout","motion","duration","gentle","clearTimeout","contextValue","useMemo","close","titleId","undefined","openInteraction","_jsxs","PopoverContext","Provider","cloneElement","Object","assign","mergeProps","onTouchEnd","props","ref","setReference","Modal","collapsable","transparent","visible","Boolean","metaAttribute","testID","_jsx","TouchableOpacity","style","position","top","bottom","left","right","onPress","activeOpacity","name","MetaConstants","PopoverContent","setFloating","PopupArrow","width","height","fillColor","colors","popup","background","subtle","strokeColor","border"],"mappings":";;;;;;;;;;;;;;;;;;;;;A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AC,MAAA,CACA9B,EAAAA,CAAAA,cAAc,CAEjB9C,CAAAA,MAAM,CAANA,MAAM,EACN,CACF0C,KAAK,CACH+C,GAAA,CAACc,UAAU,CACTvB,CAAAA,GAAG,CAAElD,QAAkB,CACvBC,OAAO,CAAEA,OAAQ,CACjByE,KAAK,CAAE5D,WAAY,CACnB6D,MAAM,CAAEhE,YAAa,CACrBiE,SAAS,CAAEhG,KAAK,CAACiG,MAAM,CAACC,KAAK,CAACC,UAAU,CAACC,MAAO,CAChDC,WAAW,CAAErG,KAAK,CAACiG,MAAM,CAACC,KAAK,CAACI,MAAM,CAACF,MAAO,CAC/C,CACF,CAAAnH,QAAA,CAEAD,OAAO,CACM,CAAC,GACZ,CAAC,CAAA,CACe,CAAC,CAE9B;;;;"}
|
|
@@ -14,7 +14,7 @@ import '../BladeProvider/useTheme.js';
|
|
|
14
14
|
import { useIsMobile } from '../../utils/useIsMobile.js';
|
|
15
15
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
16
16
|
|
|
17
|
-
var PopoverHeader=function PopoverHeader(_ref){var title=_ref.title,titleLeading=_ref.titleLeading;var _usePopoverContext=usePopoverContext(),titleId=_usePopoverContext.titleId;var isFloating=!(title||titleLeading);if(isFloating){return jsx(BaseBox,{borderRadius:"max",position:"absolute",padding:"spacing.2",top:"spacing.2",right:"spacing.2",zIndex:1,children:jsx(PopoverCloseButton,{})});}return jsxs(BaseBox,{display:"flex",flexDirection:"row",flexWrap:isReactNative()?'wrap':'nowrap',alignItems:"center",gap:"spacing.3",children:[titleLeading?React__default.cloneElement(titleLeading,{size:'large'}):null,title?jsx(BaseBox,{id:titleId,paddingRight:"spacing.4",children:jsx(Text,{size:"large",weight:"semibold",children:title})}):null,jsx(BaseBox,{marginLeft:"auto",children:jsx(PopoverCloseButton,{})})]});};var PopoverContent=React__default.forwardRef(function(_ref2,ref){var children=_ref2.children,title=_ref2.title,titleLeading=_ref2.titleLeading,footer=_ref2.footer,arrow=_ref2.arrow,side=_ref2.side,style=_ref2.style,isVisible=_ref2.isVisible;var isMobile=useIsMobile();return jsxs(PopoverContentWrapper,{ref:ref,styles:style,side:side,isVisible:isVisible,isMobile:isMobile,children:[jsxs(BaseBox,{padding:"spacing.4",display:"flex",flexDirection:"column",gap:"spacing.4",children:[jsx(PopoverHeader,{title:title,titleLeading:titleLeading}),jsx(BaseBox,{children:children}),footer?jsx(BaseBox,{children:footer}):null]}),arrow]});});
|
|
17
|
+
var PopoverHeader=function PopoverHeader(_ref){var title=_ref.title,titleLeading=_ref.titleLeading;var _usePopoverContext=usePopoverContext(),titleId=_usePopoverContext.titleId,openInteraction=_usePopoverContext.openInteraction;var showCloseButton=openInteraction==='click';var isFloating=!(title||titleLeading);if(isFloating){if(!showCloseButton){return null;}return jsx(BaseBox,{borderRadius:"max",position:"absolute",padding:"spacing.2",top:"spacing.2",right:"spacing.2",zIndex:1,children:jsx(PopoverCloseButton,{})});}return jsxs(BaseBox,{display:"flex",flexDirection:"row",flexWrap:isReactNative()?'wrap':'nowrap',alignItems:"center",gap:"spacing.3",children:[titleLeading?React__default.cloneElement(titleLeading,{size:'large'}):null,title?jsx(BaseBox,{id:titleId,paddingRight:"spacing.4",children:jsx(Text,{size:"large",weight:"semibold",children:title})}):null,showCloseButton?jsx(BaseBox,{marginLeft:"auto",children:jsx(PopoverCloseButton,{})}):null]});};var PopoverContent=React__default.forwardRef(function(_ref2,ref){var children=_ref2.children,title=_ref2.title,titleLeading=_ref2.titleLeading,footer=_ref2.footer,arrow=_ref2.arrow,side=_ref2.side,style=_ref2.style,isVisible=_ref2.isVisible;var isMobile=useIsMobile();return jsxs(PopoverContentWrapper,{ref:ref,styles:style,side:side,isVisible:isVisible,isMobile:isMobile,children:[jsxs(BaseBox,{padding:"spacing.4",display:"flex",flexDirection:"column",gap:"spacing.4",children:[jsx(PopoverHeader,{title:title,titleLeading:titleLeading}),jsx(BaseBox,{children:children}),footer?jsx(BaseBox,{children:footer}):null]}),arrow]});});
|
|
18
18
|
|
|
19
19
|
export { PopoverContent };
|
|
20
20
|
//# sourceMappingURL=PopoverContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverContent.js","sources":["../../../../../src/components/Popover/PopoverContent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */\nimport React from 'react';\nimport { PopoverContentWrapper } from './PopoverContentWrapper';\nimport type { PopoverContentProps } from './types';\nimport { PopoverCloseButton } from './PopoverCloseButton';\nimport { usePopoverContext } from './PopoverContext';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Text } from '~components/Typography';\nimport { isReactNative } from '~utils';\nimport { useIsMobile } from '~utils/useIsMobile';\n\ntype PopoverHeaderProps = {\n title?: string;\n titleLeading?: React.ReactNode;\n};\n\nconst PopoverHeader = ({ title, titleLeading }: PopoverHeaderProps): React.ReactElement => {\n const { titleId } = usePopoverContext();\n\n const isFloating = !(title || titleLeading);\n if (isFloating) {\n return (\n <BaseBox\n borderRadius=\"max\"\n position=\"absolute\"\n padding=\"spacing.2\"\n top=\"spacing.2\"\n right=\"spacing.2\"\n zIndex={1}\n >\n <PopoverCloseButton />\n </BaseBox>\n );\n }\n\n return (\n <BaseBox\n display=\"flex\"\n flexDirection=\"row\"\n flexWrap={isReactNative() ? 'wrap' : 'nowrap'}\n alignItems=\"center\"\n gap=\"spacing.3\"\n >\n {titleLeading\n ? React.cloneElement(titleLeading as React.ReactElement, { size: 'large' })\n : null}\n {title ? (\n <BaseBox id={titleId} paddingRight=\"spacing.4\">\n <Text size=\"large\" weight=\"semibold\">\n {title}\n </Text>\n </BaseBox>\n ) : null}\n <BaseBox marginLeft=\"auto\">\n
|
|
1
|
+
{"version":3,"file":"PopoverContent.js","sources":["../../../../../src/components/Popover/PopoverContent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */\nimport React from 'react';\nimport { PopoverContentWrapper } from './PopoverContentWrapper';\nimport type { PopoverContentProps } from './types';\nimport { PopoverCloseButton } from './PopoverCloseButton';\nimport { usePopoverContext } from './PopoverContext';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Text } from '~components/Typography';\nimport { isReactNative } from '~utils';\nimport { useIsMobile } from '~utils/useIsMobile';\n\ntype PopoverHeaderProps = {\n title?: string;\n titleLeading?: React.ReactNode;\n};\n\nconst PopoverHeader = ({ title, titleLeading }: PopoverHeaderProps): React.ReactElement | null => {\n const { titleId, openInteraction } = usePopoverContext();\n\n const showCloseButton = openInteraction === 'click';\n const isFloating = !(title || titleLeading);\n\n if (isFloating) {\n if (!showCloseButton) {\n return null;\n }\n return (\n <BaseBox\n borderRadius=\"max\"\n position=\"absolute\"\n padding=\"spacing.2\"\n top=\"spacing.2\"\n right=\"spacing.2\"\n zIndex={1}\n >\n <PopoverCloseButton />\n </BaseBox>\n );\n }\n\n return (\n <BaseBox\n display=\"flex\"\n flexDirection=\"row\"\n flexWrap={isReactNative() ? 'wrap' : 'nowrap'}\n alignItems=\"center\"\n gap=\"spacing.3\"\n >\n {titleLeading\n ? React.cloneElement(titleLeading as React.ReactElement, { size: 'large' })\n : null}\n {title ? (\n <BaseBox id={titleId} paddingRight=\"spacing.4\">\n <Text size=\"large\" weight=\"semibold\">\n {title}\n </Text>\n </BaseBox>\n ) : null}\n {showCloseButton ? (\n <BaseBox marginLeft=\"auto\">\n <PopoverCloseButton />\n </BaseBox>\n ) : null}\n </BaseBox>\n );\n};\n\nconst PopoverContent = React.forwardRef<HTMLDivElement, PopoverContentProps>(\n ({ children, title, titleLeading, footer, arrow, side, style, isVisible }, ref) => {\n const isMobile = useIsMobile();\n return (\n <PopoverContentWrapper\n ref={ref as never}\n styles={style}\n side={side}\n isVisible={isVisible}\n isMobile={isMobile}\n >\n <BaseBox padding=\"spacing.4\" display=\"flex\" flexDirection=\"column\" gap=\"spacing.4\">\n <PopoverHeader title={title} titleLeading={titleLeading} />\n <BaseBox>{children}</BaseBox>\n {footer ? <BaseBox>{footer}</BaseBox> : null}\n </BaseBox>\n {arrow}\n </PopoverContentWrapper>\n );\n },\n);\n\nexport { PopoverContent };\n"],"names":["PopoverHeader","_ref","title","titleLeading","_usePopoverContext","usePopoverContext","titleId","openInteraction","showCloseButton","isFloating","_jsx","BaseBox","borderRadius","position","padding","top","right","zIndex","children","PopoverCloseButton","_jsxs","display","flexDirection","flexWrap","isReactNative","alignItems","gap","React","cloneElement","size","id","paddingRight","Text","weight","marginLeft","PopoverContent","forwardRef","_ref2","ref","footer","arrow","side","style","isVisible","isMobile","useIsMobile","PopoverContentWrapper","styles"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAMA,aAAa,CAAG,SAAhBA,aAAaA,CAAAC,IAAA,CAA+E,CAAzE,IAAAC,KAAK,CAAAD,IAAA,CAALC,KAAK,CAAEC,YAAY,CAAAF,IAAA,CAAZE,YAAY,CAC1C,IAAAC,kBAAA,CAAqCC,iBAAiB,EAAE,CAAhDC,OAAO,CAAAF,kBAAA,CAAPE,OAAO,CAAEC,eAAe,CAAAH,kBAAA,CAAfG,eAAe,CAEhC,IAAMC,eAAe,CAAGD,eAAe,GAAK,OAAO,CACnD,IAAME,UAAU,CAAG,EAAEP,KAAK,EAAIC,YAAY,CAAC,CAE3C,GAAIM,UAAU,CAAE,CACd,GAAI,CAACD,eAAe,CAAE,CACpB,WAAW,CACb,CACA,OACEE,GAAA,CAACC,OAAO,CAAA,CACNC,YAAY,CAAC,KAAK,CAClBC,QAAQ,CAAC,UAAU,CACnBC,OAAO,CAAC,WAAW,CACnBC,GAAG,CAAC,WAAW,CACfC,KAAK,CAAC,WAAW,CACjBC,MAAM,CAAE,CAAE,CAAAC,QAAA,CAEVR,GAAA,CAACS,kBAAkB,CAAA,EAAE,CAAC,CACf,CAAC,CAEd,CAEA,OACEC,IAAA,CAACT,OAAO,CACNU,CAAAA,OAAO,CAAC,MAAM,CACdC,aAAa,CAAC,KAAK,CACnBC,QAAQ,CAAEC,aAAa,EAAE,CAAG,MAAM,CAAG,QAAS,CAC9CC,UA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S,CAAA1B,QAAA,CAEnBE,CAAAA,IAAA,CAACT,OAAO,EAACG,OAAO,CAAC,WAAW,CAACO,OAAO,CAAC,MAAM,CAACC,aAAa,CAAC,QAAQ,CAACI,GAAG,CAAC,WAAW,CAAAR,QAAA,CAChFR,CAAAA,GAAA,CAACV,aAAa,CAAA,CAACE,KAAK,CAAEA,KAAM,CAACC,YAAY,CAAEA,YAAa,CAAE,CAAC,CAC3DO,GAAA,CAACC,OAAO,CAAA,CAAAO,QAAA,CAAEA,QAAQ,CAAU,CAAC,CAC5BqB,MAAM,CAAG7B,GAAA,CAACC,OAAO,EAAAO,QAAA,CAAEqB,MAAM,CAAU,CAAC,CAAG,IAAI,CACrC,CAAA,CAAC,CACTC,KAAK,CACe,CAAA,CAAC,CAE5B,CACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverContext.js","sources":["../../../../../src/components/Popover/PopoverContext.ts"],"sourcesContent":["import React from 'react';\nimport { throwBladeError } from '~utils/logger';\n\ntype PopoverContextProps = {\n close: () => void;\n defaultInitialFocusRef: React.RefObject<HTMLElement>;\n titleId?: string;\n} | null;\nconst PopoverContext = React.createContext<PopoverContextProps>(null);\n\nconst usePopoverContext = (): NonNullable<PopoverContextProps> => {\n const context = React.useContext(PopoverContext);\n\n if (__DEV__) {\n if (!context) {\n throwBladeError({\n message: `usePopoverContext must be used within Popover`,\n moduleName: 'Popover',\n });\n }\n }\n\n return context!;\n};\n\nexport { PopoverContext, usePopoverContext };\n"],"names":["PopoverContext","React","createContext","usePopoverContext","context","useContext","__DEV__","throwBladeError","message","moduleName"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PopoverContext.js","sources":["../../../../../src/components/Popover/PopoverContext.ts"],"sourcesContent":["import React from 'react';\nimport { throwBladeError } from '~utils/logger';\n\ntype PopoverContextProps = {\n close: () => void;\n defaultInitialFocusRef: React.RefObject<HTMLElement>;\n titleId?: string;\n openInteraction?: 'hover' | 'click';\n} | null;\nconst PopoverContext = React.createContext<PopoverContextProps>(null);\n\nconst usePopoverContext = (): NonNullable<PopoverContextProps> => {\n const context = React.useContext(PopoverContext);\n\n if (__DEV__) {\n if (!context) {\n throwBladeError({\n message: `usePopoverContext must be used within Popover`,\n moduleName: 'Popover',\n });\n }\n }\n\n return context!;\n};\n\nexport { PopoverContext, usePopoverContext };\n"],"names":["PopoverContext","React","createContext","usePopoverContext","context","useContext","__DEV__","throwBladeError","message","moduleName"],"mappings":";;;AASM,IAAAA,cAAc,CAAGC,cAAK,CAACC,aAAa,CAAsB,IAAI,EAE9D,IAAAC,iBAAiB,CAAG,SAApBA,iBAAiBA,EAA2C,CAChE,IAAMC,OAAO,CAAGH,cAAK,CAACI,UAAU,CAACL,cAAc,CAAC,CAEhD,GAAIM,OAAO,CAAE,CACX,GAAI,CAACF,OAAO,CAAE,CACZG,eAAe,CAAC,CACdC,OAAO,CAAE,CAAA,6CAAA,CAA+C,CACxDC,UAAU,CAAE,SACd,CAAC,CAAC,CACJ,CACF,CAEA,OAAOL,OAAO,CAChB;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
|
-
import { useFloating, shift, flip, offset, arrow, autoUpdate, useTransitionStyles, useClick, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
|
|
4
|
+
import { useFloating, shift, flip, offset, arrow, autoUpdate, useTransitionStyles, useClick, useHover, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
|
|
5
5
|
import React__default from 'react';
|
|
6
6
|
import { PopoverContent } from './PopoverContent.js';
|
|
7
7
|
import { ARROW_HEIGHT, ARROW_WIDTH } from './constants.js';
|
|
@@ -29,7 +29,7 @@ import { makeAccessible } from '../../utils/makeAccessible/makeAccessible.web.js
|
|
|
29
29
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
30
30
|
import { PopupArrow } from '../PopupArrow/PopupArrow.web.js';
|
|
31
31
|
|
|
32
|
-
var _excluded = ["content", "title", "titleLeading", "footer", "children", "placement", "onOpenChange", "zIndex", "isOpen", "defaultIsOpen", "initialFocusRef"];
|
|
32
|
+
var _excluded = ["content", "title", "titleLeading", "footer", "children", "placement", "onOpenChange", "zIndex", "isOpen", "defaultIsOpen", "initialFocusRef", "openInteraction"];
|
|
33
33
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
34
34
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
35
35
|
var Popover = function Popover(_ref) {
|
|
@@ -46,6 +46,8 @@ var Popover = function Popover(_ref) {
|
|
|
46
46
|
isOpen = _ref.isOpen,
|
|
47
47
|
defaultIsOpen = _ref.defaultIsOpen,
|
|
48
48
|
initialFocusRef = _ref.initialFocusRef,
|
|
49
|
+
_ref$openInteraction = _ref.openInteraction,
|
|
50
|
+
openInteraction = _ref$openInteraction === void 0 ? 'click' : _ref$openInteraction,
|
|
49
51
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
50
52
|
var _useTheme = useTheme(),
|
|
51
53
|
theme = _useTheme.theme;
|
|
@@ -121,11 +123,14 @@ var Popover = function Popover(_ref) {
|
|
|
121
123
|
// remove click handler if popover is controlled
|
|
122
124
|
var isControlled = isOpen !== undefined;
|
|
123
125
|
var click = useClick(context, {
|
|
124
|
-
enabled: !isControlled
|
|
126
|
+
enabled: !isControlled && openInteraction === 'click'
|
|
127
|
+
});
|
|
128
|
+
var hover = useHover(context, {
|
|
129
|
+
enabled: !isControlled && openInteraction === 'hover'
|
|
125
130
|
});
|
|
126
131
|
var dismiss = useDismiss(context);
|
|
127
132
|
var role = useRole(context);
|
|
128
|
-
var _useInteractions = useInteractions([click, dismiss, role]),
|
|
133
|
+
var _useInteractions = useInteractions([click, dismiss, role, hover]),
|
|
129
134
|
getReferenceProps = _useInteractions.getReferenceProps,
|
|
130
135
|
getFloatingProps = _useInteractions.getFloatingProps;
|
|
131
136
|
var triggerRef = React__default.useRef(null);
|
|
@@ -134,9 +139,10 @@ var Popover = function Popover(_ref) {
|
|
|
134
139
|
return {
|
|
135
140
|
close: close,
|
|
136
141
|
defaultInitialFocusRef: defaultInitialFocusRef,
|
|
137
|
-
titleId: titleId
|
|
142
|
+
titleId: titleId,
|
|
143
|
+
openInteraction: openInteraction
|
|
138
144
|
};
|
|
139
|
-
}, [close, titleId]);
|
|
145
|
+
}, [close, titleId, openInteraction]);
|
|
140
146
|
|
|
141
147
|
// Inject aria attributes to trigger
|
|
142
148
|
// Doing it this way instead of makeAccessible()
|
|
@@ -158,7 +164,7 @@ var Popover = function Popover(_ref) {
|
|
|
158
164
|
ref: mergedRef
|
|
159
165
|
}, mergeProps(children.props, getReferenceProps()))), isMounted && /*#__PURE__*/jsx(FloatingPortal, {
|
|
160
166
|
children: /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
161
|
-
initialFocus: initialFocusRef !== null && initialFocusRef !== void 0 ? initialFocusRef : defaultInitialFocusRef,
|
|
167
|
+
initialFocus: initialFocusRef !== null && initialFocusRef !== void 0 ? initialFocusRef : openInteraction === 'hover' ? -1 : defaultInitialFocusRef,
|
|
162
168
|
context: context,
|
|
163
169
|
modal: true,
|
|
164
170
|
guards: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.web.js","sources":["../../../../../../src/components/Popover/Popover.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\nimport {\n shift,\n FloatingPortal,\n arrow,\n flip,\n offset,\n useFloating,\n useInteractions,\n useRole,\n useTransitionStyles,\n autoUpdate,\n useClick,\n useDismiss,\n FloatingFocusManager,\n} from '@floating-ui/react';\nimport React from 'react';\nimport type { PopoverProps } from './types';\nimport { PopoverContent } from './PopoverContent';\nimport { ARROW_HEIGHT, ARROW_WIDTH } from './constants';\nimport { PopoverContext } from './PopoverContext';\nimport { useTheme } from '~components/BladeProvider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { size } from '~tokens/global';\nimport { useControllableState } from '~utils/useControllable';\nimport { mergeProps } from '~utils/mergeProps';\nimport { PopupArrow } from '~components/PopupArrow';\nimport { useMergeRefs } from '~utils/useMergeRefs';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { useId } from '~utils/useId';\nimport { getFloatingPlacementParts } from '~utils/getFloatingPlacementParts';\nimport { componentZIndices } from '~utils/componentZIndices';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\nconst Popover = ({\n content,\n title,\n titleLeading,\n footer,\n children,\n placement = 'top',\n onOpenChange,\n zIndex = componentZIndices.popover,\n isOpen,\n defaultIsOpen,\n initialFocusRef,\n ...rest\n}: PopoverProps): React.ReactElement => {\n const { theme } = useTheme();\n const defaultInitialFocusRef = React.useRef<HTMLButtonElement>(null);\n const arrowRef = React.useRef<SVGSVGElement>(null);\n const titleId = useId('popover-title');\n\n const GAP = theme.spacing[2];\n const [side] = getFloatingPlacementParts(placement);\n const isHorizontal = side === 'left' || side === 'right';\n const isOppositeAxis = side === 'right' || side === 'bottom';\n\n const [controllableIsOpen, controllableSetIsOpen] = useControllableState({\n value: isOpen,\n defaultValue: defaultIsOpen,\n onChange: (isOpen) => onOpenChange?.({ isOpen }),\n });\n\n const { refs, floatingStyles, context, placement: computedPlacement } = useFloating({\n open: controllableIsOpen,\n onOpenChange: (isOpen) => controllableSetIsOpen(() => isOpen),\n placement,\n strategy: 'fixed',\n middleware: [\n shift({ crossAxis: false, padding: GAP }),\n flip({ padding: GAP, fallbackAxisSideDirection: 'end' }),\n offset(GAP + ARROW_HEIGHT),\n arrow({\n element: arrowRef,\n padding: isHorizontal ? GAP + ARROW_HEIGHT : ARROW_WIDTH,\n }),\n ],\n whileElementsMounted: autoUpdate,\n });\n\n const close = React.useCallback(() => {\n controllableSetIsOpen(() => false);\n }, [controllableSetIsOpen]);\n\n // we need to animate from the offset of the computed placement\n // because placement can change dynamically based on available space\n const [computedSide] = getFloatingPlacementParts(computedPlacement);\n const computedIsHorizontal = computedSide === 'left' || computedSide === 'right';\n const animationOffset = isOppositeAxis ? -size[4] : size[4];\n const { isMounted, styles } = useTransitionStyles(context, {\n duration: theme.motion.duration.quick,\n initial: {\n opacity: 0,\n transform: `translate${computedIsHorizontal ? 'X' : 'Y'}(${animationOffset}px)`,\n },\n });\n\n // remove click handler if popover is controlled\n const isControlled = isOpen !== undefined;\n const click = useClick(context, { enabled: !isControlled });\n const dismiss = useDismiss(context);\n const role = useRole(context);\n\n const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const mergedRef = useMergeRefs(refs.setReference, triggerRef);\n\n const contextValue = React.useMemo(() => {\n return {\n close,\n defaultInitialFocusRef,\n titleId,\n };\n }, [close, titleId]);\n\n // Inject aria attributes to trigger\n // Doing it this way instead of makeAccessible()\n // because with makeAccessible we will need to make sure aria-controls, aria-expanded etc\n // are exposed from the trigger component prop, which we cannot ensure\n React.useLayoutEffect(() => {\n if (!triggerRef.current) return;\n\n const props = getReferenceProps() as Record<string, string>;\n for (const key of Object.keys(props)) {\n if (key.startsWith('aria-')) {\n triggerRef.current.setAttribute(key, props[key]);\n }\n }\n }, [getReferenceProps, triggerRef]);\n\n return (\n <PopoverContext.Provider value={contextValue}>\n {/* Cloning the trigger children to enhance it with ref and event handler */}\n {React.cloneElement(children, {\n ref: mergedRef,\n ...mergeProps(children.props, getReferenceProps()),\n })}\n {isMounted && (\n <FloatingPortal>\n <FloatingFocusManager\n initialFocus={initialFocusRef ?? defaultInitialFocusRef}\n context={context}\n modal={true}\n guards={true}\n >\n <BaseBox\n ref={refs.setFloating}\n style={floatingStyles}\n // TODO: Tokenize zIndex values\n zIndex={zIndex}\n {...getFloatingProps()}\n {...metaAttribute({ name: MetaConstants.Popover })}\n {...makeAccessible({ labelledBy: titleId })}\n {...makeAnalyticsAttribute(rest)}\n >\n <PopoverContent\n title={title}\n titleLeading={titleLeading}\n footer={footer}\n style={styles}\n arrow={\n <PopupArrow\n ref={arrowRef}\n context={context}\n width={ARROW_WIDTH}\n height={ARROW_HEIGHT}\n fillColor={theme.colors.popup.background.subtle}\n strokeColor={theme.colors.popup.border.subtle}\n />\n }\n >\n {content}\n </PopoverContent>\n </BaseBox>\n </FloatingFocusManager>\n </FloatingPortal>\n )}\n </PopoverContext.Provider>\n );\n};\n\nexport { Popover };\n"],"names":["Popover","_ref","content","title","titleLeading","footer","children","_ref$placement","placement","onOpenChange","_ref$zIndex","zIndex","componentZIndices","popover","isOpen","defaultIsOpen","initialFocusRef","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","defaultInitialFocusRef","React","useRef","arrowRef","titleId","useId","GAP","spacing","_getFloatingPlacement","getFloatingPlacementParts","_getFloatingPlacement2","_slicedToArray","side","isHorizontal","isOppositeAxis","_useControllableState","useControllableState","value","defaultValue","onChange","_useControllableState2","controllableIsOpen","controllableSetIsOpen","_useFloating","useFloating","open","strategy","middleware","shift","crossAxis","padding","flip","fallbackAxisSideDirection","offset","ARROW_HEIGHT","arrow","element","ARROW_WIDTH","whileElementsMounted","autoUpdate","refs","floatingStyles","context","computedPlacement","close","useCallback","_getFloatingPlacement3","_getFloatingPlacement4","computedSide","computedIsHorizontal","animationOffset","size","_useTransitionStyles","useTransitionStyles","duration","motion","quick","initial","opacity","transform","concat","isMounted","styles","isControlled","undefined","click","useClick","enabled","dismiss","useDismiss","role","useRole","_useInteractions","useInteractions","getReferenceProps","getFloatingProps","triggerRef","mergedRef","useMergeRefs","setReference","contextValue","useMemo","useLayoutEffect","current","props","_i","_Object$keys","Object","keys","length","key","startsWith","setAttribute","_jsxs","PopoverContext","Provider","cloneElement","_objectSpread","ref","mergeProps","_jsx","FloatingPortal","FloatingFocusManager","initialFocus","modal","guards","BaseBox","setFloating","style","metaAttribute","name","MetaConstants","makeAccessible","labelledBy","makeAnalyticsAttribute","PopoverContent","PopupArrow","width","height","fillColor","colors","popup","background","subtle","strokeColor","border"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAMA,OAAO,GAAG,SAAVA,OAAOA,CAAAC,IAAA,EAa2B;AAAA,EAAA,IAZtCC,OAAO,GAAAD,IAAA,CAAPC,OAAO;IACPC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,YAAY,GAAAH,IAAA,CAAZG,YAAY;IACZC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAAC,cAAA,GAAAN,IAAA,CACRO,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,cAAA;IACjBE,YAAY,GAAAR,IAAA,CAAZQ,YAAY;IAAAC,WAAA,GAAAT,IAAA,CACZU,MAAM;AAANA,IAAAA,MAAM,GAAAD,WAAA,KAAA,KAAA,CAAA,GAAGE,iBAAiB,CAACC,OAAO,GAAAH,WAAA;IAClCI,MAAM,GAAAb,IAAA,CAANa,MAAM;IACNC,aAAa,GAAAd,IAAA,CAAbc,aAAa;IACbC,eAAe,GAAAf,IAAA,CAAfe,eAAe;AACZC,IAAAA,IAAI,GAAA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BC,YAAAA,MAAM,EAAEA,MAAO;AACf8H,YAAAA,KAAK,EAAE9C,MAAO;YACd3B,KAAK,eACHiE,GAAA,CAACgB,UAAU,EAAA;AACTlB,cAAAA,GAAG,EAAE/F,QAAS;AACduC,cAAAA,OAAO,EAAEA,OAAQ;AACjB2E,cAAAA,KAAK,EAAEhF,WAAY;AACnBiF,cAAAA,MAAM,EAAEpF,YAAa;cACrBqF,SAAS,EAAExH,KAAK,CAACyH,MAAM,CAACC,KAAK,CAACC,UAAU,CAACC,MAAO;cAChDC,WAAW,EAAE7H,KAAK,CAACyH,MAAM,CAACC,KAAK,CAACI,MAAM,CAACF,MAAAA;AAAO,aAC/C,CACF;AAAA5I,YAAAA,QAAA,EAEAJ,OAAAA;WACa,CAAA;SACT,CAAA,CAAA;OACW,CAAA;AAAC,KACT,CACjB,CAAA;AAAA,GACsB,CAAC,CAAA;AAE9B;;;;"}
|
|
1
|
+
{"version":3,"file":"Popover.web.js","sources":["../../../../../../src/components/Popover/Popover.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\nimport {\n shift,\n FloatingPortal,\n arrow,\n flip,\n offset,\n useFloating,\n useInteractions,\n useRole,\n useTransitionStyles,\n autoUpdate,\n useClick,\n useHover,\n useDismiss,\n FloatingFocusManager,\n} from '@floating-ui/react';\nimport React from 'react';\nimport type { PopoverProps } from './types';\nimport { PopoverContent } from './PopoverContent';\nimport { ARROW_HEIGHT, ARROW_WIDTH } from './constants';\nimport { PopoverContext } from './PopoverContext';\nimport { useTheme } from '~components/BladeProvider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { size } from '~tokens/global';\nimport { useControllableState } from '~utils/useControllable';\nimport { mergeProps } from '~utils/mergeProps';\nimport { PopupArrow } from '~components/PopupArrow';\nimport { useMergeRefs } from '~utils/useMergeRefs';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { useId } from '~utils/useId';\nimport { getFloatingPlacementParts } from '~utils/getFloatingPlacementParts';\nimport { componentZIndices } from '~utils/componentZIndices';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\nconst Popover = ({\n content,\n title,\n titleLeading,\n footer,\n children,\n placement = 'top',\n onOpenChange,\n zIndex = componentZIndices.popover,\n isOpen,\n defaultIsOpen,\n initialFocusRef,\n openInteraction = 'click',\n ...rest\n}: PopoverProps): React.ReactElement => {\n const { theme } = useTheme();\n const defaultInitialFocusRef = React.useRef<HTMLButtonElement>(null);\n const arrowRef = React.useRef<SVGSVGElement>(null);\n const titleId = useId('popover-title');\n\n const GAP = theme.spacing[2];\n const [side] = getFloatingPlacementParts(placement);\n const isHorizontal = side === 'left' || side === 'right';\n const isOppositeAxis = side === 'right' || side === 'bottom';\n\n const [controllableIsOpen, controllableSetIsOpen] = useControllableState({\n value: isOpen,\n defaultValue: defaultIsOpen,\n onChange: (isOpen) => onOpenChange?.({ isOpen }),\n });\n\n const { refs, floatingStyles, context, placement: computedPlacement } = useFloating({\n open: controllableIsOpen,\n onOpenChange: (isOpen) => controllableSetIsOpen(() => isOpen),\n placement,\n strategy: 'fixed',\n middleware: [\n shift({ crossAxis: false, padding: GAP }),\n flip({ padding: GAP, fallbackAxisSideDirection: 'end' }),\n offset(GAP + ARROW_HEIGHT),\n arrow({\n element: arrowRef,\n padding: isHorizontal ? GAP + ARROW_HEIGHT : ARROW_WIDTH,\n }),\n ],\n whileElementsMounted: autoUpdate,\n });\n\n const close = React.useCallback(() => {\n controllableSetIsOpen(() => false);\n }, [controllableSetIsOpen]);\n\n // we need to animate from the offset of the computed placement\n // because placement can change dynamically based on available space\n const [computedSide] = getFloatingPlacementParts(computedPlacement);\n const computedIsHorizontal = computedSide === 'left' || computedSide === 'right';\n const animationOffset = isOppositeAxis ? -size[4] : size[4];\n const { isMounted, styles } = useTransitionStyles(context, {\n duration: theme.motion.duration.quick,\n initial: {\n opacity: 0,\n transform: `translate${computedIsHorizontal ? 'X' : 'Y'}(${animationOffset}px)`,\n },\n });\n\n // remove click handler if popover is controlled\n const isControlled = isOpen !== undefined;\n const click = useClick(context, { enabled: !isControlled && openInteraction === 'click' });\n const hover = useHover(context, { enabled: !isControlled && openInteraction === 'hover' });\n const dismiss = useDismiss(context);\n const role = useRole(context);\n\n const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role, hover]);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const mergedRef = useMergeRefs(refs.setReference, triggerRef);\n\n const contextValue = React.useMemo(() => {\n return {\n close,\n defaultInitialFocusRef,\n titleId,\n openInteraction,\n };\n }, [close, titleId, openInteraction]);\n\n // Inject aria attributes to trigger\n // Doing it this way instead of makeAccessible()\n // because with makeAccessible we will need to make sure aria-controls, aria-expanded etc\n // are exposed from the trigger component prop, which we cannot ensure\n React.useLayoutEffect(() => {\n if (!triggerRef.current) return;\n\n const props = getReferenceProps() as Record<string, string>;\n for (const key of Object.keys(props)) {\n if (key.startsWith('aria-')) {\n triggerRef.current.setAttribute(key, props[key]);\n }\n }\n }, [getReferenceProps, triggerRef]);\n\n return (\n <PopoverContext.Provider value={contextValue}>\n {/* Cloning the trigger children to enhance it with ref and event handler */}\n {React.cloneElement(children, {\n ref: mergedRef,\n ...mergeProps(children.props, getReferenceProps()),\n })}\n {isMounted && (\n <FloatingPortal>\n <FloatingFocusManager\n initialFocus={\n initialFocusRef ?? (openInteraction === 'hover' ? -1 : defaultInitialFocusRef)\n }\n context={context}\n modal={true}\n guards={true}\n >\n <BaseBox\n ref={refs.setFloating}\n style={floatingStyles}\n // TODO: Tokenize zIndex values\n zIndex={zIndex}\n {...getFloatingProps()}\n {...metaAttribute({ name: MetaConstants.Popover })}\n {...makeAccessible({ labelledBy: titleId })}\n {...makeAnalyticsAttribute(rest)}\n >\n <PopoverContent\n title={title}\n titleLeading={titleLeading}\n footer={footer}\n style={styles}\n arrow={\n <PopupArrow\n ref={arrowRef}\n context={context}\n width={ARROW_WIDTH}\n height={ARROW_HEIGHT}\n fillColor={theme.colors.popup.background.subtle}\n strokeColor={theme.colors.popup.border.subtle}\n />\n }\n >\n {content}\n </PopoverContent>\n </BaseBox>\n </FloatingFocusManager>\n </FloatingPortal>\n )}\n </PopoverContext.Provider>\n );\n};\n\nexport { Popover };\n"],"names":["Popover","_ref","content","title","titleLeading","footer","children","_ref$placement","placement","onOpenChange","_ref$zIndex","zIndex","componentZIndices","popover","isOpen","defaultIsOpen","initialFocusRef","_ref$openInteraction","openInteraction","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","defaultInitialFocusRef","React","useRef","arrowRef","titleId","useId","GAP","spacing","_getFloatingPlacement","getFloatingPlacementParts","_getFloatingPlacement2","_slicedToArray","side","isHorizontal","isOppositeAxis","_useControllableState","useControllableState","value","defaultValue","onChange","_useControllableState2","controllableIsOpen","controllableSetIsOpen","_useFloating","useFloating","open","strategy","middleware","shift","crossAxis","padding","flip","fallbackAxisSideDirection","offset","ARROW_HEIGHT","arrow","element","ARROW_WIDTH","whileElementsMounted","autoUpdate","refs","floatingStyles","context","computedPlacement","close","useCallback","_getFloatingPlacement3","_getFloatingPlacement4","computedSide","computedIsHorizontal","animationOffset","size","_useTransitionStyles","useTransitionStyles","duration","motion","quick","initial","opacity","transform","concat","isMounted","styles","isControlled","undefined","click","useClick","enabled","hover","useHover","dismiss","useDismiss","role","useRole","_useInteractions","useInteractions","getReferenceProps","getFloatingProps","triggerRef","mergedRef","useMergeRefs","setReference","contextValue","useMemo","useLayoutEffect","current","props","_i","_Object$keys","Object","keys","length","key","startsWith","setAttribute","_jsxs","PopoverContext","Provider","cloneElement","_objectSpread","ref","mergeProps","_jsx","FloatingPortal","FloatingFocusManager","initialFocus","modal","guards","BaseBox","setFloating","style","metaAttribute","name","MetaConstants","makeAccessible","labelledBy","makeAnalyticsAttribute","PopoverContent","PopupArrow","width","height","fillColor","colors","popup","background","subtle","strokeColor","border"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,I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O,EAAEA,OAAQ;AACjB6E,cAAAA,KAAK,EAAElF,WAAY;AACnBmF,cAAAA,MAAM,EAAEtF,YAAa;cACrBuF,SAAS,EAAE1H,KAAK,CAAC2H,MAAM,CAACC,KAAK,CAACC,UAAU,CAACC,MAAO;cAChDC,WAAW,EAAE/H,KAAK,CAAC2H,MAAM,CAACC,KAAK,CAACI,MAAM,CAACF,MAAAA;AAAO,aAC/C,CACF;AAAAhJ,YAAAA,QAAA,EAEAJ,OAAAA;WACa,CAAA;SACT,CAAA,CAAA;OACW,CAAA;AAAC,KACT,CACjB,CAAA;AAAA,GACsB,CAAC,CAAA;AAE9B;;;;"}
|
|
@@ -16,9 +16,14 @@ var PopoverHeader = function PopoverHeader(_ref) {
|
|
|
16
16
|
var title = _ref.title,
|
|
17
17
|
titleLeading = _ref.titleLeading;
|
|
18
18
|
var _usePopoverContext = usePopoverContext(),
|
|
19
|
-
titleId = _usePopoverContext.titleId
|
|
19
|
+
titleId = _usePopoverContext.titleId,
|
|
20
|
+
openInteraction = _usePopoverContext.openInteraction;
|
|
21
|
+
var showCloseButton = openInteraction === 'click';
|
|
20
22
|
var isFloating = !(title || titleLeading);
|
|
21
23
|
if (isFloating) {
|
|
24
|
+
if (!showCloseButton) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
22
27
|
return /*#__PURE__*/jsx(BaseBox, {
|
|
23
28
|
borderRadius: "max",
|
|
24
29
|
position: "absolute",
|
|
@@ -45,10 +50,10 @@ var PopoverHeader = function PopoverHeader(_ref) {
|
|
|
45
50
|
weight: "semibold",
|
|
46
51
|
children: title
|
|
47
52
|
})
|
|
48
|
-
}) : null, /*#__PURE__*/jsx(BaseBox, {
|
|
53
|
+
}) : null, showCloseButton ? /*#__PURE__*/jsx(BaseBox, {
|
|
49
54
|
marginLeft: "auto",
|
|
50
55
|
children: /*#__PURE__*/jsx(PopoverCloseButton, {})
|
|
51
|
-
})]
|
|
56
|
+
}) : null]
|
|
52
57
|
});
|
|
53
58
|
};
|
|
54
59
|
var PopoverContent = /*#__PURE__*/React__default.forwardRef(function (_ref2, ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverContent.js","sources":["../../../../../../src/components/Popover/PopoverContent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */\nimport React from 'react';\nimport { PopoverContentWrapper } from './PopoverContentWrapper';\nimport type { PopoverContentProps } from './types';\nimport { PopoverCloseButton } from './PopoverCloseButton';\nimport { usePopoverContext } from './PopoverContext';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Text } from '~components/Typography';\nimport { isReactNative } from '~utils';\nimport { useIsMobile } from '~utils/useIsMobile';\n\ntype PopoverHeaderProps = {\n title?: string;\n titleLeading?: React.ReactNode;\n};\n\nconst PopoverHeader = ({ title, titleLeading }: PopoverHeaderProps): React.ReactElement => {\n const { titleId } = usePopoverContext();\n\n const isFloating = !(title || titleLeading);\n if (isFloating) {\n return (\n <BaseBox\n borderRadius=\"max\"\n position=\"absolute\"\n padding=\"spacing.2\"\n top=\"spacing.2\"\n right=\"spacing.2\"\n zIndex={1}\n >\n <PopoverCloseButton />\n </BaseBox>\n );\n }\n\n return (\n <BaseBox\n display=\"flex\"\n flexDirection=\"row\"\n flexWrap={isReactNative() ? 'wrap' : 'nowrap'}\n alignItems=\"center\"\n gap=\"spacing.3\"\n >\n {titleLeading\n ? React.cloneElement(titleLeading as React.ReactElement, { size: 'large' })\n : null}\n {title ? (\n <BaseBox id={titleId} paddingRight=\"spacing.4\">\n <Text size=\"large\" weight=\"semibold\">\n {title}\n </Text>\n </BaseBox>\n ) : null}\n <BaseBox marginLeft=\"auto\">\n
|
|
1
|
+
{"version":3,"file":"PopoverContent.js","sources":["../../../../../../src/components/Popover/PopoverContent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */\nimport React from 'react';\nimport { PopoverContentWrapper } from './PopoverContentWrapper';\nimport type { PopoverContentProps } from './types';\nimport { PopoverCloseButton } from './PopoverCloseButton';\nimport { usePopoverContext } from './PopoverContext';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Text } from '~components/Typography';\nimport { isReactNative } from '~utils';\nimport { useIsMobile } from '~utils/useIsMobile';\n\ntype PopoverHeaderProps = {\n title?: string;\n titleLeading?: React.ReactNode;\n};\n\nconst PopoverHeader = ({ title, titleLeading }: PopoverHeaderProps): React.ReactElement | null => {\n const { titleId, openInteraction } = usePopoverContext();\n\n const showCloseButton = openInteraction === 'click';\n const isFloating = !(title || titleLeading);\n\n if (isFloating) {\n if (!showCloseButton) {\n return null;\n }\n return (\n <BaseBox\n borderRadius=\"max\"\n position=\"absolute\"\n padding=\"spacing.2\"\n top=\"spacing.2\"\n right=\"spacing.2\"\n zIndex={1}\n >\n <PopoverCloseButton />\n </BaseBox>\n );\n }\n\n return (\n <BaseBox\n display=\"flex\"\n flexDirection=\"row\"\n flexWrap={isReactNative() ? 'wrap' : 'nowrap'}\n alignItems=\"center\"\n gap=\"spacing.3\"\n >\n {titleLeading\n ? React.cloneElement(titleLeading as React.ReactElement, { size: 'large' })\n : null}\n {title ? (\n <BaseBox id={titleId} paddingRight=\"spacing.4\">\n <Text size=\"large\" weight=\"semibold\">\n {title}\n </Text>\n </BaseBox>\n ) : null}\n {showCloseButton ? (\n <BaseBox marginLeft=\"auto\">\n <PopoverCloseButton />\n </BaseBox>\n ) : null}\n </BaseBox>\n );\n};\n\nconst PopoverContent = React.forwardRef<HTMLDivElement, PopoverContentProps>(\n ({ children, title, titleLeading, footer, arrow, side, style, isVisible }, ref) => {\n const isMobile = useIsMobile();\n return (\n <PopoverContentWrapper\n ref={ref as never}\n styles={style}\n side={side}\n isVisible={isVisible}\n isMobile={isMobile}\n >\n <BaseBox padding=\"spacing.4\" display=\"flex\" flexDirection=\"column\" gap=\"spacing.4\">\n <PopoverHeader title={title} titleLeading={titleLeading} />\n <BaseBox>{children}</BaseBox>\n {footer ? <BaseBox>{footer}</BaseBox> : null}\n </BaseBox>\n {arrow}\n </PopoverContentWrapper>\n );\n },\n);\n\nexport { PopoverContent };\n"],"names":["PopoverHeader","_ref","title","titleLeading","_usePopoverContext","usePopoverContext","titleId","openInteraction","showCloseButton","isFloating","_jsx","BaseBox","borderRadius","position","padding","top","right","zIndex","children","PopoverCloseButton","_jsxs","display","flexDirection","flexWrap","isReactNative","alignItems","gap","React","cloneElement","size","id","paddingRight","Text","weight","marginLeft","PopoverContent","forwardRef","_ref2","ref","footer","arrow","side","style","isVisible","isMobile","useIsMobile","PopoverContentWrapper","styles"],"mappings":";;;;;;;;;;;;;AAAA;AAgBA,IAAMA,aAAa,GAAG,SAAhBA,aAAaA,CAAAC,IAAA,EAA+E;AAAA,EAAA,IAAzEC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,YAAY,GAAAF,IAAA,CAAZE,YAAY,CAAA;AAC1C,EAAA,IAAAC,kBAAA,GAAqCC,iBAAiB,EAAE;IAAhDC,OAAO,GAAAF,kBAAA,CAAPE,OAAO;IAAEC,eAAe,GAAAH,kBAAA,CAAfG,eAAe,CAAA;AAEhC,EAAA,IAAMC,eAAe,GAAGD,eAAe,KAAK,OAAO,CAAA;AACnD,EAAA,IAAME,UAAU,GAAG,EAAEP,KAAK,IAAIC,YAAY,CAAC,CAAA;AAE3C,EAAA,IAAIM,UAAU,EAAE;IACd,IAAI,CAACD,eAAe,EAAE;AACpB,MAAA,OAAO,IAAI,CAAA;AACb,KAAA;IACA,oBACEE,GAAA,CAACC,OAAO,EAAA;AACNC,MAAAA,YAAY,EAAC,KAAK;AAClBC,MAAAA,QAAQ,EAAC,UAAU;AACnBC,MAAAA,OAAO,EAAC,WAAW;AACnBC,MAAAA,GAAG,EAAC,WAAW;AACfC,MAAAA,KAAK,EAAC,WAAW;AACjBC,MAAAA,MAAM,EAAE,CAAE;AAAAC,MAAAA,QAAA,eAEVR,GAAA,CAACS,kBAAkB,EAAE,EAAA,CAAA;AAAC,KACf,CAAC,CAAA;AAEd,GAAA;E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GAAAL,KAAA,CAALK,KAAK;IAAEC,SAAS,GAAAN,KAAA,CAATM,SAAS,CAAA;AACrE,EAAA,IAAMC,QAAQ,GAAGC,WAAW,EAAE,CAAA;EAC9B,oBACEzB,IAAA,CAAC0B,qBAAqB,EAAA;AACpBR,IAAAA,GAAG,EAAEA,GAAa;AAClBS,IAAAA,MAAM,EAAEL,KAAM;AACdD,IAAAA,IAAI,EAAEA,IAAK;AACXE,IAAAA,SAAS,EAAEA,SAAU;AACrBC,IAAAA,QAAQ,EAAEA,QAAS;IAAA1B,QAAA,EAAA,cAEnBE,IAAA,CAACT,OAAO,EAAA;AAACG,MAAAA,OAAO,EAAC,WAAW;AAACO,MAAAA,OAAO,EAAC,MAAM;AAACC,MAAAA,aAAa,EAAC,QAAQ;AAACI,MAAAA,GAAG,EAAC,WAAW;MAAAR,QAAA,EAAA,cAChFR,GAAA,CAACV,aAAa,EAAA;AAACE,QAAAA,KAAK,EAAEA,KAAM;AAACC,QAAAA,YAAY,EAAEA,YAAAA;AAAa,OAAE,CAAC,eAC3DO,GAAA,CAACC,OAAO,EAAA;AAAAO,QAAAA,QAAA,EAAEA,QAAAA;AAAQ,OAAU,CAAC,EAC5BqB,MAAM,gBAAG7B,GAAA,CAACC,OAAO,EAAA;AAAAO,QAAAA,QAAA,EAAEqB,MAAAA;OAAgB,CAAC,GAAG,IAAI,CAAA;KACrC,CAAC,EACTC,KAAK,CAAA;AAAA,GACe,CAAC,CAAA;AAE5B,CACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverContext.js","sources":["../../../../../../src/components/Popover/PopoverContext.ts"],"sourcesContent":["import React from 'react';\nimport { throwBladeError } from '~utils/logger';\n\ntype PopoverContextProps = {\n close: () => void;\n defaultInitialFocusRef: React.RefObject<HTMLElement>;\n titleId?: string;\n} | null;\nconst PopoverContext = React.createContext<PopoverContextProps>(null);\n\nconst usePopoverContext = (): NonNullable<PopoverContextProps> => {\n const context = React.useContext(PopoverContext);\n\n if (__DEV__) {\n if (!context) {\n throwBladeError({\n message: `usePopoverContext must be used within Popover`,\n moduleName: 'Popover',\n });\n }\n }\n\n return context!;\n};\n\nexport { PopoverContext, usePopoverContext };\n"],"names":["PopoverContext","React","createContext","usePopoverContext","context","useContext","throwBladeError","message","moduleName"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"PopoverContext.js","sources":["../../../../../../src/components/Popover/PopoverContext.ts"],"sourcesContent":["import React from 'react';\nimport { throwBladeError } from '~utils/logger';\n\ntype PopoverContextProps = {\n close: () => void;\n defaultInitialFocusRef: React.RefObject<HTMLElement>;\n titleId?: string;\n openInteraction?: 'hover' | 'click';\n} | null;\nconst PopoverContext = React.createContext<PopoverContextProps>(null);\n\nconst usePopoverContext = (): NonNullable<PopoverContextProps> => {\n const context = React.useContext(PopoverContext);\n\n if (__DEV__) {\n if (!context) {\n throwBladeError({\n message: `usePopoverContext must be used within Popover`,\n moduleName: 'Popover',\n });\n }\n }\n\n return context!;\n};\n\nexport { PopoverContext, usePopoverContext };\n"],"names":["PopoverContext","React","createContext","usePopoverContext","context","useContext","throwBladeError","message","moduleName"],"mappings":";;;;AASA,IAAMA,cAAc,gBAAGC,cAAK,CAACC,aAAa,CAAsB,IAAI,EAAC;AAErE,IAAMC,iBAAiB,GAAG,SAApBA,iBAAiBA,GAA2C;AAChE,EAAA,IAAMC,OAAO,GAAGH,cAAK,CAACI,UAAU,CAACL,cAAc,CAAC,CAAA;AAEhD,EAAA,IAAI,IAAO,EAAE;IACX,IAAI,CAACI,OAAO,EAAE;AACZE,MAAAA,eAAe,CAAC;AACdC,QAAAA,OAAO,EAAiD,+CAAA;AACxDC,QAAAA,UAAU,EAAE,SAAA;AACd,OAAC,CAAC,CAAA;AACJ,KAAA;AACF,GAAA;AAEA,EAAA,OAAOJ,OAAO,CAAA;AAChB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TourPopover.web.js","sources":["../../../../../../src/components/SpotlightPopoverTour/TourPopover.web.tsx"],"sourcesContent":["/* eslint-disable react/jsx-no-useless-fragment */\n/* eslint-disable @typescript-eslint/restrict-plus-operands */\nimport {\n shift,\n FloatingPortal,\n arrow,\n flip,\n offset,\n useFloating,\n useInteractions,\n useRole,\n useTransitionStyles,\n autoUpdate,\n useClick,\n FloatingFocusManager,\n} from '@floating-ui/react';\nimport React from 'react';\nimport { PopoverContent } from '../Popover/PopoverContent';\nimport { ARROW_HEIGHT, ARROW_WIDTH } from '../Popover/constants';\nimport { PopoverContext } from '../Popover/PopoverContext';\nimport { transitionDelay } from './tourTokens';\nimport { useTheme } from '~components/BladeProvider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { size } from '~tokens/global';\nimport { useControllableState } from '~utils/useControllable';\nimport { PopupArrow } from '~components/PopupArrow';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { useId } from '~utils/useId';\nimport { getFloatingPlacementParts } from '~utils/getFloatingPlacementParts';\nimport type { PopoverProps } from '~components/Popover';\nimport { componentZIndices } from '~utils/componentZIndices';\n\ntype TourPopoverProps = Omit<PopoverProps, 'children' | 'initialFocusRef'> & {\n attachTo: React.RefObject<HTMLElement> | undefined;\n isTransitioning: boolean;\n};\n\n// TODO: Refactor out Popover/FloatingUI logic to a reusable hook/component later on\nconst TourPopover = ({\n attachTo,\n content,\n title,\n titleLeading,\n footer,\n placement = 'top',\n onOpenChange,\n zIndex = componentZIndices.popover,\n isOpen,\n defaultIsOpen,\n isTransitioning,\n}: TourPopoverProps): React.ReactElement => {\n const { theme } = useTheme();\n const defaultInitialFocusRef = React.useRef<HTMLButtonElement>(null);\n const arrowRef = React.useRef<SVGSVGElement>(null);\n const titleId = useId('popover-title');\n\n const GAP = theme.spacing[4];\n const [side] = getFloatingPlacementParts(placement);\n const isHorizontal = side === 'left' || side === 'right';\n const isOppositeAxis = side === 'right' || side === 'bottom';\n\n const [controllableIsOpen, controllableSetIsOpen] = useControllableState({\n value: isOpen,\n defaultValue: defaultIsOpen,\n onChange: (isOpen) => onOpenChange?.({ isOpen }),\n });\n\n const { refs, floatingStyles, context, placement: computedPlacement } = useFloating({\n open: controllableIsOpen,\n onOpenChange: (isOpen) => controllableSetIsOpen(() => isOpen),\n placement,\n strategy: 'fixed',\n middleware: [\n shift({ crossAxis: false, padding: GAP }),\n flip({ padding: GAP, fallbackAxisSideDirection: 'end' }),\n offset(GAP + ARROW_HEIGHT),\n arrow({\n element: arrowRef,\n padding: isHorizontal ? GAP + ARROW_HEIGHT : ARROW_WIDTH,\n }),\n ],\n transform: true,\n whileElementsMounted: autoUpdate,\n });\n\n const close = React.useCallback(() => {\n controllableSetIsOpen(() => false);\n }, [controllableSetIsOpen]);\n\n // we need to animate from the offset of the computed placement\n // because placement can change dynamically based on available space\n const [computedSide] = getFloatingPlacementParts(computedPlacement);\n const computedIsHorizontal = computedSide === 'left' || computedSide === 'right';\n const animationOffset = isOppositeAxis ? -size[4] : size[4];\n\n const { isMounted, styles } = useTransitionStyles(context, {\n duration: {\n open: transitionDelay,\n close: theme.motion.duration.xquick,\n },\n initial: {\n opacity: 0,\n transform: `translate${computedIsHorizontal ? 'X' : 'Y'}(${animationOffset}px)`,\n },\n });\n\n // remove click handler if popover is controlled\n const isControlled = isOpen !== undefined;\n const click = useClick(context, { enabled: !isControlled });\n const role = useRole(context);\n\n const { getFloatingProps } = useInteractions([click, role]);\n\n const contextValue = React.useMemo(() => {\n return {\n close,\n defaultInitialFocusRef,\n titleId,\n };\n }, [close, titleId]);\n\n // https://github.com/floating-ui/floating-ui/discussions/2352#discussioncomment-6044834\n React.useLayoutEffect(() => {\n window.setTimeout(() => {\n if (!attachTo) return;\n refs.setReference(attachTo.current);\n refs.setPositionReference(attachTo.current);\n });\n }, [attachTo, refs, isOpen]);\n\n return (\n <PopoverContext.Provider value={contextValue}>\n <FloatingPortal>\n <FloatingFocusManager\n // TODO: check if isTransitioning is enough since scrolling can take longer\n disabled={isOpen === false || !isMounted || isTransitioning}\n initialFocus={defaultInitialFocusRef}\n context={context}\n modal={true}\n guards={true}\n >\n {isMounted ? (\n <BaseBox\n ref={refs.setFloating}\n style={{ ...floatingStyles, pointerEvents: isMounted ? 'auto' : 'none' }}\n // TODO: Tokenize zIndex values\n zIndex={zIndex}\n {...getFloatingProps()}\n {...metaAttribute({ name: MetaConstants.TourPopover })}\n {...makeAccessible({ labelledBy: titleId })}\n >\n <PopoverContent\n title={title}\n titleLeading={titleLeading}\n footer={footer}\n style={styles}\n arrow={\n <PopupArrow\n ref={arrowRef}\n context={context}\n width={ARROW_WIDTH}\n height={ARROW_HEIGHT}\n fillColor={theme.colors.popup.background.subtle}\n strokeColor={theme.colors.popup.border.subtle}\n />\n }\n >\n {content}\n </PopoverContent>\n </BaseBox>\n ) : (\n <></>\n )}\n </FloatingFocusManager>\n </FloatingPortal>\n </PopoverContext.Provider>\n );\n};\n\nexport { TourPopover };\n"],"names":["TourPopover","_ref","attachTo","content","title","titleLeading","footer","_ref$placement","placement","onOpenChange","_ref$zIndex","zIndex","componentZIndices","popover","isOpen","defaultIsOpen","isTransitioning","_useTheme","useTheme","theme","defaultInitialFocusRef","React","useRef","arrowRef","titleId","useId","GAP","spacing","_getFloatingPlacement","getFloatingPlacementParts","_getFloatingPlacement2","_slicedToArray","side","isHorizontal","isOppositeAxis","_useControllableState","useControllableState","value","defaultValue","onChange","_useControllableState2","controllableIsOpen","controllableSetIsOpen","_useFloating","useFloating","open","strategy","middleware","shift","crossAxis","padding","flip","fallbackAxisSideDirection","offset","ARROW_HEIGHT","arrow","element","ARROW_WIDTH","transform","whileElementsMounted","autoUpdate","refs","floatingStyles","context","computedPlacement","close","useCallback","_getFloatingPlacement3","_getFloatingPlacement4","computedSide","computedIsHorizontal","animationOffset","size","_useTransitionStyles","useTransitionStyles","duration","transitionDelay","motion","xquick","initial","opacity","concat","isMounted","styles","isControlled","undefined","click","useClick","enabled","role","useRole","_useInteractions","useInteractions","getFloatingProps","contextValue","useMemo","useLayoutEffect","window","setTimeout","setReference","current","setPositionReference","_jsx","PopoverContext","Provider","children","FloatingPortal","FloatingFocusManager","disabled","initialFocus","modal","guards","BaseBox","_objectSpread","ref","setFloating","style","pointerEvents","metaAttribute","name","MetaConstants","makeAccessible","labelledBy","PopoverContent","PopupArrow","width","height","fillColor","colors","popup","background","subtle","strokeColor","border","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;AACA,IAAMA,WAAW,GAAG,SAAdA,WAAWA,CAAAC,IAAA,EAY2B;AAAA,EAAA,IAX1CC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,OAAO,GAAAF,IAAA,CAAPE,OAAO;IACPC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,YAAY,GAAAJ,IAAA,CAAZI,YAAY;IACZC,MAAM,GAAAL,IAAA,CAANK,MAAM;IAAAC,cAAA,GAAAN,IAAA,CACNO,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,cAAA;IACjBE,YAAY,GAAAR,IAAA,CAAZQ,YAAY;IAAAC,WAAA,GAAAT,IAAA,CACZU,MAAM;AAANA,IAAAA,MAAM,GAAAD,WAAA,KAAA,KAAA,CAAA,GAAGE,iBAAiB,CAACC,OAAO,GAAAH,WAAA;IAClCI,MAAM,GAAAb,IAAA,CAANa,MAAM;IACNC,aAAa,GAAAd,IAAA,CAAbc,aAAa;IACbC,eAAe,GAAAf,IAAA,CAAfe,eAAe,CAAA;AAEf,EAAA,IAAAC,SAAA,GAAkBC,QAAQ,EAAE;IAApBC,KAAK,GAAAF,SAAA,CAALE,KAAK,CAAA;AACb,EAAA,IAAMC,sBAAsB,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC,CAAA;AACpE,EAAA,IAAMC,QAAQ,GAAGF,cAAK,CAACC,MAAM,CAAgB,IAAI,CAAC,CAAA;AAClD,EAAA,IAAME,OAAO,GA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ACXkF,gBAAgB,EAAE,CAAA,EAClByB,aAAa,CAAC;UAAEC,IAAI,EAAEC,aAAa,CAACxH,WAAAA;SAAa,CAAC,CAClDyH,EAAAA,cAAc,CAAC;AAAEC,UAAAA,UAAU,EAAElG,OAAAA;AAAQ,SAAC,CAAC,CAAA,EAAA,EAAA,EAAA;UAAAiF,QAAA,eAE3CH,GAAA,CAACqB,cAAc,EAAA;AACbvH,YAAAA,KAAK,EAAEA,KAAM;AACbC,YAAAA,YAAY,EAAEA,YAAa;AAC3BC,YAAAA,MAAM,EAAEA,MAAO;AACf8G,YAAAA,KAAK,EAAEjC,MAAO;YACd5B,KAAK,eACH+C,GAAA,CAACsB,UAAU,EAAA;AACTV,cAAAA,GAAG,EAAE3F,QAAS;AACdwC,cAAAA,OAAO,EAAEA,OAAQ;AACjB8D,cAAAA,KAAK,EAAEpE,WAAY;AACnBqE,cAAAA,MAAM,EAAExE,YAAa;cACrByE,SAAS,EAAE5G,KAAK,CAAC6G,MAAM,CAACC,KAAK,CAACC,UAAU,CAACC,MAAO;cAChDC,WAAW,EAAEjH,KAAK,CAAC6G,MAAM,CAACC,KAAK,CAACI,MAAM,CAACF,MAAAA;AAAO,aAC/C,CACF;AAAA1B,YAAAA,QAAA,EAEAtG,OAAAA;WACa,CAAA;AAAC,SAAA,CACV,CAAC,gBAEVmG,GAAA,CAAAgC,QAAA,EAAI,EAAA,CAAA;OAEc,CAAA;KACR,CAAA;AAAC,GACM,CAAC,CAAA;AAE9B;;;;"}
|
|
1
|
+
{"version":3,"file":"TourPopover.web.js","sources":["../../../../../../src/components/SpotlightPopoverTour/TourPopover.web.tsx"],"sourcesContent":["/* eslint-disable react/jsx-no-useless-fragment */\n/* eslint-disable @typescript-eslint/restrict-plus-operands */\nimport {\n shift,\n FloatingPortal,\n arrow,\n flip,\n offset,\n useFloating,\n useInteractions,\n useRole,\n useTransitionStyles,\n autoUpdate,\n useClick,\n FloatingFocusManager,\n} from '@floating-ui/react';\nimport React from 'react';\nimport { PopoverContent } from '../Popover/PopoverContent';\nimport { ARROW_HEIGHT, ARROW_WIDTH } from '../Popover/constants';\nimport { PopoverContext } from '../Popover/PopoverContext';\nimport { transitionDelay } from './tourTokens';\nimport { useTheme } from '~components/BladeProvider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { size } from '~tokens/global';\nimport { useControllableState } from '~utils/useControllable';\nimport { PopupArrow } from '~components/PopupArrow';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { useId } from '~utils/useId';\nimport { getFloatingPlacementParts } from '~utils/getFloatingPlacementParts';\nimport type { PopoverProps } from '~components/Popover';\nimport { componentZIndices } from '~utils/componentZIndices';\n\ntype TourPopoverProps = Omit<PopoverProps, 'children' | 'initialFocusRef'> & {\n attachTo: React.RefObject<HTMLElement> | undefined;\n isTransitioning: boolean;\n};\n\n// TODO: Refactor out Popover/FloatingUI logic to a reusable hook/component later on\nconst TourPopover = ({\n attachTo,\n content,\n title,\n titleLeading,\n footer,\n placement = 'top',\n onOpenChange,\n zIndex = componentZIndices.popover,\n isOpen,\n defaultIsOpen,\n isTransitioning,\n}: TourPopoverProps): React.ReactElement => {\n const { theme } = useTheme();\n const defaultInitialFocusRef = React.useRef<HTMLButtonElement>(null);\n const arrowRef = React.useRef<SVGSVGElement>(null);\n const titleId = useId('popover-title');\n\n const GAP = theme.spacing[4];\n const [side] = getFloatingPlacementParts(placement);\n const isHorizontal = side === 'left' || side === 'right';\n const isOppositeAxis = side === 'right' || side === 'bottom';\n\n const [controllableIsOpen, controllableSetIsOpen] = useControllableState({\n value: isOpen,\n defaultValue: defaultIsOpen,\n onChange: (isOpen) => onOpenChange?.({ isOpen }),\n });\n\n const { refs, floatingStyles, context, placement: computedPlacement } = useFloating({\n open: controllableIsOpen,\n onOpenChange: (isOpen) => controllableSetIsOpen(() => isOpen),\n placement,\n strategy: 'fixed',\n middleware: [\n shift({ crossAxis: false, padding: GAP }),\n flip({ padding: GAP, fallbackAxisSideDirection: 'end' }),\n offset(GAP + ARROW_HEIGHT),\n arrow({\n element: arrowRef,\n padding: isHorizontal ? GAP + ARROW_HEIGHT : ARROW_WIDTH,\n }),\n ],\n transform: true,\n whileElementsMounted: autoUpdate,\n });\n\n const close = React.useCallback(() => {\n controllableSetIsOpen(() => false);\n }, [controllableSetIsOpen]);\n\n // we need to animate from the offset of the computed placement\n // because placement can change dynamically based on available space\n const [computedSide] = getFloatingPlacementParts(computedPlacement);\n const computedIsHorizontal = computedSide === 'left' || computedSide === 'right';\n const animationOffset = isOppositeAxis ? -size[4] : size[4];\n\n const { isMounted, styles } = useTransitionStyles(context, {\n duration: {\n open: transitionDelay,\n close: theme.motion.duration.xquick,\n },\n initial: {\n opacity: 0,\n transform: `translate${computedIsHorizontal ? 'X' : 'Y'}(${animationOffset}px)`,\n },\n });\n\n // remove click handler if popover is controlled\n const isControlled = isOpen !== undefined;\n const click = useClick(context, { enabled: !isControlled });\n const role = useRole(context);\n\n const { getFloatingProps } = useInteractions([click, role]);\n\n const contextValue = React.useMemo(() => {\n return {\n close,\n defaultInitialFocusRef,\n titleId,\n openInteraction: 'click' as const,\n };\n }, [close, titleId]);\n\n // https://github.com/floating-ui/floating-ui/discussions/2352#discussioncomment-6044834\n React.useLayoutEffect(() => {\n window.setTimeout(() => {\n if (!attachTo) return;\n refs.setReference(attachTo.current);\n refs.setPositionReference(attachTo.current);\n });\n }, [attachTo, refs, isOpen]);\n\n return (\n <PopoverContext.Provider value={contextValue}>\n <FloatingPortal>\n <FloatingFocusManager\n // TODO: check if isTransitioning is enough since scrolling can take longer\n disabled={isOpen === false || !isMounted || isTransitioning}\n initialFocus={defaultInitialFocusRef}\n context={context}\n modal={true}\n guards={true}\n >\n {isMounted ? (\n <BaseBox\n ref={refs.setFloating}\n style={{ ...floatingStyles, pointerEvents: isMounted ? 'auto' : 'none' }}\n // TODO: Tokenize zIndex values\n zIndex={zIndex}\n {...getFloatingProps()}\n {...metaAttribute({ name: MetaConstants.TourPopover })}\n {...makeAccessible({ labelledBy: titleId })}\n >\n <PopoverContent\n title={title}\n titleLeading={titleLeading}\n footer={footer}\n style={styles}\n arrow={\n <PopupArrow\n ref={arrowRef}\n context={context}\n width={ARROW_WIDTH}\n height={ARROW_HEIGHT}\n fillColor={theme.colors.popup.background.subtle}\n strokeColor={theme.colors.popup.border.subtle}\n />\n }\n >\n {content}\n </PopoverContent>\n </BaseBox>\n ) : (\n <></>\n )}\n </FloatingFocusManager>\n </FloatingPortal>\n </PopoverContext.Provider>\n );\n};\n\nexport { TourPopover };\n"],"names":["TourPopover","_ref","attachTo","content","title","titleLeading","footer","_ref$placement","placement","onOpenChange","_ref$zIndex","zIndex","componentZIndices","popover","isOpen","defaultIsOpen","isTransitioning","_useTheme","useTheme","theme","defaultInitialFocusRef","React","useRef","arrowRef","titleId","useId","GAP","spacing","_getFloatingPlacement","getFloatingPlacementParts","_getFloatingPlacement2","_slicedToArray","side","isHorizontal","isOppositeAxis","_useControllableState","useControllableState","value","defaultValue","onChange","_useControllableState2","controllableIsOpen","controllableSetIsOpen","_useFloating","useFloating","open","strategy","middleware","shift","crossAxis","padding","flip","fallbackAxisSideDirection","offset","ARROW_HEIGHT","arrow","element","ARROW_WIDTH","transform","whileElementsMounted","autoUpdate","refs","floatingStyles","context","computedPlacement","close","useCallback","_getFloatingPlacement3","_getFloatingPlacement4","computedSide","computedIsHorizontal","animationOffset","size","_useTransitionStyles","useTransitionStyles","duration","transitionDelay","motion","xquick","initial","opacity","concat","isMounted","styles","isControlled","undefined","click","useClick","enabled","role","useRole","_useInteractions","useInteractions","getFloatingProps","contextValue","useMemo","openInteraction","useLayoutEffect","window","setTimeout","setReference","current","setPositionReference","_jsx","PopoverContext","Provider","children","FloatingPortal","FloatingFocusManager","disabled","initialFocus","modal","guards","BaseBox","_objectSpread","ref","setFloating","style","pointerEvents","metaAttribute","name","MetaConstants","makeAccessible","labelledBy","PopoverContent","PopupArrow","width","height","fillColor","colors","popup","background","subt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AAA,EAAA,EAAA,EAAA;UAAAkF,QAAA,eAE3CH,GAAA,CAACqB,cAAc,EAAA;AACbxH,YAAAA,KAAK,EAAEA,KAAM;AACbC,YAAAA,YAAY,EAAEA,YAAa;AAC3BC,YAAAA,MAAM,EAAEA,MAAO;AACf+G,YAAAA,KAAK,EAAElC,MAAO;YACd5B,KAAK,eACHgD,GAAA,CAACsB,UAAU,EAAA;AACTV,cAAAA,GAAG,EAAE5F,QAAS;AACdwC,cAAAA,OAAO,EAAEA,OAAQ;AACjB+D,cAAAA,KAAK,EAAErE,WAAY;AACnBsE,cAAAA,MAAM,EAAEzE,YAAa;cACrB0E,SAAS,EAAE7G,KAAK,CAAC8G,MAAM,CAACC,KAAK,CAACC,UAAU,CAACC,MAAO;cAChDC,WAAW,EAAElH,KAAK,CAAC8G,MAAM,CAACC,KAAK,CAACI,MAAM,CAACF,MAAAA;AAAO,aAC/C,CACF;AAAA1B,YAAAA,QAAA,EAEAvG,OAAAA;WACa,CAAA;AAAC,SAAA,CACV,CAAC,gBAEVoG,GAAA,CAAAgC,QAAA,EAAI,EAAA,CAAA;OAEc,CAAA;KACR,CAAA;AAAC,GACM,CAAC,CAAA;AAE9B;;;;"}
|
|
@@ -5,7 +5,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
5
5
|
import { useToaster, resolveValue } from 'react-hot-toast';
|
|
6
6
|
import React__default from 'react';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
|
-
import { PEEKS, MAX_TOASTS, MIN_TOAST_MOBILE, MIN_TOAST_DESKTOP, CONTAINER_GUTTER_MOBILE, CONTAINER_GUTTER_DESKTOP, GUTTER, SCALE_FACTOR, PEEK_GUTTER,
|
|
8
|
+
import { PEEKS, MAX_TOASTS, MIN_TOAST_MOBILE, MIN_TOAST_DESKTOP, CONTAINER_GUTTER_MOBILE, CONTAINER_GUTTER_DESKTOP, TOAST_Z_INDEX, GUTTER, SCALE_FACTOR, PEEK_GUTTER, TOAST_MAX_WIDTH } from './constants.js';
|
|
9
9
|
import '../../utils/index.js';
|
|
10
10
|
import '../Box/BaseBox/index.js';
|
|
11
11
|
import { useIsMobile } from '../../utils/useIsMobile.js';
|
|
@@ -20,7 +20,7 @@ import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
|
|
|
20
20
|
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
21
21
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
22
22
|
|
|
23
|
-
var _excluded = ["reverseOrder", "position", "offsetBottom", "toastOptions", "containerClassName"];
|
|
23
|
+
var _excluded = ["reverseOrder", "position", "offsetBottom", "zIndex", "toastOptions", "containerClassName"];
|
|
24
24
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
25
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
26
26
|
var StyledToastWrapper = /*#__PURE__*/styled(BaseBox).withConfig({
|
|
@@ -81,6 +81,7 @@ var Toaster = function Toaster(_ref2) {
|
|
|
81
81
|
_ref2$position = _ref2.position,
|
|
82
82
|
position = _ref2$position === void 0 ? 'top-center' : _ref2$position,
|
|
83
83
|
offsetBottom = _ref2.offsetBottom,
|
|
84
|
+
zIndex = _ref2.zIndex,
|
|
84
85
|
toastOptions = _ref2.toastOptions,
|
|
85
86
|
containerClassName = _ref2.containerClassName,
|
|
86
87
|
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
@@ -119,6 +120,9 @@ var Toaster = function Toaster(_ref2) {
|
|
|
119
120
|
var hasPromoToast = promoToasts.length > 0 && ((_promoToasts$ = promoToasts[0]) === null || _promoToasts$ === void 0 ? void 0 : _promoToasts$.visible);
|
|
120
121
|
var promoToastHeight = (_promoToasts$0$height = (_promoToasts$2 = promoToasts[0]) === null || _promoToasts$2 === void 0 ? void 0 : _promoToasts$2.height) !== null && _promoToasts$0$height !== void 0 ? _promoToasts$0$height : 0;
|
|
121
122
|
var isExpanded = hasManuallyExpanded || recomputedToasts.length <= minToasts;
|
|
123
|
+
|
|
124
|
+
// Use container zIndex if provided, otherwise use default
|
|
125
|
+
var containerZIndex = zIndex !== null && zIndex !== void 0 ? zIndex : TOAST_Z_INDEX;
|
|
122
126
|
React__default.useLayoutEffect(function () {
|
|
123
127
|
// find the first toast which is visible
|
|
124
128
|
var firstToast = infoToasts.find(function (t, index) {
|
|
@@ -220,7 +224,7 @@ var Toaster = function Toaster(_ref2) {
|
|
|
220
224
|
};
|
|
221
225
|
return /*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread(_objectSpread({
|
|
222
226
|
position: "fixed",
|
|
223
|
-
zIndex:
|
|
227
|
+
zIndex: containerZIndex,
|
|
224
228
|
top: makeSize(defaultGutter),
|
|
225
229
|
left: makeSize(defaultGutter),
|
|
226
230
|
right: makeSize(defaultGutter),
|
|
@@ -272,6 +276,10 @@ var Toaster = function Toaster(_ref2) {
|
|
|
272
276
|
if (isExpanded) {
|
|
273
277
|
toastHeight = toast.height;
|
|
274
278
|
}
|
|
279
|
+
|
|
280
|
+
// Maintain relative stacking order (newer toasts in front)
|
|
281
|
+
// Use -1 * index so newer toasts (lower index) have higher z-index values
|
|
282
|
+
var wrapperZIndex = -1 * index;
|
|
275
283
|
return /*#__PURE__*/jsx(StyledToastWrapper, {
|
|
276
284
|
index: index,
|
|
277
285
|
ref: ref,
|
|
@@ -279,7 +287,7 @@ var Toaster = function Toaster(_ref2) {
|
|
|
279
287
|
isVisible: toast.visible,
|
|
280
288
|
isPromotional: isPromotional,
|
|
281
289
|
style: _objectSpread(_objectSpread({}, positionStyle), {}, {
|
|
282
|
-
zIndex:
|
|
290
|
+
zIndex: wrapperZIndex,
|
|
283
291
|
height: toastHeight,
|
|
284
292
|
overflow: 'hidden'
|
|
285
293
|
}),
|
|
@@ -307,9 +315,11 @@ var Toaster = function Toaster(_ref2) {
|
|
|
307
315
|
}));
|
|
308
316
|
};
|
|
309
317
|
var ToastContainer = function ToastContainer(_ref4) {
|
|
310
|
-
var offsetBottom = _ref4.offsetBottom
|
|
318
|
+
var offsetBottom = _ref4.offsetBottom,
|
|
319
|
+
zIndex = _ref4.zIndex;
|
|
311
320
|
return /*#__PURE__*/jsx(Toaster, {
|
|
312
321
|
offsetBottom: offsetBottom,
|
|
322
|
+
zIndex: zIndex,
|
|
313
323
|
position: "bottom-left"
|
|
314
324
|
});
|
|
315
325
|
};
|