@fluentui/react-popover 9.0.0-nightly.d730088d7f.0 → 9.0.0-rc.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. package/CHANGELOG.json +868 -27
  2. package/CHANGELOG.md +280 -81
  3. package/Spec.md +20 -0
  4. package/dist/{react-popover.d.ts → index.d.ts} +116 -67
  5. package/{lib → dist}/tsdoc-metadata.json +0 -0
  6. package/lib/Popover.js.map +1 -1
  7. package/lib/PopoverSurface.js.map +1 -1
  8. package/lib/PopoverTrigger.js.map +1 -1
  9. package/lib/components/Popover/Popover.js +5 -5
  10. package/lib/components/Popover/Popover.js.map +1 -1
  11. package/lib/components/Popover/Popover.types.js.map +1 -1
  12. package/lib/components/Popover/index.js.map +1 -1
  13. package/lib/components/Popover/renderPopover.js +30 -26
  14. package/lib/components/Popover/renderPopover.js.map +1 -1
  15. package/lib/components/Popover/usePopover.js +116 -54
  16. package/lib/components/Popover/usePopover.js.map +1 -1
  17. package/lib/components/PopoverSurface/PopoverSurface.js +7 -7
  18. package/lib/components/PopoverSurface/PopoverSurface.js.map +1 -1
  19. package/lib/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  20. package/lib/components/PopoverSurface/index.js.map +1 -1
  21. package/lib/components/PopoverSurface/renderPopoverSurface.js +13 -13
  22. package/lib/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  23. package/lib/components/PopoverSurface/usePopoverSurface.js +40 -64
  24. package/lib/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  25. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +41 -22
  26. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  27. package/lib/components/PopoverTrigger/PopoverTrigger.js +6 -5
  28. package/lib/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
  29. package/lib/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
  30. package/lib/components/PopoverTrigger/index.js.map +1 -1
  31. package/lib/components/PopoverTrigger/renderPopoverTrigger.js +1 -1
  32. package/lib/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
  33. package/lib/components/PopoverTrigger/usePopoverTrigger.js +40 -55
  34. package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  35. package/lib/index.js +5 -4
  36. package/lib/index.js.map +1 -1
  37. package/lib/popoverContext.js +6 -9
  38. package/lib/popoverContext.js.map +1 -1
  39. package/lib-commonjs/Popover.js +1 -1
  40. package/lib-commonjs/Popover.js.map +1 -1
  41. package/lib-commonjs/PopoverSurface.js +1 -1
  42. package/lib-commonjs/PopoverSurface.js.map +1 -1
  43. package/lib-commonjs/PopoverTrigger.js +1 -1
  44. package/lib-commonjs/PopoverTrigger.js.map +1 -1
  45. package/lib-commonjs/components/Popover/Popover.js +5 -5
  46. package/lib-commonjs/components/Popover/Popover.js.map +1 -1
  47. package/lib-commonjs/components/Popover/Popover.types.js.map +1 -1
  48. package/lib-commonjs/components/Popover/index.js +1 -1
  49. package/lib-commonjs/components/Popover/index.js.map +1 -1
  50. package/lib-commonjs/components/Popover/renderPopover.js +34 -30
  51. package/lib-commonjs/components/Popover/renderPopover.js.map +1 -1
  52. package/lib-commonjs/components/Popover/usePopover.js +121 -59
  53. package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
  54. package/lib-commonjs/components/PopoverSurface/PopoverSurface.js +8 -8
  55. package/lib-commonjs/components/PopoverSurface/PopoverSurface.js.map +1 -1
  56. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.js.map +1 -1
  57. package/lib-commonjs/components/PopoverSurface/index.js +1 -1
  58. package/lib-commonjs/components/PopoverSurface/index.js.map +1 -1
  59. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js +18 -20
  60. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.js.map +1 -1
  61. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js +44 -70
  62. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.js.map +1 -1
  63. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +45 -24
  64. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
  65. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js +6 -5
  66. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.js.map +1 -1
  67. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
  68. package/lib-commonjs/components/PopoverTrigger/index.js +1 -1
  69. package/lib-commonjs/components/PopoverTrigger/index.js.map +1 -1
  70. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js +3 -3
  71. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.js.map +1 -1
  72. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +45 -61
  73. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
  74. package/lib-commonjs/index.js +99 -5
  75. package/lib-commonjs/index.js.map +1 -1
  76. package/lib-commonjs/popoverContext.js +8 -11
  77. package/lib-commonjs/popoverContext.js.map +1 -1
  78. package/package.json +23 -27
  79. package/lib/Popover.d.ts +0 -1
  80. package/lib/PopoverSurface.d.ts +0 -1
  81. package/lib/PopoverTrigger.d.ts +0 -1
  82. package/lib/common/isConformant.d.ts +0 -4
  83. package/lib/common/isConformant.js +0 -13
  84. package/lib/common/isConformant.js.map +0 -1
  85. package/lib/common/mockUsePopoverContext.d.ts +0 -7
  86. package/lib/common/mockUsePopoverContext.js +0 -38
  87. package/lib/common/mockUsePopoverContext.js.map +0 -1
  88. package/lib/components/Popover/Popover.d.ts +0 -6
  89. package/lib/components/Popover/Popover.types.d.ts +0 -100
  90. package/lib/components/Popover/index.d.ts +0 -4
  91. package/lib/components/Popover/renderPopover.d.ts +0 -5
  92. package/lib/components/Popover/usePopover.d.ts +0 -10
  93. package/lib/components/PopoverSurface/PopoverSurface.d.ts +0 -6
  94. package/lib/components/PopoverSurface/PopoverSurface.types.d.ts +0 -21
  95. package/lib/components/PopoverSurface/index.d.ts +0 -5
  96. package/lib/components/PopoverSurface/renderPopoverSurface.d.ts +0 -5
  97. package/lib/components/PopoverSurface/usePopoverSurface.d.ts +0 -13
  98. package/lib/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +0 -7
  99. package/lib/components/PopoverTrigger/PopoverTrigger.d.ts +0 -6
  100. package/lib/components/PopoverTrigger/PopoverTrigger.types.d.ts +0 -11
  101. package/lib/components/PopoverTrigger/index.d.ts +0 -4
  102. package/lib/components/PopoverTrigger/renderPopoverTrigger.d.ts +0 -5
  103. package/lib/components/PopoverTrigger/usePopoverTrigger.d.ts +0 -10
  104. package/lib/index.d.ts +0 -4
  105. package/lib/popoverContext.d.ts +0 -8
  106. package/lib-commonjs/Popover.d.ts +0 -1
  107. package/lib-commonjs/PopoverSurface.d.ts +0 -1
  108. package/lib-commonjs/PopoverTrigger.d.ts +0 -1
  109. package/lib-commonjs/common/isConformant.d.ts +0 -4
  110. package/lib-commonjs/common/isConformant.js +0 -24
  111. package/lib-commonjs/common/isConformant.js.map +0 -1
  112. package/lib-commonjs/common/mockUsePopoverContext.d.ts +0 -7
  113. package/lib-commonjs/common/mockUsePopoverContext.js +0 -49
  114. package/lib-commonjs/common/mockUsePopoverContext.js.map +0 -1
  115. package/lib-commonjs/components/Popover/Popover.d.ts +0 -6
  116. package/lib-commonjs/components/Popover/Popover.types.d.ts +0 -100
  117. package/lib-commonjs/components/Popover/index.d.ts +0 -4
  118. package/lib-commonjs/components/Popover/renderPopover.d.ts +0 -5
  119. package/lib-commonjs/components/Popover/usePopover.d.ts +0 -10
  120. package/lib-commonjs/components/PopoverSurface/PopoverSurface.d.ts +0 -6
  121. package/lib-commonjs/components/PopoverSurface/PopoverSurface.types.d.ts +0 -21
  122. package/lib-commonjs/components/PopoverSurface/index.d.ts +0 -5
  123. package/lib-commonjs/components/PopoverSurface/renderPopoverSurface.d.ts +0 -5
  124. package/lib-commonjs/components/PopoverSurface/usePopoverSurface.d.ts +0 -13
  125. package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.d.ts +0 -7
  126. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.d.ts +0 -6
  127. package/lib-commonjs/components/PopoverTrigger/PopoverTrigger.types.d.ts +0 -11
  128. package/lib-commonjs/components/PopoverTrigger/index.d.ts +0 -4
  129. package/lib-commonjs/components/PopoverTrigger/renderPopoverTrigger.d.ts +0 -5
  130. package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.d.ts +0 -10
  131. package/lib-commonjs/index.d.ts +0 -4
  132. package/lib-commonjs/popoverContext.d.ts +0 -8
