@fluentui/react-popover 0.0.0-nightly-20230316-0427.1 → 0.0.0-nightly-20230317-1454.1

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.
Files changed (91) hide show
  1. package/.swcrc +39 -0
  2. package/CHANGELOG.json +68 -23
  3. package/CHANGELOG.md +28 -14
  4. package/lib/Popover.js +1 -1
  5. package/lib/Popover.js.map +1 -1
  6. package/lib/PopoverSurface.js +1 -1
  7. package/lib/PopoverSurface.js.map +1 -1
  8. package/lib/PopoverTrigger.js +1 -1
  9. package/lib/PopoverTrigger.js.map +1 -1
  10. package/lib/components/Popover/Popover.js +4 -3
  11. package/lib/components/Popover/Popover.js.map +1 -1
  12. package/lib/components/Popover/Popover.types.js +1 -1
  13. package/lib/components/Popover/Popover.types.js.map +1 -1
  14. package/lib/components/Popover/constants.js +1 -2
  15. package/lib/components/Popover/constants.js.map +1 -1
  16. package/lib/components/Popover/index.js +4 -4
  17. package/lib/components/Popover/index.js.map +1 -1
  18. package/lib/components/Popover/renderPopover.js +2 -2
  19. package/lib/components/Popover/renderPopover.js.map +1 -1
  20. package/lib/components/Popover/usePopover.js +22 -28
  21. package/lib/components/Popover/usePopover.js.map +1 -1
  22. package/lib/components/PopoverSurface/PopoverSurface.js +6 -6
  23. package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
  24. package/lib/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  25. package/lib/components/PopoverSurface/index.js +5 -5
  26. package/lib/components/PopoverSurface/index.js.map +1 -1
  27. package/lib/components/PopoverSurface/renderPopoverSurface.js +4 -6
  28. package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  29. package/lib/components/PopoverSurface/usePopoverSurface.js +12 -12
  30. package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  31. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +6 -6
  32. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  33. package/lib/components/PopoverTrigger/PopoverTrigger.js +4 -3
  34. package/lib/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
  35. package/lib/components/PopoverTrigger/PopoverTrigger.types.js +1 -1
  36. package/lib/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
  37. package/lib/components/PopoverTrigger/index.js +4 -4
  38. package/lib/components/PopoverTrigger/index.js.map +1 -1
  39. package/lib/components/PopoverTrigger/renderPopoverTrigger.js +1 -2
  40. package/lib/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
  41. package/lib/components/PopoverTrigger/usePopoverTrigger.js +16 -15
  42. package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  43. package/lib/index.js +4 -4
  44. package/lib/index.js.map +1 -1
  45. package/lib/popoverContext.js +2 -2
  46. package/lib/popoverContext.js.map +1 -1
  47. package/lib-commonjs/Popover.js +5 -4
  48. package/lib-commonjs/Popover.js.map +1 -1
  49. package/lib-commonjs/PopoverSurface.js +5 -4
  50. package/lib-commonjs/PopoverSurface.js.map +1 -1
  51. package/lib-commonjs/PopoverTrigger.js +5 -4
  52. package/lib-commonjs/PopoverTrigger.js.map +1 -1
  53. package/lib-commonjs/components/Popover/Popover.js +14 -13
  54. package/lib-commonjs/components/Popover/Popover.js.map +1 -1
  55. package/lib-commonjs/components/Popover/Popover.types.js +5 -2
  56. package/lib-commonjs/components/Popover/Popover.types.js.map +1 -1
  57. package/lib-commonjs/components/Popover/constants.js +10 -8
  58. package/lib-commonjs/components/Popover/constants.js.map +1 -1
  59. package/lib-commonjs/components/Popover/index.js +8 -7
  60. package/lib-commonjs/components/Popover/index.js.map +1 -1
  61. package/lib-commonjs/components/Popover/renderPopover.js +31 -47
  62. package/lib-commonjs/components/Popover/renderPopover.js.map +1 -1
  63. package/lib-commonjs/components/Popover/usePopover.js +173 -173
  64. package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
  65. package/lib-commonjs/components/PopoverSurface/PopoverSurface.js +19 -20
  66. package/lib-commonjs/components/PopoverSurface/PopoverSurface.js.map +1 -1
  67. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.js +3 -2
  68. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  69. package/lib-commonjs/components/PopoverSurface/index.js +9 -8
  70. package/lib-commonjs/components/PopoverSurface/index.js.map +1 -1
  71. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +23 -28
  72. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  73. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +69 -81
  74. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  75. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +243 -113
  76. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  77. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js +15 -14
  78. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
  79. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.js +5 -2
  80. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
  81. package/lib-commonjs/components/PopoverTrigger/index.js +8 -7
  82. package/lib-commonjs/components/PopoverTrigger/index.js.map +1 -1
  83. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js +12 -11
  84. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
  85. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +71 -80
  86. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  87. package/lib-commonjs/index.js +30 -92
  88. package/lib-commonjs/index.js.map +1 -1
  89. package/lib-commonjs/popoverContext.js +34 -25
  90. package/lib-commonjs/popoverContext.js.map +1 -1
  91. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"names":["React","require","react_utilities_1","react_shared_contexts_1","react_positioning_1","react_portal_1","react_tabster_1","index_1","constants_1","usePopover_unstable","props","contextTarget","setContextTarget","usePositioningMouseTarget","initialState","size","children","Children","toArray","process","env","NODE_ENV","length","console","warn","popoverTrigger","undefined","popoverSurface","open","setOpenState","useOpenState","setOpenTimeoutRef","useRef","setOpen","useEventCallback","e","shouldOpen","clearTimeout","current","Event","persist","type","setTimeout","_a","mouseLeaveDelay","useEffect","toggleOpen","useCallback","positioningRefs","usePopoverRefs","targetDocument","useFluent_unstable","useOnClickOutside","contains","elementContains","element","callback","ev","refs","triggerRef","contentRef","disabled","closeOnScroll","openOnContext","useOnScrollOutside","findFirstFocusable","useFocusFinders","unstable_disableAutoFocus","containerTabIndex","getAttribute","firstFocusable","isNaN","focus","inline","exports","state","onOpenChange","data","call","useControllableState","defaultState","defaultOpen","positioningOptions","position","align","arrowPadding","popoverSurfaceBorderRadius","target","resolvePositioningShorthand","positioning","coverTarget","withArrow","offset","mergeArrowOffset","arrowHeights","targetRef","containerRef","arrowRef","usePositioning"],"sources":["../../../../../../../../../packages/react-components/react-popover/src/components/Popover/usePopover.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n useControllableState,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePositioning,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePositioningMouseTarget,\n} from '@fluentui/react-positioning';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { OpenPopoverEvents, PopoverProps, PopoverState } from './Popover.types';\nimport { popoverSurfaceBorderRadius } from './constants';\n\n/**\n * Create the state required to render Popover.\n *\n * The returned state can be modified with hooks such as usePopoverStyles,\n * before being passed to renderPopover_unstable.\n *\n * @param props - props from this instance of Popover\n */\nexport const usePopover_unstable = (props: PopoverProps): PopoverState => {\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n const initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at most two children');\n }\n }\n\n let popoverTrigger: React.ReactElement | undefined = undefined;\n let popoverSurface: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n popoverTrigger = children[0];\n popoverSurface = children[1];\n } else if (children.length === 1) {\n popoverSurface = children[0];\n }\n\n const [open, setOpenState] = useOpenState(initialState);\n\n const setOpenTimeoutRef = React.useRef(0);\n\n const setOpen = useEventCallback((e: OpenPopoverEvents, shouldOpen: boolean) => {\n clearTimeout(setOpenTimeoutRef.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave') {\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeoutRef.current = setTimeout(() => {\n setOpenState(e, shouldOpen);\n }, props.mouseLeaveDelay ?? 500);\n } else {\n setOpenState(e, shouldOpen);\n }\n });\n\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeoutRef.current);\n };\n }, []);\n\n const toggleOpen = React.useCallback<PopoverState['toggleOpen']>(\n e => {\n setOpen(e, !open);\n },\n [setOpen, open],\n );\n\n const positioningRefs = usePopoverRefs(initialState);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open,\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open || !closeOnScroll,\n });\n\n const { findFirstFocusable } = useFocusFinders();\n\n React.useEffect(() => {\n if (props.unstable_disableAutoFocus) {\n return;\n }\n\n if (open && positioningRefs.contentRef.current) {\n const containerTabIndex = positioningRefs.contentRef.current.getAttribute('tabIndex') ?? undefined;\n const firstFocusable = isNaN(containerTabIndex)\n ? findFirstFocusable(positioningRefs.contentRef.current)\n : positioningRefs.contentRef.current;\n firstFocusable?.focus();\n }\n }, [findFirstFocusable, open, positioningRefs.contentRef, props.unstable_disableAutoFocus]);\n\n return {\n ...initialState,\n ...positioningRefs,\n popoverTrigger,\n popoverSurface,\n open,\n setOpen,\n toggleOpen,\n setContextTarget,\n contextTarget,\n inline: props.inline ?? false,\n };\n};\n\n/**\n * Creates and manages the Popover open state\n */\nfunction useOpenState(\n state: Pick<PopoverState, 'setContextTarget' | 'onOpenChange'> & Pick<PopoverProps, 'open' | 'defaultOpen'>,\n) {\n const onOpenChange: PopoverState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n\n const setOpen = React.useCallback(\n (e: OpenPopoverEvents, shouldOpen: boolean) => {\n if (shouldOpen && e.type === 'contextmenu') {\n setContextTarget(e as React.MouseEvent);\n }\n\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n\n setOpenState(shouldOpen);\n onOpenChange?.(e, { open: shouldOpen });\n },\n [setOpenState, onOpenChange, setContextTarget],\n );\n\n return [open, setOpen] as const;\n}\n\n/**\n * Creates and sets the necessary trigger, target and content refs used by Popover\n */\nfunction usePopoverRefs(\n state: Pick<PopoverState, 'size' | 'contextTarget'> &\n Pick<PopoverProps, 'positioning' | 'openOnContext' | 'withArrow'>,\n) {\n const positioningOptions = {\n position: 'above' as const,\n align: 'center' as const,\n arrowPadding: 2 * popoverSurfaceBorderRadius,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (positioningOptions.coverTarget) {\n state.withArrow = false;\n }\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeights[state.size]);\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePositioning(positioningOptions);\n\n return {\n triggerRef,\n contentRef,\n arrowRef,\n } as const;\n}\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,iBAAA,gBAAAD,OAAA;AAMA,MAAAE,uBAAA,gBAAAF,OAAA;AACA,MAAAG,mBAAA,gBAAAH,OAAA;AAMA,MAAAI,cAAA,gBAAAJ,OAAA;AACA,MAAAK,eAAA,gBAAAL,OAAA;AACA,MAAAM,OAAA,gBAAAN,OAAA;AAEA,MAAAO,WAAA,gBAAAP,OAAA;AAEA;;;;;;;;AAQO,MAAMQ,mBAAmB,GAAIC,KAAmB,IAAkB;;EACvE,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGR,mBAAA,CAAAS,yBAAyB,EAAE;EACrE,MAAMC,YAAY,GAAG;IACnBC,IAAI,EAAE,QAAQ;IACdJ,aAAa;IACbC,gBAAgB;IAChB,GAAGF;GACK;EAEV,MAAMM,QAAQ,GAAGhB,KAAK,CAACiB,QAAQ,CAACC,OAAO,CAACR,KAAK,CAACM,QAAQ,CAAyB;EAE/E,IAAIG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,IAAIL,QAAQ,CAACM,MAAM,KAAK,CAAC,EAAE;MACzB;MACAC,OAAO,CAACC,IAAI,CAAC,yCAAyC,CAAC;;IAGzD,IAAIR,QAAQ,CAACM,MAAM,GAAG,CAAC,EAAE;MACvB;MACAC,OAAO,CAACC,I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,mBAAA,CAAAyF,gBAAgB,CAACX,kBAAkB,CAACU,MAAM,EAAErF,OAAA,CAAAuF,YAAY,CAACnB,KAAK,CAAC5D,IAAI,CAAC,CAAC;;EAGnG,MAAM;IAAEgF,SAAS,EAAEpC,UAAU;IAAEqC,YAAY,EAAEpC,UAAU;IAAEqC;EAAQ,CAAE,GAAG7F,mBAAA,CAAA8F,cAAc,CAAChB,kBAAkB,CAAC;EAExG,OAAO;IACLvB,UAAU;IACVC,UAAU;IACVqC;GACQ;AACZ"}
