@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,12 +1,19 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.usePopoverTrigger = 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_tabster_1 = require("@fluentui/react-tabster");
8
- var popoverContext_1 = require("../../popoverContext");
9
- 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_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
15
+
16
+ var popoverContext_1 = /*#__PURE__*/require("../../popoverContext");
10
17
  /**
11
18
  * Create the state required to render PopoverTrigger.
12
19
  *
@@ -14,65 +21,91 @@ var mergeProps = react_utilities_1.makeMergeProps({});
14
21
  * before being passed to renderPopoverTrigger.
15
22
  *
16
23
  * @param props - props from this instance of PopoverTrigger
17
- * @param defaultProps - (optional) default prop values provided by the implementing type
18
24
  */
19
- var usePopoverTrigger = function (props, defaultProps) {
20
- var setOpen = popoverContext_1.usePopoverContext(function (context) { return context.setOpen; });
21
- var open = popoverContext_1.usePopoverContext(function (context) { return context.open; });
22
- var triggerRef = popoverContext_1.usePopoverContext(function (context) { return context.triggerRef; });
23
- var openOnHover = popoverContext_1.usePopoverContext(function (context) { return context.openOnHover; });
24
- var openOnContext = popoverContext_1.usePopoverContext(function (context) { return context.openOnContext; });
25
- var triggerAttributes = react_tabster_1.useModalAttributes().triggerAttributes;
26
- var state = mergeProps({
27
- children: null,
28
- }, defaultProps, props);
29
- var onContextMenu = react_utilities_1.useEventCallback(function (e) {
30
- var _a, _b;
31
- if (openOnContext) {
32
- e.preventDefault();
33
- setOpen(e, true);
34
- }
35
- (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onContextMenu) === null || _b === void 0 ? void 0 : _b.call(_a, e);
36
- });
37
- var onClick = react_utilities_1.useEventCallback(function (e) {
38
- var _a, _b;
39
- if (!openOnContext) {
40
- setOpen(e, !open);
41
- }
42
- (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
43
- });
44
- var onKeyDown = react_utilities_1.useEventCallback(function (e) {
45
- var _a, _b, _c;
46
- if (react_utilities_1.shouldPreventDefaultOnKeyDown(e) && (e.key === ' ' || e.key === 'Enter')) {
47
- e.preventDefault();
48
- (_a = e.target) === null || _a === void 0 ? void 0 : _a.click();
49
- }
50
- if (e.key === 'Escape') {
51
- setOpen(e, false);
52
- }
53
- (_c = (_b = child.props) === null || _b === void 0 ? void 0 : _b.onKeyDown) === null || _c === void 0 ? void 0 : _c.call(_b, e);
54
- });
55
- var onMouseEnter = react_utilities_1.useEventCallback(function (e) {
56
- var _a, _b;
57
- if (openOnHover) {
58
- setOpen(e, true);
59
- }
60
- (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onMouseEnter) === null || _b === void 0 ? void 0 : _b.call(_a, e);
61
- });
62
- var onMouseLeave = react_utilities_1.useEventCallback(function (e) {
63
- var _a, _b;
64
- if (openOnHover) {
65
- setOpen(e, false);
66
- }
67
- (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onMouseLeave) === null || _b === void 0 ? void 0 : _b.call(_a, e);
68
- });
69
- var child = React.Children.only(state.children);
70
- state.children = React.cloneElement(child, tslib_1.__assign({ 'aria-haspopup': 'true', onClick: onClick,
71
- onMouseEnter: onMouseEnter,
72
- onKeyDown: onKeyDown,
73
- onMouseLeave: onMouseLeave,
74
- onContextMenu: onContextMenu, ref: react_utilities_1.useMergedRefs(child.props.ref, triggerRef) }, triggerAttributes));
75
- return state;
25
+
26
+
27
+ var usePopoverTrigger = function (props) {
28
+ var setOpen = popoverContext_1.usePopoverContext(function (context) {
29
+ return context.setOpen;
30
+ });
31
+ var open = popoverContext_1.usePopoverContext(function (context) {
32
+ return context.open;
33
+ });
34
+ var triggerRef = popoverContext_1.usePopoverContext(function (context) {
35
+ return context.triggerRef;
36
+ });
37
+ var openOnHover = popoverContext_1.usePopoverContext(function (context) {
38
+ return context.openOnHover;
39
+ });
40
+ var openOnContext = popoverContext_1.usePopoverContext(function (context) {
41
+ return context.openOnContext;
42
+ });
43
+ var triggerAttributes = react_tabster_1.useModalAttributes().triggerAttributes;
44
+ var onContextMenu = react_utilities_1.useEventCallback(function (e) {
45
+ var _a, _b;
46
+
47
+ if (openOnContext) {
48
+ e.preventDefault();
49
+ setOpen(e, true);
50
+ }
51
+
52
+ (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onContextMenu) === null || _b === void 0 ? void 0 : _b.call(_a, e);
53
+ });
54
+ var onClick = react_utilities_1.useEventCallback(function (e) {
55
+ var _a, _b;
56
+
57
+ if (!openOnContext) {
58
+ setOpen(e, !open);
59
+ }
60
+
61
+ (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
62
+ });
63
+ var onKeyDown = react_utilities_1.useEventCallback(function (e) {
64
+ var _a, _b, _c;
65
+
66
+ if (react_utilities_1.shouldPreventDefaultOnKeyDown(e) && (e.key === ' ' || e.key === 'Enter')) {
67
+ e.preventDefault();
68
+ (_a = e.target) === null || _a === void 0 ? void 0 : _a.click();
69
+ }
70
+
71
+ if (e.key === 'Escape') {
72
+ setOpen(e, false);
73
+ }
74
+
75
+ (_c = (_b = child.props) === null || _b === void 0 ? void 0 : _b.onKeyDown) === null || _c === void 0 ? void 0 : _c.call(_b, e);
76
+ });
77
+ var onMouseEnter = react_utilities_1.useEventCallback(function (e) {
78
+ var _a, _b;
79
+
80
+ if (openOnHover) {
81
+ setOpen(e, true);
82
+ }
83
+
84
+ (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onMouseEnter) === null || _b === void 0 ? void 0 : _b.call(_a, e);
85
+ });
86
+ var onMouseLeave = react_utilities_1.useEventCallback(function (e) {
87
+ var _a, _b;
88
+
89
+ if (openOnHover) {
90
+ setOpen(e, false);
91
+ }
92
+
93
+ (_b = (_a = child.props) === null || _a === void 0 ? void 0 : _a.onMouseLeave) === null || _b === void 0 ? void 0 : _b.call(_a, e);
94
+ });
95
+ var child = React.Children.only(props.children);
96
+ return {
97
+ children: React.cloneElement(child, tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, triggerAttributes), {
98
+ 'aria-haspopup': 'true'
99
+ }), child.props), {
100
+ onClick: onClick,
101
+ onMouseEnter: onMouseEnter,
102
+ onKeyDown: onKeyDown,
103
+ onMouseLeave: onMouseLeave,
104
+ onContextMenu: onContextMenu,
105
+ ref: react_utilities_1.useMergedRefs(child.ref, triggerRef)
106
+ }))
107
+ };
76
108
  };