@@ -1,83 +1,145 @@
1
- import { __assign } from "tslib";
2
1
  import * as React from 'react';
3
- import { useControllableState, useEventCallback, useOnClickOutside, useOnScrollOutside } from '@fluentui/react-utilities';
4
- import { useFluent } from '@fluentui/react-shared-contexts';
5
- import { usePopper, resolvePositioningShorthand, mergeArrowOffset, usePopperMouseTarget } from '@fluentui/react-positioning';
6
2
  import { elementContains } from '@fluentui/react-portal';
3
+ import { mergeArrowOffset, resolvePositioningShorthand, usePopper, usePopperMouseTarget } from '@fluentui/react-positioning';
4
+ import { useFluent } from '@fluentui/react-shared-contexts';
5
+ import { useFocusFinders } from '@fluentui/react-tabster';
6
+ import { useControllableState, useEventCallback, useOnClickOutside, useOnScrollOutside } from '@fluentui/react-utilities';
7
7
  import { arrowHeights } from '../PopoverSurface/index';
8
8
  /**
9
9
  * Create the state required to render Popover.
10
10
  *
11
11
  * The returned state can be modified with hooks such as usePopoverStyles,
12
- * before being passed to renderPopover.
12
+ * before being passed to renderPopover_unstable.
13
13
  *
14
14
  * @param props - props from this instance of Popover
15
15
  */
16
16
 