1
+ {"version":3,"sources":["../../../lib/components/Popover/usePopover.js"],"sourcesContent":["import * as React from \"react\";\nimport { useControllableState, useEventCallback, useOnClickOutside, useOnScrollOutside } from \"@fluentui/react-utilities\";\nimport { useFluent_unstable as useFluent } from \"@fluentui/react-shared-contexts\";\nimport { usePositioning, resolvePositioningShorthand, mergeArrowOffset, usePositioningMouseTarget } from \"@fluentui/react-positioning\";\nimport { elementContains } from \"@fluentui/react-portal\";\nimport { useFocusFinders } from \"@fluentui/react-tabster\";\nimport { arrowHeights } from \"../PopoverSurface/index\";\nimport { popoverSurfaceBorderRadius } from \"./constants\";\n/**\n * Create the state required to render Popover.\n *\n * The returned state can be modified with hooks such as usePopoverStyles,\n * before being passed to renderPopover_unstable.\n *\n * @param props - props from this instance of Popover\n */\nexport const usePopover_unstable = props => {\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n const initialState = {\n size: \"medium\",\n contextTarget,\n setContextTarget,\n ...props\n };\n const children = React.Children.toArray(props.children);\n if (process.env.NODE_ENV !== \"production\") {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn(\"Popover must contain at least one child\");\n }\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn(\"Popover must contain at most two children\");\n }\n }\n let popoverTrigger = undefined;\n let popoverSurface = undefined;\n if (children.length === 2) {\n popoverTrigger = children[0];\n popoverSurface = children[1];\n } else if (children.length === 1) {\n popoverSurface = children[0];\n }\n const [open, setOpenState] = useOpenState(initialState);\n const setOpenTimeoutRef = React.useRef(0);\n const setOpen = useEventCallback((e, shouldOpen) => {\n clearTimeout(setOpenTimeoutRef.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n if (e.type === \"mouseleave\") {\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeoutRef.current = setTimeout(() => {\n setOpenState(e, shouldOpen);\n }, props.mouseLeaveDelay ?? 500);\n } else {\n setOpenState(e, shouldOpen);\n }\n });\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeoutRef.current);\n };\n }, []);\n const toggleOpen = React.useCallback(e => {\n setOpen(e, !open);\n }, [setOpen, open]);\n const positioningRefs = usePopoverRefs(initialState);\n const {\n targetDocument\n } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open\n });\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open || !closeOnScroll\n });\n const {\n findFirstFocusable\n } = useFocusFinders();\n React.useEffect(() => {\n if (props.unstable_disableAutoFocus) {\n return;\n }\n if (open && positioningRefs.contentRef.current) {\n const containerTabIndex = positioningRefs.contentRef.current.getAttribute(\"tabIndex\") ?? undefined;\n const firstFocusable = isNaN(containerTabIndex) ? findFirstFocusable(positioningRefs.contentRef.current) : positioningRefs.contentRef.current;\n firstFocusable?.focus();\n }\n }, [findFirstFocusable, open, positioningRefs.contentRef, props.unstable_disableAutoFocus]);\n return {\n ...initialState,\n ...positioningRefs,\n popoverTrigger,\n popoverSurface,\n open,\n setOpen,\n toggleOpen,\n setContextTarget,\n contextTarget,\n inline: props.inline ?? false\n };\n};\n/**\n * Creates and manages the Popover open state\n */\nfunction useOpenState(state) {\n const onOpenChange = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false\n });\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n const setOpen = React.useCallback((e, shouldOpen) => {\n if (shouldOpen && e.type === \"contextmenu\") {\n setContextTarget(e);\n }\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n setOpenState(shouldOpen);\n onOpenChange?.(e, {\n open: shouldOpen\n });\n }, [setOpenState, onOpenChange, setContextTarget]);\n return [open, setOpen];\n}\n/**\n * Creates and sets the necessary trigger, target and content refs used by Popover\n */\nfunction usePopoverRefs(state) {\n const positioningOptions = {\n position: \"above\",\n align: \"center\",\n arrowPadding: 2 * popoverSurfaceBorderRadius,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning)\n };\n // no reason to render arrow when covering the target\n if (positioningOptions.coverTarget) {\n state.withArrow = false;\n }\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeights[state.size]);\n }\n const {\n targetRef: triggerRef,\n containerRef: contentRef,\n arrowRef\n } = usePositioning(positioningOptions);\n return {\n triggerRef,\n contentRef,\n arrowRef\n };\n}\n//# sourceMappingURL=usePopover.js.map"],"names":["usePopover_unstable","props","contextTarget","setContextTarget","usePositioningMouseTarget","initialState","size","children","React","Children","toArray","process","env","NODE_ENV","length","console","warn","popoverTrigger","undefined","popoverSurface","open","setOpenState","useOpenState","setOpenTimeoutRef","useRef","setOpen","useEventCallback","e","shouldOpen","clearTimeout","current","Event","persist","type","setTimeout","mouseLeaveDelay","useEffect","toggleOpen","useCallback","positioningRefs","usePopoverRefs","targetDocument","useFluent","useOnClickOutside","contains","elementContains","element","callback","ev","refs","triggerRef","contentRef","disabled","closeOnScroll","openOnContext","useOnScrollOutside","findFirstFocusable","useFocusFinders","unstable_disableAutoFocus","containerTabIndex","getAttribute","firstFocusable","isNaN","focus","inline","state","onOpenChange","data","useControllableState","defaultState","defaultOpen","positioningOptions","position","align","arrowPadding","popoverSurfaceBorderRadius","target","resolvePositioningShorthand","positioning","coverTarget","withArrow","offset","mergeArrowOffset","arrowHeights","targetRef","containerRef","arrowRef","usePositioning"],"mappings":";;;;+BAgBaA;;aAAAA;;;6DAhBU;gCACuE;qCAC9C;kCACyD;6BACzE;8BACA;uBACH;2BACc;AASpC,MAAMA,sBAAsBC,CAAAA,QAAS;IAC1C,MAAM,CAACC,eAAeC,iBAAiB,GAAGC,IAAAA,2CAAyB;IACnE,MAAMC,eAAe;QACnBC,MAAM;QACNJ;QACAC;QACA,GAAGF,KAAK;IACV;IACA,MAAMM,WAAWC,OAAMC,QAAQ,CAACC,OAAO,CAACT,MAAMM,QAAQ;IACtD,IAAII,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAIN,SAASO,MAAM,KAAK,GAAG;YACzB,sCAAsC;YACtCC,QAAQC,IAAI,CAAC;QACf,CAAC;QACD,IAAIT,SAASO,MAAM,GAAG,GAAG;YACvB,sCAAsC;YACtCC,QAAQC,IAAI,CAAC;QACf,CAAC;IACH,CAAC;IACD,IAAIC,iBAAiBC;IACrB,IAAIC,iBAAiBD;IACrB,IAAIX,SAASO,MAAM,KAAK,GAAG;QACzBG,iBAAiBV,QAAQ,CAAC,EAAE;QAC5BY,iBAAiBZ,QAAQ,CAAC,EAAE;IAC9B,OAAO,IAAIA,SAASO,MAAM,KAAK,GAAG;QAChCK,iBAAiBZ,QAAQ,CAAC,EAAE;IAC9B,CAAC;IACD,MAAM,CAACa,MAAMC,aAAa,GAAGC,aAAajB;IAC1C,MAAMkB,oBAAoBf,OAAMgB,MAAM,CAAC;IACvC,MAAMC,UAAUC,IAAAA,gCAAgB,EAAC,CAACC,GAAGC,aAAe;QAClDC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C,eAAevC,GAAG;YAChBP,MAAMQ;QACR;IACF,GAAG;QAACP;QAAc6C;QAAc/D;KAAiB;IACjD,OAAO;QAACiB;QAAMK;KAAQ;AACxB;AACA;;CAEC,GACD,SAASe,eAAeyB,KAAK,EAAE;IAC7B,MAAMM,qBAAqB;QACzBC,UAAU;QACVC,OAAO;QACPC,cAAc,IAAIC,qCAA0B;QAC5CC,QAAQX,MAAMX,aAAa,GAAGW,MAAM/D,aAAa,GAAGgB,SAAS;QAC7D,GAAG2D,IAAAA,6CAA2B,EAACZ,MAAMa,WAAW,CAAC;IACnD;IACA,qDAAqD;IACrD,IAAIP,mBAAmBQ,WAAW,EAAE;QAClCd,MAAMe,SAAS,GAAG,KAAK;IACzB,CAAC;IACD,IAAIf,MAAMe,SAAS,EAAE;QACnBT,mBAAmBU,MAAM,GAAGC,IAAAA,kCAAgB,EAACX,mBAAmBU,MAAM,EAAEE,mBAAY,CAAClB,MAAM3D,IAAI,CAAC;IAClG,CAAC;IACD,MAAM,EACJ8E,WAAWlC,WAAU,EACrBmC,cAAclC,WAAU,EACxBmC,SAAQ,EACT,GAAGC,IAAAA,gCAAc,EAAChB;IACnB,OAAO;QACLrB;QACAC;QACAmC;IACF;AACF,EACA,sCAAsC"}
@@ -1,25 +1,24 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "PopoverSurface", {
6
+ enumerable: true,
7
+ get: ()=>PopoverSurface
5
8
  });
