@fluentui/react-popover 9.0.0-alpha.8 → 9.0.0-nightly.f81b28ceb3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. package/CHANGELOG.json +1800 -1
  2. package/CHANGELOG.md +566 -2
  3. package/Spec.md +6 -6
  4. package/dist/react-popover.d.ts +59 -77
  5. package/lib/Popover.js.map +1 -1
  6. package/lib/PopoverSurface.js.map +1 -1
  7. package/lib/PopoverTrigger.js.map +1 -1
  8. package/lib/common/isConformant.d.ts +1 -1
  9. package/lib/common/isConformant.js +9 -5
  10. package/lib/common/isConformant.js.map +1 -1
  11. package/lib/common/mockUsePopoverContext.d.ts +1 -1
  12. package/lib/common/mockUsePopoverContext.js +28 -6
  13. package/lib/common/mockUsePopoverContext.js.map +1 -1
  14. package/lib/components/Popover/Popover.d.ts +2 -2
  15. package/lib/components/Popover/Popover.js +4 -3
  16. package/lib/components/Popover/Popover.js.map +1 -1
  17. package/lib/components/Popover/Popover.types.d.ts +24 -33
  18. package/lib/components/Popover/Popover.types.js.map +1 -1
  19. package/lib/components/Popover/index.js.map +1 -1
  20. package/lib/components/Popover/renderPopover.d.ts +1 -1
  21. package/lib/components/Popover/renderPopover.js +29 -17
  22. package/lib/components/Popover/renderPopover.js.map +1 -1
  23. package/lib/components/Popover/usePopover.d.ts +2 -3
  24. package/lib/components/Popover/usePopover.js +110 -88
  25. package/lib/components/Popover/usePopover.js.map +1 -1
  26. package/lib/components/PopoverSurface/PopoverSurface.d.ts +3 -3
  27. package/lib/components/PopoverSurface/PopoverSurface.js +5 -4
  28. package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
  29. package/lib/components/PopoverSurface/PopoverSurface.types.d.ts +9 -18
  30. package/lib/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  31. package/lib/components/PopoverSurface/index.js.map +1 -1
  32. package/lib/components/PopoverSurface/renderPopoverSurface.d.ts +1 -1
  33. package/lib/components/PopoverSurface/renderPopoverSurface.js +18 -10
  34. package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  35. package/lib/components/PopoverSurface/usePopoverSurface.d.ts +4 -4
  36. package/lib/components/PopoverSurface/usePopoverSurface.js +94 -54
  37. package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  38. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +2 -2
  39. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +88 -64
  40. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  41. package/lib/components/PopoverTrigger/PopoverTrigger.d.ts +2 -2
  42. package/lib/components/PopoverTrigger/PopoverTrigger.js +4 -3
  43. package/lib/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
  44. package/lib/components/PopoverTrigger/PopoverTrigger.types.d.ts +3 -4
  45. package/lib/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
  46. package/lib/components/PopoverTrigger/index.js.map +1 -1
  47. package/lib/components/PopoverTrigger/renderPopoverTrigger.d.ts +1 -1
  48. package/lib/components/PopoverTrigger/renderPopoverTrigger.js +1 -1
  49. package/lib/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
  50. package/lib/components/PopoverTrigger/usePopoverTrigger.d.ts +2 -3
  51. package/lib/components/PopoverTrigger/usePopoverTrigger.js +83 -60
  52. package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  53. package/lib/index.js.map +1 -1
  54. package/lib/popoverContext.d.ts +4 -5
  55. package/lib/popoverContext.js +19 -12
  56. package/lib/popoverContext.js.map +1 -1
  57. package/lib/tsdoc-metadata.json +1 -1
  58. package/lib-commonjs/Popover.js +7 -2
  59. package/lib-commonjs/Popover.js.map +1 -1
  60. package/lib-commonjs/PopoverSurface.js +7 -2
  61. package/lib-commonjs/PopoverSurface.js.map +1 -1
  62. package/lib-commonjs/PopoverTrigger.js +7 -2
  63. package/lib-commonjs/PopoverTrigger.js.map +1 -1
  64. package/lib-commonjs/common/isConformant.d.ts +1 -1
  65. package/lib-commonjs/common/isConformant.js +18 -7
  66. package/lib-commonjs/common/isConformant.js.map +1 -1
  67. package/lib-commonjs/common/mockUsePopoverContext.d.ts +1 -1
  68. package/lib-commonjs/common/mockUsePopoverContext.js +38 -9
  69. package/lib-commonjs/common/mockUsePopoverContext.js.map +1 -1
  70. package/lib-commonjs/components/Popover/Popover.d.ts +2 -2
  71. package/lib-commonjs/components/Popover/Popover.js +14 -6
  72. package/lib-commonjs/components/Popover/Popover.js.map +1 -1
  73. package/lib-commonjs/components/Popover/Popover.types.d.ts +24 -33
  74. package/lib-commonjs/components/Popover/Popover.types.js +4 -1
  75. package/lib-commonjs/components/Popover/Popover.types.js.map +1 -1
  76. package/lib-commonjs/components/Popover/index.js +10 -2
  77. package/lib-commonjs/components/Popover/index.js.map +1 -1
  78. package/lib-commonjs/components/Popover/renderPopover.d.ts +1 -1
  79. package/lib-commonjs/components/Popover/renderPopover.js +39 -20
  80. package/lib-commonjs/components/Popover/renderPopover.js.map +1 -1
  81. package/lib-commonjs/components/Popover/usePopover.d.ts +2 -3
  82. package/lib-commonjs/components/Popover/usePopover.js +127 -93
  83. package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
  84. package/lib-commonjs/components/PopoverSurface/PopoverSurface.d.ts +3 -3
  85. package/lib-commonjs/components/PopoverSurface/PopoverSurface.js +18 -9
  86. package/lib-commonjs/components/PopoverSurface/PopoverSurface.js.map +1 -1
  87. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.d.ts +9 -18
  88. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.js +4 -1
  89. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  90. package/lib-commonjs/components/PopoverSurface/index.js +11 -2
  91. package/lib-commonjs/components/PopoverSurface/index.js.map +1 -1
  92. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.d.ts +1 -1
  93. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +32 -14
  94. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  95. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.d.ts +4 -4
  96. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +110 -60
  97. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  98. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +2 -2
  99. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +95 -65
  100. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  101. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.d.ts +2 -2
  102. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js +14 -6
  103. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
  104. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.d.ts +3 -4
  105. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.js +4 -1
  106. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
  107. package/lib-commonjs/components/PopoverTrigger/index.js +10 -2
  108. package/lib-commonjs/components/PopoverTrigger/index.js.map +1 -1
  109. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.d.ts +1 -1
  110. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js +7 -2
  111. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
  112. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.d.ts +2 -3
  113. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +98 -65
  114. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  115. package/lib-commonjs/index.js +10 -2
  116. package/lib-commonjs/index.js.map +1 -1
  117. package/lib-commonjs/popoverContext.d.ts +4 -5
  118. package/lib-commonjs/popoverContext.js +28 -14
  119. package/lib-commonjs/popoverContext.js.map +1 -1
  120. package/package.json +18 -15
  121. package/.storybook/main.js +0 -11
  122. package/.storybook/preview.js +0 -4
  123. package/bundle-size/Popover.fixture.js +0 -7
  124. package/config/api-extractor.json +0 -3
  125. package/config/tests.js +0 -7
  126. package/e2e/Popover.e2e.ts +0 -139
  127. package/etc/react-popover.api.md +0 -135
  128. package/just.config.ts +0 -3
  129. package/lib/Popover.stories.d.ts +0 -62
  130. package/lib/Popover.stories.js +0 -114
  131. package/lib/Popover.stories.js.map +0 -1
  132. package/lib/components/Popover/getOffsetWithArrow.d.ts +0 -7
  133. package/lib/components/Popover/getOffsetWithArrow.js +0 -34
  134. package/lib/components/Popover/getOffsetWithArrow.js.map +0 -1
  135. package/lib-amd/Popover.d.ts +0 -1
  136. package/lib-amd/Popover.js +0 -6
  137. package/lib-amd/Popover.js.map +0 -1
  138. package/lib-amd/Popover.stories.d.ts +0 -62
  139. package/lib-amd/Popover.stories.js +0 -121
  140. package/lib-amd/Popover.stories.js.map +0 -1
  141. package/lib-amd/PopoverSurface.d.ts +0 -1
  142. package/lib-amd/PopoverSurface.js +0 -6
  143. package/lib-amd/PopoverSurface.js.map +0 -1
  144. package/lib-amd/PopoverTrigger.d.ts +0 -1
  145. package/lib-amd/PopoverTrigger.js +0 -6
  146. package/lib-amd/PopoverTrigger.js.map +0 -1
  147. package/lib-amd/common/isConformant.d.ts +0 -4
  148. package/lib-amd/common/isConformant.js +0 -14
  149. package/lib-amd/common/isConformant.js.map +0 -1
  150. package/lib-amd/common/mockUsePopoverContext.d.ts +0 -7
  151. package/lib-amd/common/mockUsePopoverContext.js +0 -20
  152. package/lib-amd/common/mockUsePopoverContext.js.map +0 -1
  153. package/lib-amd/components/Popover/Popover.d.ts +0 -6
  154. package/lib-amd/components/Popover/Popover.js +0 -15
  155. package/lib-amd/components/Popover/Popover.js.map +0 -1
  156. package/lib-amd/components/Popover/Popover.types.d.ts +0 -109
  157. package/lib-amd/components/Popover/Popover.types.js +0 -5
  158. package/lib-amd/components/Popover/Popover.types.js.map +0 -1
  159. package/lib-amd/components/Popover/getOffsetWithArrow.d.ts +0 -7
  160. package/lib-amd/components/Popover/getOffsetWithArrow.js +0 -40
  161. package/lib-amd/components/Popover/getOffsetWithArrow.js.map +0 -1
  162. package/lib-amd/components/Popover/index.d.ts +0 -4
  163. package/lib-amd/components/Popover/index.js +0 -9
  164. package/lib-amd/components/Popover/index.js.map +0 -1
  165. package/lib-amd/components/Popover/renderPopover.d.ts +0 -5
  166. package/lib-amd/components/Popover/renderPopover.js +0 -29
  167. package/lib-amd/components/Popover/renderPopover.js.map +0 -1
  168. package/lib-amd/components/Popover/usePopover.d.ts +0 -11
  169. package/lib-amd/components/Popover/usePopover.js +0 -112
  170. package/lib-amd/components/Popover/usePopover.js.map +0 -1
  171. package/lib-amd/components/PopoverSurface/PopoverSurface.d.ts +0 -6
  172. package/lib-amd/components/PopoverSurface/PopoverSurface.js +0 -15
  173. package/lib-amd/components/PopoverSurface/PopoverSurface.js.map +0 -1
  174. package/lib-amd/components/PopoverSurface/PopoverSurface.types.d.ts +0 -30
  175. package/lib-amd/components/PopoverSurface/PopoverSurface.types.js +0 -5
  176. package/lib-amd/components/PopoverSurface/PopoverSurface.types.js.map +0 -1
  177. package/lib-amd/components/PopoverSurface/index.d.ts +0 -5
  178. package/lib-amd/components/PopoverSurface/index.js +0 -10
  179. package/lib-amd/components/PopoverSurface/index.js.map +0 -1
  180. package/lib-amd/components/PopoverSurface/renderPopoverSurface.d.ts +0 -5
  181. package/lib-amd/components/PopoverSurface/renderPopoverSurface.js +0 -21
  182. package/lib-amd/components/PopoverSurface/renderPopoverSurface.js.map +0 -1
  183. package/lib-amd/components/PopoverSurface/usePopoverSurface.d.ts +0 -13
  184. package/lib-amd/components/PopoverSurface/usePopoverSurface.js +0 -69
  185. package/lib-amd/components/PopoverSurface/usePopoverSurface.js.map +0 -1
  186. package/lib-amd/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +0 -7
  187. package/lib-amd/components/PopoverSurface/usePopoverSurfaceStyles.js +0 -81
  188. package/lib-amd/components/PopoverSurface/usePopoverSurfaceStyles.js.map +0 -1
  189. package/lib-amd/components/PopoverTrigger/PopoverTrigger.d.ts +0 -6
  190. package/lib-amd/components/PopoverTrigger/PopoverTrigger.js +0 -15
  191. package/lib-amd/components/PopoverTrigger/PopoverTrigger.js.map +0 -1
  192. package/lib-amd/components/PopoverTrigger/PopoverTrigger.types.d.ts +0 -12
  193. package/lib-amd/components/PopoverTrigger/PopoverTrigger.types.js +0 -5
  194. package/lib-amd/components/PopoverTrigger/PopoverTrigger.types.js.map +0 -1
  195. package/lib-amd/components/PopoverTrigger/index.d.ts +0 -4
  196. package/lib-amd/components/PopoverTrigger/index.js +0 -9
  197. package/lib-amd/components/PopoverTrigger/index.js.map +0 -1
  198. package/lib-amd/components/PopoverTrigger/renderPopoverTrigger.d.ts +0 -5
  199. package/lib-amd/components/PopoverTrigger/renderPopoverTrigger.js +0 -13
  200. package/lib-amd/components/PopoverTrigger/renderPopoverTrigger.js.map +0 -1
  201. package/lib-amd/components/PopoverTrigger/usePopoverTrigger.d.ts +0 -11
  202. package/lib-amd/components/PopoverTrigger/usePopoverTrigger.js +0 -75
  203. package/lib-amd/components/PopoverTrigger/usePopoverTrigger.js.map +0 -1
  204. package/lib-amd/index.d.ts +0 -4
  205. package/lib-amd/index.js +0 -9
  206. package/lib-amd/index.js.map +0 -1
  207. package/lib-amd/popoverContext.d.ts +0 -9
  208. package/lib-amd/popoverContext.js +0 -22
  209. package/lib-amd/popoverContext.js.map +0 -1
  210. package/lib-commonjs/Popover.stories.d.ts +0 -62
  211. package/lib-commonjs/Popover.stories.js +0 -122
  212. package/lib-commonjs/Popover.stories.js.map +0 -1
  213. package/lib-commonjs/components/Popover/getOffsetWithArrow.d.ts +0 -7
  214. package/lib-commonjs/components/Popover/getOffsetWithArrow.js +0 -38
  215. package/lib-commonjs/components/Popover/getOffsetWithArrow.js.map +0 -1
  216. package/src/components/Popover/Popover.types.ts +0 -124
  217. package/src/components/PopoverSurface/PopoverSurface.types.ts +0 -36
  218. package/src/components/PopoverTrigger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AE,KAAK,CAAC,CAAC;SACnB;QAED,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAG,CAAC,EAAE;IAC5B,CAAC,CAAC;IAEF,KAAK,CAAC,SAAS,GAAG,UAAC,CAAmC;;QACpD,8DAA8D;QAC9D,mHAAmH;QACnH,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,WAAI,UAAU,CAAC,OAAO,0CAAE,QAAQ,CAAC,CAAC,CAAC,MAAqB,EAAC,EAAE;YAC/E,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;SACnB;QAED,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,CAAC,EAAE;IACzB,CAAC,CAAC;IAEM,IAAA,kBAAkB,GAAK,eAAe,EAAE,mBAAtB,CAAuB;IAEjD,KAAK,CAAC,SAAS,CAAC;QACd,IAAI,KAAK,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE;YACpC,IAAM,cAAc,GAAG,kBAAkB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC9D,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,GAAG;SACzB;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { makeMergeProps, useMergedRefs } from '@fluentui/react-utilities';\nimport { useFocusFinders, useModalAttributes } from '@fluentui/react-tabster';\nimport { PopoverSurfaceProps, PopoverSurfaceState } from './PopoverSurface.types';\nimport { usePopoverContext } from '../../popoverContext';\n\nconst mergeProps = makeMergeProps<PopoverSurfaceState>({});\n\n/**\n * Create the state required to render PopoverSurface.\n *\n * The returned state can be modified with hooks such as usePopoverSurfaceStyles,\n * before being passed to renderPopoverSurface.\n *\n * @param props - props from this instance of PopoverSurface\n * @param ref - reference to root HTMLElement of PopoverSurface\n * @param defaultProps - (optional) default prop values provided by the implementing type\n */\nexport const usePopoverSurface = (\n props: PopoverSurfaceProps,\n ref: React.Ref<HTMLElement>,\n defaultProps?: PopoverSurfaceProps,\n): PopoverSurfaceState => {\n const contentRef = usePopoverContext(context => context.contentRef);\n const open = usePopoverContext(context => context.open);\n const openOnHover = usePopoverContext(context => context.openOnHover);\n const setOpen = usePopoverContext(context => context.setOpen);\n const mountNode = usePopoverContext(context => context.mountNode);\n const arrowRef = usePopoverContext(context => context.arrowRef);\n const size = usePopoverContext(context => context.size);\n const noArrow = usePopoverContext(context => context.noArrow);\n const brand = usePopoverContext(context => context.brand);\n const inverted = usePopoverContext(context => context.inverted);\n const trapFocus = usePopoverContext(context => context.trapFocus);\n const { modalAttributes } = useModalAttributes({ trapFocus });\n\n const state = mergeProps(\n {\n brand,\n inverted,\n noArrow,\n size,\n arrowRef,\n open,\n mountNode,\n role: 'dialog',\n ref: useMergedRefs(ref, contentRef),\n ...modalAttributes,\n },\n defaultProps,\n props,\n );\n\n const {\n onMouseEnter: onMouseEnterOriginal,\n onMouseLeave: onMouseLeaveOriginal,\n onKeyDown: onKeyDownOriginal,\n } = state;\n state.onMouseEnter = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, true);\n }\n\n onMouseEnterOriginal?.(e);\n };\n\n state.onMouseLeave = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, false);\n }\n\n onMouseLeaveOriginal?.(e);\n };\n\n state.onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\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 HTMLElement)) {\n setOpen(e, false);\n }\n\n onKeyDownOriginal?.(e);\n };\n\n const { findFirstFocusable } = useFocusFinders();\n\n React.useEffect(() => {\n if (state.open && contentRef.current) {\n const firstFocusable = findFirstFocusable(contentRef.current);\n firstFocusable?.focus();\n }\n }, [contentRef, findFirstFocusable, state.open]);\n return state;\n};\n"]}
