@fluentui/react-popover 9.0.4 → 9.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +147 -5
- package/CHANGELOG.md +43 -6
- package/dist/index.d.ts +13 -6
- package/lib/components/Popover/usePopover.js +4 -1
- package/lib/components/Popover/usePopover.js.map +1 -1
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js +4 -4
- package/lib/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
- package/lib/components/PopoverTrigger/usePopoverTrigger.js +22 -21
- package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib/popoverContext.js +5 -5
- package/lib/popoverContext.js.map +1 -1
- package/lib-commonjs/components/Popover/usePopover.js +4 -1
- package/lib-commonjs/components/Popover/usePopover.js.map +1 -1
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js +4 -4
- package/lib-commonjs/components/PopoverSurface/usePopoverSurfaceStyles.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +23 -20
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib-commonjs/popoverContext.js +5 -5
- package/lib-commonjs/popoverContext.js.map +1 -1
- package/package.json +16 -14
- package/dist/tsdoc-metadata.json +0 -11
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,149 @@
|
|
2
2
|
"name": "@fluentui/react-popover",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Tue, 20 Sep 2022 20:54:08 GMT",
|
6
|
+
"tag": "@fluentui/react-popover_v9.1.1",
|
7
|
+
"version": "9.1.1",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "beachball",
|
12
|
+
"package": "@fluentui/react-popover",
|
13
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.14",
|
14
|
+
"commit": "9617a5a46ef4c5e310a066a5374ff2ed61db3c66"
|
15
|
+
}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"date": "Thu, 15 Sep 2022 09:49:12 GMT",
|
21
|
+
"tag": "@fluentui/react-popover_v9.1.0",
|
22
|
+
"version": "9.1.0",
|
23
|
+
"comments": {
|
24
|
+
"patch": [
|
25
|
+
{
|
26
|
+
"author": "esteban.230@hotmail.com",
|
27
|
+
"package": "@fluentui/react-popover",
|
28
|
+
"commit": "3b1fea37fa1f5c4abbf76919e37833f3f1010647",
|
29
|
+
"comment": "fix: Allow PopoverSurface to trap focus when it's focusable."
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"author": "bernardo.sunderhus@gmail.com",
|
33
|
+
"package": "@fluentui/react-popover",
|
34
|
+
"commit": "6c6fe4c8246abec30d9cd3ba2079d379c4d7acb8",
|
35
|
+
"comment": "bugfix: stops propagation on Escape keydown"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"author": "miroslav.stastny@microsoft.com",
|
39
|
+
"package": "@fluentui/react-popover",
|
40
|
+
"commit": "0137f992b99b3b8ec927be8f7aef751d27cd5830",
|
41
|
+
"comment": "fix: Rename colorNeutralForegroundInvertedStatic token to colorNeutralForegroundStaticInverted"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"author": "olfedias@microsoft.com",
|
45
|
+
"package": "@fluentui/react-popover",
|
46
|
+
"commit": "e610024474cfe5d45f61501a8b6a21daf4c794a2",
|
47
|
+
"comment": "chore: Update Griffel to latest version"
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"author": "behowell@microsoft.com",
|
51
|
+
"package": "@fluentui/react-popover",
|
52
|
+
"commit": "e598325b985cad3e5057f00893e0176416edd292",
|
53
|
+
"comment": "refactor: Replace useMergedEventCallbacks utility with mergeCallbacks"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"author": "seanmonahan@microsoft.com",
|
57
|
+
"package": "@fluentui/react-popover",
|
58
|
+
"commit": "1d0a72865a151962362aa3e5054ac9bf8178f09c",
|
59
|
+
"comment": "fix: update color tokens"
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"author": "lingfangao@hotmail.com",
|
63
|
+
"package": "@fluentui/react-popover",
|
64
|
+
"commit": "a0cfab0e5f74e3a3bfa9c269fff574295042d7f2",
|
65
|
+
"comment": "chore: fix no-context-default-value lint violations"
|
66
|
+
}
|
67
|
+
],
|
68
|
+
"none": [
|
69
|
+
{
|
70
|
+
"author": "martinhochel@microsoft.com",
|
71
|
+
"package": "@fluentui/react-popover",
|
72
|
+
"commit": "ba9444d594f3a960cc590eae5237c08bf7c5a07f",
|
73
|
+
"comment": "chore: consume cypress.config from it's package boundary"
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"author": "martinhochel@microsoft.com",
|
77
|
+
"package": "@fluentui/react-popover",
|
78
|
+
"commit": "e6cf183695d6d67a24e038c49a876224e5ed35e5",
|
79
|
+
"comment": "chore: update package scaffold"
|
80
|
+
}
|
81
|
+
],
|
82
|
+
"minor": [
|
83
|
+
{
|
84
|
+
"author": "bernardo.sunderhus@gmail.com",
|
85
|
+
"package": "@fluentui/react-popover",
|
86
|
+
"commit": "0547583ebcebe746110e5ef8d0599b0972b1f4c6",
|
87
|
+
"comment": "chore(react-popover): Updates trigger to use useARIAButton"
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"author": "beachball",
|
91
|
+
"package": "@fluentui/react-popover",
|
92
|
+
"comment": "Bump @fluentui/react-aria to v9.2.0",
|
93
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
94
|
+
},
|
95
|
+
{
|
96
|
+
"author": "beachball",
|
97
|
+
"package": "@fluentui/react-popover",
|
98
|
+
"comment": "Bump @fluentui/react-context-selector to v9.0.3",
|
99
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
100
|
+
},
|
101
|
+
{
|
102
|
+
"author": "beachball",
|
103
|
+
"package": "@fluentui/react-popover",
|
104
|
+
"comment": "Bump @fluentui/react-portal to v9.0.5",
|
105
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"author": "beachball",
|
109
|
+
"package": "@fluentui/react-popover",
|
110
|
+
"comment": "Bump @fluentui/react-positioning to v9.2.0",
|
111
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
112
|
+
},
|
113
|
+
{
|
114
|
+
"author": "beachball",
|
115
|
+
"package": "@fluentui/react-popover",
|
116
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.0.1",
|
117
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"author": "beachball",
|
121
|
+
"package": "@fluentui/react-popover",
|
122
|
+
"comment": "Bump @fluentui/react-tabster to v9.1.1",
|
123
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
124
|
+
},
|
125
|
+
{
|
126
|
+
"author": "beachball",
|
127
|
+
"package": "@fluentui/react-popover",
|
128
|
+
"comment": "Bump @fluentui/react-theme to v9.1.0",
|
129
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
130
|
+
},
|
131
|
+
{
|
132
|
+
"author": "beachball",
|
133
|
+
"package": "@fluentui/react-popover",
|
134
|
+
"comment": "Bump @fluentui/react-utilities to v9.1.0",
|
135
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
136
|
+
},
|
137
|
+
{
|
138
|
+
"author": "beachball",
|
139
|
+
"package": "@fluentui/react-popover",
|
140
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.13",
|
141
|
+
"commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
|
142
|
+
}
|
143
|
+
]
|
144
|
+
}
|
145
|
+
},
|
146
|
+
{
|
147
|
+
"date": "Wed, 03 Aug 2022 16:03:53 GMT",
|
6
148
|
"tag": "@fluentui/react-popover_v9.0.4",
|
7
149
|
"version": "9.0.4",
|
8
150
|
"comments": {
|
@@ -31,25 +173,25 @@
|
|
31
173
|
"author": "beachball",
|
32
174
|
"package": "@fluentui/react-popover",
|
33
175
|
"comment": "Bump @fluentui/react-portal to v9.0.4",
|
34
|
-
"commit": "
|
176
|
+
"commit": "ee4a8be0d0831a6615f878f98db6a97cc61a802d"
|
35
177
|
},
|
36
178
|
{
|
37
179
|
"author": "beachball",
|
38
180
|
"package": "@fluentui/react-popover",
|
39
181
|
"comment": "Bump @fluentui/react-positioning to v9.1.2",
|
40
|
-
"commit": "
|
182
|
+
"commit": "ee4a8be0d0831a6615f878f98db6a97cc61a802d"
|
41
183
|
},
|
42
184
|
{
|
43
185
|
"author": "beachball",
|
44
186
|
"package": "@fluentui/react-popover",
|
45
187
|
"comment": "Bump @fluentui/react-tabster to v9.1.0",
|
46
|
-
"commit": "
|
188
|
+
"commit": "ee4a8be0d0831a6615f878f98db6a97cc61a802d"
|
47
189
|
},
|
48
190
|
{
|
49
191
|
"author": "beachball",
|
50
192
|
"package": "@fluentui/react-popover",
|
51
193
|
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.12",
|
52
|
-
"commit": "
|
194
|
+
"commit": "ee4a8be0d0831a6615f878f98db6a97cc61a802d"
|
53
195
|
}
|
54
196
|
]
|
55
197
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,21 +1,58 @@
|
|
1
1
|
# Change Log - @fluentui/react-popover
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Tue, 20 Sep 2022 20:54:08 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.1.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-popover_v9.1.1)
|
8
|
+
|
9
|
+
Tue, 20 Sep 2022 20:54:08 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-popover_v9.1.0..@fluentui/react-popover_v9.1.1)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.14 ([PR #24870](https://github.com/microsoft/fluentui/pull/24870) by beachball)
|
15
|
+
|
16
|
+
## [9.1.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-popover_v9.1.0)
|
17
|
+
|
18
|
+
Thu, 15 Sep 2022 09:49:12 GMT
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-popover_v9.0.4..@fluentui/react-popover_v9.1.0)
|
20
|
+
|
21
|
+
### Minor changes
|
22
|
+
|
23
|
+
- chore(react-popover): Updates trigger to use useARIAButton ([PR #24177](https://github.com/microsoft/fluentui/pull/24177) by bernardo.sunderhus@gmail.com)
|
24
|
+
- Bump @fluentui/react-aria to v9.2.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
25
|
+
- Bump @fluentui/react-context-selector to v9.0.3 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
26
|
+
- Bump @fluentui/react-portal to v9.0.5 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
27
|
+
- Bump @fluentui/react-positioning to v9.2.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
28
|
+
- Bump @fluentui/react-shared-contexts to v9.0.1 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
29
|
+
- Bump @fluentui/react-tabster to v9.1.1 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
30
|
+
- Bump @fluentui/react-theme to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
31
|
+
- Bump @fluentui/react-utilities to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
32
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.13 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
|
33
|
+
|
34
|
+
### Patches
|
35
|
+
|
36
|
+
- fix: Allow PopoverSurface to trap focus when it's focusable. ([PR #24134](https://github.com/microsoft/fluentui/pull/24134) by esteban.230@hotmail.com)
|
37
|
+
- bugfix: stops propagation on Escape keydown ([PR #24750](https://github.com/microsoft/fluentui/pull/24750) by bernardo.sunderhus@gmail.com)
|
38
|
+
- fix: Rename colorNeutralForegroundInvertedStatic token to colorNeutralForegroundStaticInverted ([PR #24611](https://github.com/microsoft/fluentui/pull/24611) by miroslav.stastny@microsoft.com)
|
39
|
+
- chore: Update Griffel to latest version ([PR #24221](https://github.com/microsoft/fluentui/pull/24221) by olfedias@microsoft.com)
|
40
|
+
- refactor: Replace useMergedEventCallbacks utility with mergeCallbacks ([PR #24152](https://github.com/microsoft/fluentui/pull/24152) by behowell@microsoft.com)
|
41
|
+
- fix: update color tokens ([PR #24027](https://github.com/microsoft/fluentui/pull/24027) by seanmonahan@microsoft.com)
|
42
|
+
- chore: fix no-context-default-value lint violations ([PR #24276](https://github.com/microsoft/fluentui/pull/24276) by lingfangao@hotmail.com)
|
43
|
+
|
7
44
|
## [9.0.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-popover_v9.0.4)
|
8
45
|
|
9
|
-
Wed, 03 Aug 2022 16:
|
46
|
+
Wed, 03 Aug 2022 16:03:53 GMT
|
10
47
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-popover_v9.0.3..@fluentui/react-popover_v9.0.4)
|
11
48
|
|
12
49
|
### Patches
|
13
50
|
|
14
51
|
- chore: Bump Griffel dependencies ([PR #24114](https://github.com/microsoft/fluentui/pull/24114) by miroslav.stastny@microsoft.com)
|
15
|
-
- Bump @fluentui/react-portal to v9.0.4 ([PR #
|
16
|
-
- Bump @fluentui/react-positioning to v9.1.2 ([PR #
|
17
|
-
- Bump @fluentui/react-tabster to v9.1.0 ([PR #
|
18
|
-
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.12 ([PR #
|
52
|
+
- Bump @fluentui/react-portal to v9.0.4 ([PR #24131](https://github.com/microsoft/fluentui/pull/24131) by beachball)
|
53
|
+
- Bump @fluentui/react-positioning to v9.1.2 ([PR #24131](https://github.com/microsoft/fluentui/pull/24131) by beachball)
|
54
|
+
- Bump @fluentui/react-tabster to v9.1.0 ([PR #24131](https://github.com/microsoft/fluentui/pull/24131) by beachball)
|
55
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.12 ([PR #24131](https://github.com/microsoft/fluentui/pull/24131) by beachball)
|
19
56
|
|
20
57
|
## [9.0.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-popover_v9.0.3)
|
21
58
|
|
package/dist/index.d.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import { ARIAButtonResultProps } from '@fluentui/react-aria';
|
2
|
+
import { ARIAButtonType } from '@fluentui/react-aria';
|
1
3
|
import type { ComponentProps } from '@fluentui/react-utilities';
|
2
4
|
import type { ComponentState } from '@fluentui/react-utilities';
|
3
5
|
import type { ContextSelector } from '@fluentui/react-context-selector';
|
@@ -212,17 +214,22 @@ export declare type PopoverSurfaceState = ComponentState<PopoverSurfaceSlots> &
|
|
212
214
|
*/
|
213
215
|
export declare const PopoverTrigger: React_2.FC<PopoverTriggerProps> & FluentTriggerComponent;
|
214
216
|
|
215
|
-
|
216
|
-
|
217
|
-
|
217
|
+
/**
|
218
|
+
* Props that are passed to the child of the DialogTrigger when cloned to ensure correct behaviour for the Dialog
|
219
|
+
*/
|
220
|
+
export declare type PopoverTriggerChildProps<Type extends ARIAButtonType = ARIAButtonType, Props = {}> = ARIAButtonResultProps<Type, Props & {
|
221
|
+
'aria-expanded'?: 'true' | 'false';
|
222
|
+
ref: React_2.Ref<unknown>;
|
223
|
+
onMouseEnter: React_2.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;
|
224
|
+
onMouseLeave: React_2.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;
|
225
|
+
onContextMenu: React_2.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;
|
226
|
+
}>;
|
218
227
|
|
219
228
|
/**
|
220
229
|
* PopoverTrigger Props
|
221
230
|
*/
|
222
231
|
export declare type PopoverTriggerProps = {
|
223
|
-
children: (React_2.ReactElement
|
224
|
-
ref?: React_2.Ref<unknown>;
|
225
|
-
}) | ((props: PopoverTriggerChildProps) => React_2.ReactElement | null);
|
232
|
+
children: React_2.ReactElement | ((props: PopoverTriggerChildProps) => React_2.ReactElement | null);
|
226
233
|
};
|
227
234
|
|
228
235
|
/**
|
@@ -106,8 +106,11 @@ export const usePopover_unstable = props => {
|
|
106
106
|
findFirstFocusable
|
107
107
|
} = useFocusFinders();
|
108
108
|
React.useEffect(() => {
|
109
|
+
var _a;
|
110
|
+
|
109
111
|
if (open && positioningRefs.contentRef.current) {
|
110
|
-
const
|
112
|
+
const containerTabIndex = (_a = positioningRefs.contentRef.current.getAttribute('tabIndex')) !== null && _a !== void 0 ? _a : undefined;
|
113
|
+
const firstFocusable = isNaN(containerTabIndex) ? findFirstFocusable(positioningRefs.contentRef.current) : positioningRefs.contentRef.current;
|
111
114
|
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
112
115
|
}
|
113
116
|
}, [findFirstFocusable, open, positioningRefs.contentRef]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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,kBAAkB,IAAI,SAA/B,QAAgD,iCAAhD;AACA,SACE,cADF,EAEE,2BAFF,EAGE,gBAHF,EAIE,yBAJF,QAKO,6BALP;AAMA,SAAS,eAAT,QAAgC,wBAAhC;AACA,SAAS,eAAT,QAAgC,yBAAhC;AACA,SAAS,YAAT,QAA6B,yBAA7B;AAEA,SAAS,0BAAT,QAA2C,aAA3C;AAEA;;;;;;;AAOG;;AACH,OAAO,MAAM,mBA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,IAAI,kBAAkB,CAAC,WAAvB,EAAoC;IAClC,KAAK,CAAC,SAAN,GAAkB,KAAlB;EACD;;EAED,IAAI,KAAK,CAAC,SAAV,EAAqB;IACnB,kBAAkB,CAAC,MAAnB,GAA4B,gBAAgB,CAAC,kBAAkB,CAAC,MAApB,EAA4B,YAAY,CAAC,KAAK,CAAC,IAAP,CAAxC,CAA5C;EACD;;EAED,MAAM;IAAE,SAAS,EAAE,UAAb;IAAyB,YAAY,EAAE,UAAvC;IAAmD;EAAnD,IAAgE,cAAc,CAAC,kBAAD,CAApF;EAEA,OAAO;IACL,UADK;IAEL,UAFK;IAGL;EAHK,CAAP;AAKD","sourcesContent":["import * as React from 'react';\nimport {\n useControllableState,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePositioning,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePositioningMouseTarget,\n} from '@fluentui/react-positioning';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { OpenPopoverEvents, PopoverProps, PopoverState } from './Popover.types';\nimport { popoverSurfaceBorderRadius } from './constants';\n\n/**\n * Create the state required to render Popover.\n *\n * The returned state can be modified with hooks such as usePopoverStyles,\n * before being passed to renderPopover_unstable.\n *\n * @param props - props from this instance of Popover\n */\nexport const usePopover_unstable = (props: PopoverProps): PopoverState => {\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n const initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at most two children');\n }\n }\n\n let popoverTrigger: React.ReactElement | undefined = undefined;\n let popoverSurface: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n popoverTrigger = children[0];\n popoverSurface = children[1];\n } else if (children.length === 1) {\n popoverSurface = children[0];\n }\n\n const [open, setOpenState] = useOpenState(initialState);\n\n const setOpenTimeoutRef = React.useRef(0);\n\n const setOpen = useEventCallback((e: OpenPopoverEvents, shouldOpen: boolean) => {\n clearTimeout(setOpenTimeoutRef.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave') {\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeoutRef.current = setTimeout(() => {\n setOpenState(e, shouldOpen);\n }, props.mouseLeaveDelay ?? 500);\n } else {\n setOpenState(e, shouldOpen);\n }\n });\n\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeoutRef.current);\n };\n }, []);\n\n const toggleOpen = React.useCallback<PopoverState['toggleOpen']>(\n e => {\n setOpen(e, !open);\n },\n [setOpen, open],\n );\n\n const positioningRefs = usePopoverRefs(initialState);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open,\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open || !closeOnScroll,\n });\n\n const { findFirstFocusable } = useFocusFinders();\n\n React.useEffect(() => {\n if (open && positioningRefs.contentRef.current) {\n const firstFocusable = findFirstFocusable(positioningRefs.contentRef.current);\n firstFocusable?.focus();\n }\n }, [findFirstFocusable, open, positioningRefs.contentRef]);\n\n return {\n ...initialState,\n ...positioningRefs,\n popoverTrigger,\n popoverSurface,\n open,\n setOpen,\n toggleOpen,\n setContextTarget,\n contextTarget,\n inline: props.inline ?? false,\n };\n};\n\n/**\n * Creates and manages the Popover open state\n */\nfunction useOpenState(\n state: Pick<PopoverState, 'setContextTarget' | 'onOpenChange'> & Pick<PopoverProps, 'open' | 'defaultOpen'>,\n) {\n const onOpenChange: PopoverState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n\n const setOpen = React.useCallback(\n (e: OpenPopoverEvents, shouldOpen: boolean) => {\n if (shouldOpen && e.type === 'contextmenu') {\n setContextTarget(e as React.MouseEvent);\n }\n\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n\n setOpenState(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'> &\n Pick<PopoverProps, 'positioning' | 'openOnContext' | 'withArrow'>,\n) {\n const positioningOptions = {\n position: 'above' as const,\n align: 'center' as const,\n arrowPadding: 2 * popoverSurfaceBorderRadius,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (positioningOptions.coverTarget) {\n state.withArrow = false;\n }\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeights[state.size]);\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePositioning(positioningOptions);\n\n return {\n triggerRef,\n contentRef,\n arrowRef,\n } as const;\n}\n"],"sourceRoot":"../src/"}
|
1
|
+
{"version":3,"sources":["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,kBAAkB,IAAI,SAA/B,QAAgD,iCAAhD;AACA,SACE,cADF,EAEE,2BAFF,EAGE,gBAHF,EAIE,yBAJF,QAKO,6BALP;AAMA,SAAS,eAAT,QAAgC,wBAAhC;AACA,SAAS,eAAT,QAAgC,yBAAhC;AACA,SAAS,YAAT,QAA6B,yBAA7B;AAEA,SAAS,0BAAT,QAA2C,aAA3C;AAEA;;;;;;;AAOG;;AACH,OAAO,MAAM,mBAAmB,GAAI,KAAD,IAAsC;;;EACvE,MAAM,CAAC,aAAD,EAAgB,gBAAhB,IAAoC,yBAAyB,EAAnE;EACA,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,QADa;IAEnB,aAFmB;IAGnB,gBAHmB;IAInB,GAAG;EAJgB,CAArB;EAOA,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAN,CAAe,OAAf,CAAuB,KAAK,CAAC,QAA7B,CAAjB;;EAEA,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;IACzC,IAAI,QAAQ,CAAC,MAAT,KAAoB,CAAxB,EAA2B;MACzB;MACA,OAAO,CAAC,IAAR,CAAa,yCAAb;IACD;;IAED,IAAI,QAAQ,CAAC,MAAT,GAAkB,CAAtB,EAAyB;MACvB;MACA,OAAO,CAAC,IAAR,CAAa,2CAAb;IACD;EACF;;EAED,IAAI,cAAc,GAAmC,SAArD;EACA,IAAI,cAAc,GAAmC,SAArD;;EACA,IAAI,QAAQ,CAAC,MAAT,KAAoB,CAAxB,EAA2B;IACzB,cAAc,GAAG,QAAQ,C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';\nimport {\n useControllableState,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePositioning,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePositioningMouseTarget,\n} from '@fluentui/react-positioning';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { OpenPopoverEvents, PopoverProps, PopoverState } from './Popover.types';\nimport { popoverSurfaceBorderRadius } from './constants';\n\n/**\n * Create the state required to render Popover.\n *\n * The returned state can be modified with hooks such as usePopoverStyles,\n * before being passed to renderPopover_unstable.\n *\n * @param props - props from this instance of Popover\n */\nexport const usePopover_unstable = (props: PopoverProps): PopoverState => {\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n const initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at most two children');\n }\n }\n\n let popoverTrigger: React.ReactElement | undefined = undefined;\n let popoverSurface: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n popoverTrigger = children[0];\n popoverSurface = children[1];\n } else if (children.length === 1) {\n popoverSurface = children[0];\n }\n\n const [open, setOpenState] = useOpenState(initialState);\n\n const setOpenTimeoutRef = React.useRef(0);\n\n const setOpen = useEventCallback((e: OpenPopoverEvents, shouldOpen: boolean) => {\n clearTimeout(setOpenTimeoutRef.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave') {\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeoutRef.current = setTimeout(() => {\n setOpenState(e, shouldOpen);\n }, props.mouseLeaveDelay ?? 500);\n } else {\n setOpenState(e, shouldOpen);\n }\n });\n\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeoutRef.current);\n };\n }, []);\n\n const toggleOpen = React.useCallback<PopoverState['toggleOpen']>(\n e => {\n setOpen(e, !open);\n },\n [setOpen, open],\n );\n\n const positioningRefs = usePopoverRefs(initialState);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open,\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open || !closeOnScroll,\n });\n\n const { findFirstFocusable } = useFocusFinders();\n\n React.useEffect(() => {\n if (open && positioningRefs.contentRef.current) {\n const containerTabIndex = positioningRefs.contentRef.current.getAttribute('tabIndex') ?? undefined;\n const firstFocusable = isNaN(containerTabIndex)\n ? findFirstFocusable(positioningRefs.contentRef.current)\n : positioningRefs.contentRef.current;\n firstFocusable?.focus();\n }\n }, [findFirstFocusable, open, positioningRefs.contentRef]);\n\n return {\n ...initialState,\n ...positioningRefs,\n popoverTrigger,\n popoverSurface,\n open,\n setOpen,\n toggleOpen,\n setContextTarget,\n contextTarget,\n inline: props.inline ?? false,\n };\n};\n\n/**\n * Creates and manages the Popover open state\n */\nfunction useOpenState(\n state: Pick<PopoverState, 'setContextTarget' | 'onOpenChange'> & Pick<PopoverProps, 'open' | 'defaultOpen'>,\n) {\n const onOpenChange: PopoverState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n\n const setOpen = React.useCallback(\n (e: OpenPopoverEvents, shouldOpen: boolean) => {\n if (shouldOpen && e.type === 'contextmenu') {\n setContextTarget(e as React.MouseEvent);\n }\n\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n\n setOpenState(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'> &\n Pick<PopoverProps, 'positioning' | 'openOnContext' | 'withArrow'>,\n) {\n const positioningOptions = {\n position: 'above' as const,\n align: 'center' as const,\n arrowPadding: 2 * popoverSurfaceBorderRadius,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (positioningOptions.coverTarget) {\n state.withArrow = false;\n }\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeights[state.size]);\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePositioning(positioningOptions);\n\n return {\n triggerRef,\n contentRef,\n arrowRef,\n } as const;\n}\n"],"sourceRoot":"../src/"}
|
@@ -35,12 +35,12 @@ const useStyles = /*#__PURE__*/__styles({
|
|
35
35
|
"zhjwy3": ["fjscplz", "f1gn591s"]
|
36
36
|
},
|
37
37
|
"inverted": {
|
38
|
-
"De3pzq": "
|
39
|
-
"sj55zd": "
|
38
|
+
"De3pzq": "fg3r6xk",
|
39
|
+
"sj55zd": "fonrgv7"
|
40
40
|
},
|
41
41
|
"brand": {
|
42
42
|
"De3pzq": "ffp7eso",
|
43
|
-
"sj55zd": "
|
43
|
+
"sj55zd": "f1phragk"
|
44
44
|
},
|
45
45
|
"smallPadding": {
|
46
46
|
"z8tnut": "f1kcqot9",
|
@@ -98,7 +98,7 @@ const useStyles = /*#__PURE__*/__styles({
|
|
98
98
|
"Bwwlvwl": "fm1ycve"
|
99
99
|
}
|
100
100
|
}, {
|
101
|
-
"d": [".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f1hg901r{box-shadow:var(--shadow16);}", ".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".f5ogflp{border-top-width:1px;}", ".f1hqa2wf{border-right-width:1px;}", ".finvdd3{border-left-width:1px;}", ".f1f09k3d{border-bottom-width:1px;}", ".fzkkow9{border-top-style:solid;}", ".fcdblym{border-right-style:solid;}", ".fjik90z{border-left-style:solid;}", ".fg706s2{border-bottom-style:solid;}", ".fghlq4f{border-top-color:var(--colorTransparentStroke);}", ".f1gn591s{border-right-color:var(--colorTransparentStroke);}", ".fjscplz{border-left-color:var(--colorTransparentStroke);}", ".fb073pr{border-bottom-color:var(--colorTransparentStroke);}", ".
|
101
|
+
"d": [".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f1hg901r{box-shadow:var(--shadow16);}", ".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".f5ogflp{border-top-width:1px;}", ".f1hqa2wf{border-right-width:1px;}", ".finvdd3{border-left-width:1px;}", ".f1f09k3d{border-bottom-width:1px;}", ".fzkkow9{border-top-style:solid;}", ".fcdblym{border-right-style:solid;}", ".fjik90z{border-left-style:solid;}", ".fg706s2{border-bottom-style:solid;}", ".fghlq4f{border-top-color:var(--colorTransparentStroke);}", ".f1gn591s{border-right-color:var(--colorTransparentStroke);}", ".fjscplz{border-left-color:var(--colorTransparentStroke);}", ".fb073pr{border-bottom-color:var(--colorTransparentStroke);}", ".fg3r6xk{background-color:var(--colorNeutralBackgroundStatic);}", ".fonrgv7{color:var(--colorNeutralForegroundStaticInverted);}", ".ffp7eso{background-color:var(--colorBrandBackground);}", ".f1phragk{color:var(--colorNeutralForegroundOnBrand);}", ".f1kcqot9{padding-top:12px;}", ".f11qrl6u{padding-right:12px;}", ".fjlbh76{padding-left:12px;}", ".fpe6lb7{padding-bottom:12px;}", ".fqag9an{padding-top:16px;}", ".f1gbmcue{padding-right:16px;}", ".f1rh9g5y{padding-left:16px;}", ".fp67ikv{padding-bottom:16px;}", ".fc7z3ec{padding-top:20px;}", ".fat0sn4{padding-right:20px;}", ".fekwl8i{padding-left:20px;}", ".fe2my4m{padding-bottom:20px;}", ".f1ekdpwm{width:8.484px;}", ".f83vc9z{height:8.484px;}", ".f1kmc0fn{width:11.312px;}", ".fb6lvc5{height:11.312px;}", ".f1euv43f{position:absolute;}", ".f1u2r49w{background-color:inherit;}", ".fd7fpy0{visibility:hidden;}", ".f1bsuimh{z-index:-1;}", ".f1wl9k8s::before{content:\"\";}", ".f1wkw4r9::before{visibility:visible;}", ".f1j7ml58::before{position:absolute;}", ".fyl8oag::before{box-sizing:border-box;}", ".frdoeuz::before{width:inherit;}", ".fb81m9q::before{height:inherit;}", ".f1ljr5q2::before{background-color:inherit;}", ".fyfemzf::before{border-right-width:1px;}", ".focyt6c::before{border-right-style:solid;}", ".fnhxbxj::before{border-right-color:var(--colorTransparentStroke);}", ".fdw6hkg::before{border-bottom-width:1px;}", ".f11yjt3y::before{border-bottom-style:solid;}", ".f1172wan::before{border-bottom-color:var(--colorTransparentStroke);}", ".f9e5op9::before{border-bottom-right-radius:var(--borderRadiusSmall);}", ".f112wvtl::before{border-bottom-left-radius:var(--borderRadiusSmall);}", ".ftj5xct::before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);}", ".fyavhwi::before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);}", "[data-popper-placement^=\"top\"] .f1773hnp{bottom:-1px;}", "[data-popper-placement^=\"top\"] .f1n8855c{--angle:0;}", "[data-popper-placement^=\"right\"] .f1v7783n{left:-1px;}", "[data-popper-placement^=\"right\"] .fsw6im5{--angle:90deg;}", "[data-popper-placement^=\"bottom\"] .fh2hsk5{top:-1px;}", "[data-popper-placement^=\"bottom\"] .f159pzir{--angle:180deg;}", "[data-popper-placement^=\"left\"] .f11yvu4{right:-1px;}", "[data-popper-placement^=\"left\"] .fm1ycve{--angle:270deg;}"]
|
102
102
|
});
|
103
103
|
/**
|
104
104
|
* Apply styling to the PopoverSurface slots based on the state
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverSurface/usePopoverSurfaceStyles.ts"],"names":[],"mappings":"AAAA,SAAS,UAAT,YAAiC,YAAjC,QAAqD,gBAArD;AACA,SAAS,uBAAT,EAAkC,iBAAlC,QAA2D,6BAA3D;AACA,SAAS,MAAT,QAAuB,uBAAvB;AAKA,OAAO,MAAM,wBAAwB,GAAwC;EAC3E,IAAI,EAAE;AADqE,CAAtE;AAIP,OAAO,MAAM,YAAY,GAAgC;EACvD,KAAK,EAAE,CADgD;EAEvD,MAAM,EAAE,CAF+C;EAGvD,KAAK,EAAE;AAHgD,CAAlD;AAMP;;AAEG;;AACH,MAAM,SAA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AAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAAlB;AAmCA;;AAEG;;;AACH,OAAO,MAAM,gCAAgC,GAAI,KAAD,IAAoD;EAClG,MAAM,MAAM,GAAG,SAAS,EAAxB;EACA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CACjC,wBAAwB,CAAC,IADQ,EAEjC,MAAM,CAAC,IAF0B,EAGjC,KAAK,CAAC,IAAN,KAAe,OAAf,IAA0B,MAAM,CAAC,YAHA,EAIjC,KAAK,CAAC,IAAN,KAAe,QAAf,IAA2B,MAAM,CAAC,aAJD,EAKjC,KAAK,CAAC,IAAN,KAAe,OAAf,IAA0B,MAAM,CAAC,YALA,EAMjC,KAAK,CAAC,UAAN,KAAqB,UAArB,IAAmC,MAAM,CAAC,QANT,EAOjC,KAAK,CAAC,UAAN,KAAqB,OAArB,IAAgC,MAAM,CAAC,KAPN,EAQjC,KAAK,CAAC,IAAN,CAAW,SARsB,CAAnC;EAWA,KAAK,CAAC,cAAN,GAAuB,YAAY,CACjC,MAAM,CAAC,KAD0B,EAEjC,KAAK,CAAC,IAAN,KAAe,OAAf,GAAyB,MAAM,CAAC,UAAhC,GAA6C,MAAM,CAAC,gBAFnB,CAAnC;EAKA,OAAO,KAAP;AACD,CAnBM","sourcesContent":["import { shorthands, makeStyles, mergeClasses } from '@griffel/react';\nimport { createArrowHeightStyles, createArrowStyles } from '@fluentui/react-positioning';\nimport { tokens } from '@fluentui/react-theme';\nimport type { PopoverSize } from '../Popover/Popover.types';\nimport type { PopoverSurfaceSlots, PopoverSurfaceState } from './PopoverSurface.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const popoverSurfaceClassNames: SlotClassNames<PopoverSurfaceSlots> = {\n root: 'fui-PopoverSurface',\n};\n\nexport const arrowHeights: Record<PopoverSize, number> = {\n small: 6,\n medium: 8,\n large: 8,\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n backgroundColor: tokens.colorNeutralBackground1,\n boxShadow: tokens.shadow16,\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n ...shorthands.border('1px', 'solid', tokens.colorTransparentStroke),\n },\n\n inverted: {\n backgroundColor: tokens.colorNeutralBackgroundStatic,\n color: tokens.colorNeutralForegroundStaticInverted,\n },\n\n brand: {\n backgroundColor: tokens.colorBrandBackground,\n color: tokens.colorNeutralForegroundOnBrand,\n },\n\n smallPadding: {\n ...shorthands.padding('12px'),\n },\n\n mediumPadding: {\n ...shorthands.padding('16px'),\n },\n\n largePadding: {\n ...shorthands.padding('20px'),\n },\n\n smallArrow: createArrowHeightStyles(arrowHeights.small),\n mediumLargeArrow: createArrowHeightStyles(arrowHeights.medium),\n arrow: createArrowStyles({ arrowHeight: undefined }),\n});\n\n/**\n * Apply styling to the PopoverSurface slots based on the state\n */\nexport const usePopoverSurfaceStyles_unstable = (state: PopoverSurfaceState): PopoverSurfaceState => {\n const styles = useStyles();\n state.root.className = mergeClasses(\n popoverSurfaceClassNames.root,\n styles.root,\n state.size === 'small' && styles.smallPadding,\n state.size === 'medium' && styles.mediumPadding,\n state.size === 'large' && styles.largePadding,\n state.appearance === 'inverted' && styles.inverted,\n state.appearance === 'brand' && styles.brand,\n state.root.className,\n );\n\n state.arrowClassName = mergeClasses(\n styles.arrow,\n state.size === 'small' ? styles.smallArrow : styles.mediumLargeArrow,\n );\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PopoverTrigger.types.js","sourceRoot":"../src/","sources":["components/PopoverTrigger/PopoverTrigger.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\n/**\n * PopoverTrigger Props\n */\nexport type PopoverTriggerProps = {\n children
|
1
|
+
{"version":3,"file":"PopoverTrigger.types.js","sourceRoot":"../src/","sources":["components/PopoverTrigger/PopoverTrigger.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ARIAButtonResultProps, ARIAButtonType } from '@fluentui/react-aria';\nimport * as React from 'react';\n\n/**\n * PopoverTrigger Props\n */\nexport type PopoverTriggerProps = {\n children: React.ReactElement | ((props: PopoverTriggerChildProps) => React.ReactElement | null);\n};\n\n/**\n * PopoverTrigger State\n */\nexport type PopoverTriggerState = {\n children: React.ReactElement | null;\n};\n\n/**\n * Props that are passed to the child of the DialogTrigger when cloned to ensure correct behaviour for the Dialog\n */\nexport type PopoverTriggerChildProps<Type extends ARIAButtonType = ARIAButtonType, Props = {}> = ARIAButtonResultProps<\n Type,\n Props & {\n 'aria-expanded'?: 'true' | 'false';\n ref: React.Ref<unknown>;\n onMouseEnter: React.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;\n onMouseLeave: React.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;\n onContextMenu: React.MouseEventHandler<HTMLButtonElement & HTMLAnchorElement & HTMLDivElement>;\n }\n>;\n"]}
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { applyTriggerPropsToChildren, getTriggerChild,
|
2
|
+
import { applyTriggerPropsToChildren, getTriggerChild, mergeCallbacks, useMergedRefs, useEventCallback } from '@fluentui/react-utilities';
|
3
3
|
import { useModalAttributes } from '@fluentui/react-tabster';
|
4
4
|
import { usePopoverContext_unstable } from '../../popoverContext';
|
5
|
+
import { useARIAButtonProps } from '@fluentui/react-aria';
|
6
|
+
import { Escape } from '@fluentui/keyboard-keys';
|
5
7
|
/**
|
6
8
|
* Create the state required to render PopoverTrigger.
|
7
9
|
*
|
@@ -42,23 +44,19 @@ export const usePopoverTrigger_unstable = props => {
|
|
42
44
|
};
|
43
45
|
|
44
46
|
const onKeyDown = e => {
|
45
|
-
|
47
|
+
if (e.key === Escape && open) {
|
48
|
+
setOpen(e, false); // stop propagation to avoid conflicting with other elements that listen for `Escape`
|
49
|
+
// e,g: Dialog, Menu
|
46
50
|
|
47
|
-
|
48
|
-
e.preventDefault();
|
49
|
-
(_a = e.target) === null || _a === void 0 ? void 0 : _a.click();
|
50
|
-
}
|
51
|
-
|
52
|
-
if (e.key === 'Escape') {
|
53
|
-
setOpen(e, false);
|
51
|
+
e.stopPropagation();
|
54
52
|
}
|
55
53
|
};
|
56
54
|
|
57
|
-
const onMouseEnter =
|
55
|
+
const onMouseEnter = e => {
|
58
56
|
if (openOnHover) {
|
59
57
|
setOpen(e, true);
|
60
58
|
}
|
61
|
-
}
|
59
|
+
};
|
62
60
|
|
63
61
|
const onMouseLeave = e => {
|
64
62
|
if (openOnHover) {
|
@@ -66,17 +64,20 @@ export const usePopoverTrigger_unstable = props => {
|
|
66
64
|
}
|
67
65
|
};
|
68
66
|
|
67
|
+
const triggerProps = { ...triggerAttributes,
|
68
|
+
'aria-expanded': `${open}`,
|
69
|
+
...(child === null || child === void 0 ? void 0 : child.props),
|
70
|
+
onMouseEnter: useEventCallback(mergeCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onMouseEnter, onMouseEnter)),
|
71
|
+
onMouseLeave: useEventCallback(mergeCallbacks((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.onMouseLeave, onMouseLeave)),
|
72
|
+
onContextMenu: useEventCallback(mergeCallbacks((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.onContextMenu, onContextMenu)),
|
73
|
+
ref: useMergedRefs(triggerRef, child === null || child === void 0 ? void 0 : child.ref)
|
74
|
+
};
|
75
|
+
const ariaButtonTriggerProps = useARIAButtonProps((child === null || child === void 0 ? void 0 : child.type) === 'button' || (child === null || child === void 0 ? void 0 : child.type) === 'a' ? child.type : 'div', { ...triggerProps,
|
76
|
+
onClick: useEventCallback(mergeCallbacks((_d = child === null || child === void 0 ? void 0 : child.props) === null || _d === void 0 ? void 0 : _d.onClick, onClick)),
|
77
|
+
onKeyDown: useEventCallback(mergeCallbacks((_e = child === null || child === void 0 ? void 0 : child.props) === null || _e === void 0 ? void 0 : _e.onKeyDown, onKeyDown))
|
78
|
+
});
|
69
79
|
return {
|
70
|
-
children: applyTriggerPropsToChildren(props.children,
|
71
|
-
'aria-expanded': `${open}`,
|
72
|
-
...(child === null || child === void 0 ? void 0 : child.props),
|
73
|
-
onClick: useMergedEventCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onClick, onClick),
|
74
|
-
onMouseEnter: useMergedEventCallbacks((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.onMouseEnter, onMouseEnter),
|
75
|
-
onKeyDown: useMergedEventCallbacks((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.onKeyDown, onKeyDown),
|
76
|
-
onMouseLeave: useMergedEventCallbacks((_d = child === null || child === void 0 ? void 0 : child.props) === null || _d === void 0 ? void 0 : _d.onMouseLeave, onMouseLeave),
|
77
|
-
onContextMenu: useMergedEventCallbacks((_e = child === null || child === void 0 ? void 0 : child.props) === null || _e === void 0 ? void 0 : _e.onContextMenu, onContextMenu),
|
78
|
-
ref: useMergedRefs(triggerRef, child === null || child === void 0 ? void 0 : child.ref)
|
79
|
-
})
|
80
|
+
children: applyTriggerPropsToChildren(props.children, useARIAButtonProps((child === null || child === void 0 ? void 0 : child.type) === 'button' || (child === null || child === void 0 ? void 0 : child.type) === 'a' ? child.type : 'div', openOnContext ? triggerProps : ariaButtonTriggerProps))
|
80
81
|
};
|
81
82
|
};
|
82
83
|
//# sourceMappingURL=usePopoverTrigger.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings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P,MAAY,IAAZ,IAAY,EAAA,KAAA,KAAA,CAAZ,GAAY,KAAA,CAAZ,GAAY,EAAA,CAAE,SAAf,EAA0B,SAA1B,CAAf;EAH7B,CAF+C,CAAjD;EASA,OAAO;IACL,QAAQ,EAAE,2BAA2B,CACnC,KAAK,CAAC,QAD6B,EAEnC,kBAAkB,CAChB,CAAA,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,IAAP,MAAgB,QAAhB,IAA4B,CAAA,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,IAAP,MAAgB,GAA5C,GAAkD,KAAK,CAAC,IAAxD,GAA+D,KAD/C,EAEhB,aAAa,GAAG,YAAH,GAAkB,sBAFf,CAFiB;EADhC,CAAP;AASD,CA5EM","sourcesContent":["import * as React from 'react';\nimport {\n applyTriggerPropsToChildren,\n getTriggerChild,\n mergeCallbacks,\n useMergedRefs,\n useEventCallback,\n} from '@fluentui/react-utilities';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext_unstable } from '../../popoverContext';\nimport type { PopoverTriggerChildProps, PopoverTriggerProps, PopoverTriggerState } from './PopoverTrigger.types';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\nimport { Escape } from '@fluentui/keyboard-keys';\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_unstable.\n *\n * @param props - props from this instance of PopoverTrigger\n */\nexport const usePopoverTrigger_unstable = (props: PopoverTriggerProps): PopoverTriggerState => {\n const { children } = props;\n const child = React.isValidElement(children)\n ? getTriggerChild<Partial<PopoverTriggerChildProps>>(children)\n : undefined;\n\n const open = usePopoverContext_unstable(context => context.open);\n const setOpen = usePopoverContext_unstable(context => context.setOpen);\n const toggleOpen = usePopoverContext_unstable(context => context.toggleOpen);\n const triggerRef = usePopoverContext_unstable(context => context.triggerRef);\n const openOnHover = usePopoverContext_unstable(context => context.openOnHover);\n const openOnContext = usePopoverContext_unstable(context => context.openOnContext);\n const { triggerAttributes } = useModalAttributes();\n\n const onContextMenu = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnContext) {\n e.preventDefault();\n setOpen(e, true);\n }\n };\n\n const onClick = (e: React.MouseEvent<HTMLElement>) => {\n if (!openOnContext) {\n toggleOpen(e);\n }\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (e.key === Escape && open) {\n setOpen(e, false);\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Menu\n e.stopPropagation();\n }\n };\n\n const onMouseEnter = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, true);\n }\n };\n\n const onMouseLeave = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, false);\n }\n };\n\n const triggerProps = {\n ...triggerAttributes,\n 'aria-expanded': `${open}`,\n ...child?.props,\n onMouseEnter: useEventCallback(mergeCallbacks(child?.props?.onMouseEnter, onMouseEnter)),\n onMouseLeave: useEventCallback(mergeCallbacks(child?.props?.onMouseLeave, onMouseLeave)),\n onContextMenu: useEventCallback(mergeCallbacks(child?.props?.onContextMenu, onContextMenu)),\n ref: useMergedRefs(triggerRef, child?.ref),\n } as const;\n\n const ariaButtonTriggerProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n {\n ...triggerProps,\n onClick: useEventCallback(mergeCallbacks(child?.props?.onClick, onClick)),\n onKeyDown: useEventCallback(mergeCallbacks(child?.props?.onKeyDown, onKeyDown)),\n },\n );\n\n return {\n children: applyTriggerPropsToChildren<PopoverTriggerChildProps>(\n props.children,\n useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n openOnContext ? triggerProps : ariaButtonTriggerProps,\n ),\n ),\n };\n};\n"],"sourceRoot":"../src/"}
|
package/lib/popoverContext.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { createContext, useContextSelector } from '@fluentui/react-context-selector';
|
2
|
-
|
3
|
-
|
1
|
+
import { createContext, useContextSelector } from '@fluentui/react-context-selector';
|
2
|
+
export const PopoverContext = /*#__PURE__*/createContext(undefined);
|
3
|
+
const popoverContextDefaultValue = {
|
4
4
|
open: false,
|
5
5
|
setOpen: () => null,
|
6
6
|
toggleOpen: () => null,
|
@@ -18,7 +18,7 @@ export const PopoverContext = /*#__PURE__*/createContext({
|
|
18
18
|
size: 'medium',
|
19
19
|
trapFocus: false,
|
20
20
|
inline: false
|
21
|
-
}
|
21
|
+
};
|
22
22
|
export const PopoverProvider = PopoverContext.Provider;
|
23
|
-
export const usePopoverContext_unstable = selector => useContextSelector(PopoverContext, selector);
|
23
|
+
export const usePopoverContext_unstable = selector => useContextSelector(PopoverContext, (ctx = popoverContextDefaultValue) => selector(ctx));
|
24
24
|
//# sourceMappingURL=popoverContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["popoverContext.ts"],"names":[],"mappings":"AAAA,SAAS,aAAT,EAAwB,kBAAxB,QAAkD,kCAAlD,
|
1
|
+
{"version":3,"sources":["popoverContext.ts"],"names":[],"mappings":"AAAA,SAAS,aAAT,EAAwB,kBAAxB,QAAkD,kCAAlD;AAIA,OAAO,MAAM,cAAc,gBAAiC,aAAa,CACvE,SADuE,CAAlE;AAGP,MAAM,0BAA0B,GAAwB;EACtD,IAAI,EAAE,KADgD;EAEtD,OAAO,EAAE,MAAM,IAFuC;EAGtD,UAAU,EAAE,MAAM,IAHoC;EAItD,UAAU,EAAE;IAAE,OAAO,EAAE;EAAX,CAJ0C;EAKtD,UAAU,EAAE;IAAE,OAAO,EAAE;EAAX,CAL0C;EAMtD,QAAQ,EAAE;IAAE,OAAO,EAAE;EAAX,CAN4C;EAOtD,aAAa,EAAE,KAPuC;EAQtD,WAAW,EAAE,KARyC;EAStD,IAAI,EAAE,QATgD;EAUtD,SAAS,EAAE,KAV2C;EAWtD,MAAM,EAAE;AAX8C,CAAxD;AAcA,OAAO,MAAM,eAAe,GAAG,cAAc,CAAC,QAAvC;AAwBP,OAAO,MAAM,0BAA0B,GAAO,QAAJ,IACxC,kBAAkB,CAAC,cAAD,EAAiB,CAAC,GAAG,GAAG,0BAAP,KAAsC,QAAQ,CAAC,GAAD,CAA/D,CADb","sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { ContextSelector, Context } from '@fluentui/react-context-selector';\nimport type { PopoverState } from './components/Popover/index';\n\nexport const PopoverContext: Context<PopoverContextValue> = createContext<PopoverContextValue | undefined>(\n undefined,\n) as Context<PopoverContextValue>;\nconst popoverContextDefaultValue: PopoverContextValue = {\n open: false,\n setOpen: () => null,\n toggleOpen: () => null,\n triggerRef: { current: null },\n contentRef: { current: null },\n arrowRef: { current: null },\n openOnContext: false,\n openOnHover: false,\n size: 'medium' as const,\n trapFocus: false,\n inline: false,\n};\n\nexport const PopoverProvider = PopoverContext.Provider;\n\n/**\n * Context shared between Popover and its children components\n */\nexport type PopoverContextValue = Pick<\n PopoverState,\n | 'open'\n | 'toggleOpen'\n | 'setOpen'\n | 'triggerRef'\n | 'contentRef'\n | 'openOnHover'\n | 'openOnContext'\n | 'mountNode'\n | 'withArrow'\n | 'arrowRef'\n | 'size'\n | 'appearance'\n | 'trapFocus'\n | 'legacyTrapFocus'\n | 'inline'\n>;\n\nexport const usePopoverContext_unstable = <T>(selector: ContextSelector<PopoverContextValue, T>): T =>\n useContextSelector(PopoverContext, (ctx = popoverContextDefaultValue) => selector(ctx));\n"],"sourceRoot":"../src/"}
|
@@ -121,8 +121,11 @@ const usePopover_unstable = props => {
|
|
121
121
|
findFirstFocusable
|
122
122
|
} = react_tabster_1.useFocusFinders();
|
123
123
|
React.useEffect(() => {
|
124
|
+
var _a;
|
125
|
+
|
124
126
|
if (open && positioningRefs.contentRef.current) {
|
125
|
-
const
|
127
|
+
const containerTabIndex = (_a = positioningRefs.contentRef.current.getAttribute('tabIndex')) !== null && _a !== void 0 ? _a : undefined;
|
128
|
+
const firstFocusable = isNaN(containerTabIndex) ? findFirstFocusable(positioningRefs.contentRef.current) : positioningRefs.contentRef.current;
|
126
129
|
firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
|
127
130
|
}
|
128
131
|
}, [findFirstFocusable, open, positioningRefs.contentRef]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/Popover/usePopover.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAMA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AACA,MAAA,mBAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AAMA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AAEA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AAEA;;;;;;;AAOG;;;AACI,MAAM,mBAAmB,GAAI,KAAD,IAAsC;;;EACvE,MAAM,CAAC,aAAD,EAAgB,gBAAhB,IAAoC,mBAAA,CAAA,yBAAA,EAA1C;EACA,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,QADa;IAEnB,aAFmB;IAGnB,gBAHmB;IAInB,GAAG;EAJgB,CAArB;EAOA,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAN,CAAe,OAAf,CAAuB,KAAK,CAAC,QAA7B,CAAjB;;EAEA,IAAI,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA7B,EAA2C;IACzC,IAAI,QAAQ,CAAC,MAAT,KAAoB,CAAxB,EAA2B;MACzB;MACA,OAAO,CAAC,IAAR,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A5C,CAA5B;EACD;;EAED,MAAM;IAAE,SAAS,EAAE,UAAb;IAAyB,YAAY,EAAE,UAAvC;IAAmD;EAAnD,IAAgE,mBAAA,CAAA,cAAA,CAAe,kBAAf,CAAtE;EAEA,OAAO;IACL,UADK;IAEL,UAFK;IAGL;EAHK,CAAP;AAKD","sourcesContent":["import * as React from 'react';\nimport {\n useControllableState,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePositioning,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePositioningMouseTarget,\n} from '@fluentui/react-positioning';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { OpenPopoverEvents, PopoverProps, PopoverState } from './Popover.types';\nimport { popoverSurfaceBorderRadius } from './constants';\n\n/**\n * Create the state required to render Popover.\n *\n * The returned state can be modified with hooks such as usePopoverStyles,\n * before being passed to renderPopover_unstable.\n *\n * @param props - props from this instance of Popover\n */\nexport const usePopover_unstable = (props: PopoverProps): PopoverState => {\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n const initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at most two children');\n }\n }\n\n let popoverTrigger: React.ReactElement | undefined = undefined;\n let popoverSurface: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n popoverTrigger = children[0];\n popoverSurface = children[1];\n } else if (children.length === 1) {\n popoverSurface = children[0];\n }\n\n const [open, setOpenState] = useOpenState(initialState);\n\n const setOpenTimeoutRef = React.useRef(0);\n\n const setOpen = useEventCallback((e: OpenPopoverEvents, shouldOpen: boolean) => {\n clearTimeout(setOpenTimeoutRef.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave') {\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeoutRef.current = setTimeout(() => {\n setOpenState(e, shouldOpen);\n }, props.mouseLeaveDelay ?? 500);\n } else {\n setOpenState(e, shouldOpen);\n }\n });\n\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeoutRef.current);\n };\n }, []);\n\n const toggleOpen = React.useCallback<PopoverState['toggleOpen']>(\n e => {\n setOpen(e, !open);\n },\n [setOpen, open],\n );\n\n const positioningRefs = usePopoverRefs(initialState);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open,\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open || !closeOnScroll,\n });\n\n const { findFirstFocusable } = useFocusFinders();\n\n React.useEffect(() => {\n if (open && positioningRefs.contentRef.current) {\n const firstFocusable = findFirstFocusable(positioningRefs.contentRef.current);\n firstFocusable?.focus();\n }\n }, [findFirstFocusable, open, positioningRefs.contentRef]);\n\n return {\n ...initialState,\n ...positioningRefs,\n popoverTrigger,\n popoverSurface,\n open,\n setOpen,\n toggleOpen,\n setContextTarget,\n contextTarget,\n inline: props.inline ?? false,\n };\n};\n\n/**\n * Creates and manages the Popover open state\n */\nfunction useOpenState(\n state: Pick<PopoverState, 'setContextTarget' | 'onOpenChange'> & Pick<PopoverProps, 'open' | 'defaultOpen'>,\n) {\n const onOpenChange: PopoverState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n\n const setOpen = React.useCallback(\n (e: OpenPopoverEvents, shouldOpen: boolean) => {\n if (shouldOpen && e.type === 'contextmenu') {\n setContextTarget(e as React.MouseEvent);\n }\n\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n\n setOpenState(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'> &\n Pick<PopoverProps, 'positioning' | 'openOnContext' | 'withArrow'>,\n) {\n const positioningOptions = {\n position: 'above' as const,\n align: 'center' as const,\n arrowPadding: 2 * popoverSurfaceBorderRadius,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (positioningOptions.coverTarget) {\n state.withArrow = false;\n }\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeights[state.size]);\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePositioning(positioningOptions);\n\n return {\n triggerRef,\n contentRef,\n arrowRef,\n } as const;\n}\n"],"sourceRoot":"../src/"}
|
1
|
+
{"version":3,"sources":["components/Popover/usePopover.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAA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,OAAO;IACL,UADK;IAEL,UAFK;IAGL;EAHK,CAAP;AAKD","sourcesContent":["import * as React from 'react';\nimport {\n useControllableState,\n useEventCallback,\n useOnClickOutside,\n useOnScrollOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport {\n usePositioning,\n resolvePositioningShorthand,\n mergeArrowOffset,\n usePositioningMouseTarget,\n} from '@fluentui/react-positioning';\nimport { elementContains } from '@fluentui/react-portal';\nimport { useFocusFinders } from '@fluentui/react-tabster';\nimport { arrowHeights } from '../PopoverSurface/index';\nimport type { OpenPopoverEvents, PopoverProps, PopoverState } from './Popover.types';\nimport { popoverSurfaceBorderRadius } from './constants';\n\n/**\n * Create the state required to render Popover.\n *\n * The returned state can be modified with hooks such as usePopoverStyles,\n * before being passed to renderPopover_unstable.\n *\n * @param props - props from this instance of Popover\n */\nexport const usePopover_unstable = (props: PopoverProps): PopoverState => {\n const [contextTarget, setContextTarget] = usePositioningMouseTarget();\n const initialState = {\n size: 'medium',\n contextTarget,\n setContextTarget,\n ...props,\n } as const;\n\n const children = React.Children.toArray(props.children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (children.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at least one child');\n }\n\n if (children.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('Popover must contain at most two children');\n }\n }\n\n let popoverTrigger: React.ReactElement | undefined = undefined;\n let popoverSurface: React.ReactElement | undefined = undefined;\n if (children.length === 2) {\n popoverTrigger = children[0];\n popoverSurface = children[1];\n } else if (children.length === 1) {\n popoverSurface = children[0];\n }\n\n const [open, setOpenState] = useOpenState(initialState);\n\n const setOpenTimeoutRef = React.useRef(0);\n\n const setOpen = useEventCallback((e: OpenPopoverEvents, shouldOpen: boolean) => {\n clearTimeout(setOpenTimeoutRef.current);\n if (!(e instanceof Event) && e.persist) {\n // < React 17 still uses pooled synthetic events\n e.persist();\n }\n\n if (e.type === 'mouseleave') {\n // FIXME leaking Node timeout type\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n setOpenTimeoutRef.current = setTimeout(() => {\n setOpenState(e, shouldOpen);\n }, props.mouseLeaveDelay ?? 500);\n } else {\n setOpenState(e, shouldOpen);\n }\n });\n\n // Clear timeout on unmount\n // Setting state after a component unmounts can cause memory leaks\n React.useEffect(() => {\n return () => {\n clearTimeout(setOpenTimeoutRef.current);\n };\n }, []);\n\n const toggleOpen = React.useCallback<PopoverState['toggleOpen']>(\n e => {\n setOpen(e, !open);\n },\n [setOpen, open],\n );\n\n const positioningRefs = usePopoverRefs(initialState);\n\n const { targetDocument } = useFluent();\n useOnClickOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open,\n });\n\n // only close on scroll for context, or when closeOnScroll is specified\n const closeOnScroll = initialState.openOnContext || initialState.closeOnScroll;\n useOnScrollOutside({\n contains: elementContains,\n element: targetDocument,\n callback: ev => setOpen(ev, false),\n refs: [positioningRefs.triggerRef, positioningRefs.contentRef],\n disabled: !open || !closeOnScroll,\n });\n\n const { findFirstFocusable } = useFocusFinders();\n\n React.useEffect(() => {\n if (open && positioningRefs.contentRef.current) {\n const containerTabIndex = positioningRefs.contentRef.current.getAttribute('tabIndex') ?? undefined;\n const firstFocusable = isNaN(containerTabIndex)\n ? findFirstFocusable(positioningRefs.contentRef.current)\n : positioningRefs.contentRef.current;\n firstFocusable?.focus();\n }\n }, [findFirstFocusable, open, positioningRefs.contentRef]);\n\n return {\n ...initialState,\n ...positioningRefs,\n popoverTrigger,\n popoverSurface,\n open,\n setOpen,\n toggleOpen,\n setContextTarget,\n contextTarget,\n inline: props.inline ?? false,\n };\n};\n\n/**\n * Creates and manages the Popover open state\n */\nfunction useOpenState(\n state: Pick<PopoverState, 'setContextTarget' | 'onOpenChange'> & Pick<PopoverProps, 'open' | 'defaultOpen'>,\n) {\n const onOpenChange: PopoverState['onOpenChange'] = useEventCallback((e, data) => state.onOpenChange?.(e, data));\n\n const [open, setOpenState] = useControllableState({\n state: state.open,\n defaultState: state.defaultOpen,\n initialState: false,\n });\n state.open = open !== undefined ? open : state.open;\n const setContextTarget = state.setContextTarget;\n\n const setOpen = React.useCallback(\n (e: OpenPopoverEvents, shouldOpen: boolean) => {\n if (shouldOpen && e.type === 'contextmenu') {\n setContextTarget(e as React.MouseEvent);\n }\n\n if (!shouldOpen) {\n setContextTarget(undefined);\n }\n\n setOpenState(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'> &\n Pick<PopoverProps, 'positioning' | 'openOnContext' | 'withArrow'>,\n) {\n const positioningOptions = {\n position: 'above' as const,\n align: 'center' as const,\n arrowPadding: 2 * popoverSurfaceBorderRadius,\n target: state.openOnContext ? state.contextTarget : undefined,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n // no reason to render arrow when covering the target\n if (positioningOptions.coverTarget) {\n state.withArrow = false;\n }\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeights[state.size]);\n }\n\n const { targetRef: triggerRef, containerRef: contentRef, arrowRef } = usePositioning(positioningOptions);\n\n return {\n triggerRef,\n contentRef,\n arrowRef,\n } as const;\n}\n"],"sourceRoot":"../src/"}
|
@@ -45,12 +45,12 @@ const useStyles = /*#__PURE__*/react_1.__styles({
|
|
45
45
|
"zhjwy3": ["fjscplz", "f1gn591s"]
|
46
46
|
},
|
47
47
|
"inverted": {
|
48
|
-
"De3pzq": "
|
49
|
-
"sj55zd": "
|
48
|
+
"De3pzq": "fg3r6xk",
|
49
|
+
"sj55zd": "fonrgv7"
|
50
50
|
},
|
51
51
|
"brand": {
|
52
52
|
"De3pzq": "ffp7eso",
|
53
|
-
"sj55zd": "
|
53
|
+
"sj55zd": "f1phragk"
|
54
54
|
},
|
55
55
|
"smallPadding": {
|
56
56
|
"z8tnut": "f1kcqot9",
|
@@ -108,7 +108,7 @@ const useStyles = /*#__PURE__*/react_1.__styles({
|
|
108
108
|
"Bwwlvwl": "fm1ycve"
|
109
109
|
}
|
110
110
|
}, {
|
111
|
-
"d": [".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f1hg901r{box-shadow:var(--shadow16);}", ".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".f5ogflp{border-top-width:1px;}", ".f1hqa2wf{border-right-width:1px;}", ".finvdd3{border-left-width:1px;}", ".f1f09k3d{border-bottom-width:1px;}", ".fzkkow9{border-top-style:solid;}", ".fcdblym{border-right-style:solid;}", ".fjik90z{border-left-style:solid;}", ".fg706s2{border-bottom-style:solid;}", ".fghlq4f{border-top-color:var(--colorTransparentStroke);}", ".f1gn591s{border-right-color:var(--colorTransparentStroke);}", ".fjscplz{border-left-color:var(--colorTransparentStroke);}", ".fb073pr{border-bottom-color:var(--colorTransparentStroke);}", ".
|
111
|
+
"d": [".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f1hg901r{box-shadow:var(--shadow16);}", ".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".f5ogflp{border-top-width:1px;}", ".f1hqa2wf{border-right-width:1px;}", ".finvdd3{border-left-width:1px;}", ".f1f09k3d{border-bottom-width:1px;}", ".fzkkow9{border-top-style:solid;}", ".fcdblym{border-right-style:solid;}", ".fjik90z{border-left-style:solid;}", ".fg706s2{border-bottom-style:solid;}", ".fghlq4f{border-top-color:var(--colorTransparentStroke);}", ".f1gn591s{border-right-color:var(--colorTransparentStroke);}", ".fjscplz{border-left-color:var(--colorTransparentStroke);}", ".fb073pr{border-bottom-color:var(--colorTransparentStroke);}", ".fg3r6xk{background-color:var(--colorNeutralBackgroundStatic);}", ".fonrgv7{color:var(--colorNeutralForegroundStaticInverted);}", ".ffp7eso{background-color:var(--colorBrandBackground);}", ".f1phragk{color:var(--colorNeutralForegroundOnBrand);}", ".f1kcqot9{padding-top:12px;}", ".f11qrl6u{padding-right:12px;}", ".fjlbh76{padding-left:12px;}", ".fpe6lb7{padding-bottom:12px;}", ".fqag9an{padding-top:16px;}", ".f1gbmcue{padding-right:16px;}", ".f1rh9g5y{padding-left:16px;}", ".fp67ikv{padding-bottom:16px;}", ".fc7z3ec{padding-top:20px;}", ".fat0sn4{padding-right:20px;}", ".fekwl8i{padding-left:20px;}", ".fe2my4m{padding-bottom:20px;}", ".f1ekdpwm{width:8.484px;}", ".f83vc9z{height:8.484px;}", ".f1kmc0fn{width:11.312px;}", ".fb6lvc5{height:11.312px;}", ".f1euv43f{position:absolute;}", ".f1u2r49w{background-color:inherit;}", ".fd7fpy0{visibility:hidden;}", ".f1bsuimh{z-index:-1;}", ".f1wl9k8s::before{content:\"\";}", ".f1wkw4r9::before{visibility:visible;}", ".f1j7ml58::before{position:absolute;}", ".fyl8oag::before{box-sizing:border-box;}", ".frdoeuz::before{width:inherit;}", ".fb81m9q::before{height:inherit;}", ".f1ljr5q2::before{background-color:inherit;}", ".fyfemzf::before{border-right-width:1px;}", ".focyt6c::before{border-right-style:solid;}", ".fnhxbxj::before{border-right-color:var(--colorTransparentStroke);}", ".fdw6hkg::before{border-bottom-width:1px;}", ".f11yjt3y::before{border-bottom-style:solid;}", ".f1172wan::before{border-bottom-color:var(--colorTransparentStroke);}", ".f9e5op9::before{border-bottom-right-radius:var(--borderRadiusSmall);}", ".f112wvtl::before{border-bottom-left-radius:var(--borderRadiusSmall);}", ".ftj5xct::before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);}", ".fyavhwi::before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);}", "[data-popper-placement^=\"top\"] .f1773hnp{bottom:-1px;}", "[data-popper-placement^=\"top\"] .f1n8855c{--angle:0;}", "[data-popper-placement^=\"right\"] .f1v7783n{left:-1px;}", "[data-popper-placement^=\"right\"] .fsw6im5{--angle:90deg;}", "[data-popper-placement^=\"bottom\"] .fh2hsk5{top:-1px;}", "[data-popper-placement^=\"bottom\"] .f159pzir{--angle:180deg;}", "[data-popper-placement^=\"left\"] .f11yvu4{right:-1px;}", "[data-popper-placement^=\"left\"] .fm1ycve{--angle:270deg;}"]
|
112
112
|
});
|
113
113
|
/**
|
114
114
|
* Apply styling to the PopoverSurface slots based on the state
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverSurface/usePopoverSurfaceStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,mBAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAKa,OAAA,CAAA,wBAAA,GAAgE;EAC3E,IAAI,EAAE;AADqE,CAAhE;AAIA,OAAA,CAAA,YAAA,GAA4C;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","sourcesContent":["import { shorthands, makeStyles, mergeClasses } from '@griffel/react';\nimport { createArrowHeightStyles, createArrowStyles } from '@fluentui/react-positioning';\nimport { tokens } from '@fluentui/react-theme';\nimport type { PopoverSize } from '../Popover/Popover.types';\nimport type { PopoverSurfaceSlots, PopoverSurfaceState } from './PopoverSurface.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const popoverSurfaceClassNames: SlotClassNames<PopoverSurfaceSlots> = {\n root: 'fui-PopoverSurface',\n};\n\nexport const arrowHeights: Record<PopoverSize, number> = {\n small: 6,\n medium: 8,\n large: 8,\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n backgroundColor: tokens.colorNeutralBackground1,\n boxShadow: tokens.shadow16,\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n ...shorthands.border('1px', 'solid', tokens.colorTransparentStroke),\n },\n\n inverted: {\n backgroundColor: tokens.colorNeutralBackgroundStatic,\n color: tokens.colorNeutralForegroundStaticInverted,\n },\n\n brand: {\n backgroundColor: tokens.colorBrandBackground,\n color: tokens.colorNeutralForegroundOnBrand,\n },\n\n smallPadding: {\n ...shorthands.padding('12px'),\n },\n\n mediumPadding: {\n ...shorthands.padding('16px'),\n },\n\n largePadding: {\n ...shorthands.padding('20px'),\n },\n\n smallArrow: createArrowHeightStyles(arrowHeights.small),\n mediumLargeArrow: createArrowHeightStyles(arrowHeights.medium),\n arrow: createArrowStyles({ arrowHeight: undefined }),\n});\n\n/**\n * Apply styling to the PopoverSurface slots based on the state\n */\nexport const usePopoverSurfaceStyles_unstable = (state: PopoverSurfaceState): PopoverSurfaceState => {\n const styles = useStyles();\n state.root.className = mergeClasses(\n popoverSurfaceClassNames.root,\n styles.root,\n state.size === 'small' && styles.smallPadding,\n state.size === 'medium' && styles.mediumPadding,\n state.size === 'large' && styles.largePadding,\n state.appearance === 'inverted' && styles.inverted,\n state.appearance === 'brand' && styles.brand,\n state.root.className,\n );\n\n state.arrowClassName = mergeClasses(\n styles.arrow,\n state.size === 'small' ? styles.smallArrow : styles.mediumLargeArrow,\n );\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
@@ -12,6 +12,10 @@ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
12
12
|
const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
|
13
13
|
|
14
14
|
const popoverContext_1 = /*#__PURE__*/require("../../popoverContext");
|
15
|
+
|
16
|
+
const react_aria_1 = /*#__PURE__*/require("@fluentui/react-aria");
|
17
|
+
|
18
|
+
const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
|
15
19
|
/**
|
16
20
|
* Create the state required to render PopoverTrigger.
|
17
21
|
*
|
@@ -53,23 +57,19 @@ const usePopoverTrigger_unstable = props => {
|
|
53
57
|
};
|
54
58
|
|
55
59
|
const onKeyDown = e => {
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
e.preventDefault();
|
60
|
-
(_a = e.target) === null || _a === void 0 ? void 0 : _a.click();
|
61
|
-
}
|
60
|
+
if (e.key === keyboard_keys_1.Escape && open) {
|
61
|
+
setOpen(e, false); // stop propagation to avoid conflicting with other elements that listen for `Escape`
|
62
|
+
// e,g: Dialog, Menu
|
62
63
|
|
63
|
-
|
64
|
-
setOpen(e, false);
|
64
|
+
e.stopPropagation();
|
65
65
|
}
|
66
66
|
};
|
67
67
|
|
68
|
-
const onMouseEnter =
|
68
|
+
const onMouseEnter = e => {
|
69
69
|
if (openOnHover) {
|
70
70
|
setOpen(e, true);
|
71
71
|
}
|
72
|
-
}
|
72
|
+
};
|
73
73
|
|
74
74
|
const onMouseLeave = e => {
|
75
75
|
if (openOnHover) {
|
@@ -77,17 +77,20 @@ const usePopoverTrigger_unstable = props => {
|
|
77
77
|
}
|
78
78
|
};
|
79
79
|
|
80
|
+
const triggerProps = { ...triggerAttributes,
|
81
|
+
'aria-expanded': `${open}`,
|
82
|
+
...(child === null || child === void 0 ? void 0 : child.props),
|
83
|
+
onMouseEnter: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onMouseEnter, onMouseEnter)),
|
84
|
+
onMouseLeave: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.onMouseLeave, onMouseLeave)),
|
85
|
+
onContextMenu: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.onContextMenu, onContextMenu)),
|
86
|
+
ref: react_utilities_1.useMergedRefs(triggerRef, child === null || child === void 0 ? void 0 : child.ref)
|
87
|
+
};
|
88
|
+
const ariaButtonTriggerProps = react_aria_1.useARIAButtonProps((child === null || child === void 0 ? void 0 : child.type) === 'button' || (child === null || child === void 0 ? void 0 : child.type) === 'a' ? child.type : 'div', { ...triggerProps,
|
89
|
+
onClick: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks((_d = child === null || child === void 0 ? void 0 : child.props) === null || _d === void 0 ? void 0 : _d.onClick, onClick)),
|
90
|
+
onKeyDown: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks((_e = child === null || child === void 0 ? void 0 : child.props) === null || _e === void 0 ? void 0 : _e.onKeyDown, onKeyDown))
|
91
|
+
});
|
80
92
|
return {
|
81
|
-
children: react_utilities_1.applyTriggerPropsToChildren(props.children,
|
82
|
-
'aria-expanded': `${open}`,
|
83
|
-
...(child === null || child === void 0 ? void 0 : child.props),
|
84
|
-
onClick: react_utilities_1.useMergedEventCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onClick, onClick),
|
85
|
-
onMouseEnter: react_utilities_1.useMergedEventCallbacks((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.onMouseEnter, onMouseEnter),
|
86
|
-
onKeyDown: react_utilities_1.useMergedEventCallbacks((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.onKeyDown, onKeyDown),
|
87
|
-
onMouseLeave: react_utilities_1.useMergedEventCallbacks((_d = child === null || child === void 0 ? void 0 : child.props) === null || _d === void 0 ? void 0 : _d.onMouseLeave, onMouseLeave),
|
88
|
-
onContextMenu: react_utilities_1.useMergedEventCallbacks((_e = child === null || child === void 0 ? void 0 : child.props) === null || _e === void 0 ? void 0 : _e.onContextMenu, onContextMenu),
|
89
|
-
ref: react_utilities_1.useMergedRefs(triggerRef, child === null || child === void 0 ? void 0 : child.ref)
|
90
|
-
})
|
93
|
+
children: react_utilities_1.applyTriggerPropsToChildren(props.children, react_aria_1.useARIAButtonProps((child === null || child === void 0 ? void 0 : child.type) === 'button' || (child === null || child === void 0 ? void 0 : child.type) === 'a' ? child.type : 'div', openOnContext ? triggerProps : ariaButtonTriggerProps))
|
91
94
|
};
|
92
95
|
};
|
93
96
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;
|
1
|
+
{"version":3,"sources":["components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAOA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;;AAEA,MAAA,YAAA,gBAAA,OAAA,CAAA,sBAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,yBAAA,CAAA;AAEA;;;;;;;AAOG;;;AACI,MAAM,0BAA0B,GAAI,KAAD,I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AA,2BAAA,CACR,KAAK,CAAC,QADE,EAER,YAAA,CAAA,kBAAA,CACE,CAAA,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,IAAP,MAAgB,QAAhB,IAA4B,CAAA,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,IAAP,MAAgB,GAA5C,GAAkD,KAAK,CAAC,IAAxD,GAA+D,KADjE,EAEE,aAAa,GAAG,YAAH,GAAkB,sBAFjC,CAFQ;EADL,CAAP;AASD,CA5EM;;AAAM,OAAA,CAAA,0BAAA,GAA0B,0BAA1B","sourcesContent":["import * as React from 'react';\nimport {\n applyTriggerPropsToChildren,\n getTriggerChild,\n mergeCallbacks,\n useMergedRefs,\n useEventCallback,\n} from '@fluentui/react-utilities';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext_unstable } from '../../popoverContext';\nimport type { PopoverTriggerChildProps, PopoverTriggerProps, PopoverTriggerState } from './PopoverTrigger.types';\nimport { useARIAButtonProps } from '@fluentui/react-aria';\nimport { Escape } from '@fluentui/keyboard-keys';\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_unstable.\n *\n * @param props - props from this instance of PopoverTrigger\n */\nexport const usePopoverTrigger_unstable = (props: PopoverTriggerProps): PopoverTriggerState => {\n const { children } = props;\n const child = React.isValidElement(children)\n ? getTriggerChild<Partial<PopoverTriggerChildProps>>(children)\n : undefined;\n\n const open = usePopoverContext_unstable(context => context.open);\n const setOpen = usePopoverContext_unstable(context => context.setOpen);\n const toggleOpen = usePopoverContext_unstable(context => context.toggleOpen);\n const triggerRef = usePopoverContext_unstable(context => context.triggerRef);\n const openOnHover = usePopoverContext_unstable(context => context.openOnHover);\n const openOnContext = usePopoverContext_unstable(context => context.openOnContext);\n const { triggerAttributes } = useModalAttributes();\n\n const onContextMenu = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnContext) {\n e.preventDefault();\n setOpen(e, true);\n }\n };\n\n const onClick = (e: React.MouseEvent<HTMLElement>) => {\n if (!openOnContext) {\n toggleOpen(e);\n }\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (e.key === Escape && open) {\n setOpen(e, false);\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Menu\n e.stopPropagation();\n }\n };\n\n const onMouseEnter = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, true);\n }\n };\n\n const onMouseLeave = (e: React.MouseEvent<HTMLElement>) => {\n if (openOnHover) {\n setOpen(e, false);\n }\n };\n\n const triggerProps = {\n ...triggerAttributes,\n 'aria-expanded': `${open}`,\n ...child?.props,\n onMouseEnter: useEventCallback(mergeCallbacks(child?.props?.onMouseEnter, onMouseEnter)),\n onMouseLeave: useEventCallback(mergeCallbacks(child?.props?.onMouseLeave, onMouseLeave)),\n onContextMenu: useEventCallback(mergeCallbacks(child?.props?.onContextMenu, onContextMenu)),\n ref: useMergedRefs(triggerRef, child?.ref),\n } as const;\n\n const ariaButtonTriggerProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n {\n ...triggerProps,\n onClick: useEventCallback(mergeCallbacks(child?.props?.onClick, onClick)),\n onKeyDown: useEventCallback(mergeCallbacks(child?.props?.onKeyDown, onKeyDown)),\n },\n );\n\n return {\n children: applyTriggerPropsToChildren<PopoverTriggerChildProps>(\n props.children,\n useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n openOnContext ? triggerProps : ariaButtonTriggerProps,\n ),\n ),\n };\n};\n"],"sourceRoot":"../src/"}
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.usePopoverContext_unstable = exports.PopoverProvider = exports.PopoverContext = void 0;
|
7
7
|
|
8
|
-
const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
|
8
|
+
const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
exports.PopoverContext = /*#__PURE__*/react_context_selector_1.createContext(undefined);
|
11
|
+
const popoverContextDefaultValue = {
|
12
12
|
open: false,
|
13
13
|
setOpen: () => null,
|
14
14
|
toggleOpen: () => null,
|
@@ -26,10 +26,10 @@ exports.PopoverContext = /*#__PURE__*/react_context_selector_1.createContext({
|
|
26
26
|
size: 'medium',
|
27
27
|
trapFocus: false,
|
28
28
|
inline: false
|
29
|
-
}
|
29
|
+
};
|
30
30
|
exports.PopoverProvider = exports.PopoverContext.Provider;
|
31
31
|
|
32
|
-
const usePopoverContext_unstable = selector => react_context_selector_1.useContextSelector(exports.PopoverContext, selector);
|
32
|
+
const usePopoverContext_unstable = selector => react_context_selector_1.useContextSelector(exports.PopoverContext, (ctx = popoverContextDefaultValue) => selector(ctx));
|
33
33
|
|
34
34
|
exports.usePopoverContext_unstable = usePopoverContext_unstable;
|
35
35
|
//# sourceMappingURL=popoverContext.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["popoverContext.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA,
|
1
|
+
{"version":3,"sources":["popoverContext.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;AAIa,OAAA,CAAA,cAAA,gBAA+C,wBAAA,CAAA,aAAA,CAC1D,SAD0D,CAA/C;AAGb,MAAM,0BAA0B,GAAwB;EACtD,IAAI,EAAE,KADgD;EAEtD,OAAO,EAAE,MAAM,IAFuC;EAGtD,UAAU,EAAE,MAAM,IAHoC;EAItD,UAAU,EAAE;IAAE,OAAO,EAAE;EAAX,CAJ0C;EAKtD,UAAU,EAAE;IAAE,OAAO,EAAE;EAAX,CAL0C;EAMtD,QAAQ,EAAE;IAAE,OAAO,EAAE;EAAX,CAN4C;EAOtD,aAAa,EAAE,KAPuC;EAQtD,WAAW,EAAE,KARyC;EAStD,IAAI,EAAE,QATgD;EAUtD,SAAS,EAAE,KAV2C;EAWtD,MAAM,EAAE;AAX8C,CAAxD;AAca,OAAA,CAAA,eAAA,GAAkB,OAAA,CAAA,cAAA,CAAe,QAAjC;;AAwBN,MAAM,0BAA0B,GAAO,QAAJ,IACxC,wBAAA,CAAA,kBAAA,CAAmB,OAAA,CAAA,cAAnB,EAAmC,CAAC,GAAG,GAAG,0BAAP,KAAsC,QAAQ,CAAC,GAAD,CAAjF,CADK;;AAAM,OAAA,CAAA,0BAAA,GAA0B,0BAA1B","sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { ContextSelector, Context } from '@fluentui/react-context-selector';\nimport type { PopoverState } from './components/Popover/index';\n\nexport const PopoverContext: Context<PopoverContextValue> = createContext<PopoverContextValue | undefined>(\n undefined,\n) as Context<PopoverContextValue>;\nconst popoverContextDefaultValue: PopoverContextValue = {\n open: false,\n setOpen: () => null,\n toggleOpen: () => null,\n triggerRef: { current: null },\n contentRef: { current: null },\n arrowRef: { current: null },\n openOnContext: false,\n openOnHover: false,\n size: 'medium' as const,\n trapFocus: false,\n inline: false,\n};\n\nexport const PopoverProvider = PopoverContext.Provider;\n\n/**\n * Context shared between Popover and its children components\n */\nexport type PopoverContextValue = Pick<\n PopoverState,\n | 'open'\n | 'toggleOpen'\n | 'setOpen'\n | 'triggerRef'\n | 'contentRef'\n | 'openOnHover'\n | 'openOnContext'\n | 'mountNode'\n | 'withArrow'\n | 'arrowRef'\n | 'size'\n | 'appearance'\n | 'trapFocus'\n | 'legacyTrapFocus'\n | 'inline'\n>;\n\nexport const usePopoverContext_unstable = <T>(selector: ContextSelector<PopoverContextValue, T>): T =>\n useContextSelector(PopoverContext, (ctx = popoverContextDefaultValue) => selector(ctx));\n"],"sourceRoot":"../src/"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-popover",
|
3
|
-
"version": "9.
|
3
|
+
"version": "9.1.1",
|
4
4
|
"description": "Popover component for Fluent UI",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -19,29 +19,31 @@
|
|
19
19
|
"just": "just-scripts",
|
20
20
|
"lint": "just-scripts lint",
|
21
21
|
"start": "yarn storybook",
|
22
|
-
"e2e": "
|
23
|
-
"e2e:local": "
|
24
|
-
"storybook": "
|
22
|
+
"e2e": "cypress run --component",
|
23
|
+
"e2e:local": "cypress open --component",
|
24
|
+
"storybook": "start-storybook",
|
25
25
|
"test": "jest --passWithNoTests",
|
26
26
|
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
|
27
|
-
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/packages/react-components/react-popover/src && yarn docs",
|
27
|
+
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/types/packages/react-components/react-popover/src && yarn docs",
|
28
28
|
"type-check": "tsc -b tsconfig.json"
|
29
29
|
},
|
30
30
|
"devDependencies": {
|
31
31
|
"@fluentui/eslint-plugin": "*",
|
32
32
|
"@fluentui/react-conformance": "*",
|
33
|
-
"@fluentui/react-conformance-griffel": "9.0.0-beta.
|
33
|
+
"@fluentui/react-conformance-griffel": "9.0.0-beta.14",
|
34
34
|
"@fluentui/scripts": "^1.0.0"
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
|
-
"@fluentui/
|
38
|
-
"@fluentui/react-
|
39
|
-
"@fluentui/react-
|
40
|
-
"@fluentui/react-
|
41
|
-
"@fluentui/react-
|
42
|
-
"@fluentui/react-
|
43
|
-
"@fluentui/react-
|
44
|
-
"@
|
37
|
+
"@fluentui/keyboard-keys": "^9.0.0",
|
38
|
+
"@fluentui/react-aria": "^9.2.0",
|
39
|
+
"@fluentui/react-context-selector": "^9.0.3",
|
40
|
+
"@fluentui/react-portal": "^9.0.5",
|
41
|
+
"@fluentui/react-positioning": "^9.2.0",
|
42
|
+
"@fluentui/react-shared-contexts": "^9.0.1",
|
43
|
+
"@fluentui/react-tabster": "^9.1.1",
|
44
|
+
"@fluentui/react-theme": "^9.1.0",
|
45
|
+
"@fluentui/react-utilities": "^9.1.0",
|
46
|
+
"@griffel/react": "^1.3.0",
|
45
47
|
"tslib": "^2.1.0"
|
46
48
|
},
|
47
49
|
"peerDependencies": {
|
package/dist/tsdoc-metadata.json
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
3
|
-
{
|
4
|
-
"tsdocVersion": "0.12",
|
5
|
-
"toolPackages": [
|
6
|
-
{
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
8
|
-
"packageVersion": "7.18.1"
|
9
|
-
}
|
10
|
-
]
|
11
|
-
}
|