6
- exports.PopoverSurface = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const usePopoverSurface_1 = /*#__PURE__*/require("./usePopoverSurface");
9
- const renderPopoverSurface_1 = /*#__PURE__*/require("./renderPopoverSurface");
10
- const usePopoverSurfaceStyles_1 = /*#__PURE__*/require("./usePopoverSurfaceStyles");
11
- const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
12
- /**
13
- * PopoverSurface component renders react children in a positioned box
14
- */
15
- exports.PopoverSurface = /*#__PURE__*/React.forwardRef((props, ref) => {
16
- const state = usePopoverSurface_1.usePopoverSurface_unstable(props, ref);
17
- usePopoverSurfaceStyles_1.usePopoverSurfaceStyles_unstable(state);
18
- const {
19
- usePopoverSurfaceStyles_unstable: useCustomStyles
20
- } = react_shared_contexts_1.useCustomStyleHooks_unstable();
21
- useCustomStyles(state);
22
- return renderPopoverSurface_1.renderPopoverSurface_unstable(state);
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _usePopoverSurface = require("./usePopoverSurface");
12
+ const _renderPopoverSurface = require("./renderPopoverSurface");
13
+ const _usePopoverSurfaceStyles = require("./usePopoverSurfaceStyles");
14
+ const _reactSharedContexts = require("@fluentui/react-shared-contexts");
15
+ const PopoverSurface = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
16
+ const state = (0, _usePopoverSurface.usePopoverSurface_unstable)(props, ref);
17
+ (0, _usePopoverSurfaceStyles.usePopoverSurfaceStyles_unstable)(state);
18
+ const { usePopoverSurfaceStyles_unstable: useCustomStyles } = (0, _reactSharedContexts.useCustomStyleHooks_unstable)();
19
+ useCustomStyles(state);
20
+ return (0, _renderPopoverSurface.renderPopoverSurface_unstable)(state);
23
21
  });
