@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/PopoverTrigger.types.ts +0 -13
@@ -1,17 +1,23 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.usePopover = void 0;
4
- var React = require("react");
5
- var react_utilities_1 = require("@fluentui/react-utilities");
6
- var react_shared_contexts_1 = require("@fluentui/react-shared-contexts");
7
- var react_positioning_1 = require("@fluentui/react-positioning");
8
- var react_portal_1 = require("@fluentui/react-portal");
9
- var index_1 = require("../PopoverSurface/index");
10
- var getOffsetWithArrow_1 = require("./getOffsetWithArrow");
11
- /**
12
- * Names of the shorthand properties in PopoverProps
13
- */
14
- var mergeProps = react_utilities_1.makeMergeProps({});
7
+
8
+ var tslib_1 = /*#__PURE__*/require("tslib");
9
+
10
+ var React = /*#__PURE__*/require("react");
11
+
12
+ var react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
13
+
14
+ var react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
15
+
16
+ var react_positioning_1 = /*#__PURE__*/require("@fluentui/react-positioning");
17
+
18
+ var react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
19
+
20
+ var index_1 = /*#__PURE__*/require("../PopoverSurface/index");
15
21
  /**
16
22
  * Create the state required to render Popover.
17
23
  *
@@ -19,99 +25,127 @@ var mergeProps = react_utilities_1.makeMergeProps({});
19
25
  * before being passed to renderPopover.
20
26
  *
21
27
  * @param props - props from this instance of Popover
22
- * @param defaultProps - (optional) default prop values provided by the implementing type
23
28
  */
24
- var usePopover = function (props, defaultProps) {
25
- var state = mergeProps({
26
- size: 'medium',
27
- open: undefined,
28
- setOpen: function () { return null; },
29
- triggerRef: { current: null },
30
- contentRef: { current: null },
31
- arrowRef: { current: null },
32
- children: null,
33
- position: 'above',
34
- align: 'center',
35
- setContextTarget: function () { return null; },
36
- contextTarget: undefined,
37
- }, defaultProps, props);
38
- // no reason to render arrow when covering the target
39
- if (state.coverTarget) {
40
- state.noArrow = true;
41
- }
42
- var _a = React.useState(), contextTarget = _a[0], setContextTarget = _a[1];
43
- state.setContextTarget = setContextTarget;
44
- state.contextTarget = contextTarget;
45
- useOpenState(state);
46
- usePopoverRefs(state);
47
- var targetDocument = react_shared_contexts_1.useFluent().targetDocument;
48
- react_utilities_1.useOnClickOutside({
49
- contains: react_portal_1.elementContains,
50
- element: targetDocument,
51
- callback: function (ev) { return state.setOpen(ev, false); },
52
- refs: [state.triggerRef, state.contentRef],
53
- disabled: !state.open,
54
- });
55
- react_utilities_1.useOnScrollOutside({
56
- contains: react_portal_1.elementContains,
57
- element: targetDocument,
58
- callback: function (ev) { return state.setOpen(ev, false); },
59
- refs: [state.triggerRef, state.contentRef],
60
- disabled: !state.open || !state.openOnContext,
61
- });
62
- return state;
29
+
30
+
31
+ var usePopover = function (props) {
32
+ var _a = react_positioning_1.usePopperMouseTarget(),
33
+ contextTarget = _a[0],
34
+ setContextTarget = _a[1];
35
+
36
+ var initialState = tslib_1.__assign({
37
+ size: 'medium',
38
+ contextTarget: contextTarget,
39
+ setContextTarget: setContextTarget
40
+ }, props);
41
+
42
+ var _b = useOpenState(initialState),
43
+ open = _b[0],
44
+ setOpen = _b[1];
45
+
46
+ var popperRefs = usePopoverRefs(initialState);
47
+ var targetDocument = react_shared_contexts_1.useFluent().targetDocument;
48
+ react_utilities_1.useOnClickOutside({
49
+ contains: react_portal_1.elementContains,
50
+ element: targetDocument,
51
+ callback: function (ev) {
52
+ return setOpen(ev, false);
53
+ },
54
+ refs: [popperRefs.triggerRef, popperRefs.contentRef],
55
+ disabled: !open
56
+ });
57
+ react_utilities_1.useOnScrollOutside({
58
+ contains: react_portal_1.elementContains,
59
+ element: targetDocument,
60
+ callback: function (ev) {
61
+ return setOpen(ev, false);
62
+ },
63
+ refs: [popperRefs.triggerRef, popperRefs.contentRef],
64
+ disabled: !open || !initialState.openOnContext
65
+ });
66
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, initialState), popperRefs), {
67
+ open: open,
68
+ setOpen: setOpen,
69
+ setContextTarget: setContextTarget,
70
+ contextTarget: contextTarget
71
+ });
63
72
  };