109
+
77
110
  exports.usePopoverTrigger = usePopoverTrigger;
78
111
  //# sourceMappingURL=usePopoverTrigger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePopoverTrigger.js","sourceRoot":"../src/","sources":["components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,6DAKmC;AACnC,yDAA6D;AAE7D,uDAAyD;AAEzD,IAAM,UAAU,GAAG,gCAAc,CAAsB,EAAE,CAAC,CAAC;AAE3D;;;;;;;;GAQG;AACI,IAAM,iBAAiB,GAAG,UAC/B,KAA0B,EAC1B,YAAkC;IAElC,IAAM,OAAO,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,OAAO,EAAf,CAAe,CAAC,CAAC;IAC9D,IAAM,IAAI,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,IAAI,EAAZ,CAAY,CAAC,CAAC;IACxD,IAAM,UAAU,GAAG,kCAAiB,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CA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CAAC,EAAE,KAAK,CAAC,CAAC;SACnB;QAED,YAAA,KAAK,CAAC,KAAK,0CAAE,SAAS,mDAAG,CAAC,EAAE;IAC9B,CAAC,CAAC,CAAC;IAEH,IAAM,YAAY,GAAG,kCAAgB,CAAC,UAAC,CAAgC;;QACrE,IAAI,WAAW,EAAE;YACf,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;SAClB;QACD,YAAA,KAAK,CAAC,KAAK,0CAAE,YAAY,mDAAG,CAAC,EAAE;IACjC,CAAC,CAAC,CAAC;IAEH,IAAM,YAAY,GAAG,kCAAgB,CAAC,UAAC,CAAgC;;QACrE,IAAI,WAAW,EAAE;YACf,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;SACnB;QACD,YAAA,KAAK,CAAC,KAAK,0CAAE,YAAY,mDAAG,CAAC,EAAE;IACjC,CAAC,CAAC,CAAC;IAEH,IAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClD,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,qBACvC,eAAe,EAAE,MAAM,EACvB,OAAO,SAAA;QACP,YAAY,cAAA;QACZ,SAAS,WAAA;QACT,YAAY,cAAA;QACZ,aAAa,eAAA,EACb,GAAG,EAAE,+BAAa,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,IAC5C,iBAAiB,EACpB,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AA3EW,QAAA,iBAAiB,qBA2E5B","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,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,IAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,IAAA,gBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;AAGA;;;;;;;AAOG;;;AACI,IAAM,iBAAiB,GAAG,UAAC,KAAD,EAA2B;AAC1D,MAAM,OAAO,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,OAAA;AAAe,GAA5C,CAAhB;AACA,MAAM,IAAI,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,IAAA;AAAY,GAAzC,CAAb;AACA,MAAM,UAAU,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,UAAA;AAAkB,GAA/C,CAAnB;AACA,MAAM,WAAW,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,WAAA;AAAmB,GAAhD,CAApB;AACA,MAAM,aAAa,GAAG,gBAAA,CAAA,iBAAA,CAAkB,UAAA,OAAA,EAAO;AAAI,WAAA,OAAO,CAAP,aAAA;AAAqB,GAAlD,CAAtB;AACQ,MAAA,iBAAiB,GAAK,eAAA,CAAA,kBAAA,GAAL,iBAAjB;AAER,MAAM,aAAa,GAAG,iBAAA,CAAA,gBAAA,CAAiB,UAAC,CAAD,EAAiC;;;AACtE,QAAI,aAAJ,EAAmB;AACjB,MAAA,CAAC,CAAC,cAAF;AACA,MAAA,OAA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,CAAe,IAAf,CAAoB,KAAK,CAAC,QAA1B,CAAd;AACA,SAAO;AACL,IAAA,QAAQ,EAAE,KAAK,CAAC,YAAN,CAAmB,KAAnB,EAAwB,OAAA,CAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,OAAA,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,iBAAA,CAAA,aAAA,CAAgB,KAAuE,CAAC,GAAxF,EAA6F,UAA7F;AANS,KAHkB,CAAxB;AADL,GAAP;AAaD,CAjEM;;AAAM,OAAA,CAAA,iBAAA,GAAiB,iBAAjB","sourceRoot":""}