24
- exports.PopoverSurface.displayName = 'PopoverSurface';
22
+ PopoverSurface.displayName = "PopoverSurface"; //# sourceMappingURL=PopoverSurface.js.map
23
+
25
24
  //# sourceMappingURL=PopoverSurface.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","require","usePopoverSurface_1","renderPopoverSurface_1","usePopoverSurfaceStyles_1","react_shared_contexts_1","exports","PopoverSurface","forwardRef","props","ref","state","usePopoverSurface_unstable","usePopoverSurfaceStyles_unstable","useCustomStyles","useCustomStyleHooks_unstable","renderPopoverSurface_unstable","displayName"],"sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverSurface/PopoverSurface.tsx"],"sourcesContent":["import * as React from 'react';\nimport { usePopoverSurface_unstable } from './usePopoverSurface';\nimport { renderPopoverSurface_unstable } from './renderPopoverSurface';\nimport { usePopoverSurfaceStyles_unstable } from './usePopoverSurfaceStyles';\nimport type { PopoverSurfaceProps } from './PopoverSurface.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * PopoverSurface component renders react children in a positioned box\n */\nexport const PopoverSurface: ForwardRefComponent<PopoverSurfaceProps> = React.forwardRef((props, ref) => {\n const state = usePopoverSurface_unstable(props, ref);\n\n usePopoverSurfaceStyles_unstable(state);\n\n const { usePopoverSurfaceStyles_unstable: useCustomStyles } = useCustomStyleHooks_unstable();\n useCustomStyles(state);\n\n return renderPopoverSurface_unstable(state);\n});\n\nPopoverSurface.displayName = 'PopoverSurface';\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,mBAAA,gBAAAD,OAAA;AACA,MAAAE,sBAAA,gBAAAF,OAAA;AACA,MAAAG,yBAAA,gBAAAH,OAAA;AAGA,MAAAI,uBAAA,gBAAAJ,OAAA;AAEA;;;AAGaK,OAAA,CAAAC,cAAc,gBAA6CP,KAAK,CAACQ,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EACtG,MAAMC,KAAK,GAAGT,mBAAA,CAAAU,0BAA0B,CAACH,KAAK,EAAEC,GAAG,CAAC;EAEpDN,yBAAA,CAAAS,gCAAgC,CAACF,KAAK,CAAC;EAEvC,MAAM;IAAEE,gCAAgC,EAAEC;EAAe,CAAE,GAAGT,uBAAA,CAAAU,4BAA4B,EAAE;EAC5FD,eAAe,CAACH,KAAK,CAAC;EAEtB,OAAOR,sBAAA,CAAAa,6BAA6B,CAACL,KAAK,CAAC;AAC7C,CAAC,CAAC;AAEFL,OAAA,CAAAC,cAAc,CAACU,WAAW,GAAG,gBAAgB"}