1
+ {"version":3,"sources":["../../../src/components/PopoverSurface/usePopoverSurface.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,qBAAT,EAAgC,aAAhC,QAAqD,2BAArD;AACA,SAAS,eAAT,EAA0B,kBAA1B,QAAoD,yBAApD;AACA,SAAS,iBAAT,QAAkC,sBAAlC;AAGA,OAAO,IAAM,mBAAmB,GAAqC,CAAC,MAAD,CAA9D;AAEP;;;;;;;;AAQG;;AACH,OAAO,IAAM,iBAAiB,GAAG,UAAC,KAAD,EAA6B,GAA7B,EAA2D;AAC1F,MAAM,UAAU,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,UAAA;AAAkB,GAA9B,CAApC;AACA,MAAM,IAAI,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,IAAA;AAAY,GAAxB,CAA9B;AACA,MAAM,WAAW,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,WAAA;AAAmB,GAA/B,CAArC;AACA,MAAM,OAAO,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,OAAA;AAAe,GAA3B,CAAjC;AACA,MAAM,SAAS,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,SAAA;AAAiB,GAA7B,CAAnC;AACA,MAAM,QAAQ,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,QAAA;AAAgB,GAA5B,CAAlC;AACA,MAAM,IAAI,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,IAAA;AAAY,GAAxB,CAA9B;AACA,MAAM,OAAO,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,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AAvC,CALH;AAMA,SAAO,KAAP;AACD,CAvEM","sourceRoot":""}
@@ -1,5 +1,5 @@
1
- import { PopoverSize } from '../Popover/Popover.types';
2
- import { PopoverSurfaceState } from './PopoverSurface.types';
1
+ import type { PopoverSize } from '../Popover/Popover.types';
2
+ import type { PopoverSurfaceState } from './PopoverSurface.types';
3
3
  export declare const arrowHeights: Record<PopoverSize, number>;
4
4
  /**
5
5
  * Apply styling to the PopoverSurface slots based on the state
@@ -1,76 +1,100 @@
1
- import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';
1
+ import { __styles, mergeClasses } from '@fluentui/react-make-styles';
2
2
  export var arrowHeights = {
3
- small: 6,
4
- medium: 8,
5
- large: 8,
3
+ small: 6,
4
+ medium: 8,
5
+ large: 8
6
6
  };
7
7
  /**
8
8
  * Styles for the root slot
9
9
  */
10
- var useStyles = makeStyles({
11
- root: function (theme) { return ({
12
- backgroundColor: theme.alias.color.neutral.neutralBackground1,
13
- boxShadow: theme.alias.shadow.shadow16,
14
- borderRadius: '4px',
15
- }); },
16
- inverted: function (theme) { return ({
17
- // TODO: neutral background inverted missing from superset and theme
18
- backgroundColor: theme.global.palette.grey[16],
19
- color: theme.alias.color.neutral.neutralForegroundInverted,
20
- }); },
21
- brand: function (theme) { return ({
22
- backgroundColor: theme.alias.color.neutral.brandBackground,
23
- // TODO: clarify with designers what foreground color should be with brand background,
24
- color: theme.alias.color.neutral.neutralForegroundInverted,
25
- }); },
26
- smallPadding: function () { return ({
27
- padding: '12px',
28
- }); },
29
- mediumPadding: function () { return ({
30
- padding: '16px',
31
- }); },
32
- largePadding: function () { return ({
33
- padding: '20px',
34
- }); },
35
- smallArrow: function () { return ({
36
- width: Math.SQRT2 * arrowHeights.small + "px",
37
- height: Math.SQRT2 * arrowHeights.small + "px",
38
- }); },
39
- mediumLargeArrow: function () { return ({
40
- width: Math.SQRT2 * arrowHeights.medium + "px",
41
- height: Math.SQRT2 * arrowHeights.medium + "px",
42
- }); },
43
- // TODO dedupe these styles with tooltip
44
- arrow: function (theme) { return ({
45
- position: 'absolute',
46
- background: 'inherit',
47
- visibility: 'hidden',
48
- zIndex: -1,
49
- ':before': {
50
- content: '""',
51
- borderRadius: '4px',
52
- position: 'absolute',
53
- width: 'inherit',
54
- height: 'inherit',
55
- background: 'inherit',
56
- visibility: 'visible',
57
- borderBottomRightRadius: theme.global.borderRadius.small,
58
- transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',
59
- },
60
- // Popper sets data-popper-placement on the root element, which is used to align the arrow
61
- ':global([data-popper-placement^="top"])': { bottom: 0, '--angle': '0' },
62
- ':global([data-popper-placement^="right"])': { left: 0, '--angle': '90deg' },
63
- ':global([data-popper-placement^="bottom"])': { top: 0, '--angle': '180deg' },
64
- ':global([data-popper-placement^="left"])': { right: 0, '--angle': '270deg' },
65
- }); },
10
+
11
+ var useStyles = /*#__PURE__*/__styles({
12
+ "root": {
13
+ "De3pzq": "fxugw4r",
14
+ "E5pizo": ["f1hg901r", "f136t921"],
15
+ "Dimara": "ff3glw6",
16
+ "B4j52fo": "f5ogflp",
17
+ "Bekrc4i": ["f1hqa2wf", "finvdd3"],
18
+ "Bn0qgzm": "f1f09k3d",
19
+ "ibv6hh": ["finvdd3", "f1hqa2wf"],
20
+ "icvyot": "fzkkow9",
21
+ "vrafjx": ["fcdblym", "fjik90z"],
22
+ "oivjwe": "fg706s2",
23
+ "wvpqe5": ["fjik90z", "fcdblym"],
24
+ "g2u3we": "fghlq4f",
25
+ "h3c5rm": ["f1gn591s", "fjscplz"],
26
+ "B9xav0g": "fb073pr",
27
+ "zhjwy3": ["fjscplz", "f1gn591s"]
28
+ },
29
+ "inverted": {
30
+ "De3pzq": "f1c73kur",
31
+ "sj55zd": "fqpbvvt"
32
+ },
33
+ "brand": {
34
+ "De3pzq": "ffp7eso",
35
+ "sj55zd": "fqpbvvt"
36
+ },
37
+ "smallPadding": {
38
+ "z8tnut": "f1kcqot9",
39
+ "z189sj": ["f11qrl6u", "fjlbh76"],
40
+ "Byoj8tv": "fpe6lb7",
41
+ "uwmqm3": ["fjlbh76", "f11qrl6u"]
42
+ },
43
+ "mediumPadding": {
44
+ "z8tnut": "fqag9an",
45
+ "z189sj": ["f1gbmcue", "f1rh9g5y"],
46
+ "Byoj8tv": "fp67ikv",
47
+ "uwmqm3": ["f1rh9g5y", "f1gbmcue"]
48
+ },
49
+ "largePadding": {
50
+ "z8tnut": "fc7z3ec",
51
+ "z189sj": ["fat0sn4", "fekwl8i"],
52
+ "Byoj8tv": "fe2my4m",
53
+ "uwmqm3": ["fekwl8i", "fat0sn4"]
54
+ },
55
+ "smallArrow": {
56
+ "a9b677": "f1smug5u",
57
+ "Bqenvij": "f11ci07v"
58
+ },
59
+ "mediumLargeArrow": {
60
+ "a9b677": "ftmg478",
61
+ "Bqenvij": "f7bsbfx"
62
+ },
63
+ "arrow": {
64
+ "qhf8xq": "f1euv43f",
65
+ "ayd6f0": "f1uo6wrk",
66
+ "Bcdw1i0": "fd7fpy0",
67
+ "Bj3rh1h": "f1bsuimh",
68
+ "rurcny": "fuzzvh5",
69
+ "zf3lio": "f1qudtws",
70
+ "xx9plb": "fxf9f1y",
71
+ "Bdn98qo": "f103af6e",
72
+ "Bbc2r3f": "f15umuo5",
73
+ "B4zgs9e": "ffo048g",
74
+ "Bex5imi": "fkk33zh",
75
+ "px8gyy": ["f5bg3dr", "f1rfdd74"],
76
+ "h6z6rw": ["fzd2j21", "f2549he"],
77
+ "hl6cv3": "fotnskf",
78
+ "Bh2vraf": "f1n8855c",
79
+ "yayu3t": ["f1nq055x", "f13ohf3"],
80
+ "wedwtw": "fsw6im5",
81
+ "rhl9o9": "ftghsr9",
82
+ "Bu8t5uz": "f159pzir",
83
+ "B6q6orb": ["f1l8vbt4", "fsxzh25"],
84
+ "Bwwlvwl": "fm1ycve"
85
+ }
86
+ }, {
87
+ "d": [".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f1hg901r{box-shadow:var(--shadow16);}", ".f136t921{box-shadow:var(--shadow-16);}", ".ff3glw6{border-radius:4px;}", ".f5ogflp{border-top-width:1px;}", ".f1hqa2wf{border-right-width:1px;}", ".finvdd3{border-left-width:1px;}", ".f1f09k3d{border-bottom-width:1px;}", ".fzkkow9{border-top-style:solid;}", ".fcdblym{border-right-style:solid;}", ".fjik90z{border-left-style:solid;}", ".fg706s2{border-bottom-style:solid;}", ".fghlq4f{border-top-color:var(--colorTransparentStroke);}", ".f1gn591s{border-right-color:var(--colorTransparentStroke);}", ".fjscplz{border-left-color:var(--colorTransparentStroke);}", ".fb073pr{border-bottom-color:var(--colorTransparentStroke);}", ".f1c73kur{background-color:var(--colorNeutralForeground1);}", ".fqpbvvt{color:var(--colorNeutralForegroundInverted);}", ".ffp7eso{background-color:var(--colorBrandBackground);}", ".f1kcqot9{padding-top:12px;}", ".f11qrl6u{padding-right:12px;}", ".fjlbh76{padding-left:12px;}", ".fpe6lb7{padding-bottom:12px;}", ".fqag9an{padding-top:16px;}", ".f1gbmcue{padding-right:16px;}", ".f1rh9g5y{padding-left:16px;}", ".fp67ikv{padding-bottom:16px;}", ".fc7z3ec{padding-top:20px;}", ".fat0sn4{padding-right:20px;}", ".fekwl8i{padding-left:20px;}", ".fe2my4m{padding-bottom:20px;}", ".f1smug5u{width:8.485281374238571px;}", ".f11ci07v{height:8.485281374238571px;}", ".ftmg478{width:11.313708498984761px;}", ".f7bsbfx{height:11.313708498984761px;}", ".f1euv43f{position:absolute;}", ".f1uo6wrk{background:inherit;}", ".fd7fpy0{visibility:hidden;}", ".f1bsuimh{z-index:-1;}", ".fuzzvh5:before{content:\"\";}", ".f1qudtws:before{border-radius:4px;}", ".fxf9f1y:before{position:absolute;}", ".f103af6e:before{width:inherit;}", ".f15umuo5:before{height:inherit;}", ".ffo048g:before{background:inherit;}", ".fkk33zh:before{visibility:visible;}", ".f5bg3dr:before{border-bottom-right-radius:var(--borderRadiusSmall);}", ".f1rfdd74:before{border-bottom-left-radius:var(--borderRadiusSmall);}", ".fzd2j21:before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);}", ".f2549he:before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);}", "[data-popper-placement^=\"top\"] .fotnskf{bottom:0;}", "[data-popper-placement^=\"top\"] .f1n8855c{--angle:0;}", "[data-popper-placement^=\"right\"] .f1nq055x{left:0;}", "[data-popper-placement^=\"right\"] .f13ohf3{right:0;}", "[data-popper-placement^=\"right\"] .fsw6im5{--angle:90deg;}", "[data-popper-placement^=\"bottom\"] .ftghsr9{top:0;}", "[data-popper-placement^=\"bottom\"] .f159pzir{--angle:180deg;}", "[data-popper-placement^=\"left\"] .f1l8vbt4{right:0;}", "[data-popper-placement^=\"left\"] .fsxzh25{left:0;}", "[data-popper-placement^=\"left\"] .fm1ycve{--angle:270deg;}"]
66
88
  });
67
89
  /**
68
90
  * Apply styling to the PopoverSurface slots based on the state
69
91
  */
92
+
93
+
70
94
  export var usePopoverSurfaceStyles = function (state) {
71
- var styles = useStyles();
72
- state.className = mergeClasses(styles.root, state.className, state.size === 'small' && styles.smallPadding, state.size === 'medium' && styles.mediumPadding, state.size === 'large' && styles.largePadding, state.inverted && styles.inverted, state.brand && styles.brand);
73
- state.arrowClassName = mergeClasses(styles.arrow, state.size === 'small' ? styles.smallArrow : styles.mediumLargeArrow);
74
- return state;
95
+ var styles = useStyles();
96
+ state.root.className = mergeClasses(styles.root, state.size === 'small' && styles.smallPadding, state.size === 'medium' && styles.mediumPadding, state.size === 'large' && styles.largePadding, state.appearance === 'inverted' && styles.inverted, state.appearance === 'brand' && styles.brand, state.root.className);
97
+ state.arrowClassName = mergeClasses(styles.arrow, state.size === 'small' ? styles.smallArrow : styles.mediumLargeArrow);
98
+ return state;
75
99
  };
76
100
  //# sourceMappingURL=usePopoverSurfaceStyles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePopoverSurfaceStyles.js","sourceRoot":"../src/","sources":["components/PopoverSurface/usePopoverSurfaceStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAIvE,MAAM,CAAC,IAAM,YAAY,GAAgC;IACvD,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;CACT,CAAC;AAEF;;GAEG;AACH,IAAM,SAAS,GAAG,UAAU,CAAC;IAC3B,IAAI,EAAE,UAAA,KAAK,IAAI,OAAA,CAAC;QACd,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB;QAC7D,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ;QACtC,YAAY,EAAE,KAAK;KACpB,CAAC,EAJa,CAIb;IAEF,QAAQ,EAAE,UAAA,KAAK,IAAI,OAAA,CAAC;QAClB,oEAAoE;QACpE,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,yBAAyB;KAC3D,CAAC,EAJiB,CAIjB;IAEF,KAAK,EAAE,UAAA,KAAK,IAAI,OAAA,CAAC;QACf,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe;QAC1D,sFAAsF;QACtF,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,yBAAyB;KAC3D,CAAC,EAJc,CAId;IAEF,YAAY,EAAE,cAAM,OAAA,CAAC;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E,4CAA4C,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE;QAC7E,0CAA0C,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE;KAC9E,CAAC,EAvBc,CAuBd;CACH,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,IAAM,uBAAuB,GAAG,UAAC,KAA0B;IAChE,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,KAAK,CAAC,SAAS,GAAG,YAAY,CAC5B,MAAM,CAAC,IAAI,EACX,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,YAAY,EAC7C,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,aAAa,EAC/C,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,YAAY,EAC7C,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,EACjC,KAAK,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAC5B,CAAC;IAEF,KAAK,CAAC,cAAc,GAAG,YAAY,CACjC,MAAM,CAAC,KAAK,EACZ,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CACrE,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';\nimport { PopoverSize } from '../Popover/Popover.types';\nimport { PopoverSurfaceState } from './PopoverSurface.types';\n\nexport const arrowHeights: Record<PopoverSize, number> = {\n small: 6,\n medium: 8,\n large: 8,\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: theme => ({\n backgroundColor: theme.alias.color.neutral.neutralBackground1,\n boxShadow: theme.alias.shadow.shadow16,\n borderRadius: '4px',\n }),\n\n inverted: theme => ({\n // TODO: neutral background inverted missing from superset and theme\n backgroundColor: theme.global.palette.grey[16],\n color: theme.alias.color.neutral.neutralForegroundInverted,\n }),\n\n brand: theme => ({\n backgroundColor: theme.alias.color.neutral.brandBackground,\n // TODO: clarify with designers what foreground color should be with brand background,\n color: theme.alias.color.neutral.neutralForegroundInverted,\n }),\n\n smallPadding: () => ({\n padding: '12px',\n }),\n\n mediumPadding: () => ({\n padding: '16px',\n }),\n\n largePadding: () => ({\n padding: '20px',\n }),\n\n smallArrow: () => ({\n width: `${Math.SQRT2 * arrowHeights.small}px`,\n height: `${Math.SQRT2 * arrowHeights.small}px`,\n }),\n\n mediumLargeArrow: () => ({\n width: `${Math.SQRT2 * arrowHeights.medium}px`,\n height: `${Math.SQRT2 * arrowHeights.medium}px`,\n }),\n\n // TODO dedupe these styles with tooltip\n arrow: theme => ({\n position: 'absolute',\n background: 'inherit',\n visibility: 'hidden',\n zIndex: -1,\n\n ':before': {\n content: '\"\"',\n borderRadius: '4px',\n position: 'absolute',\n width: 'inherit',\n height: 'inherit',\n background: 'inherit',\n visibility: 'visible',\n borderBottomRightRadius: theme.global.borderRadius.small,\n transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',\n },\n\n // Popper sets data-popper-placement on the root element, which is used to align the arrow\n ':global([data-popper-placement^=\"top\"])': { bottom: 0, '--angle': '0' },\n ':global([data-popper-placement^=\"right\"])': { left: 0, '--angle': '90deg' },\n ':global([data-popper-placement^=\"bottom\"])': { top: 0, '--angle': '180deg' },\n ':global([data-popper-placement^=\"left\"])': { right: 0, '--angle': '270deg' },\n }),\n});\n\n/**\n * Apply styling to the PopoverSurface slots based on the state\n */\nexport const usePopoverSurfaceStyles = (state: PopoverSurfaceState): PopoverSurfaceState => {\n const styles = useStyles();\n state.className = mergeClasses(\n styles.root,\n state.className,\n state.size === 'small' && styles.smallPadding,\n state.size === 'medium' && styles.mediumPadding,\n state.size === 'large' && styles.largePadding,\n state.inverted && styles.inverted,\n state.brand && styles.brand,\n );\n\n state.arrowClassName = mergeClasses(\n styles.arrow,\n state.size === 'small' ? styles.smallArrow : styles.mediumLargeArrow,\n );\n\n return state;\n};\n"]}
1
+ {"version":3,"sources":["../../../src/components/PopoverSurface/usePopoverSurfaceStyles.ts"],"names":[],"mappings":"AAAA,mBAAqB,YAArB,QAAyC,6BAAzC;AAIA,OAAO,IAAM,YAAY,GAAgC;AACvD,EAAA,KAAK,EAAE,CADgD;AAEvD,EAAA,MAAM,EAAE,CAF+C;AAGvD,EAAA,KAAK,EAAE;AAHgD,CAAlD;AAMP;;AAEG;;AACH,IAAM,SAAS,gBAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAlB;AAqEA;;AAEG;;;AACH,OAAO,IAAM,uBAAuB,GAAG,UAAC,KAAD,EAA2B;AAChE,MAAM,MAAM,GAAG,SAAS,EAAxB;AACA,EAAA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CACjC,MAAM,CAAC,IAD0B,EAEjC,KAAK,CAAC,IAAN,KAAe,OAAf,IAA0B,MAAM,CAAC,YAFA,EAGjC,KAAK,CAAC,IAAN,KAAe,QAAf,IAA2B,MAAM,CAAC,aAHD,EAIjC,KAAK,CAAC,IAAN,KAAe,OAAf,IAA0B,MAAM,CAAC,YAJA,EAKjC,KAAK,CAAC,UAAN,KAAqB,UAArB,IAAmC,MAAM,CAAC,QALT,EAMjC,KAAK,CAAC,UAAN,KAAqB,OAArB,IAAgC,MAAM,CAAC,KANN,EAOjC,KAAK,CAAC,IAAN,CAAW,SAPsB,CAAnC;AAUA,EAAA,KAAK,CAAC,cAAN,GAAuB,YAAY,CACjC,MAAM,CAAC,KAD0B,EAEjC,KAAK,CAAC,IAAN,KAAe,OAAf,GAAyB,MAAM,CAAC,UAAhC,GAA6C,MAAM,CAAC,gBAFnB,CAAnC;AAKA,SAAO,KAAP;AACD,CAlBM","sourceRoot":""}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { PopoverTriggerProps } from './PopoverTrigger.types';
2
+ import type { PopoverTriggerProps } from './PopoverTrigger.types';
3
3
  /**
4
- * PopoverTrigger component
4
+ * Wraps a trigger element as an only child and adds the necessary event handling to open a popover.
5
5
  */
6
6
  export declare const PopoverTrigger: React.FC<PopoverTriggerProps>;
@@ -1,11 +1,12 @@
1
1
  import { usePopoverTrigger } from './usePopoverTrigger';
2
2
  import { renderPopoverTrigger } from './renderPopoverTrigger';
3
3
  /**
4
- * PopoverTrigger component
4
+ * Wraps a trigger element as an only child and adds the necessary event handling to open a popover.
5
5
  */
6
+
6
7
  export var PopoverTrigger = function (props) {
7
- var state = usePopoverTrigger(props);
8
- return renderPopoverTrigger(state);
8
+ var state = usePopoverTrigger(props);
9
+ return renderPopoverTrigger(state);
9
10
  };
10
11
  PopoverTrigger.displayName = 'PopoverTrigger';
11
12
  //# sourceMappingURL=PopoverTrigger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PopoverTrigger.js","sourceRoot":"../src/","sources":["components/PopoverTrigger/PopoverTrigger.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,IAAM,cAAc,GAAkC,UAAA,KAAK;IAChE,IAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAEvC,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,cAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC","sourcesContent":["import * as React from 'react';\nimport { usePopoverTrigger } from './usePopoverTrigger';\nimport { PopoverTriggerProps } from './PopoverTrigger.types';\nimport { renderPopoverTrigger } from './renderPopoverTrigger';\n\n/**\n * PopoverTrigger component\n */\nexport const PopoverTrigger: React.FC<PopoverTriggerProps> = props => {\n const state = usePopoverTrigger(props);\n\n return renderPopoverTrigger(state);\n};\n\nPopoverTrigger.displayName = 'PopoverTrigger';\n"]}
1
+ {"version":3,"sources":["../../../src/components/PopoverTrigger/PopoverTrigger.tsx"],"names":[],"mappings":"AACA,SAAS,iBAAT,QAAkC,qBAAlC;AACA,SAAS,oBAAT,QAAqC,wBAArC;AAGA;;AAEG;;AACH,OAAO,IAAM,cAAc,GAAkC,UAAA,KAAA,EAAK;AAChE,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAD,CAA/B;AAEA,SAAO,oBAAoB,CAAC,KAAD,CAA3B;AACD,CAJM;AAMP,cAAc,CAAC,WAAf,GAA6B,gBAA7B","sourceRoot":""}
@@ -2,11 +2,10 @@ import * as React from 'react';
2
2
  /**
3
3
  * PopoverTrigger Props
4
4
  */
5
- export interface PopoverTriggerProps {
5
+ export declare type PopoverTriggerProps = {
6
6
  children: React.ReactElement;
7
- }
7
+ };
8
8
  /**
9
9
  * PopoverTrigger State
10
10
  */
11
- export interface PopoverTriggerState extends PopoverTriggerProps {
12
- }
11
+ export declare type PopoverTriggerState = PopoverTriggerProps;
@@ -1 +1 @@
1
- {"version":3,"file":"PopoverTrigger.types.js","sourceRoot":"../src/","sources":["components/PopoverTrigger/PopoverTrigger.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\n/**\n * PopoverTrigger Props\n */\nexport interface PopoverTriggerProps {\n children: React.ReactElement;\n}\n\n/**\n * PopoverTrigger State\n */\nexport interface PopoverTriggerState extends PopoverTriggerProps {}\n"]}
1
+ {"version":3,"file":"PopoverTrigger.types.js","sourceRoot":"","sources":["../../../src/components/PopoverTrigger/PopoverTrigger.types.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/PopoverTrigger/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './PopoverTrigger';\nexport * from './PopoverTrigger.types';\nexport * from './renderPopoverTrigger';\nexport * from './usePopoverTrigger';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/PopoverTrigger/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { PopoverTriggerState } from './PopoverTrigger.types';
1
+ import type { PopoverTriggerState } from './PopoverTrigger.types';
2
2
  /**
3
3
  * Render the final JSX of PopoverTrigger
4
4
  */
@@ -2,6 +2,6 @@
2
2
  * Render the final JSX of PopoverTrigger
3
3
  */
4
4
  export var renderPopoverTrigger = function (state) {
5
- return state.children;
5
+ return state.children;
6
6
  };
7
7
  //# sourceMappingURL=renderPopoverTrigger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderPopoverTrigger.js","sourceRoot":"../src/","sources":["components/PopoverTrigger/renderPopoverTrigger.tsx"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,IAAM,oBAAoB,GAAG,UAAC,KAA0B;IAC7D,OAAO,KAAK,CAAC,QAAQ,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import { PopoverTriggerState } from './PopoverTrigger.types';\n\n/**\n * Render the final JSX of PopoverTrigger\n */\nexport const renderPopoverTrigger = (state: PopoverTriggerState): JSX.Element => {\n return state.children;\n};\n"]}
1
+ {"version":3,"sources":["../../../src/components/PopoverTrigger/renderPopoverTrigger.tsx"],"names":[],"mappings":"AAEA;;AAEG;AACH,OAAO,IAAM,oBAAoB,GAAG,UAAC,KAAD,EAA2B;AAC7D,SAAO,KAAK,CAAC,QAAb;AACD,CAFM","sourceRoot":""}
@@ -1,4 +1,4 @@
1
- import { PopoverTriggerProps, PopoverTriggerState } from './PopoverTrigger.types';
1
+ import type { PopoverTriggerProps, PopoverTriggerState } from './PopoverTrigger.types';
2
2
  /**
3
3
  * Create the state required to render PopoverTrigger.
4
4
  *
@@ -6,6 +6,5 @@ import { PopoverTriggerProps, PopoverTriggerState } from './PopoverTrigger.types
6
6
  * before being passed to renderPopoverTrigger.
7
7
  *
8
8
  * @param props - props from this instance of PopoverTrigger
9
- * @param defaultProps - (optional) default prop values provided by the implementing type
10
9
  */
11
- export declare const usePopoverTrigger: (props: PopoverTriggerProps, defaultProps?: PopoverTriggerProps | undefined) => PopoverTriggerState;
10
+ export declare const usePopoverTrigger: (props: PopoverTriggerProps) => PopoverTriggerState;
@@ -1,9 +1,8 @@
1
1
  import { __assign } from "tslib";
2
2
  import * as React from 'react';
3
- import { makeMergeProps, useMergedRefs, useEventCallback, shouldPreventDefaultOnKeyDown, } from '@fluentui/react-utilities';
3
+ import { useMergedRefs, useEventCallback, shouldPreventDefaultOnKeyDown } from '@fluentui/react-utilities';
4
4
  import { useModalAttributes } from '@fluentui/react-tabster';
5
5
  import { usePopoverContext } from '../../popoverContext';
6
- var mergeProps = makeMergeProps({});
7
6
  /**
8
7
  * Create the state required to render PopoverTrigger.
9
8
  *
@@ -11,64 +10,88 @@ var mergeProps = makeMergeProps({});
11
10
  * before being passed to renderPopoverTrigger.
12
11
  *
13
12
  * @param props - props from this instance of PopoverTrigger
14
- * @param defaultProps - (optional) default prop values provided by the implementing type
15
13
  */
16
- export var usePopoverTrigger = function (props, defaultProps) {
17
- var setOpen = usePopoverContext(function (context) { return context.setOpen; });
18
- var open = usePopoverContext(function (context) { return context.open; });
19
- var triggerRef = usePopoverContext(function (context) { return context.triggerRef; });
20
- var openOnHover = usePopoverContext(function (context) { return context.openOnHover; });
21
- var openOnContext = usePopoverContext(function (context) { return context.openOnContext; });
22
- var triggerAttributes = useModalAttributes().triggerAttributes;
23
- var state = mergeProps({
24
- children: null,
25
- }, defaultProps, props);
26
- var onContextMenu = useEventCallback(function (e) {
27
- var _a, _b;
28
- if (openOnContext) {
29
- e.preventDefault();
30
- setOpen(e, true);
31
- }
32
- (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onContextMenu) === null || _b === void 0 ? void 0 : _b.call(_a, e);
33
- });
34
- var onClick = useEventCallback(function (e) {
35
- var _a, _b;
36
- if (!openOnContext) {
37
- setOpen(e, !open);
38
- }
39
- (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
40
- });
41
- var onKeyDown = useEventCallback(function (e) {
42
- var _a, _b, _c;
43
- if (shouldPreventDefaultOnKeyDown(e) && (e.key === ' ' || e.key === 'Enter')) {
44
- e.preventDefault();
45
- (_a = e.target) === null || _a === void 0 ? void 0 : _a.click();
46
- }
47
- if (e.key === 'Escape') {
48
- setOpen(e, false);
49
- }
50
- (_c = (_b = child.props) === null || _b === void 0 ? void 0 : _b.onKeyDown) === null || _c === void 0 ? void 0 : _c.call(_b, e);
51
- });
52
- var onMouseEnter = useEventCallback(function (e) {
53
- var _a, _b;
54
- if (openOnHover) {
55
- setOpen(e, true);
56
- }
57
- (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onMouseEnter) === null || _b === void 0 ? void 0 : _b.call(_a, e);
58
- });
59
- var onMouseLeave = useEventCallback(function (e) {
60
- var _a, _b;
61
- if (openOnHover) {
62
- setOpen(e, false);
63
- }
64
- (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onMouseLeave) === null || _b === void 0 ? void 0 : _b.call(_a, e);
65
- });
66
- var child = React.Children.only(state.children);
67
- state.children = React.cloneElement(child, __assign({ 'aria-haspopup': 'true', onClick: onClick,
68
- onMouseEnter: onMouseEnter,
69
- onKeyDown: onKeyDown,
70
- onMouseLeave: onMouseLeave,
71
- onContextMenu: onContextMenu, ref: useMergedRefs(child.props.ref, triggerRef) }, triggerAttributes));
72
- return state;
14
+
15
+ export var usePopoverTrigger = function (props) {
16
+ var setOpen = usePopoverContext(function (context) {
17
+ return context.setOpen;
18
+ });
19
+ var open = usePopoverContext(function (context) {
20
+ return context.open;
21
+ });
22
+ var triggerRef = usePopoverContext(function (context) {
23
+ return context.triggerRef;
24
+ });
25
+ var openOnHover = usePopoverContext(function (context) {
26
+ return context.openOnHover;
27
+ });
28
+ var openOnContext = usePopoverContext(function (context) {
29
+ return context.openOnContext;
30
+ });
31
+ var triggerAttributes = useModalAttributes().triggerAttributes;
32
+ var onContextMenu = useEventCallback(function (e) {
33
+ var _a, _b;
34
+
35
+ if (openOnContext) {
36
+ e.preventDefault();
37
+ setOpen(e, true);
38
+ }
39
+
40
+ (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onContextMenu) === null || _b === void 0 ? void 0 : _b.call(_a, e);
41
+ });
42
+ var onClick = useEventCallback(function (e) {
43
+ var _a, _b;
44
+
45
+ if (!openOnContext) {
46
+ setOpen(e, !open);
47
+ }
48
+
49
+ (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
50
+ });
51
+ var onKeyDown = useEventCallback(function (e) {
52
+ var _a, _b, _c;
53
+
54
+ if (shouldPreventDefaultOnKeyDown(e) && (e.key === ' ' || e.key === 'Enter')) {
55
+ e.preventDefault();
56
+ (_a = e.target) === null || _a === void 0 ? void 0 : _a.click();
57
+ }
58
+
59
+ if (e.key === 'Escape') {
60
+ setOpen(e, false);
61
+ }
62
+
63
+ (_c = (_b = child.props) === null || _b === void 0 ? void 0 : _b.onKeyDown) === null || _c === void 0 ? void 0 : _c.call(_b, e);
64
+ });
65
+ var onMouseEnter = useEventCallback(function (e) {
66
+ var _a, _b;
67
+
68
+ if (openOnHover) {
69
+ setOpen(e, true);
70
+ }
71
+
72
+ (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onMouseEnter) === null || _b === void 0 ? void 0 : _b.call(_a, e);
73
+ });
74
+ var onMouseLeave = useEventCallback(function (e) {
75
+ var _a, _b;
76
+
77
+ if (openOnHover) {
78
+ setOpen(e, false);
79
+ }
80
+
81
+ (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onMouseLeave) === null || _b === void 0 ? void 0 : _b.call(_a, e);
82
+ });
83
+ var child = React.Children.only(props.children);
84
+ return {
85
+ children: /*#__PURE__*/React.cloneElement(child, __assign(__assign(__assign(__assign({}, triggerAttributes), {
86
+ 'aria-haspopup': 'true'
87
+ }), child.props), {
88
+ onClick: onClick,
89
+ onMouseEnter: onMouseEnter,
90
+ onKeyDown: onKeyDown,
91
+ onMouseLeave: onMouseLeave,
92
+ onContextMenu: onContextMenu,
93
+ ref: useMergedRefs(child.ref, triggerRef)
94
+ }))
95
+ };
73
96
  };
74
97
  //# sourceMappingURL=usePopoverTrigger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePopoverTrigger.js","sourceRoot":"../src/","sources":["components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,IAAM,UAAU,GAAG,cAAc,CAAsB,EAAE,CAAC,CAAC;AAE3D;;;;;;;;G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EAAE,UAAU,CAAC,IAC5C,iBAAiB,EACpB,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport {\n makeMergeProps,\n useMergedRefs,\n useEventCallback,\n shouldPreventDefaultOnKeyDown,\n} from '@fluentui/react-utilities';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { PopoverTriggerProps, PopoverTriggerState } from './PopoverTrigger.types';\nimport { usePopoverContext } from '../../popoverContext';\n\nconst mergeProps = makeMergeProps<PopoverTriggerState>({});\n\n/**\n * Create the state required to render PopoverTrigger.\n *\n * The returned state can be modified with hooks such as usePopoverTriggerStyles,\n * before being passed to renderPopoverTrigger.\n *\n * @param props - props from this instance of PopoverTrigger\n * @param defaultProps - (optional) default prop values provided by the implementing type\n */\nexport const usePopoverTrigger = (\n props: PopoverTriggerProps,\n defaultProps?: PopoverTriggerProps,\n): PopoverTriggerState => {\n const setOpen = usePopoverContext(context => context.setOpen);\n const open = usePopoverContext(context => context.open);\n const triggerRef = usePopoverContext(context => context.triggerRef);\n const openOnHover = usePopoverContext(context => context.openOnHover);\n const openOnContext = usePopoverContext(context => context.openOnContext);\n const { triggerAttributes } = useModalAttributes();\n\n const state = mergeProps(\n {\n children: (null as unknown) as React.ReactElement,\n },\n defaultProps,\n props,\n );\n\n const onContextMenu = useEventCallback((e: React.MouseEvent<HTMLElement>) => {\n if (openOnContext) {\n e.preventDefault();\n setOpen(e, true);\n }\n\n child.props?.onContextMenu?.(e);\n });\n\n const onClick = useEventCallback((e: React.MouseEvent<HTMLElement>) => {\n if (!openOnContext) {\n setOpen(e, !open);\n }\n child.props?.onClick?.(e);\n });\n\n const onKeyDown = useEventCallback((e: React.KeyboardEvent<HTMLElement>) => {\n if (shouldPreventDefaultOnKeyDown(e) && (e.key === ' ' || e.key === 'Enter')) {\n e.preventDefault();\n (e.target as HTMLElement)?.click();\n }\n\n if (e.key === 'Escape') {\n setOpen(e, false);\n }\n\n child.props?.onKeyDown?.(e);\n });\n\n const onMouseEnter = useEventCallback((e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, true);\n }\n child.props?.onMouseEnter?.(e);\n });\n\n const onMouseLeave = useEventCallback((e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, false);\n }\n child.props?.onMouseLeave?.(e);\n });\n\n const child = React.Children.only(state.children);\n state.children = React.cloneElement(child, {\n 'aria-haspopup': 'true',\n onClick,\n onMouseEnter,\n onKeyDown,\n onMouseLeave,\n onContextMenu,\n ref: useMergedRefs(child.props.ref, triggerRef),\n ...triggerAttributes,\n });\n\n return state;\n};\n"]}
1
+ {"version":3,"sources":["../../../src/components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,aAAT,EAAwB,gBAAxB,EAA0C,6BAA1C,QAA+E,2BAA/E;AACA,SAAS,kBAAT,QAAmC,yBAAnC;AACA,SAAS,iBAAT,QAAkC,sBAAlC;AAGA;;;;;;;AAOG;;AACH,OAAO,IAAM,iBAAiB,GAAG,UAAC,KAAD,EAA2B;AAC1D,MAAM,OAAO,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,OAAA;AAAe,GAA3B,CAAjC;AACA,MAAM,IAAI,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,IAAA;AAAY,GAAxB,CAA9B;AACA,MAAM,UAAU,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,UAAA;AAAkB,GAA9B,CAApC;AACA,MAAM,WAAW,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,WAAA;AAAmB,GAA/B,CAArC;AACA,MAAM,aAAa,GAAG,iBAAiB,CAAC,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,aAAA;AAAqB,G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,GAAyB,KAAA,CAAzB,GAAyB,EAAA,CAAA,IAAA,CAAA,EAAA,EAAG,CAAH,CAAzB;AACD,GALoC,CAArC;AAOA,MAAM,KAAK,GAAG,KAAK,CAAC,QAAN,CAAe,IAAf,CAAoB,KAAK,CAAC,QAA1B,CAAd;AACA,SAAO;AACL,IAAA,QAAQ,eAAE,KAAK,CAAC,YAAN,CAAmB,KAAnB,EAAwB,QAAA,CAAA,QAAA,CAAA,QAAA,CAAA,QAAA,CAAA,EAAA,EAC7B,iBAD6B,CAAA,EACZ;AACpB,uBAAiB;AADG,KADY,CAAA,EAG7B,KAAK,CAAC,KAHuB,CAAA,EAGlB;AACd,MAAA,OAAO,EAAA,OADO;AAEd,MAAA,YAAY,EAAA,YAFE;AAGd,MAAA,SAAS,EAAA,SAHK;AAId,MAAA,YAAY,EAAA,YAJE;AAKd,MAAA,aAAa,EAAA,aALC;AAMd,MAAA,GAAG,EAAE,aAAa,CAAG,KAAuE,CAAC,GAA3E,EAAgF,UAAhF;AANJ,KAHkB,CAAxB;AADL,GAAP;AAaD,CAjEM","sourceRoot":""}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './Popover';\nexport * from './PopoverSurface';\nexport * from './popoverContext';\nexport * from './PopoverTrigger';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
@@ -1,9 +1,8 @@
1
- import { ContextSelector, Context } from '@fluentui/react-context-selector';
2
- import { PopoverState } from './components/Popover/index';
1
+ import type { ContextSelector, Context } from '@fluentui/react-context-selector';
2
+ import type { PopoverState } from './components/Popover/index';
3
3
  export declare const PopoverContext: Context<PopoverContextValue>;
4
4
  /**
5
5
  * Context shared between Popover and its children components
6
6
  */
7
- export interface PopoverContextValue extends Pick<PopoverState, 'open' | 'setOpen' | 'triggerRef' | 'contentRef' | 'target' | 'openOnHover' | 'openOnContext' | 'mountNode' | 'noArrow' | 'arrowRef' | 'size' | 'brand' | 'inverted' | 'trapFocus'> {
8
- }
9
- export declare const usePopoverContext: <T>(selector: ContextSelector<PopoverContextValue, T>) => T;
7
+ export declare type PopoverContextValue = Pick<PopoverState, 'open' | 'setOpen' | 'triggerRef' | 'contentRef' | 'openOnHover' | 'openOnContext' | 'mountNode' | 'noArrow' | 'arrowRef' | 'size' | 'appearance' | 'trapFocus'>;
8
+ export declare const usePopoverContext: <T>(selector: ContextSelector<Pick<PopoverState, "mountNode" | "open" | "setOpen" | "triggerRef" | "contentRef" | "openOnHover" | "openOnContext" | "noArrow" | "arrowRef" | "size" | "appearance" | "trapFocus">, T>) => T;
@@ -1,17 +1,24 @@
1
1
  import { createContext, useContextSelector } from '@fluentui/react-context-selector';
2
- export var PopoverContext = createContext({
3
- open: false,
4
- setOpen: function () { return null; },
5
- triggerRef: { current: null },
6
- contentRef: { current: null },
7
- arrowRef: { current: null },
8
- target: undefined,
9
- openOnContext: false,
10
- openOnHover: false,
11
- size: 'medium',
12
- trapFocus: false,
2
+ export var PopoverContext = /*#__PURE__*/createContext({
3
+ open: false,
4
+ setOpen: function () {
5
+ return null;
6
+ },
7
+ triggerRef: {
8
+ current: null
9
+ },
10
+ contentRef: {
11
+ current: null
12
+ },
13
+ arrowRef: {
14
+ current: null
15
+ },
16
+ openOnContext: false,
17
+ openOnHover: false,
18
+ size: 'medium',
19
+ trapFocus: false
13
20
  });
14
21
  export var usePopoverContext = function (selector) {
15
- return useContextSelector(PopoverContext, selector);
22
+ return useContextSelector(PopoverContext, selector);
16
23
  };
17
24
  //# sourceMappingURL=popoverContext.js.map