17
- export var usePopover = function (props) {
18
- var _a = usePopperMouseTarget(),
19
- contextTarget = _a[0],
20
- setContextTarget = _a[1];
17
+ export const usePopover_unstable = props => {
18
+ var _a;
21
19
 
22
- var initialState = __assign({
20
+ const [contextTarget, setContextTarget] = usePopperMouseTarget();
21
+ const initialState = {
23
22
  size: 'medium',
24
- contextTarget: contextTarget,
25
- setContextTarget: setContextTarget
26
- }, props);
23
+ contextTarget,
24
+ setContextTarget,
25
+ ...props
26
+ };
27
+ const children = React.Children.toArray(props.children);
28
+
29
+ if (process.env.NODE_ENV !== 'production') {
30
+ if (children.length === 0) {
31
+ // eslint-disable-next-line no-console
32
+ console.warn('Popover must contain at least one child');
33
+ }
34
+
35
+ if (children.length > 2) {
36
+ // eslint-disable-next-line no-console
37
+ console.warn('Popover must contain at most two children');
38
+ }
39
+ }
40
+
41
+ let popoverTrigger = undefined;
42
+ let popoverSurface = undefined;
43
+
44
+ if (children.length === 2) {
45
+ popoverTrigger = children[0];
46
+ popoverSurface = children[1];
47
+ } else if (children.length === 1) {
48
+ popoverSurface = children[0];
49
+ }
50
+
51
+ const [open, setOpenState] = useOpenState(initialState);
52
+ const setOpenTimeoutRef = React.useRef(0);
53
+ const setOpen = useEventCallback((e, shouldOpen) => {
54
+ var _a;
55
+
56
+ clearTimeout(setOpenTimeoutRef.current);
27
57
 
28
- var _b = useOpenState(initialState),
29
- open = _b[0],
30
- setOpen = _b[1];
58
+ if (!(e instanceof Event) && e.persist) {
59
+ // < React 17 still uses pooled synthetic events
60
+ e.persist();
61
+ }
31
62
 
32
- var popperRefs = usePopoverRefs(initialState);
33
- var targetDocument = useFluent().targetDocument;
63
+ if (e.type === 'mouseleave') {
64
+ // FIXME leaking Node timeout type
65
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
66
+ // @ts-ignore
67
+ setOpenTimeoutRef.current = setTimeout(() => {
68
+ setOpenState(e, shouldOpen);
69
+ }, (_a = props.mouseLeaveDelay) !== null && _a !== void 0 ? _a : 500);
70
+ } else {
71
+ setOpenState(e, shouldOpen);
72
+ }
73
+ }); // Clear timeout on unmount
74
+ // Setting state after a component unmounts can cause memory leaks
75
+
76
+ React.useEffect(() => {
77
+ return () => {
78
+ clearTimeout(setOpenTimeoutRef.current);
79
+ };
80
+ }, []);
81
+ const toggleOpen = React.useCallback(e => {
82
+ setOpen(e, !open);
83
+ }, [setOpen, open]);
84
+ const popperRefs = usePopoverRefs(initialState);
85
+ const {
86
+ targetDocument
87
+ } = useFluent();
34
88
  useOnClickOutside({
35
89
  contains: elementContains,
36
90
  element: targetDocument,
37
- callback: function (ev) {
38
- return setOpen(ev, false);
39
- },
91
+ callback: ev => setOpen(ev, false),
40
92
  refs: [popperRefs.triggerRef, popperRefs.contentRef],
41
93
  disabled: !open
42
- });
94
+ }); // only close on scroll for context, or when closeOnScroll is specified
95
+
96
+ const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;
43
97
  useOnScrollOutside({
44
98
  contains: elementContains,
45
99
  element: targetDocument,
46
- callback: function (ev) {
47
- return setOpen(ev, false);
48
- },
100
+ callback: ev => setOpen(ev, false),
49
101
  refs: [popperRefs.triggerRef, popperRefs.contentRef],
50
- disabled: !open || !initialState.openOnContext
51
- });
52
- return __assign(__assign(__assign({}, initialState), popperRefs), {
53
- open: open,
54
- setOpen: setOpen,
55
- setContextTarget: setContextTarget,
56
- contextTarget: contextTarget
102
+ disabled: !open || !closeOnScroll
57
103
  });
104
+ const {
105
+ findFirstFocusable
106
+ } = useFocusFinders();
107
+ React.useEffect(() => {
108
+ if (open && popperRefs.contentRef.current) {
109
+ const firstFocusable = findFirstFocusable(popperRefs.contentRef.current);
110
+ firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
111
+ }
112
+ }, [findFirstFocusable, open, popperRefs.contentRef]);
113
+ return { ...initialState,
114
+ ...popperRefs,
115
+ popoverTrigger,
116
+ popoverSurface,
117
+ open,
118
+ setOpen,
119
+ toggleOpen,
120
+ setContextTarget,
121
+ contextTarget,
122
+ inline: (_a = props.inline) !== null && _a !== void 0 ? _a : false
123
+ };
58
124
  };
59
125
  /**
60
126
  * Creates and manages the Popover open state
61
127
  */
62
128
 