1
+ {"version":3,"sources":["../../../lib/components/PopoverSurface/PopoverSurface.js"],"sourcesContent":["import * as React from \"react\";\nimport { usePopoverSurface_unstable } from \"./usePopoverSurface\";\nimport { renderPopoverSurface_unstable } from \"./renderPopoverSurface\";\nimport { usePopoverSurfaceStyles_unstable } from \"./usePopoverSurfaceStyles\";\nimport { useCustomStyleHooks_unstable } from \"@fluentui/react-shared-contexts\";\n/**\n * PopoverSurface component renders react children in a positioned box\n */\nexport const PopoverSurface = /*#__PURE__*/React.forwardRef((props, ref) => {\n const state = usePopoverSurface_unstable(props, ref);\n usePopoverSurfaceStyles_unstable(state);\n const {\n usePopoverSurfaceStyles_unstable: useCustomStyles\n } = useCustomStyleHooks_unstable();\n useCustomStyles(state);\n return renderPopoverSurface_unstable(state);\n});\nPopoverSurface.displayName = \"PopoverSurface\";\n//# sourceMappingURL=PopoverSurface.js.map"],"names":["PopoverSurface","React","forwardRef","props","ref","state","usePopoverSurface_unstable","usePopoverSurfaceStyles_unstable","useCustomStyles","useCustomStyleHooks_unstable","renderPopoverSurface_unstable","displayName"],"mappings":";;;;+BAQaA;;aAAAA;;;6DARU;mCACoB;sCACG;yCACG;qCACJ;AAItC,MAAMA,iBAAiB,WAAW,GAAEC,OAAMC,UAAU,CAAC,CAACC,OAAOC,MAAQ;IAC1E,MAAMC,QAAQC,IAAAA,6CAA0B,EAACH,OAAOC;IAChDG,IAAAA,yDAAgC,EAACF;IACjC,MAAM,EACJE,kCAAkCC,gBAAe,EAClD,GAAGC,IAAAA,iDAA4B;IAChCD,gBAAgBH;IAChB,OAAOK,IAAAA,mDAA6B,EAACL;AACvC;AACAL,eAAeW,WAAW,GAAG,kBAC7B,0CAA0C"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
5
+ //# sourceMappingURL=PopoverSurface.types.js.map
6
+
6
7
  //# sourceMappingURL=PopoverSurface.types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverSurface/PopoverSurface.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { PopoverContextValue } from '../../popoverContext';\n\n/**\n * PopoverSurface Props\n */\nexport type PopoverSurfaceProps = ComponentProps<PopoverSurfaceSlots>;\n\n/**\n * Names of the slots in PopoverSurfaceProps\n */\nexport type PopoverSurfaceSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * PopoverSurface State\n */\nexport type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> &\n Pick<PopoverContextValue, 'appearance' | 'arrowRef' | 'inline' | 'mountNode' | 'size' | 'withArrow'> & {\n /**\n * CSS class for the arrow element\n */\n arrowClassName?: string;\n };\n"],"mappings":""}
1
+ {"version":3,"sources":["../../../lib/components/PopoverSurface/PopoverSurface.types.js"],"sourcesContent":["export {};\n//# sourceMappingURL=PopoverSurface.types.js.map"],"names":[],"mappings":";;;;CACA,gDAAgD"}
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- const tslib_1 = /*#__PURE__*/require("tslib");
7
- tslib_1.__exportStar(require("./PopoverSurface"), exports);
8
- tslib_1.__exportStar(require("./PopoverSurface.types"), exports);
9
- tslib_1.__exportStar(require("./renderPopoverSurface"), exports);
10
- tslib_1.__exportStar(require("./usePopoverSurface"), exports);
11
- tslib_1.__exportStar(require("./usePopoverSurfaceStyles"), exports);
5
+ const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
+ _exportStar(require("./PopoverSurface"), exports);
7
+ _exportStar(require("./PopoverSurface.types"), exports);
8
+ _exportStar(require("./renderPopoverSurface"), exports);
9
+ _exportStar(require("./usePopoverSurface"), exports);
10
+ _exportStar(require("./usePopoverSurfaceStyles"), exports);
11
+ //# sourceMappingURL=index.js.map
12
+
12
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverSurface/index.ts"],"sourcesContent":["export * from './PopoverSurface';\nexport * from './PopoverSurface.types';\nexport * from './renderPopoverSurface';\nexport * from './usePopoverSurface';\nexport * from './usePopoverSurfaceStyles';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,sBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,4BAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,4BAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,yBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,+BAAAC,OAAA"}
1
+ {"version":3,"sources":["../../../lib/components/PopoverSurface/index.js"],"sourcesContent":["export * from \"./PopoverSurface\";\nexport * from \"./PopoverSurface.types\";\nexport * from \"./renderPopoverSurface\";\nexport * from \"./usePopoverSurface\";\nexport * from \"./usePopoverSurfaceStyles\";\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;CACd,iCAAiC"}
@@ -1,32 +1,27 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "renderPopoverSurface_unstable", {
6
+ enumerable: true,
7
+ get: ()=>renderPopoverSurface_unstable
5
8
  });
6
- exports.renderPopoverSurface_unstable = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
9
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
10
- /**
11
- * Render the final JSX of PopoverSurface
12
- */
13
- const renderPopoverSurface_unstable = state => {
14
- const {
15
- slots,
16
- slotProps
17
- } = react_utilities_1.getSlots(state);
18
- const surface = React.createElement(slots.root, {
19
- ...slotProps.root
20
- }, state.withArrow && React.createElement("div", {
21
- ref: state.arrowRef,
22
- className: state.arrowClassName
23
- }), slotProps.root.children);
24
- if (state.inline) {
25
- return surface;
26
- }
27
- return React.createElement(react_portal_1.Portal, {
28
- mountNode: state.mountNode
29
- }, surface);
30
- };
31
- exports.renderPopoverSurface_unstable = renderPopoverSurface_unstable;
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _reactPortal = require("@fluentui/react-portal");
12
+ const _reactUtilities = require("@fluentui/react-utilities");
13
+ const renderPopoverSurface_unstable = (state)=>{
14
+ const { slots , slotProps } = (0, _reactUtilities.getSlots)(state);
15
+ const surface = /*#__PURE__*/ _react.createElement(slots.root, slotProps.root, state.withArrow && /*#__PURE__*/ _react.createElement("div", {
16
+ ref: state.arrowRef,
17
+ className: state.arrowClassName
18
+ }), slotProps.root.children);
19
+ if (state.inline) {
20
+ return surface;
21
+ }
22
+ return /*#__PURE__*/ _react.createElement(_reactPortal.Portal, {
23
+ mountNode: state.mountNode
24
+ }, surface);
25
+ }; //# sourceMappingURL=renderPopoverSurface.js.map
26
+
32
27
  //# sourceMappingURL=renderPopoverSurface.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","require","react_portal_1","react_utilities_1","renderPopoverSurface_unstable","state","slots","slotProps","getSlots","surface","createElement","root","withArrow","ref","arrowRef","className","arrowClassName","children","inline","Portal","mountNode","exports"],"sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverSurface/renderPopoverSurface.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { PopoverSurfaceSlots, PopoverSurfaceState } from './PopoverSurface.types';\n\n/**\n * Render the final JSX of PopoverSurface\n */\nexport const renderPopoverSurface_unstable = (state: PopoverSurfaceState) => {\n const { slots, slotProps } = getSlots<PopoverSurfaceSlots>(state);\n\n const surface = (\n <slots.root {...slotProps.root}>\n {state.withArrow && <div ref={state.arrowRef} className={state.arrowClassName} />}\n {slotProps.root.children}\n </slots.root>\n );\n\n if (state.inline) {\n return surface;\n }\n\n return <Portal mountNode={state.mountNode}>{surface}</Portal>;\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,cAAA,gBAAAD,OAAA;AACA,MAAAE,iBAAA,gBAAAF,OAAA;AAGA;;;AAGO,MAAMG,6BAA6B,GAAIC,KAA0B,IAAI;EAC1E,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGJ,iBAAA,CAAAK,QAAQ,CAAsBH,KAAK,CAAC;EAEjE,MAAMI,OAAO,GACXT,KAAA,CAAAU,aAAA,CAACJ,KAAK,CAACK,IAAI;IAAA,GAAKJ,SAAS,CAACI;EAAI,GAC3BN,KAAK,CAACO,SAAS,IAAIZ,KAAA,CAAAU,aAAA;IAAKG,GAAG,EAAER,KAAK,CAACS,QAAQ;IAAEC,SAAS,EAAEV,KAAK,CAACW;EAAc,EAAI,EAChFT,SAAS,CAACI,IAAI,CAACM,QAAQ,CAE3B;EAED,IAAIZ,KAAK,CAACa,MAAM,EAAE;IAChB,OAAOT,OAAO;;EAGhB,OAAOT,KAAA,CAAAU,aAAA,CAACR,cAAA,CAAAiB,MAAM;IAACC,SAAS,EAAEf,KAAK,CAACe;EAAS,GAAGX,OAAO,CAAU;AAC/D,CAAC;AAfYY,OAAA,CAAAjB,6BAA6B,GAAAA,6BAAA"}
1
+ {"version":3,"sources":["../../../lib/components/PopoverSurface/renderPopoverSurface.js"],"sourcesContent":["import * as React from \"react\";\nimport { Portal } from \"@fluentui/react-portal\";\nimport { getSlots } from \"@fluentui/react-utilities\";\n/**\n * Render the final JSX of PopoverSurface\n */\nexport const renderPopoverSurface_unstable = state => {\n const {\n slots,\n slotProps\n } = getSlots(state);\n const surface = /*#__PURE__*/React.createElement(slots.root, slotProps.root, state.withArrow && /*#__PURE__*/React.createElement(\"div\", {\n ref: state.arrowRef,\n className: state.arrowClassName\n }), slotProps.root.children);\n if (state.inline) {\n return surface;\n }\n return /*#__PURE__*/React.createElement(Portal, {\n mountNode: state.mountNode\n }, surface);\n};\n//# sourceMappingURL=renderPopoverSurface.js.map"],"names":["renderPopoverSurface_unstable","state","slots","slotProps","getSlots","surface","React","createElement","root","withArrow","ref","arrowRef","className","arrowClassName","children","inline","Portal","mountNode"],"mappings":";;;;+BAMaA;;aAAAA;;;6DANU;6BACA;gCACE;AAIlB,MAAMA,gCAAgCC,CAAAA,QAAS;IACpD,MAAM,EACJC,MAAK,EACLC,UAAS,EACV,GAAGC,IAAAA,wBAAQ,EAACH;IACb,MAAMI,UAAU,WAAW,GAAEC,OAAMC,aAAa,CAACL,MAAMM,IAAI,EAAEL,UAAUK,IAAI,EAAEP,MAAMQ,SAAS,IAAI,WAAW,GAAEH,OAAMC,aAAa,CAAC,OAAO;QACtIG,KAAKT,MAAMU,QAAQ;QACnBC,WAAWX,MAAMY,cAAc;IACjC,IAAIV,UAAUK,IAAI,CAACM,QAAQ;IAC3B,IAAIb,MAAMc,MAAM,EAAE;QAChB,OAAOV;IACT,CAAC;IACD,OAAO,WAAW,GAAEC,OAAMC,aAAa,CAACS,mBAAM,EAAE;QAC9CC,WAAWhB,MAAMgB,SAAS;IAC5B,GAAGZ;AACL,GACA,gDAAgD"}
@@ -1,85 +1,73 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "usePopoverSurface_unstable", {
6
+ enumerable: true,
7
+ get: ()=>usePopoverSurface_unstable
5
8
  });