@@ -1,8 +1,16 @@
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("./Popover"), exports);
10
+
5
11
  tslib_1.__exportStar(require("./PopoverSurface"), exports);
12
+
6
13
  tslib_1.__exportStar(require("./popoverContext"), exports);
14
+
7
15
  tslib_1.__exportStar(require("./PopoverTrigger"), exports);
8
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,2DAAiC;AACjC,2DAAiC;AACjC,2DAAiC","sourcesContent":["export * from './Popover';\nexport * from './PopoverSurface';\nexport * from './popoverContext';\nexport * from './PopoverTrigger';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,WAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA","sourceRoot":""}
@@ -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,21 +1,35 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.usePopoverContext = exports.PopoverContext = void 0;
4
- var react_context_selector_1 = require("@fluentui/react-context-selector");
5
- exports.PopoverContext = react_context_selector_1.createContext({
6
- open: false,
7
- setOpen: function () { return null; },
8
- triggerRef: { current: null },
9
- contentRef: { current: null },
10
- arrowRef: { current: null },
11
- target: undefined,
12
- openOnContext: false,
13
- openOnHover: false,
14
- size: 'medium',
15
- trapFocus: false,
7
+
8
+ var react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
9
+
10
+ exports.PopoverContext = /*#__PURE__*/react_context_selector_1.createContext({
11
+ open: false,
12
+ setOpen: function () {
13
+ return null;
14
+ },
15
+ triggerRef: {
16
+ current: null
17
+ },
18
+ contentRef: {
19
+ current: null
20
+ },
21
+ arrowRef: {
22
+ current: null
23
+ },
24
+ openOnContext: false,
25
+ openOnHover: false,
26
+ size: 'medium',
27
+ trapFocus: false
16
28
  });
29
+
17
30
  var usePopoverContext = function (selector) {
18
- return react_context_selector_1.useContextSelector(exports.PopoverContext, selector);
31
+ return react_context_selector_1.useContextSelector(exports.PopoverContext, selector);
19
32
  };
33
+
20
34
  exports.usePopoverContext = usePopoverContext;
21
35
  //# sourceMappingURL=popoverContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"popoverContext.js","sourceRoot":"../src/","sources":["popoverContext.ts"],"names":[],"mappings":";;;AAAA,2EAA+G;AAGlG,QAAA,cAAc,GAAiC,sCAAa,CAAsB;IAC7F,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;IACnB,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;IAC7B,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;IAC7B,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;IAC3B,MAAM,EAAE,SAAS;IACjB,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,KAAK;IAClB,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,KAAK;CACjB,CAAC,CAAC;AAwBI,IAAM,iBAAiB,GAAG,UAAI,QAAiD;IACpF,OAAA,2CAAkB,CAAC,sBAAc,EAAE,QAAQ,CAAC;AAA5C,CAA4C,CAAC;AADlC,QAAA,iBAAiB,qBACiB","sourcesContent":["import { createContext, useContextSelector, ContextSelector, Context } from '@fluentui/react-context-selector';\nimport { PopoverState } from './components/Popover/index';\n\nexport const PopoverContext: Context<PopoverContextValue> = createContext<PopoverContextValue>({\n open: false,\n setOpen: () => null,\n triggerRef: { current: null },\n contentRef: { current: null },\n arrowRef: { current: null },\n target: undefined,\n openOnContext: false,\n openOnHover: false,\n size: 'medium',\n trapFocus: false,\n});\n\n/**\n * Context shared between Popover and its children components\n */\nexport interface PopoverContextValue\n extends Pick<\n PopoverState,\n | 'open'\n | 'setOpen'\n | 'triggerRef'\n | 'contentRef'\n | 'target'\n | 'openOnHover'\n | 'openOnContext'\n | 'mountNode'\n | 'noArrow'\n | 'arrowRef'\n | 'size'\n | 'brand'\n | 'inverted'\n | 'trapFocus'\n > {}\n\nexport const usePopoverContext = <T>(selector: ContextSelector<PopoverContextValue, T>): T =>\n useContextSelector(PopoverContext, selector);\n"]}
1
+ {"version":3,"sources":["../src/popoverContext.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;AAIa,OAAA,CAAA,cAAA,gBAA+C,wBAAA,CAAA,aAAA,CAAmC;AAC7F,EAAA,IAAI,EAAE,KADuF;AAE7F,EAAA,OAAO,EAAE,YAAA;AAAM,WAAA,IAAA;AAAI,GAF0E;AAG7F,EAAA,UAAU,EAAE;AAAE,IAAA,OAAO,EAAE;AAAX,GAHiF;AAI7F,EAAA,UAAU,EAAE;AAAE,IAAA,OAAO,EAAE;AAAX,GAJiF;AAK7F,EAAA,QAAQ,EAAE;AAAE,IAAA,OAAO,EAAE;AAAX,GALmF;AAM7F,EAAA,aAAa,EAAE,KAN8E;AAO7F,EAAA,WAAW,EAAE,KAPgF;AAQ7F,EAAA,IAAI,EAAE,QARuF;AAS7F,EAAA,SAAS,EAAE;AATkF,CAAnC,CAA/C;;AA+BN,IAAM,iBAAiB,GAAG,UAAI,QAAJ,EAAqD;AACpF,SAAA,wBAAA,CAAA,kBAAA,CAAmB,OAAA,CAAA,cAAnB,EAAmC,QAAnC,CAAA;AAA4C,CADvC;;AAAM,OAAA,CAAA,iBAAA,GAAiB,iBAAjB","sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-popover",
3
- "version": "9.0.0-alpha.8",
3
+ "version": "9.0.0-nightly.f81b28ceb3.1",
4
4
  "description": "Popover component for Fluent UI",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -18,16 +18,19 @@
18
18
  "code-style": "just-scripts code-style",
19
19
  "just": "just-scripts",
20
20
  "lint": "just-scripts lint",
21
- "start": "echo \"This is DEPRECATED instead use 'storybook'\" && just-scripts dev:storybook",
22
- "start-test": "echo \"This is DEPRECATED instead use 'test --watch'\" && just-scripts jest-watch",
21
+ "start": "yarn storybook",
22
+ "e2e": "e2e",
23
23
  "storybook": "start-storybook",
24
24
  "test": "jest",
25
- "update-snapshots": "just-scripts jest -u"
25
+ "docs": "api-extractor run --config=config/api-extractor.local.json --local",
26
+ "build:local": "tsc -p . --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output dist/react-popover/src && yarn docs"
26
27
  },
27
28
  "devDependencies": {
28
- "@fluentui/eslint-plugin": "^1.3.1",
29
- "@fluentui/jest-serializer-make-styles": "^9.0.0-alpha.18",
30
- "@fluentui/react-conformance": "^0.4.1",
29
+ "@fluentui/babel-make-styles": "9.0.0-nightly.f81b28ceb3.1",
30
+ "@fluentui/eslint-plugin": "*",
31
+ "@fluentui/jest-serializer-make-styles": "9.0.0-nightly.f81b28ceb3.1",
32
+ "@fluentui/react-conformance": "*",
33
+ "@fluentui/react-conformance-make-styles": "9.0.0-nightly.f81b28ceb3.1",
31
34
  "@fluentui/scripts": "^1.0.0",
32
35
  "@types/enzyme": "3.10.3",
33
36
  "@types/enzyme-adapter-react-16": "1.0.3",
@@ -41,13 +44,13 @@
41
44
  "react-test-renderer": "^16.3.0"
42
45
  },
43
46
  "dependencies": {
44
- "@fluentui/react-context-selector": "^9.0.0-alpha.13",
45
- "@fluentui/react-make-styles": "^9.0.0-alpha.42",
46
- "@fluentui/react-portal": "^9.0.0-alpha.21",
47
- "@fluentui/react-positioning": "^9.0.0-alpha.29",
48
- "@fluentui/react-shared-contexts": "^9.0.0-alpha.15",
49
- "@fluentui/react-tabster": "^9.0.0-alpha.34",
50
- "@fluentui/react-utilities": "^9.0.0-alpha.29",
47
+ "@fluentui/react-context-selector": "9.0.0-nightly.f81b28ceb3.1",
48
+ "@fluentui/react-make-styles": "9.0.0-nightly.f81b28ceb3.1",
49
+ "@fluentui/react-portal": "9.0.0-nightly.f81b28ceb3.1",
50
+ "@fluentui/react-positioning": "9.0.0-nightly.f81b28ceb3.1",
51
+ "@fluentui/react-shared-contexts": "9.0.0-nightly.f81b28ceb3.1",
52
+ "@fluentui/react-tabster": "9.0.0-nightly.f81b28ceb3.1",
53
+ "@fluentui/react-utilities": "9.0.0-nightly.f81b28ceb3.1",
51
54
  "tslib": "^2.1.0"
52
55
  },
53
56
  "peerDependencies": {
@@ -57,7 +60,7 @@
57
60
  "react-dom": ">=16.8.0 <18.0.0"
58
61
  },
59
62
  "beachball": {
60
- "tag": "alpha",
63
+ "tag": "beta",
61
64
  "disallowedChangeTypes": [
62
65
  "major",
63
66
  "minor",
@@ -1,11 +0,0 @@
1
- const rootMain = require('../../../.storybook/main');
2
-
3
- module.exports = /** @type {Pick<import('../../../.storybook/main').StorybookConfig,'addons'|'stories'|'webpackFinal'>} */ ({
4
- stories: [...rootMain.stories, '../src/**/*.stories.mdx', '../src/**/*.stories.@(ts|tsx)'],
5
- addons: [...rootMain.addons],
6
- webpackFinal: (config, options) => {
7
- const localConfig = { ...rootMain.webpackFinal(config, options) };
8
-
9
- return localConfig;
10
- },
11
- });
@@ -1,4 +0,0 @@
1
- import * as rootPreview from '../../../.storybook/preview';
2
-
3
- export const decorators = [...rootPreview.decorators];
4
- export const parameters = { layout: 'centered' };
@@ -1,7 +0,0 @@
1
- import { Popover, PopoverTrigger, PopoverSurface } from '@fluentui/react-popover';
2
-
3
- console.log(Popover, PopoverTrigger, PopoverSurface);
4
-
5
- export default {
6
- name: 'Popover',
7
- };
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@fluentui/scripts/api-extractor/api-extractor.common.json"
3
- }
package/config/tests.js DELETED
@@ -1,7 +0,0 @@
1
- /** Jest test setup file. */
2
-
3
- const { configure } = require('enzyme');
4
- const Adapter = require('enzyme-adapter-react-16');
5
-
6
- // Configure enzyme.
7
- configure({ adapter: new Adapter() });
@@ -1,139 +0,0 @@
1
- const popoverTriggerSelector = '[aria-haspopup="true"]';
2
- const popoverContentSelector = '[role="dialog"]';
3
- const popoverStoriesTitle = 'Components/Popover';
4
-
5
- const popoverDefaultStory = 'Default';
6
- const popoverAnchorToTargetStory = 'AnchorToTarget';
7
- const popoverControlledStory = 'Controlled';
8
- const popoverWithCustomTriggerStory = 'WithCustomTrigger';
9
- const popoverNestedStory = 'NestedPopovers';
10
-
11
- describe('Popover', () => {
12
- before(() => {
13
- cy.visitStorybook();
14
- });
15
-
16
- [popoverDefaultStory, popoverAnchorToTargetStory, popoverControlledStory].forEach(story => {
17
- describe(story, () => {
18
- beforeEach(() => {
19
- cy.get('body').click('bottomRight').loadStory(popoverStoriesTitle, story);
20
- });
21
-
22
- it('should open when clicked', () => {
23
- cy.get(popoverTriggerSelector).click().get(popoverContentSelector).should('be.visible');
24
- });
25
-
26
- ['{enter}', 'Space'].forEach((key: '{enter}' | 'Space') => {
27
- it(`should open with ${key}`, () => {
28
- cy.get(popoverTriggerSelector).focus().realPress(key);
29
-
30
- cy.get(popoverContentSelector).should('be.visible');
31
- });
32
- });
33
-
34
- it('should dismiss on click outside', () => {
35
- cy.get(popoverTriggerSelector)
36
- .click()
37
- .get('body')
38
- .click('bottomRight')
39
- .get(popoverContentSelector)
40
- .should('not.exist');
41
- });
42
-
43
- it('should dismiss on Escape keydown', () => {
44
- cy.get(popoverTriggerSelector).click().realPress('Escape');
45
- cy.get(popoverContentSelector).should('not.exist');
46
- });
47
- });
48
- });
49
-
50
- describe('With custom trigger', () => {
51
- it('should dismiss on click outside', () => {
52
- cy.loadStory(popoverStoriesTitle, popoverWithCustomTriggerStory)
53
- .get(popoverTriggerSelector)
54
- .get('body')
55
- .click('bottomRight')
56
- .get(popoverContentSelector)
57
- .should('not.exist');
58
- });
59
- });
60
-
61
- describe('Nested', () => {
62
- beforeEach(() => {
63
- // Open the whole stack of popovers
64
- cy.loadStory(popoverStoriesTitle, popoverNestedStory)
65
- .contains('Root')
66
- .click()
67
- .get('body')
68
- .contains('First')
69
- .click()
70
- .get('body')
71
- .contains('Second')
72
- .first()
73
- .click();
74
- });
75
-
76
- it('should trap focus with tab', () => {
77
- cy.focused().then(beforeFocused => {
78
- cy.focused().realPress('Tab');
79
- cy.realPress(['Shift', 'Tab']);
80
- cy.focused().then(afterFocused => {
81
- expect(beforeFocused[0]).eq(afterFocused[0]);
82
- });
83
- });
84
- });
85
-
86
- it('should trap focus with shift+tab', () => {
87
- cy.focused().then(beforeFocused => {
88
- cy.focused().realPress('Tab');
89
- cy.realPress(['Shift', 'Tab']);
90
- cy.focused().then(afterFocused => {
91
- expect(beforeFocused[0]).eq(afterFocused[0]);
92
- });
93
- });
94
- });
95
-
96
- it('should dismiss all nested popovers on outside click', () => {
97
- cy.get('body').click('bottomRight').get(popoverContentSelector).should('not.exist');
98
- });
99
-
100
- it('should not dismiss when clicking on nested content', () => {
101
- cy.contains('Second nested button').click().get(popoverContentSelector).should('have.length', 3);
102
- });
103
-
104
- it('should dismiss child popovers when clicking on parents', () => {
105
- cy.contains('First nested button')
106
- .click()
107
- .get(popoverContentSelector)
108
- .should('have.length', 2)
109
- .contains('Root button')
110
- .click()
111
- .get(popoverContentSelector)
112
- .should('have.length', 1);
113
- });
114
-
115
- it('should when opening a sibling popover, should dismiss other sibling popover', () => {
116
- const secondNestedTriggerSelector = 'button:contains(Second nested trigger)';
117
-
118
- cy.get(secondNestedTriggerSelector)
119
- .eq(1)
120
- .click()
121
- .get(popoverContentSelector)
122
- .should('have.length', 3)
123
- .get(secondNestedTriggerSelector)
124
- .eq(0)
125
- .click()
126
- .get(popoverContentSelector)
127
- .should('have.length', 3);
128
- });
129
-
130
- it('should dismiss each popover in the stack with Escape keydown', () => {
131
- cy.focused().realPress('Escape');
132
- cy.get(popoverContentSelector).should('have.length', 2);
133
- cy.focused().realPress('Escape');
134
- cy.get(popoverContentSelector).should('have.length', 1);
135
- cy.focused().realPress('Escape');
136
- cy.get(popoverContentSelector).should('not.exist');
137
- });
138
- });
139
- });