63
129
  function useOpenState(state) {
64
- var onOpenChange = useEventCallback(function (e, data) {
130
+ const onOpenChange = useEventCallback((e, data) => {
65
131
  var _a;
66
132
 
67
133
  return (_a = state.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(state, e, data);
68
134
  });
69
-
70
- var _a = useControllableState({
135
+ const [open, setOpenState] = useControllableState({
71
136
  state: state.open,
72
137
  defaultState: state.defaultOpen,
73
138
  initialState: false
74
- }),
75
- open = _a[0],
76
- setOpenState = _a[1];
77
-
139
+ });
78
140
  state.open = open !== undefined ? open : state.open;
79
- var setContextTarget = state.setContextTarget;
80
- var setOpen = React.useCallback(function (e, shouldOpen) {
141
+ const setContextTarget = state.setContextTarget;
142
+ const setOpen = React.useCallback((e, shouldOpen) => {
81
143
  if (shouldOpen && e.type === 'contextmenu') {
82
144
  setContextTarget(e);
83
145
  }
@@ -86,7 +148,7 @@ function useOpenState(state) {
86
148
  setContextTarget(undefined);
87
149
  }
88
150
 
89
- setOpenState(function (prevOpen) {
151
+ setOpenState(prevOpen => {
90
152
  // More than one event (mouse, focus, keyboard) can request the Popover to close
91
153
  // We assume the first event is the correct one
92
154
  if (prevOpen !== shouldOpen) {
@@ -106,12 +168,12 @@ function useOpenState(state) {
106
168
 
107
169
 
108
170
  function usePopoverRefs(state) {
109
- var popperOptions = __assign({
171
+ const popperOptions = {
110
172
  position: 'above',
111
173
  align: 'center',
112
- target: state.openOnContext ? state.contextTarget : undefined
113
- }, resolvePositioningShorthand(state.positioning)); // no reason to render arrow when covering the target
114
-
174
+ target: state.openOnContext ? state.contextTarget : undefined,
175
+ ...resolvePositioningShorthand(state.positioning)
176
+ }; // no reason to render arrow when covering the target
115
177
 
116
178
  if (popperOptions.coverTarget) {
117
179
  state.noArrow = true;
@@ -121,15 +183,15 @@ function usePopoverRefs(state) {
121
183
  popperOptions.offset = mergeArrowOffset(popperOptions.offset, arrowHeights[state.size]);
122
184
  }
123
185
 
124
- var _a = usePopper(popperOptions),
125
- triggerRef = _a.targetRef,
126
- contentRef = _a.containerRef,
127
- arrowRef = _a.arrowRef;
128
-
186
+ const {
187
+ targetRef: triggerRef,
188
+ containerRef: contentRef,
189
+ arrowRef
190
+ } = usePopper(popperOptions);
129
191
  return {
130
- triggerRef: triggerRef,
131
- contentRef: contentRef,
132
- arrowRef: arrowRef
192
+ triggerRef,
193
+ contentRef,
194
+ arrowRef
133
195
  };
134
196
  }
135
197
  //# sourceMappingURL=usePopover.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Popover/usePopover.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SACE,oBADF,EAEE,gBAFF,EAGE,iBAHF,EAIE,kBAJF,QAKO,2BALP;AAMA,SAAS,SAAT,QAA0B,iCAA1B;AACA,SACE,SADF,EAEE,2BAFF,EAGE,gBAHF,EAIE,oBAJF,QAKO,6BALP;AAMA,SAAS,eAAT,QAAgC,wBAAhC;AACA,SAAS,YAAT,QAA6B,yBAA7B;AAGA;;;;;;;AAOG;;AACH,OAAO,IAAM,UAAU,GAAG,UAAC,KAAD,EAAoB;AACtC,MAAA,EAAA,GAAoC,oBAAoB,EAAxD;AAAA,MAAC,aAAa,GAAA,EAAA,CAAA,CAAA,CAAd;AAAA,MAAgB,gBAAgB,GAAA,EAAA,CAAA,CAAA,CAAhC;;AACN,MAAM,YAAY,GAAG,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,SAAS,GAAd,cAAd;AACR,EAAA,iBAAiB,CAAC;AAChB,IAAA,QAAQ,EAAE,eADM;AAEhB,IAAA,OAAO,EAAE,cAFO;AAGhB,IAAA,QAAQ,EAAE,UAAA,EAAA,EA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pB,OAAG,2BAA2B,CAAC,KAAK,CAAC,WAAP;AAJV,GAAtB,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,gBAAgB,CAAC,aAAa,CAAC,MAAf,EAAuB,YAAY,CAAC,KAAK,CAAC,IAAP,CAAnC,CAAvC;AACD;;AAED,QAAM;AAAE,IAAA,SAAS,EAAE,UAAb;AAAyB,IAAA,YAAY,EAAE,UAAvC;AAAmD,IAAA;AAAnD,MAAgE,SAAS,CAAC,aAAD,CAA/E;AAEA,SAAO;AACL,IAAA,UADK;AAEL,IAAA,UAFK;AAGL,IAAA;AAHK,GAAP;AAKD","sourcesContent":["import * as React from 'react';\nimport { elementContains } from '@fluentui/react-portal';\nimport {\n mergeArrowOffset,\n resolvePositioningShorthand,\n usePopper,\n usePopperMouseTarget,\n} from '@fluentui/react-positioning';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport {\n useControllableState,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { OpenPopoverEvents, PopoverProps, PopoverState } from './Popover.types';\n\n/**\n * Create the state required to render Popover.\n *\n * The returned state can be modified with hooks such as usePopoverStyles,\n * before being passed to renderPopover_unstable.\n *\n * @param props - props from this instance of Popover\n */\nexport const usePopover_unstable = (props: PopoverProps): PopoverState => {\n const [contextTarget, setContextTarget] = usePopperMouseTarget();\n const initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at most two children');\n }\n }\n\n let popoverTrigger: React.ReactElement | undefined = undefined;\n let popoverSurface: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n popoverTrigger = children[0];\n popoverSurface = children[1];\n } else if (children.length === 1) {\n popoverSurface = children[0];\n }\n\n const [open, setOpenState] = useOpenState(initialState);\n\n const setOpenTimeoutRef = React.useRef(0);\n\n const setOpen = useEventCallback((e: OpenPopoverEvents, shouldOpen: boolean) => {\n clearTimeout(setOpenTimeoutRef.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave') {\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeoutRef.current = setTimeout(() => {\n setOpenState(e, shouldOpen);\n }, props.mouseLeaveDelay ?? 500);\n } else {\n setOpenState(e, shouldOpen);\n }\n });\n\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeoutRef.current);\n };\n }, []);\n\n const toggleOpen = React.useCallback<PopoverState['toggleOpen']>(\n e => {\n setOpen(e, !open);\n },\n [setOpen, open],\n );\n\n const popperRefs = usePopoverRefs(initialState);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [popperRefs.triggerRef, popperRefs.contentRef],\n disabled: !open,\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [popperRefs.triggerRef, popperRefs.contentRef],\n disabled: !open || !closeOnScroll,\n });\n\n const { findFirstFocusable } = useFocusFinders();\n\n React.useEffect(() => {\n if (open && popperRefs.contentRef.current) {\n const firstFocusable = findFirstFocusable(popperRefs.contentRef.current);\n firstFocusable?.focus();\n }\n }, [findFirstFocusable, open, popperRefs.contentRef]);\n\n return {\n ...initialState,\n ...popperRefs,\n popoverTrigger,\n popoverSurface,\n open,\n setOpen,\n toggleOpen,\n setContextTarget,\n contextTarget,\n inline: props.inline ?? false,\n };\n};\n\n/**\n * Creates and manages the Popover open state\n */\nfunction useOpenState(\n state: Pick<PopoverState, 'setContextTarget' | 'onOpenChange'> & Pick<PopoverProps, 'open' | 'defaultOpen'>,\n) {\n const onOpenChange: PopoverState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n\n const setOpen = React.useCallback(\n (e: OpenPopoverEvents, shouldOpen: boolean) => {\n if (shouldOpen && e.type === 'contextmenu') {\n setContextTarget(e as React.MouseEvent);\n }\n\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n\n setOpenState(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 [setOpenState, onOpenChange, setContextTarget],\n );\n\n return [open, setOpen] as const;\n}\n\n/**\n * Creates and sets the necessary trigger, target and content refs used by Popover\n */\nfunction usePopoverRefs(\n state: Pick<PopoverState, 'size' | 'contextTarget'> & Pick<PopoverProps, 'positioning' | 'openOnContext' | 'noArrow'>,\n) {\n const popperOptions = {\n position: 'above' as const,\n align: 'center' as const,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (popperOptions.coverTarget) {\n state.noArrow = true;\n }\n\n if (!state.noArrow) {\n popperOptions.offset = mergeArrowOffset(popperOptions.offset, arrowHeights[state.size]);\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePopper(popperOptions);\n\n return {\n triggerRef,\n contentRef,\n arrowRef,\n } as const;\n}\n"],"sourceRoot":"../src/"}
@@ -1,15 +1,15 @@
1
1
  import * as React from 'react';
2
- import { usePopoverSurface } from './usePopoverSurface';
3
- import { renderPopoverSurface } from './renderPopoverSurface';
4
- import { usePopoverSurfaceStyles } from './usePopoverSurfaceStyles';
2
+ import { usePopoverSurface_unstable } from './usePopoverSurface';
3
+ import { renderPopoverSurface_unstable } from './renderPopoverSurface';
4
+ import { usePopoverSurfaceStyles_unstable } from './usePopoverSurfaceStyles';
5
5
  /**
6
6
  * PopoverSurface component renders react children in a positioned box
7
7
  */
8
8
 
9
- export var PopoverSurface = /*#__PURE__*/React.forwardRef(function (props, ref) {
10
- var state = usePopoverSurface(props, ref);
11
- usePopoverSurfaceStyles(state);
12
- return renderPopoverSurface(state);
9
+ export const PopoverSurface = /*#__PURE__*/React.forwardRef((props, ref) => {
10
+ const state = usePopoverSurface_unstable(props, ref);
11
+ usePopoverSurfaceStyles_unstable(state);
12
+ return renderPopoverSurface_unstable(state);
13
13
  });
14
14
  PopoverSurface.displayName = 'PopoverSurface';
15
15
  //# sourceMappingURL=PopoverSurface.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,iBAAT,QAAkC,qBAAlC;AACA,SAAS,oBAAT,QAAqC,wBAArC;AACA,SAAS,uBAAT,QAAwC,2BAAxC;AAIA;;AAEG;;AACH,OAAO,IAAM,cAAc,gBAA6C,KAAK,CAAC,UAAN,CAAiB,UAAC,KAAD,EAAQ,GAAR,EAAW;AAClG,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAD,EAAQ,GAAR,CAA/B;AAEA,EAAA,uBAAuB,CAAC,KAAD,CAAvB;AACA,SAAO,oBAAoB,CAAC,KAAD,CAA3B;AACD,CALuE,CAAjE;AAOP,cAAc,CAAC,WAAf,GAA6B,gBAA7B","sourceRoot":""}
1
+ {"version":3,"sources":["components/PopoverSurface/PopoverSurface.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,0BAAT,QAA2C,qBAA3C;AACA,SAAS,6BAAT,QAA8C,wBAA9C;AACA,SAAS,gCAAT,QAAiD,2BAAjD;AAIA;;AAEG;;AACH,OAAO,MAAM,cAAc,gBAA6C,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AACtG,QAAM,KAAK,GAAG,0BAA0B,CAAC,KAAD,EAAQ,GAAR,CAAxC;AAEA,EAAA,gCAAgC,CAAC,KAAD,CAAhC;AACA,SAAO,6BAA6B,CAAC,KAAD,CAApC;AACD,CALuE,CAAjE;AAOP,cAAc,CAAC,WAAf,GAA6B,gBAA7B","sourcesContent":["import * as React from 'react';\nimport { usePopoverSurface_unstable } from './usePopoverSurface';\nimport { renderPopoverSurface_unstable } from './renderPopoverSurface';\nimport { usePopoverSurfaceStyles_unstable } from './usePopoverSurfaceStyles';\nimport type { PopoverSurfaceProps } from './PopoverSurface.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * PopoverSurface component renders react children in a positioned box\n */\nexport const PopoverSurface: ForwardRefComponent<PopoverSurfaceProps> = React.forwardRef((props, ref) => {\n const state = usePopoverSurface_unstable(props, ref);\n\n usePopoverSurfaceStyles_unstable(state);\n return renderPopoverSurface_unstable(state);\n});\n\nPopoverSurface.displayName = 'PopoverSurface';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"file":"PopoverSurface.types.js","sourceRoot":"","sources":["../../../src/components/PopoverSurface/PopoverSurface.types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"PopoverSurface.types.js","sourceRoot":"../src/","sources":["components/PopoverSurface/PopoverSurface.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { PopoverContextValue } from '../../popoverContext';\n\n/**\n * PopoverSurface Props\n */\nexport type PopoverSurfaceProps = ComponentProps<PopoverSurfaceSlots>;\n\n/**\n * Names of the slots in PopoverSurfaceProps\n */\nexport type PopoverSurfaceSlots = {\n root: Slot<'div'>;\n};\n\n/**\n * PopoverSurface State\n */\nexport type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> &\n Pick<PopoverContextValue, 'appearance' | 'arrowRef' | 'inline' | 'mountNode' | 'noArrow' | 'size'> & {\n /**\n * CSS class for the arrow element\n */\n arrowClassName?: string;\n };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/PopoverSurface/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/PopoverSurface/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC","sourcesContent":["export * from './PopoverSurface';\nexport * from './PopoverSurface.types';\nexport * from './renderPopoverSurface';\nexport * from './usePopoverSurface';\nexport * from './usePopoverSurfaceStyles';\n"]}
@@ -1,27 +1,27 @@
1
- import { __assign } from "tslib";
2
1
  import * as React from 'react';
3
2
  import { Portal } from '@fluentui/react-portal';
4
3
  import { getSlots } from '@fluentui/react-utilities';
5
- import { popoverSurfaceSlots } from './usePopoverSurface';
6
4
  /**
7
5
  * Render the final JSX of PopoverSurface
8
6
  */
9
7
 
10
- export var renderPopoverSurface = function (state) {
11
- var _a = getSlots(state, popoverSurfaceSlots),
12
- slots = _a.slots,
13
- slotProps = _a.slotProps; // TODO should hidden Popovers be supported ?
14
-
8
+ export const renderPopoverSurface_unstable = state => {
9
+ const {
10
+ slots,
11
+ slotProps
12
+ } = getSlots(state);
13
+ const surface = /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
14
+ }, !state.noArrow && /*#__PURE__*/React.createElement("div", {
15
+ ref: state.arrowRef,
16
+ className: state.arrowClassName
17
+ }), slotProps.root.children);
15
18
 
16
- if (!state.open) {
17
- return null;
19
+ if (state.inline) {
20
+ return surface;
18
21
  }
19
22
 
20
23
  return /*#__PURE__*/React.createElement(Portal, {
21
24
  mountNode: state.mountNode
22
- }, /*#__PURE__*/React.createElement(slots.root, __assign({}, slotProps.root), !state.noArrow && /*#__PURE__*/React.createElement("div", {
23
- ref: state.arrowRef,
24
- className: state.arrowClassName
25
- }), slotProps.root.children));
25
+ }, surface);
26
26
  };
27
27
  //# sourceMappingURL=renderPopoverSurface.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,MAAT,QAAuB,wBAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAEA,SAAS,mBAAT,QAAoC,qBAApC;AAEA;;AAEG;;AACH,OAAO,IAAM,oBAAoB,GAAG,UAAC,KAAD,EAA2B;AACvD,MAAA,EAAA,GAAuB,QAAQ,CAAsB,KAAtB,EAA6B,mBAA7B,CAA/B;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,sBACE,KAAA,CAAA,aAAA,CAAC,MAAD,EAAO;AAAC,IAAA,SAAS,EAAE,KAAK,CAAC;AAAlB,GAAP,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,QAAA,CAAA,EAAA,EAAK,SAAS,CAAC,IAAf,CAAX,EACG,CAAC,KAAK,CAAC,OAAP,iBAAkB,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","sourceRoot":""}
1
+ {"version":3,"sources":["components/PopoverSurface/renderPopoverSurface.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,MAAT,QAAuB,wBAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,6BAA6B,GAAI,KAAD,IAA+B;AAC1E,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAsB,KAAtB,CAArC;AAEA,QAAM,OAAO,gBACX,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,EACG,CAAC,KAAK,CAAC,OAAP,iBAAkB,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;;AAOA,MAAI,KAAK,CAAC,MAAV,EAAkB;AAChB,WAAO,OAAP;AACD;;AAED,sBAAO,KAAA,CAAA,aAAA,CAAC,MAAD,EAAO;AAAC,IAAA,SAAS,EAAE,KAAK,CAAC;AAAlB,GAAP,EAAqC,OAArC,CAAP;AACD,CAfM","sourcesContent":["import * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { PopoverSurfaceSlots, PopoverSurfaceState } from './PopoverSurface.types';\n\n/**\n * Render the final JSX of PopoverSurface\n */\nexport const renderPopoverSurface_unstable = (state: PopoverSurfaceState) => {\n const { slots, slotProps } = getSlots<PopoverSurfaceSlots>(state);\n\n const surface = (\n <slots.root {...slotProps.root}>\n {!state.noArrow && <div ref={state.arrowRef} className={state.arrowClassName} />}\n {slotProps.root.children}\n </slots.root>\n );\n\n if (state.inline) {\n return surface;\n }\n\n return <Portal mountNode={state.mountNode}>{surface}</Portal>;\n};\n"],"sourceRoot":"../src/"}
@@ -1,74 +1,57 @@
1
- import { __assign } from "tslib";
2
- import * as React from 'react';
3
1
  import { getNativeElementProps, useMergedRefs } from '@fluentui/react-utilities';
4
- import { useFocusFinders, useModalAttributes } from '@fluentui/react-tabster';
5
- import { usePopoverContext } from '../../popoverContext';
6
- export var popoverSurfaceSlots = ['root'];
2
+ import { useModalAttributes } from '@fluentui/react-tabster';
3
+ import { usePopoverContext_unstable } from '../../popoverContext';
7
4
  /**
8
5
  * Create the state required to render PopoverSurface.
9
6
  *
10
- * The returned state can be modified with hooks such as usePopoverSurfaceStyles,
11
- * before being passed to renderPopoverSurface.
7
+ * The returned state can be modified with hooks such as usePopoverSurfaceStyles_unstable,
8
+ * before being passed to renderPopoverSurface_unstable.
12
9
  *
13
10
  * @param props - props from this instance of PopoverSurface
14
11
  * @param ref - reference to root HTMLDivElement of PopoverSurface
15
12
  */
16
13
 
17
- export var usePopoverSurface = function (props, ref) {
18
- var contentRef = usePopoverContext(function (context) {
19
- return context.contentRef;
14
+ export const usePopoverSurface_unstable = (props, ref) => {
15
+ const contentRef = usePopoverContext_unstable(context => context.contentRef);
16
+ const openOnHover = usePopoverContext_unstable(context => context.openOnHover);
17
+ const setOpen = usePopoverContext_unstable(context => context.setOpen);
18
+ const mountNode = usePopoverContext_unstable(context => context.mountNode);
19
+ const arrowRef = usePopoverContext_unstable(context => context.arrowRef);
20
+ const size = usePopoverContext_unstable(context => context.size);
21
+ const noArrow = usePopoverContext_unstable(context => context.noArrow);
22
+ const appearance = usePopoverContext_unstable(context => context.appearance);
23
+ const trapFocus = usePopoverContext_unstable(context => context.trapFocus);
24
+ const inline = usePopoverContext_unstable(context => context.inline);
25
+ const {
26
+ modalAttributes
27
+ } = useModalAttributes({
28
+ trapFocus
20
29
  });
21
- var open = usePopoverContext(function (context) {
22
- return context.open;
23
- });
24
- var openOnHover = usePopoverContext(function (context) {
25
- return context.openOnHover;
26
- });
27
- var setOpen = usePopoverContext(function (context) {
28
- return context.setOpen;
29
- });
30
- var mountNode = usePopoverContext(function (context) {
31
- return context.mountNode;
32
- });
33
- var arrowRef = usePopoverContext(function (context) {
34
- return context.arrowRef;
35
- });
36
- var size = usePopoverContext(function (context) {
37
- return context.size;
38
- });
39
- var noArrow = usePopoverContext(function (context) {
40
- return context.noArrow;
41
- });
42
- var appearance = usePopoverContext(function (context) {
43
- return context.appearance;
44
- });
45
- var trapFocus = usePopoverContext(function (context) {
46
- return context.trapFocus;
47
- });
48
- var modalAttributes = useModalAttributes({
49
- trapFocus: trapFocus
50
- }).modalAttributes;
51
- var state = {
52
- appearance: appearance,
53
- noArrow: noArrow,
54
- size: size,
55
- arrowRef: arrowRef,
56
- open: open,
57
- mountNode: mountNode,
30
+ const state = {
31
+ inline,
32
+ appearance,
33
+ noArrow,
34
+ size,
35
+ arrowRef,
36
+ mountNode,
58
37
  components: {
59
38
  root: 'div'
60
39
  },
61
- root: getNativeElementProps('div', __assign(__assign({
40
+ root: getNativeElementProps('div', {
62
41
  ref: useMergedRefs(ref, contentRef),
63
- role: 'dialog'
64
- }, modalAttributes), props))
42
+ role: trapFocus ? 'dialog' : 'complementary',
43
+ 'aria-modal': trapFocus ? true : undefined,
44
+ ...modalAttributes,
45
+ ...props
46
+ })
65
47
  };
66
- var _a = state.root,
67
- onMouseEnterOriginal = _a.onMouseEnter,
68
- onMouseLeaveOriginal = _a.onMouseLeave,
69
- onKeyDownOriginal = _a.onKeyDown;
48
+ const {
49
+ onMouseEnter: onMouseEnterOriginal,
50
+ onMouseLeave: onMouseLeaveOriginal,
51
+ onKeyDown: onKeyDownOriginal
52
+ } = state.root;
70
53
 
71
- state.root.onMouseEnter = function (e) {
54
+ state.root.onMouseEnter = e => {
72
55
  if (openOnHover) {
73
56
  setOpen(e, true);
74
57
  }
@@ -76,7 +59,7 @@ export var usePopoverSurface = function (props, ref) {
76
59
  onMouseEnterOriginal === null || onMouseEnterOriginal === void 0 ? void 0 : onMouseEnterOriginal(e);
77
60
  };
78
61
 
79
- state.root.onMouseLeave = function (e) {
62
+ state.root.onMouseLeave = e => {
80
63
  if (openOnHover) {
81
64
  setOpen(e, false);
82
65
  }
@@ -84,7 +67,7 @@ export var usePopoverSurface = function (props, ref) {
84
67
  onMouseLeaveOriginal === null || onMouseLeaveOriginal === void 0 ? void 0 : onMouseLeaveOriginal(e);
85
68
  };
86
69
 
87
- state.root.onKeyDown = function (e) {
70
+ state.root.onKeyDown = e => {
88
71
  var _a; // only close if the event happened inside the current popover
89
72
  // If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack
90
73
 
@@ -96,13 +79,6 @@ export var usePopoverSurface = function (props, ref) {
96
79
  onKeyDownOriginal === null || onKeyDownOriginal === void 0 ? void 0 : onKeyDownOriginal(e);
97
80
  };
98
81
 
99
- var findFirstFocusable = useFocusFinders().findFirstFocusable;
100
- React.useEffect(function () {
101
- if (state.open && contentRef.current) {
102
- var firstFocusable = findFirstFocusable(contentRef.current);
103
- firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
104
- }
105
- }, [contentRef, findFirstFocusable, state.open]);
106
82
  return state;
107
83
  };
108
84
  //# sourceMappingURL=usePopoverSurface.js.map
@@ -1 +1 @@
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,SA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AA,iBAAiB,KAAA,IAAjB,IAAA,iBAAiB,KAAA,KAAA,CAAjB,GAAiB,KAAA,CAAjB,GAAA,iBAAiB,CAAG,CAAH,CAAjB;AACD,GARD;;AAUA,SAAO,KAAP;AACD,CAnEM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useMergedRefs } from '@fluentui/react-utilities';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext_unstable } from '../../popoverContext';\nimport type { PopoverSurfaceProps, PopoverSurfaceState } from './PopoverSurface.types';\n\n/**\n * Create the state required to render PopoverSurface.\n *\n * The returned state can be modified with hooks such as usePopoverSurfaceStyles_unstable,\n * before being passed to renderPopoverSurface_unstable.\n *\n * @param props - props from this instance of PopoverSurface\n * @param ref - reference to root HTMLDivElement of PopoverSurface\n */\nexport const usePopoverSurface_unstable = (\n props: PopoverSurfaceProps,\n ref: React.Ref<HTMLDivElement>,\n): PopoverSurfaceState => {\n const contentRef = usePopoverContext_unstable(context => context.contentRef);\n const openOnHover = usePopoverContext_unstable(context => context.openOnHover);\n const setOpen = usePopoverContext_unstable(context => context.setOpen);\n const mountNode = usePopoverContext_unstable(context => context.mountNode);\n const arrowRef = usePopoverContext_unstable(context => context.arrowRef);\n const size = usePopoverContext_unstable(context => context.size);\n const noArrow = usePopoverContext_unstable(context => context.noArrow);\n const appearance = usePopoverContext_unstable(context => context.appearance);\n const trapFocus = usePopoverContext_unstable(context => context.trapFocus);\n const inline = usePopoverContext_unstable(context => context.inline);\n const { modalAttributes } = useModalAttributes({ trapFocus });\n\n const state: PopoverSurfaceState = {\n inline,\n appearance,\n noArrow,\n size,\n arrowRef,\n mountNode,\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n ref: useMergedRefs(ref, contentRef),\n role: trapFocus ? 'dialog' : 'complementary',\n 'aria-modal': trapFocus ? true : undefined,\n ...modalAttributes,\n ...props,\n }),\n };\n\n const {\n onMouseEnter: onMouseEnterOriginal,\n onMouseLeave: onMouseLeaveOriginal,\n onKeyDown: onKeyDownOriginal,\n } = state.root;\n state.root.onMouseEnter = (e: React.MouseEvent<HTMLDivElement>) => {\n if (openOnHover) {\n setOpen(e, true);\n }\n\n onMouseEnterOriginal?.(e);\n };\n\n state.root.onMouseLeave = (e: React.MouseEvent<HTMLDivElement>) => {\n if (openOnHover) {\n setOpen(e, false);\n }\n\n onMouseLeaveOriginal?.(e);\n };\n\n state.root.onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n // only close if the event happened inside the current popover\n // If using a stack of inline popovers, the user should call `stopPropagation` to avoid dismissing the entire stack\n if (e.key === 'Escape' && contentRef.current?.contains(e.target as HTMLDivElement)) {\n setOpen(e, false);\n }\n\n onKeyDownOriginal?.(e);\n };\n\n return state;\n};\n"],"sourceRoot":"../src/"}