6
- exports.usePopoverSurface_unstable = void 0;
7
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
8
- const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
9
- const popoverContext_1 = /*#__PURE__*/require("../../popoverContext");
10
- /**
11
- * Create the state required to render PopoverSurface.
12
- *
13
- * The returned state can be modified with hooks such as usePopoverSurfaceStyles_unstable,
14
- * before being passed to renderPopoverSurface_unstable.
15
- *
16
- * @param props - props from this instance of PopoverSurface
17
- * @param ref - reference to root HTMLDivElement of PopoverSurface
18
- */
19
- const usePopoverSurface_unstable = (props, ref) => {
20
- const contentRef = popoverContext_1.usePopoverContext_unstable(context => context.contentRef);
21
- const openOnHover = popoverContext_1.usePopoverContext_unstable(context => context.openOnHover);
22
- const setOpen = popoverContext_1.usePopoverContext_unstable(context => context.setOpen);
23
- const mountNode = popoverContext_1.usePopoverContext_unstable(context => context.mountNode);
24
- const arrowRef = popoverContext_1.usePopoverContext_unstable(context => context.arrowRef);
25
- const size = popoverContext_1.usePopoverContext_unstable(context => context.size);
26
- const withArrow = popoverContext_1.usePopoverContext_unstable(context => context.withArrow);
27
- const appearance = popoverContext_1.usePopoverContext_unstable(context => context.appearance);
28
- const trapFocus = popoverContext_1.usePopoverContext_unstable(context => context.trapFocus);
29
- const inertTrapFocus = popoverContext_1.usePopoverContext_unstable(context => context.inertTrapFocus);
30
- const inline = popoverContext_1.usePopoverContext_unstable(context => context.inline);
31
- const {
32
- modalAttributes
33
- } = react_tabster_1.useModalAttributes({
34
- trapFocus,
35
- legacyTrapFocus: !inertTrapFocus,
36
- alwaysFocusable: !trapFocus
37
- });
38
- const state = {
39
- inline,
40
- appearance,
41
- withArrow,
42
- size,
43
- arrowRef,
44
- mountNode,
45
- components: {
46
- root: 'div'
47
- },
48
- root: react_utilities_1.getNativeElementProps('div', {
49
- ref: react_utilities_1.useMergedRefs(ref, contentRef),
50
- role: trapFocus ? 'dialog' : 'group',
51
- 'aria-modal': trapFocus ? true : undefined,
52
- ...modalAttributes,
53
- ...props
54
- })
55
- };
56
- const {
57
- onMouseEnter: onMouseEnterOriginal,
58
- onMouseLeave: onMouseLeaveOriginal,
59
- onKeyDown: onKeyDownOriginal
60
- } = state.root;
61
- state.root.onMouseEnter = e => {
62
- if (openOnHover) {
63
- setOpen(e, true);
64
- }
65
- onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(e);
66
- };
67
- state.root.onMouseLeave = e => {
68
- if (openOnHover) {
69
- setOpen(e, false);
70
- }
71
- onMouseLeaveOriginal === null || onMouseLeaveOriginal === void 0 ? void 0 : onMouseLeaveOriginal(e);
72
- };
73
- state.root.onKeyDown = e => {
74
- var _a;
75
- // only close if the event happened inside the current popover
76
- // If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack
77
- if (e.key === 'Escape' && ((_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
78
- setOpen(e, false);
79
- }
80
- onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(e);
81
- };
82
- return state;
83
- };
84
- exports.usePopoverSurface_unstable = usePopoverSurface_unstable;
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _reactUtilities = require("@fluentui/react-utilities");
12
+ const _reactTabster = require("@fluentui/react-tabster");
13
+ const _popoverContext = require("../../popoverContext");
14
+ const usePopoverSurface_unstable = (props, ref)=>{
15
+ const contentRef = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.contentRef);
16
+ const openOnHover = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.openOnHover);
17
+ const setOpen = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.setOpen);
18
+ const mountNode = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.mountNode);
19
+ const arrowRef = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.arrowRef);
20
+ const size = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.size);
21
+ const withArrow = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.withArrow);
22
+ const appearance = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.appearance);
23
+ const trapFocus = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.trapFocus);
24
+ const inertTrapFocus = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.inertTrapFocus);
25
+ const inline = (0, _popoverContext.usePopoverContext_unstable)((context)=>context.inline);
26
+ const { modalAttributes } = (0, _reactTabster.useModalAttributes)({
27
+ trapFocus,
28
+ legacyTrapFocus: !inertTrapFocus,
29
+ alwaysFocusable: !trapFocus
30
+ });
31
+ const state = {
32
+ inline,
33
+ appearance,
34
+ withArrow,
35
+ size,
36
+ arrowRef,
37
+ mountNode,
38
+ components: {
39
+ root: "div"
40
+ },
41
+ root: (0, _reactUtilities.getNativeElementProps)("div", {
42
+ ref: (0, _reactUtilities.useMergedRefs)(ref, contentRef),
43
+ role: trapFocus ? "dialog" : "group",
44
+ "aria-modal": trapFocus ? true : undefined,
45
+ ...modalAttributes,
46
+ ...props
47
+ })
48
+ };
49
+ const { onMouseEnter: onMouseEnterOriginal , onMouseLeave: onMouseLeaveOriginal , onKeyDown: onKeyDownOriginal } = state.root;
50
+ state.root.onMouseEnter = (e)=>{
51
+ if (openOnHover) {
52
+ setOpen(e, true);
53
+ }
54
+ onMouseEnterOriginal?.(e);
55
+ };
56
+ state.root.onMouseLeave = (e)=>{
57
+ if (openOnHover) {
58
+ setOpen(e, false);
59
+ }
60
+ onMouseLeaveOriginal?.(e);
61
+ };
62
+ state.root.onKeyDown = (e)=>{
63
+ // only close if the event happened inside the current popover
64
+ // If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack
65
+ if (e.key === "Escape" && contentRef.current?.contains(e.target)) {
66
+ setOpen(e, false);
67
+ }
68
+ onKeyDownOriginal?.(e);
69
+ };
70
+ return state;
71
+ }; //# sourceMappingURL=usePopoverSurface.js.map
72
+
85
73
  //# sourceMappingURL=usePopoverSurface.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["react_utilities_1","require","react_tabster_1","popoverContext_1","usePopoverSurface_unstable","props","ref","contentRef","usePopoverContext_unstable","context","openOnHover","setOpen","mountNode","arrowRef","size","withArrow","appearance","trapFocus","inertTrapFocus","inline","modalAttributes","useModalAttributes","legacyTrapFocus","alwaysFocusable","state","components","root","getNativeElementProps","useMergedRefs","role","undefined","onMouseEnter","onMouseEnterOriginal","onMouseLeave","onMouseLeaveOriginal","onKeyDown","onKeyDownOriginal","e","key","_a","current","contains","target","exports"],"sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverSurface/usePopoverSurface.ts"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useMergedRefs } from '@fluentui/react-utilities';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext_unstable } from '../../popoverContext';\nimport type { PopoverSurfaceProps, PopoverSurfaceState } from './PopoverSurface.types';\n\n/**\n * Create the state required to render PopoverSurface.\n *\n * The returned state can be modified with hooks such as usePopoverSurfaceStyles_unstable,\n * before being passed to renderPopoverSurface_unstable.\n *\n * @param props - props from this instance of PopoverSurface\n * @param ref - reference to root HTMLDivElement of PopoverSurface\n */\nexport const usePopoverSurface_unstable = (\n props: PopoverSurfaceProps,\n ref: React.Ref<HTMLDivElement>,\n): PopoverSurfaceState => {\n const contentRef = usePopoverContext_unstable(context => context.contentRef);\n const openOnHover = usePopoverContext_unstable(context => context.openOnHover);\n const setOpen = usePopoverContext_unstable(context => context.setOpen);\n const mountNode = usePopoverContext_unstable(context => context.mountNode);\n const arrowRef = usePopoverContext_unstable(context => context.arrowRef);\n const size = usePopoverContext_unstable(context => context.size);\n const withArrow = usePopoverContext_unstable(context => context.withArrow);\n const appearance = usePopoverContext_unstable(context => context.appearance);\n const trapFocus = usePopoverContext_unstable(context => context.trapFocus);\n const inertTrapFocus = usePopoverContext_unstable(context => context.inertTrapFocus);\n const inline = usePopoverContext_unstable(context => context.inline);\n const { modalAttributes } = useModalAttributes({\n trapFocus,\n legacyTrapFocus: !inertTrapFocus,\n alwaysFocusable: !trapFocus,\n });\n\n const state: PopoverSurfaceState = {\n inline,\n appearance,\n withArrow,\n size,\n arrowRef,\n mountNode,\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n ref: useMergedRefs(ref, contentRef),\n role: trapFocus ? 'dialog' : 'group',\n 'aria-modal': trapFocus ? true : undefined,\n ...modalAttributes,\n ...props,\n }),\n };\n\n const {\n onMouseEnter: onMouseEnterOriginal,\n onMouseLeave: onMouseLeaveOriginal,\n onKeyDown: onKeyDownOriginal,\n } = state.root;\n state.root.onMouseEnter = (e: React.MouseEvent<HTMLDivElement>) => {\n if (openOnHover) {\n setOpen(e, true);\n }\n\n onMouseEnterOriginal?.(e);\n };\n\n state.root.onMouseLeave = (e: React.MouseEvent<HTMLDivElement>) => {\n if (openOnHover) {\n setOpen(e, false);\n }\n\n onMouseLeaveOriginal?.(e);\n };\n\n state.root.onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n // only close if the event happened inside the current popover\n // If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack\n if (e.key === 'Escape' && contentRef.current?.contains(e.target as HTMLDivElement)) {\n setOpen(e, false);\n }\n\n onKeyDownOriginal?.(e);\n };\n\n return state;\n};\n"],"mappings":";;;;;;AACA,MAAAA,iBAAA,gBAAAC,OAAA;AACA,MAAAC,eAAA,gBAAAD,OAAA;AACA,MAAAE,gBAAA,gBAAAF,OAAA;AAGA;;;;;;;;;AASO,MAAMG,0BAA0B,GAAGA,CACxCC,KAA0B,EAC1BC,GAA8B,KACP;EACvB,MAAMC,UAAU,GAAGJ,gBAAA,CAAAK,0BAA0B,CAACC,OAAO,IAAIA,OAAO,CAACF,UAAU,CAAC;EAC5E,MAAMG,WAAW,GAAGP,gBAAA,CAAAK,0BAA0B,CAACC,OAAO,IAAIA,OAAO,CAACC,WAAW,CAAC;EAC9E,MAAMC,OAAO,GAAGR,gBAAA,CAAAK,0BAA0B,CAACC,OAAO,IAAIA,OAAO,CAACE,OAAO,CAAC;EACtE,MAAMC,SAAS,GAAGT,gBAAA,CAAAK,0BAA0B,CAACC,OAAO,IAAIA,OAAO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AAe;MAClB,GAAGf;KACJ;GACF;EAED,MAAM;IACJ0B,YAAY,EAAEC,oBAAoB;IAClCC,YAAY,EAAEC,oBAAoB;IAClCC,SAAS,EAAEC;EAAiB,CAC7B,GAAGZ,KAAK,CAACE,IAAI;EACdF,KAAK,CAACE,IAAI,CAACK,YAAY,GAAIM,CAAmC,IAAI;IAChE,IAAI3B,WAAW,EAAE;MACfC,OAAO,CAAC0B,CAAC,EAAE,IAAI,CAAC;;IAGlBL,oBAAoB,aAApBA,oBAAoB,uBAApBA,oBAAoB,CAAGK,CAAC,CAAC;EAC3B,CAAC;EAEDb,KAAK,CAACE,IAAI,CAACO,YAAY,GAAII,CAAmC,IAAI;IAChE,IAAI3B,WAAW,EAAE;MACfC,OAAO,CAAC0B,CAAC,EAAE,KAAK,CAAC;;IAGnBH,oBAAoB,aAApBA,oBAAoB,uBAApBA,oBAAoB,CAAGG,CAAC,CAAC;EAC3B,CAAC;EAEDb,KAAK,CAACE,IAAI,CAACS,SAAS,GAAIE,CAAsC,IAAI;;IAChE;IACA;IACA,IAAIA,CAAC,CAACC,GAAG,KAAK,QAAQ,KAAI,CAAAC,EAAA,GAAAhC,UAAU,CAACiC,OAAO,cAAAD,EAAA,uBAAAA,EAAA,CAAEE,QAAQ,CAACJ,CAAC,CAACK,MAAwB,CAAC,GAAE;MAClF/B,OAAO,CAAC0B,CAAC,EAAE,KAAK,CAAC;;IAGnBD,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAGC,CAAC,CAAC;EACxB,CAAC;EAED,OAAOb,KAAK;AACd,CAAC;AAxEYmB,OAAA,CAAAvC,0BAA0B,GAAAA,0BAAA"}