73
+
64
74
  exports.usePopover = usePopover;
65
75
  /**
66
76
  * Creates and manages the Popover open state
67
- * @param state Popover state
68
77
  */
78
+
69
79
  function useOpenState(state) {
70
- var onOpenChange = react_utilities_1.useEventCallback(function (e, data) { var _a; return (_a = state.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(state, e, data); });
71
- var _a = react_utilities_1.useControllableValue(state.open, state.defaultOpen), open = _a[0], setOpen = _a[1];
72
- state.open = open !== undefined ? open : state.open;
73
- var setContextTarget = state.setContextTarget;
74
- state.setOpen = React.useCallback(function (e, shouldOpen) {
75
- if (shouldOpen && e.type === 'contextmenu') {
76
- var virtualElement = react_positioning_1.createVirtualElementFromClick(e.nativeEvent);
77
- setContextTarget(virtualElement);
78
- }
79
- if (!shouldOpen) {
80
- setContextTarget(undefined);
81
- }
82
- setOpen(function (prevOpen) {
83
- // More than one event (mouse, focus, keyboard) can request the Popover to close
84
- // We assume the first event is the correct one
85
- if (prevOpen !== shouldOpen) {
86
- onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(e, { open: shouldOpen });
87
- }
88
- return shouldOpen;
80
+ var onOpenChange = react_utilities_1.useEventCallback(function (e, data) {
81
+ var _a;
82
+
83
+ return (_a = state.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(state, e, data);
84
+ });
85
+
86
+ var _a = react_utilities_1.useControllableState({
87
+ state: state.open,
88
+ defaultState: state.defaultOpen,
89
+ initialState: false
90
+ }),
91
+ open = _a[0],
92
+ setOpenState = _a[1];
93
+
94
+ state.open = open !== undefined ? open : state.open;
95
+ var setContextTarget = state.setContextTarget;
96
+ var setOpen = React.useCallback(function (e, shouldOpen) {
97
+ if (shouldOpen && e.type === 'contextmenu') {
98
+ setContextTarget(e);
99
+ }
100
+
101
+ if (!shouldOpen) {
102
+ setContextTarget(undefined);
103
+ }
104
+
105
+ setOpenState(function (prevOpen) {
106
+ // More than one event (mouse, focus, keyboard) can request the Popover to close
107
+ // We assume the first event is the correct one
108
+ if (prevOpen !== shouldOpen) {
109
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(e, {
110
+ open: shouldOpen
89
111
  });
90
- }, [setOpen, onOpenChange, setContextTarget]);
91
- return state;
112
+ }
113
+
114
+ return shouldOpen;
115
+ });
116
+ }, [setOpenState, onOpenChange, setContextTarget]);
117
+ return [open, setOpen];
92
118
  }
93
119
  /**
94
120
  * Creates and sets the necessary trigger, target and content refs used by Popover
95
- * @param state Popover state
96
121
  */
122
+
123
+
97
124
  function usePopoverRefs(state) {
98
- if (!state.noArrow) {
99
- state.offset = getOffsetWithArrow_1.getOffsetWithArrow(state.offset, index_1.arrowHeights[state.size]);
100
- }
101
- if (!state.target && state.openOnContext && state.contextTarget) {
102
- state.target = state.contextTarget;
103
- }
104
- var _a = react_positioning_1.usePopper({
105
- align: state.align,
106
- position: state.position,
107
- target: state.target,
108
- coverTarget: state.coverTarget,
109
- offset: state.offset,
110
- arrowPadding: index_1.arrowHeights[state.size],
111
- }), triggerRef = _a.targetRef, contentRef = _a.containerRef, arrowRef = _a.arrowRef;
112
- state.contentRef = contentRef;
113
- state.triggerRef = triggerRef;
114
- state.arrowRef = arrowRef;
115
- return state;
125
+ var popperOptions = tslib_1.__assign({
126
+ position: 'above',
127
+ align: 'center',
128
+ target: state.openOnContext ? state.contextTarget : undefined
129
+ }, react_positioning_1.resolvePositioningShorthand(state.positioning)); // no reason to render arrow when covering the target
130
+
131
+
132
+ if (popperOptions.coverTarget) {
133
+ state.noArrow = true;
134
+ }
135
+
136
+ if (!state.noArrow) {
137
+ popperOptions.offset = react_positioning_1.mergeArrowOffset(popperOptions.offset, index_1.arrowHeights[state.size]);
138
+ }
139
+
140
+ var _a = react_positioning_1.usePopper(popperOptions),
141
+ triggerRef = _a.targetRef,
142
+ contentRef = _a.containerRef,
143
+ arrowRef = _a.arrowRef;
144
+
145
+ return {
146
+ triggerRef: triggerRef,
147
+ contentRef: contentRef,
148
+ arrowRef: arrowRef
149
+ };
116
150
  }
117
151
  //# sourceMappingURL=usePopover.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePopover.js","sourceRoot":"../src/","sources":["components/Popover/usePopover.ts"],"names":[],"mappings":";;;AAAA,6BAA+B;AAC/B,6DAMmC;AACnC,yEAA4D;AAC5D,iEAA6G;AAC7G,uDAAyD;AAEzD,iDAAuD;AACvD,2DAA0D;AAE1D;;GAEG;AACH,IAAM,UAAU,GAAG,gCAAc,CAAe,EAAE,CAAC,CAAC;AAEpD;;;;;;;;GAQG;AACI,IAAM,UAAU,GAAG,UAAC,KAAmB,EAAE,YAA2B;IACzE,IAAM,KAAK,GAAG,UAAU,CACtB;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAG,SAAgC;QACvC,OAAO,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QACnB,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC7B,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC7B,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC3B,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,QAAQ;QACf,gBAAgB,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QAC5B,aAAa,EAAE,SAAS;KACzB,EACD,YAAY,EACZ,KAAK,CACN,CAAC;IAEF,qDAAqD;IACrD,IAAI,KAAK,CAAC,WAAW,EAAE;QACrB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;KACtB;IAEK,IAAA,KAAoC,KAAK,CAAC,QAAQ,EAAwB,EAAzE,aAAa,QAAA,EAAE,gBAAgB,QAA0C,CAAC;IACjF,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC;IAEpC,YAAY,CAA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AAQ;QACxB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,YAAY,EAAE,oBAAY,CAAC,KAAK,CAAC,IAAI,CAAC;KACvC,CAAC,EAPiB,UAAU,eAAA,EAAgB,UAAU,kBAAA,EAAE,QAAQ,cAO/D,CAAC;IAEH,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAE1B,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import * as React from 'react';\nimport {\n makeMergeProps,\n useControllableValue,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport { usePopper, PopperVirtualElement, createVirtualElementFromClick } from '@fluentui/react-positioning';\nimport { elementContains } from '@fluentui/react-portal';\nimport { PopoverProps, PopoverState } from './Popover.types';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport { getOffsetWithArrow } from './getOffsetWithArrow';\n\n/**\n * Names of the shorthand properties in PopoverProps\n */\nconst mergeProps = makeMergeProps<PopoverState>({});\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.\n *\n * @param props - props from this instance of Popover\n * @param defaultProps - (optional) default prop values provided by the implementing type\n */\nexport const usePopover = (props: PopoverProps, defaultProps?: PopoverProps): PopoverState => {\n const state = mergeProps(\n {\n size: 'medium',\n open: (undefined as unknown) as boolean, // mergeProps typings require this\n setOpen: () => null,\n triggerRef: { current: null },\n contentRef: { current: null },\n arrowRef: { current: null },\n children: null,\n position: 'above',\n align: 'center',\n setContextTarget: () => null,\n contextTarget: undefined,\n },\n defaultProps,\n props,\n );\n\n // no reason to render arrow when covering the target\n if (state.coverTarget) {\n state.noArrow = true;\n }\n\n const [contextTarget, setContextTarget] = React.useState<PopperVirtualElement>();\n state.setContextTarget = setContextTarget;\n state.contextTarget = contextTarget;\n\n useOpenState(state);\n usePopoverRefs(state);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => state.setOpen(ev, false),\n refs: [state.triggerRef, state.contentRef],\n disabled: !state.open,\n });\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => state.setOpen(ev, false),\n refs: [state.triggerRef, state.contentRef],\n disabled: !state.open || !state.openOnContext,\n });\n\n return state;\n};\n\n/**\n * Creates and manages the Popover open state\n * @param state Popover state\n */\nfunction useOpenState(state: PopoverState): PopoverState {\n const onOpenChange: PopoverState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const [open, setOpen] = useControllableValue(state.open, state.defaultOpen);\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n\n state.setOpen = React.useCallback(\n (e, shouldOpen) => {\n if (shouldOpen && e.type === 'contextmenu') {\n const virtualElement = createVirtualElementFromClick((e as React.MouseEvent).nativeEvent);\n setContextTarget(virtualElement);\n }\n\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n\n setOpen(prevOpen => {\n // More than one event (mouse, focus, keyboard) can request the Popover to close\n // We assume the first event is the correct one\n if (prevOpen !== shouldOpen) {\n onOpenChange?.(e, { open: shouldOpen });\n }\n\n return shouldOpen;\n });\n },\n [setOpen, onOpenChange, setContextTarget],\n );\n\n return state;\n}\n\n/**\n * Creates and sets the necessary trigger, target and content refs used by Popover\n * @param state Popover state\n */\nfunction usePopoverRefs(state: PopoverState): PopoverState {\n if (!state.noArrow) {\n state.offset = getOffsetWithArrow(state.offset, arrowHeights[state.size]);\n }\n\n if (!state.target && state.openOnContext && state.contextTarget) {\n state.target = state.contextTarget;\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePopper({\n align: state.align,\n position: state.position,\n target: state.target,\n coverTarget: state.coverTarget,\n offset: state.offset,\n arrowPadding: arrowHeights[state.size],\n });\n\n state.contentRef = contentRef;\n state.triggerRef = triggerRef;\n state.arrowRef = arrowRef;\n\n return state;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/components/Popover/usePopover.ts"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAMA,IAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AACA,IAAA,mBAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AAMA,IAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,IAAA,OAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;AAGA;;;;;;;AAOG;;;AACI,IAAM,UAAU,GAAG,UAAC,KAAD,EAAoB;AACtC,MAAA,EAAA,GAAoC,mBAAA,CAAA,oBAAA,EAApC;AAAA,MAAC,aAAa,GAAA,EAAA,CAAA,CAAA,CAAd;AAAA,MAAgB,gBAAgB,GAAA,EAAA,CAAA,CAAA,CAAhC;;AACN,MAAM,YAAY,GAAG,OAAA,CAAA,QAAA,CAAA;AACnB,IAAA,IAAI,EAAE,QADa;AAEnB,IAAA,aAAa,EAAA,aAFM;AAGnB,IAAA,gBAAgB,EAAA;AAHG,GAAA,EAIhB,KAJgB,CAArB;;AAOM,MAAA,EAAA,GAAkB,YAAY,CAAC,YAAD,CAA9B;AAAA,MAAC,IAAI,GAAA,EAAA,CAAA,CAAA,CAAL;AAAA,MAAO,OAAO,GAAA,EAAA,CAAA,CAAA,CAAd;;AACN,MAAM,UAAU,GAAG,cAAc,CAAC,YAAD,CAAjC;AAEQ,MAAA,cAAc,GAAK,uBAAA,CAAA,SAAA,GAAL,cAAd;AACR,EAAA,iBAAA,CAAA,iBAAA,CAAkB;AAChB,IAAA,QAAQ,EAAE,cAAA,CAAA,eADM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uH;AAErH,MAAM,aAAa,GAAA,OAAA,CAAA,QAAA,CAAA;AACjB,IAAA,QAAQ,EAAE,OADO;AAEjB,IAAA,KAAK,EAAE,QAFU;AAGjB,IAAA,MAAM,EAAE,KAAK,CAAC,aAAN,GAAsB,KAAK,CAAC,aAA5B,GAA4C;AAHnC,GAAA,EAId,mBAAA,CAAA,2BAAA,CAA4B,KAAK,CAAC,WAAlC,CAJc,CAAnB,CAFqH,CASrH;;;AACA,MAAI,aAAa,CAAC,WAAlB,EAA+B;AAC7B,IAAA,KAAK,CAAC,OAAN,GAAgB,IAAhB;AACD;;AAED,MAAI,CAAC,KAAK,CAAC,OAAX,EAAoB;AAClB,IAAA,aAAa,CAAC,MAAd,GAAuB,mBAAA,CAAA,gBAAA,CAAiB,aAAa,CAAC,MAA/B,EAAuC,OAAA,CAAA,YAAA,CAAa,KAAK,CAAC,IAAnB,CAAvC,CAAvB;AACD;;AAEK,MAAA,EAAA,GAAgE,mBAAA,CAAA,SAAA,CAAU,aAAV,CAAhE;AAAA,MAAa,UAAU,GAAA,EAAA,CAAA,SAAvB;AAAA,MAAuC,UAAU,GAAA,EAAA,CAAA,YAAjD;AAAA,MAAmD,QAAQ,GAAA,EAAA,CAAA,QAA3D;;AAEN,SAAO;AACL,IAAA,UAAU,EAAA,UADL;AAEL,IAAA,UAAU,EAAA,UAFL;AAGL,IAAA,QAAQ,EAAA;AAHH,GAAP;AAKD","sourceRoot":""}
@@ -1,6 +1,6 @@
1
- import * as React from 'react';
2
- import { PopoverSurfaceProps } from './PopoverSurface.types';
1
+ import type { PopoverSurfaceProps } from './PopoverSurface.types';
2
+ import type { ForwardRefComponent } from '@fluentui/react-utilities';
3
3
  /**
4
4
  * PopoverSurface component renders react children in a positioned box
5
5
  */
6
- export declare const PopoverSurface: React.ForwardRefExoticComponent<PopoverSurfaceProps & React.RefAttributes<HTMLElement>>;
6
+ export declare const PopoverSurface: ForwardRefComponent<PopoverSurfaceProps>;
@@ -1,17 +1,26 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.PopoverSurface = void 0;
4
- var React = require("react");
5
- var usePopoverSurface_1 = require("./usePopoverSurface");
6
- var renderPopoverSurface_1 = require("./renderPopoverSurface");
7
- var usePopoverSurfaceStyles_1 = require("./usePopoverSurfaceStyles");
7
+
8
+ var React = /*#__PURE__*/require("react");
9
+
10
+ var usePopoverSurface_1 = /*#__PURE__*/require("./usePopoverSurface");
11
+
12
+ var renderPopoverSurface_1 = /*#__PURE__*/require("./renderPopoverSurface");
13
+
14
+ var usePopoverSurfaceStyles_1 = /*#__PURE__*/require("./usePopoverSurfaceStyles");
8
15
  /**
9
16
  * PopoverSurface component renders react children in a positioned box
10
17
  */
11
- exports.PopoverSurface = React.forwardRef(function (props, ref) {
12
- var state = usePopoverSurface_1.usePopoverSurface(props, ref);
13
- usePopoverSurfaceStyles_1.usePopoverSurfaceStyles(state);
14
- return renderPopoverSurface_1.renderPopoverSurface(state);
18
+
19
+
20
+ exports.PopoverSurface = /*#__PURE__*/React.forwardRef(function (props, ref) {
21
+ var state = usePopoverSurface_1.usePopoverSurface(props, ref);
22
+ usePopoverSurfaceStyles_1.usePopoverSurfaceStyles(state);
23
+ return renderPopoverSurface_1.renderPopoverSurface(state);
15
24
  });
16
25
  exports.PopoverSurface.displayName = 'PopoverSurface';
17
26
  //# sourceMappingURL=PopoverSurface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PopoverSurface.js","sourceRoot":"../src/","sources":["components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":";;;AAAA,6BAA+B;AAC/B,yDAAwD;AAExD,+DAA8D;AAC9D,qEAAoE;AAEpE;;GAEG;AACU,QAAA,cAAc,GAAG,KAAK,CAAC,UAAU,CAAmC,UAAC,KAAK,EAAE,GAAG;IAC1F,IAAM,KAAK,GAAG,qCAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAE5C,iDAAuB,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,2CAAoB,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH,sBAAc,CAAC,WAAW,GAAG,gBAAgB,CAAC","sourcesContent":["import * as React from 'react';\nimport { usePopoverSurface } from './usePopoverSurface';\nimport { PopoverSurfaceProps } from './PopoverSurface.types';\nimport { renderPopoverSurface } from './renderPopoverSurface';\nimport { usePopoverSurfaceStyles } from './usePopoverSurfaceStyles';\n\n/**\n * PopoverSurface component renders react children in a positioned box\n */\nexport const PopoverSurface = React.forwardRef<HTMLElement, PopoverSurfaceProps>((props, ref) => {\n const state = usePopoverSurface(props, ref);\n\n usePopoverSurfaceStyles(state);\n return renderPopoverSurface(state);\n});\n\nPopoverSurface.displayName = 'PopoverSurface';\n"]}
1
+ {"version":3,"sources":["../../../src/components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":";;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AACA,IAAA,sBAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,IAAA,yBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAIA;;AAEG;;;AACU,OAAA,CAAA,cAAA,gBAA2D,KAAK,CAAC,UAAN,CAAiB,UAAC,KAAD,EAAQ,GAAR,EAAW;AAClG,MAAM,KAAK,GAAG,mBAAA,CAAA,iBAAA,CAAkB,KAAlB,EAAyB,GAAzB,CAAd;AAEA,EAAA,yBAAA,CAAA,uBAAA,CAAwB,KAAxB;AACA,SAAO,sBAAA,CAAA,oBAAA,CAAqB,KAArB,CAAP;AACD,CALuE,CAA3D;AAOb,OAAA,CAAA,cAAA,CAAe,WAAf,GAA6B,gBAA7B","sourceRoot":""}
@@ -1,30 +1,21 @@
1
- import * as React from 'react';
2
- import { ComponentProps, ComponentState } from '@fluentui/react-utilities';
3
- import { PopoverContextValue } from '../../popoverContext';
1
+ import type { ComponentProps, ComponentState, IntrinsicShorthandProps } from '@fluentui/react-utilities';
2
+ import type { PopoverContextValue } from '../../popoverContext';
4
3
  /**
5
4
  * PopoverSurface Props
6
5
  */
7
- export interface PopoverSurfaceProps extends ComponentProps, React.HTMLAttributes<HTMLElement> {
8
- }
6
+ export declare type PopoverSurfaceProps = ComponentProps<PopoverSurfaceSlots>;
9
7
  /**
10
- * Names of the shorthand properties in PopoverSurfaceProps
8
+ * Names of the slots in PopoverSurfaceProps
11
9
  */
12
- export declare type PopoverSurfaceShorthandProps = never;
13
- /**
14
- * Names of PopoverSurfaceProps that have a default value in usePopoverSurface
15
- */
16
- export declare type PopoverSurfaceDefaultedProps = never;
10
+ export declare type PopoverSurfaceSlots = {
11
+ root: IntrinsicShorthandProps<'div'>;
12
+ };
17
13
  /**
18
14
  * PopoverSurface State
19
15
  */
20
- export interface PopoverSurfaceState extends ComponentState<PopoverSurfaceProps, PopoverSurfaceShorthandProps, PopoverSurfaceDefaultedProps>, Pick<PopoverContextValue, 'open' | 'mountNode' | 'noArrow' | 'size' | 'brand' | 'inverted'> {
21
- ref: React.Ref<HTMLElement>;
22
- /**
23
- * Ref to the arrow element
24
- */
25
- arrowRef?: React.Ref<HTMLDivElement>;
16
+ export declare type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> & Pick<PopoverContextValue, 'open' | 'mountNode' | 'noArrow' | 'size' | 'appearance' | 'arrowRef'> & {
26
17
  /**
27
18
  * CSS class for the arrow element
28
19
  */
29
20
  arrowClassName?: string;
30
- }
21
+ };
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  //# sourceMappingURL=PopoverSurface.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PopoverSurface.types.js","sourceRoot":"../src/","sources":["components/PopoverSurface/PopoverSurface.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { ComponentProps, ComponentState } from '@fluentui/react-utilities';\nimport { PopoverContextValue } from '../../popoverContext';\n\n/**\n * PopoverSurface Props\n */\nexport interface PopoverSurfaceProps extends ComponentProps, React.HTMLAttributes<HTMLElement> {}\n\n/**\n * Names of the shorthand properties in PopoverSurfaceProps\n */\nexport type PopoverSurfaceShorthandProps = never;\n\n/**\n * Names of PopoverSurfaceProps that have a default value in usePopoverSurface\n */\nexport type PopoverSurfaceDefaultedProps = never;\n\n/**\n * PopoverSurface State\n */\nexport interface PopoverSurfaceState\n extends ComponentState<PopoverSurfaceProps, PopoverSurfaceShorthandProps, PopoverSurfaceDefaultedProps>,\n Pick<PopoverContextValue, 'open' | 'mountNode' | 'noArrow' | 'size' | 'brand' | 'inverted'> {\n ref: React.Ref<HTMLElement>;\n /**\n * Ref to the arrow element\n */\n arrowRef?: React.Ref<HTMLDivElement>;\n\n /**\n * CSS class for the arrow element\n */\n arrowClassName?: string;\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var tslib_1 = /*#__PURE__*/require("tslib");
8
+
4
9
  tslib_1.__exportStar(require("./PopoverSurface"), exports);
10
+
5
11
  tslib_1.__exportStar(require("./PopoverSurface.types"), exports);
12
+
6
13
  tslib_1.__exportStar(require("./renderPopoverSurface"), exports);
14
+
7
15
  tslib_1.__exportStar(require("./usePopoverSurface"), exports);
16
+
8
17
  tslib_1.__exportStar(require("./usePopoverSurfaceStyles"), exports);
9
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/PopoverSurface/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,iEAAuC;AACvC,iEAAuC;AACvC,8DAAoC;AACpC,oEAA0C","sourcesContent":["export * from './PopoverSurface';\nexport * from './PopoverSurface.types';\nexport * from './renderPopoverSurface';\nexport * from './usePopoverSurface';\nexport * from './usePopoverSurfaceStyles';\n"]}
1
+ {"version":3,"sources":["../../../src/components/PopoverSurface/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA","sourceRoot":""}
@@ -1,4 +1,4 @@
1
- import { PopoverSurfaceState } from './PopoverSurface.types';
1
+ import type { PopoverSurfaceState } from './PopoverSurface.types';
2
2
  /**
3
3
  * Render the final JSX of PopoverSurface
4
4
  */
@@ -1,23 +1,41 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.renderPopoverSurface = void 0;
4
- var tslib_1 = require("tslib");
5
- var React = require("react");
6
- var react_utilities_1 = require("@fluentui/react-utilities");
7
- var react_portal_1 = require("@fluentui/react-portal");
7
+
8
+ var tslib_1 = /*#__PURE__*/require("tslib");
9
+
10
+ var React = /*#__PURE__*/require("react");
11
+
12
+ var react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
13
+
14
+ var react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
15
+
16
+ var usePopoverSurface_1 = /*#__PURE__*/require("./usePopoverSurface");
8
17
  /**
9
18
  * Render the final JSX of PopoverSurface
10
19
  */
20
+
21
+
11
22
  var renderPopoverSurface = function (state) {
12
- var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
13
- // TODO should hidden Popovers be supported ?
14
- if (!state.open) {
15
- return null;
16
- }
17
- return (React.createElement(react_portal_1.Portal, { mountNode: state.mountNode },
18
- React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
19
- !state.noArrow && React.createElement("div", { ref: state.arrowRef, className: state.arrowClassName }),
20
- state.children)));
23
+ var _a = react_utilities_1.getSlots(state, usePopoverSurface_1.popoverSurfaceSlots),
24
+ slots = _a.slots,
25
+ slotProps = _a.slotProps; // TODO should hidden Popovers be supported ?
26
+
27
+
28
+ if (!state.open) {
29
+ return null;
30
+ }
31
+
32
+ return React.createElement(react_portal_1.Portal, {
33
+ mountNode: state.mountNode
34
+ }, React.createElement(slots.root, tslib_1.__assign({}, slotProps.root), !state.noArrow && React.createElement("div", {
35
+ ref: state.arrowRef,
36
+ className: state.arrowClassName
37
+ }), slotProps.root.children));
21
38
  };
39
+
22
40
  exports.renderPopoverSurface = renderPopoverSurface;
23
41
  //# sourceMappingURL=renderPopoverSurface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderPopoverSurface.js","sourceRoot":"../src/","sources":["components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,6DAAqD;AACrD,uDAAgD;AAGhD;;GAEG;AACI,IAAM,oBAAoB,GAAG,UAAC,KAA0B;IACvD,IAAA,KAAuB,0BAAQ,CAAC,KAAK,CAAC,EAApC,KAAK,WAAA,EAAE,SAAS,eAAoB,CAAC;IAE7C,6CAA6C;IAC7C,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,oBAAC,qBAAM,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS;QAChC,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;YAC3B,CAAC,KAAK,CAAC,OAAO,IAAI,6BAAK,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,cAAc,GAAI;YAC/E,KAAK,CAAC,QAAQ,CACJ,CACN,CACV,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,oBAAoB,wBAgB/B","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { Portal } from '@fluentui/react-portal';\nimport { PopoverSurfaceState } from './PopoverSurface.types';\n\n/**\n * Render the final JSX of PopoverSurface\n */\nexport const renderPopoverSurface = (state: PopoverSurfaceState) => {\n const { slots, slotProps } = getSlots(state);\n\n // TODO should hidden Popovers be supported ?\n if (!state.open) {\n return null;\n }\n\n return (\n <Portal mountNode={state.mountNode}>\n <slots.root {...slotProps.root}>\n {!state.noArrow && <div ref={state.arrowRef} className={state.arrowClassName} />}\n {state.children}\n </slots.root>\n </Portal>\n );\n};\n"]}
1
+ {"version":3,"sources":["../../../src/components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,IAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAEA,IAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;AAEA;;AAEG;;;AACI,IAAM,oBAAoB,GAAG,UAAC,KAAD,EAA2B;AACvD,MAAA,EAAA,GAAuB,iBAAA,CAAA,QAAA,CAA8B,KAA9B,EAAqC,mBAAA,CAAA,mBAArC,CAAvB;AAAA,MAAE,KAAK,GAAA,EAAA,CAAA,KAAP;AAAA,MAAS,SAAS,GAAA,EAAA,CAAA,SAAlB,CADuD,CAG7D;;;AACA,MAAI,CAAC,KAAK,CAAC,IAAX,EAAiB;AACf,WAAO,IAAP;AACD;;AAED,SACE,KAAA,CAAA,aAAA,CAAC,cAAA,CAAA,MAAD,EAAO;AAAC,IAAA,SAAS,EAAE,KAAK,CAAC;AAAlB,GAAP,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,OAAA,CAAA,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,IAAf,CAAX,EACG,CAAC,KAAK,CAAC,OAAP,IAAkB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAK,IAAA,GAAG,EAAE,KAAK,CAAC,QAAhB;AAA0B,IAAA,SAAS,EAAE,KAAK,CAAC;AAA3C,GAAA,CADrB,EAEG,SAAS,CAAC,IAAV,CAAe,QAFlB,CADF,CADF;AAQD,CAhBM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB","sourceRoot":""}
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- import { PopoverSurfaceProps, PopoverSurfaceState } from './PopoverSurface.types';
2
+ import type { PopoverSurfaceProps, PopoverSurfaceSlots, PopoverSurfaceState } from './PopoverSurface.types';
3
+ export declare const popoverSurfaceSlots: Array<keyof PopoverSurfaceSlots>;
3
4
  /**
4
5
  * Create the state required to render PopoverSurface.
5
6
  *
@@ -7,7 +8,6 @@ import { PopoverSurfaceProps, PopoverSurfaceState } from './PopoverSurface.types
7
8
  * before being passed to renderPopoverSurface.
8
9
  *
9
10
  * @param props - props from this instance of PopoverSurface
10
- * @param ref - reference to root HTMLElement of PopoverSurface
11
- * @param defaultProps - (optional) default prop values provided by the implementing type
11
+ * @param ref - reference to root HTMLDivElement of PopoverSurface
12
12
  */
13
- export declare const usePopoverSurface: (props: PopoverSurfaceProps, ref: React.Ref<HTMLElement>, defaultProps?: PopoverSurfaceProps | undefined) => PopoverSurfaceState;
13
+ export declare const usePopoverSurface: (props: PopoverSurfaceProps, ref: React.Ref<HTMLDivElement>) => PopoverSurfaceState;