1
+ {"version":3,"sources":["../../../lib/components/PopoverSurface/usePopoverSurface.js"],"sourcesContent":["import * as React from \"react\";\nimport { getNativeElementProps, useMergedRefs } from \"@fluentui/react-utilities\";\nimport { useModalAttributes } from \"@fluentui/react-tabster\";\nimport { usePopoverContext_unstable } from \"../../popoverContext\";\n/**\n * Create the state required to render PopoverSurface.\n *\n * The returned state can be modified with hooks such as usePopoverSurfaceStyles_unstable,\n * before being passed to renderPopoverSurface_unstable.\n *\n * @param props - props from this instance of PopoverSurface\n * @param ref - reference to root HTMLDivElement of PopoverSurface\n */\nexport const usePopoverSurface_unstable = (props, ref) => {\n const contentRef = usePopoverContext_unstable(context => context.contentRef);\n const openOnHover = usePopoverContext_unstable(context => context.openOnHover);\n const setOpen = usePopoverContext_unstable(context => context.setOpen);\n const mountNode = usePopoverContext_unstable(context => context.mountNode);\n const arrowRef = usePopoverContext_unstable(context => context.arrowRef);\n const size = usePopoverContext_unstable(context => context.size);\n const withArrow = usePopoverContext_unstable(context => context.withArrow);\n const appearance = usePopoverContext_unstable(context => context.appearance);\n const trapFocus = usePopoverContext_unstable(context => context.trapFocus);\n const inertTrapFocus = usePopoverContext_unstable(context => context.inertTrapFocus);\n const inline = usePopoverContext_unstable(context => context.inline);\n const {\n modalAttributes\n } = useModalAttributes({\n trapFocus,\n legacyTrapFocus: !inertTrapFocus,\n alwaysFocusable: !trapFocus\n });\n const state = {\n inline,\n appearance,\n withArrow,\n size,\n arrowRef,\n mountNode,\n components: {\n root: \"div\"\n },\n root: getNativeElementProps(\"div\", {\n ref: useMergedRefs(ref, contentRef),\n role: trapFocus ? \"dialog\" : \"group\",\n \"aria-modal\": trapFocus ? true : undefined,\n ...modalAttributes,\n ...props\n })\n };\n const {\n onMouseEnter: onMouseEnterOriginal,\n onMouseLeave: onMouseLeaveOriginal,\n onKeyDown: onKeyDownOriginal\n } = state.root;\n state.root.onMouseEnter = e => {\n if (openOnHover) {\n setOpen(e, true);\n }\n onMouseEnterOriginal?.(e);\n };\n state.root.onMouseLeave = e => {\n if (openOnHover) {\n setOpen(e, false);\n }\n onMouseLeaveOriginal?.(e);\n };\n state.root.onKeyDown = e => {\n // only close if the event happened inside the current popover\n // If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack\n if (e.key === \"Escape\" && contentRef.current?.contains(e.target)) {\n setOpen(e, false);\n }\n onKeyDownOriginal?.(e);\n };\n return state;\n};\n//# sourceMappingURL=usePopoverSurface.js.map"],"names":["usePopoverSurface_unstable","props","ref","contentRef","usePopoverContext_unstable","context","openOnHover","setOpen","mountNode","arrowRef","size","withArrow","appearance","trapFocus","inertTrapFocus","inline","modalAttributes","useModalAttributes","legacyTrapFocus","alwaysFocusable","state","components","root","getNativeElementProps","useMergedRefs","role","undefined","onMouseEnter","onMouseEnterOriginal","onMouseLeave","onMouseLeaveOriginal","onKeyDown","onKeyDownOriginal","e","key","current","contains","target"],"mappings":";;;;+BAaaA;;aAAAA;;;6DAbU;gCAC8B;8BAClB;gCACQ;AAUpC,MAAMA,6BAA6B,CAACC,OAAOC,MAAQ;IACxD,MAAMC,aAAaC,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQF,UAAU;IAC3E,MAAMG,cAAcF,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQC,WAAW;IAC7E,MAAMC,UAAUH,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQE,OAAO;IACrE,MAAMC,YAAYJ,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQG,SAAS;IACzE,MAAMC,WAAWL,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQI,QAAQ;IACvE,MAAMC,OAAON,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQK,IAAI;IAC/D,MAAMC,YAAYP,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQM,SAAS;IACzE,MAAMC,aAAaR,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQO,UAAU;IAC3E,MAAMC,YAAYT,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQQ,SAAS;IACzE,MAAMC,iBAAiBV,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQS,cAAc;IACnF,MAAMC,SAASX,IAAAA,0CAA0B,EAACC,CAAAA,UAAWA,QAAQU,M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