@fluentui/react-popover 0.0.0-nightly-20221012-0423.1 → 0.0.0-nightly-20221014-0424.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +101 -23
- package/CHANGELOG.md +40 -14
- package/dist/index.d.ts +7 -1
- package/lib/components/PopoverTrigger/PopoverTrigger.types.js.map +1 -1
- package/lib/components/PopoverTrigger/usePopoverTrigger.js +7 -5
- package/lib/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js +7 -5
- package/lib-commonjs/components/PopoverTrigger/usePopoverTrigger.js.map +1 -1
- package/package.json +15 -15
package/CHANGELOG.json
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
"name": "@fluentui/react-popover",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
6
|
-
"tag": "@fluentui/react-popover_v0.0.0-nightly-
|
7
|
-
"version": "0.0.0-nightly-
|
5
|
+
"date": "Fri, 14 Oct 2022 04:30:08 GMT",
|
6
|
+
"tag": "@fluentui/react-popover_v0.0.0-nightly-20221014-0424.1",
|
7
|
+
"version": "0.0.0-nightly-20221014-0424.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
@@ -16,62 +16,140 @@
|
|
16
16
|
{
|
17
17
|
"author": "beachball",
|
18
18
|
"package": "@fluentui/react-popover",
|
19
|
-
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-
|
20
|
-
"commit": "
|
19
|
+
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20221014-0424.1",
|
20
|
+
"commit": "ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5"
|
21
21
|
},
|
22
22
|
{
|
23
23
|
"author": "beachball",
|
24
24
|
"package": "@fluentui/react-popover",
|
25
|
-
"comment": "Bump @fluentui/react-aria to v0.0.0-nightly-
|
26
|
-
"commit": "
|
25
|
+
"comment": "Bump @fluentui/react-aria to v0.0.0-nightly-20221014-0424.1",
|
26
|
+
"commit": "ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5"
|
27
27
|
},
|
28
28
|
{
|
29
29
|
"author": "beachball",
|
30
30
|
"package": "@fluentui/react-popover",
|
31
|
-
"comment": "Bump @fluentui/react-context-selector to v0.0.0-nightly-
|
32
|
-
"commit": "
|
31
|
+
"comment": "Bump @fluentui/react-context-selector to v0.0.0-nightly-20221014-0424.1",
|
32
|
+
"commit": "ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5"
|
33
33
|
},
|
34
34
|
{
|
35
35
|
"author": "beachball",
|
36
36
|
"package": "@fluentui/react-popover",
|
37
|
-
"comment": "Bump @fluentui/react-portal to v0.0.0-nightly-
|
38
|
-
"commit": "
|
37
|
+
"comment": "Bump @fluentui/react-portal to v0.0.0-nightly-20221014-0424.1",
|
38
|
+
"commit": "ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5"
|
39
39
|
},
|
40
40
|
{
|
41
41
|
"author": "beachball",
|
42
42
|
"package": "@fluentui/react-popover",
|
43
|
-
"comment": "Bump @fluentui/react-positioning to v0.0.0-nightly-
|
44
|
-
"commit": "
|
43
|
+
"comment": "Bump @fluentui/react-positioning to v0.0.0-nightly-20221014-0424.1",
|
44
|
+
"commit": "ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5"
|
45
45
|
},
|
46
46
|
{
|
47
47
|
"author": "beachball",
|
48
48
|
"package": "@fluentui/react-popover",
|
49
|
-
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
50
|
-
"commit": "
|
49
|
+
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20221014-0424.1",
|
50
|
+
"commit": "ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5"
|
51
51
|
},
|
52
52
|
{
|
53
53
|
"author": "beachball",
|
54
54
|
"package": "@fluentui/react-popover",
|
55
|
-
"comment": "Bump @fluentui/react-tabster to v0.0.0-nightly-
|
56
|
-
"commit": "
|
55
|
+
"comment": "Bump @fluentui/react-tabster to v0.0.0-nightly-20221014-0424.1",
|
56
|
+
"commit": "ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5"
|
57
57
|
},
|
58
58
|
{
|
59
59
|
"author": "beachball",
|
60
60
|
"package": "@fluentui/react-popover",
|
61
|
-
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-
|
62
|
-
"commit": "
|
61
|
+
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20221014-0424.1",
|
62
|
+
"commit": "ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5"
|
63
63
|
},
|
64
64
|
{
|
65
65
|
"author": "beachball",
|
66
66
|
"package": "@fluentui/react-popover",
|
67
|
-
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-
|
68
|
-
"commit": "
|
67
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20221014-0424.1",
|
68
|
+
"commit": "ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5"
|
69
69
|
},
|
70
70
|
{
|
71
71
|
"author": "beachball",
|
72
72
|
"package": "@fluentui/react-popover",
|
73
|
-
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-
|
74
|
-
"commit": "
|
73
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20221014-0424.1",
|
74
|
+
"commit": "ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5"
|
75
|
+
}
|
76
|
+
]
|
77
|
+
}
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"date": "Thu, 13 Oct 2022 12:56:30 GMT",
|
81
|
+
"tag": "@fluentui/react-popover_v9.2.0",
|
82
|
+
"version": "9.2.0",
|
83
|
+
"comments": {
|
84
|
+
"minor": [
|
85
|
+
{
|
86
|
+
"author": "bernardo.sunderhus@gmail.com",
|
87
|
+
"package": "@fluentui/react-popover",
|
88
|
+
"commit": "e563f3daaea9b7cc62f50bc15edd44edf5045107",
|
89
|
+
"comment": "feat: adds disableButtonEnhancement property on PopoverTrigger"
|
90
|
+
}
|
91
|
+
]
|
92
|
+
}
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"date": "Thu, 13 Oct 2022 11:02:56 GMT",
|
96
|
+
"tag": "@fluentui/react-popover_v9.1.3",
|
97
|
+
"version": "9.1.3",
|
98
|
+
"comments": {
|
99
|
+
"patch": [
|
100
|
+
{
|
101
|
+
"author": "bernardo.sunderhus@gmail.com",
|
102
|
+
"package": "@fluentui/react-popover",
|
103
|
+
"commit": "17c5fe742918bbc41ed22f492a289f53bffc5008",
|
104
|
+
"comment": "chore: improves PopoverTrigger types"
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"author": "olfedias@microsoft.com",
|
108
|
+
"package": "@fluentui/react-popover",
|
109
|
+
"commit": "1a527d440e0497ef8046b3ce240492241e7a04ac",
|
110
|
+
"comment": "chore: Update Griffel to latest version"
|
111
|
+
},
|
112
|
+
{
|
113
|
+
"author": "beachball",
|
114
|
+
"package": "@fluentui/react-popover",
|
115
|
+
"comment": "Bump @fluentui/react-aria to v9.2.2",
|
116
|
+
"commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
|
117
|
+
},
|
118
|
+
{
|
119
|
+
"author": "beachball",
|
120
|
+
"package": "@fluentui/react-popover",
|
121
|
+
"comment": "Bump @fluentui/react-context-selector to v9.0.4",
|
122
|
+
"commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
|
123
|
+
},
|
124
|
+
{
|
125
|
+
"author": "beachball",
|
126
|
+
"package": "@fluentui/react-popover",
|
127
|
+
"comment": "Bump @fluentui/react-portal to v9.0.7",
|
128
|
+
"commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"author": "beachball",
|
132
|
+
"package": "@fluentui/react-popover",
|
133
|
+
"comment": "Bump @fluentui/react-positioning to v9.2.1",
|
134
|
+
"commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
|
135
|
+
},
|
136
|
+
{
|
137
|
+
"author": "beachball",
|
138
|
+
"package": "@fluentui/react-popover",
|
139
|
+
"comment": "Bump @fluentui/react-tabster to v9.1.3",
|
140
|
+
"commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
|
141
|
+
},
|
142
|
+
{
|
143
|
+
"author": "beachball",
|
144
|
+
"package": "@fluentui/react-popover",
|
145
|
+
"comment": "Bump @fluentui/react-utilities to v9.1.1",
|
146
|
+
"commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
|
147
|
+
},
|
148
|
+
{
|
149
|
+
"author": "beachball",
|
150
|
+
"package": "@fluentui/react-popover",
|
151
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.15",
|
152
|
+
"commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
|
75
153
|
}
|
76
154
|
]
|
77
155
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,27 +1,53 @@
|
|
1
1
|
# Change Log - @fluentui/react-popover
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Fri, 14 Oct 2022 04:30:08 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-nightly-
|
7
|
+
## [0.0.0-nightly-20221014-0424.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-popover_v0.0.0-nightly-20221014-0424.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-popover_v9.
|
9
|
+
Fri, 14 Oct 2022 04:30:08 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-popover_v9.2.0..@fluentui/react-popover_v0.0.0-nightly-20221014-0424.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
14
|
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
|
15
|
-
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-
|
16
|
-
- Bump @fluentui/react-aria to v0.0.0-nightly-
|
17
|
-
- Bump @fluentui/react-context-selector to v0.0.0-nightly-
|
18
|
-
- Bump @fluentui/react-portal to v0.0.0-nightly-
|
19
|
-
- Bump @fluentui/react-positioning to v0.0.0-nightly-
|
20
|
-
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
21
|
-
- Bump @fluentui/react-tabster to v0.0.0-nightly-
|
22
|
-
- Bump @fluentui/react-theme to v0.0.0-nightly-
|
23
|
-
- Bump @fluentui/react-utilities to v0.0.0-nightly-
|
24
|
-
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-
|
15
|
+
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-20221014-0424.1 ([commit](https://github.com/microsoft/fluentui/commit/ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5) by beachball)
|
16
|
+
- Bump @fluentui/react-aria to v0.0.0-nightly-20221014-0424.1 ([commit](https://github.com/microsoft/fluentui/commit/ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5) by beachball)
|
17
|
+
- Bump @fluentui/react-context-selector to v0.0.0-nightly-20221014-0424.1 ([commit](https://github.com/microsoft/fluentui/commit/ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5) by beachball)
|
18
|
+
- Bump @fluentui/react-portal to v0.0.0-nightly-20221014-0424.1 ([commit](https://github.com/microsoft/fluentui/commit/ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5) by beachball)
|
19
|
+
- Bump @fluentui/react-positioning to v0.0.0-nightly-20221014-0424.1 ([commit](https://github.com/microsoft/fluentui/commit/ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5) by beachball)
|
20
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20221014-0424.1 ([commit](https://github.com/microsoft/fluentui/commit/ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5) by beachball)
|
21
|
+
- Bump @fluentui/react-tabster to v0.0.0-nightly-20221014-0424.1 ([commit](https://github.com/microsoft/fluentui/commit/ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5) by beachball)
|
22
|
+
- Bump @fluentui/react-theme to v0.0.0-nightly-20221014-0424.1 ([commit](https://github.com/microsoft/fluentui/commit/ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5) by beachball)
|
23
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly-20221014-0424.1 ([commit](https://github.com/microsoft/fluentui/commit/ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5) by beachball)
|
24
|
+
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20221014-0424.1 ([commit](https://github.com/microsoft/fluentui/commit/ee2ce5fd919d3e14b3db9f0ef2ed25258da50fb5) by beachball)
|
25
|
+
|
26
|
+
## [9.2.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-popover_v9.2.0)
|
27
|
+
|
28
|
+
Thu, 13 Oct 2022 12:56:30 GMT
|
29
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-popover_v9.1.3..@fluentui/react-popover_v9.2.0)
|
30
|
+
|
31
|
+
### Minor changes
|
32
|
+
|
33
|
+
- feat: adds disableButtonEnhancement property on PopoverTrigger ([PR #25112](https://github.com/microsoft/fluentui/pull/25112) by bernardo.sunderhus@gmail.com)
|
34
|
+
|
35
|
+
## [9.1.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-popover_v9.1.3)
|
36
|
+
|
37
|
+
Thu, 13 Oct 2022 11:02:56 GMT
|
38
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-popover_v9.1.2..@fluentui/react-popover_v9.1.3)
|
39
|
+
|
40
|
+
### Patches
|
41
|
+
|
42
|
+
- chore: improves PopoverTrigger types ([PR #25044](https://github.com/microsoft/fluentui/pull/25044) by bernardo.sunderhus@gmail.com)
|
43
|
+
- chore: Update Griffel to latest version ([PR #25075](https://github.com/microsoft/fluentui/pull/25075) by olfedias@microsoft.com)
|
44
|
+
- Bump @fluentui/react-aria to v9.2.2 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
|
45
|
+
- Bump @fluentui/react-context-selector to v9.0.4 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
|
46
|
+
- Bump @fluentui/react-portal to v9.0.7 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
|
47
|
+
- Bump @fluentui/react-positioning to v9.2.1 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
|
48
|
+
- Bump @fluentui/react-tabster to v9.1.3 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
|
49
|
+
- Bump @fluentui/react-utilities to v9.1.1 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
|
50
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.15 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
|
25
51
|
|
26
52
|
## [9.1.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-popover_v9.1.2)
|
27
53
|
|
package/dist/index.d.ts
CHANGED
@@ -229,7 +229,13 @@ export declare type PopoverTriggerChildProps<Type extends ARIAButtonType = ARIAB
|
|
229
229
|
/**
|
230
230
|
* PopoverTrigger Props
|
231
231
|
*/
|
232
|
-
export declare type PopoverTriggerProps = TriggerProps<PopoverTriggerChildProps
|
232
|
+
export declare type PopoverTriggerProps = TriggerProps<PopoverTriggerChildProps> & {
|
233
|
+
/**
|
234
|
+
* Disables internal trigger mechanism that ensures a child provided will be a compliant ARIA button.
|
235
|
+
* @default false
|
236
|
+
*/
|
237
|
+
disableButtonEnhancement?: boolean;
|
238
|
+
};
|
233
239
|
|
234
240
|
/**
|
235
241
|
* PopoverTrigger State
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PopoverTrigger.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverTrigger/PopoverTrigger.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ARIAButtonResultProps, ARIAButtonType } from '@fluentui/react-aria';\nimport type { TriggerProps } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\n/**\n * PopoverTrigger Props\n */\nexport type PopoverTriggerProps = TriggerProps<PopoverTriggerChildProps
|
1
|
+
{"version":3,"file":"PopoverTrigger.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverTrigger/PopoverTrigger.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ARIAButtonResultProps, ARIAButtonType } from '@fluentui/react-aria';\nimport type { TriggerProps } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\n/**\n * PopoverTrigger Props\n */\nexport type PopoverTriggerProps = TriggerProps<PopoverTriggerChildProps> & {\n /**\n * Disables internal trigger mechanism that ensures a child provided will be a compliant ARIA button.\n * @default false\n */\n disableButtonEnhancement?: boolean;\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"]}
|
@@ -14,7 +14,8 @@ import { Escape } from '@fluentui/keyboard-keys';
|
|
14
14
|
|
15
15
|
export const usePopoverTrigger_unstable = props => {
|
16
16
|
const {
|
17
|
-
children
|
17
|
+
children,
|
18
|
+
disableButtonEnhancement = false
|
18
19
|
} = props;
|
19
20
|
const child = getTriggerChild(children);
|
20
21
|
const open = usePopoverContext_unstable(context => context.open);
|
@@ -61,7 +62,7 @@ export const usePopoverTrigger_unstable = props => {
|
|
61
62
|
}
|
62
63
|
};
|
63
64
|
|
64
|
-
const
|
65
|
+
const contextMenuProps = { ...triggerAttributes,
|
65
66
|
'aria-expanded': `${open}`,
|
66
67
|
...(child === null || child === void 0 ? void 0 : child.props),
|
67
68
|
onMouseEnter: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onMouseEnter, onMouseEnter)),
|
@@ -69,12 +70,13 @@ export const usePopoverTrigger_unstable = props => {
|
|
69
70
|
onContextMenu: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onContextMenu, onContextMenu)),
|
70
71
|
ref: useMergedRefs(triggerRef, child === null || child === void 0 ? void 0 : child.ref)
|
71
72
|
};
|
72
|
-
const
|
73
|
+
const triggerChildProps = { ...contextMenuProps,
|
73
74
|
onClick: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onClick, onClick)),
|
74
75
|
onKeyDown: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onKeyDown, onKeyDown))
|
75
|
-
}
|
76
|
+
};
|
77
|
+
const ariaButtonTriggerChildProps = useARIAButtonProps((child === null || child === void 0 ? void 0 : child.type) === 'button' || (child === null || child === void 0 ? void 0 : child.type) === 'a' ? child.type : 'div', triggerChildProps);
|
76
78
|
return {
|
77
|
-
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 ?
|
79
|
+
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 ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps))
|
78
80
|
};
|
79
81
|
};
|
80
82
|
//# sourceMappingURL=usePopoverTrigger.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":"AACA,SACE,2BADF,EAEE,eAFF,EAGE,cAHF,EAIE,aAJF,EAKE,gBALF,QAMO,2BANP;AAOA,SAAS,kBAAT,QAAmC,yBAAnC;AACA,SAAS,0BAAT,QAA2C,sBAA3C;AAEA,SAAS,kBAAT,QAAmC,sBAAnC;AACA,SAAS,MAAT,QAAuB,yBAAvB;AAEA;;;;;;;AAOG;;AACH,OAAO,MAAM,0BAA0B,GAAI,KAAD,IAAoD;EAC5F,MAAM;IAAE;
|
1
|
+
{"version":3,"sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":"AACA,SACE,2BADF,EAEE,eAFF,EAGE,cAHF,EAIE,aAJF,EAKE,gBALF,QAMO,2BANP;AAOA,SAAS,kBAAT,QAAmC,yBAAnC;AACA,SAAS,0BAAT,QAA2C,sBAA3C;AAEA,SAAS,kBAAT,QAAmC,sBAAnC;AACA,SAAS,MAAT,QAAuB,yBAAvB;AAEA;;;;;;;AAOG;;AACH,OAAO,MAAM,0BAA0B,GAAI,KAAD,IAAoD;EAC5F,MAAM;IAAE,QAAF;IAAY,wBAAwB,GAAG;EAAvC,IAAiD,KAAvD;EACA,MAAM,KAAK,GAAG,eAAe,CAAC,QAAD,CAA7B;EAEA,MAAM,IAAI,GAAG,0BAA0B,CAAC,OAAO,IAAI,OAAO,CAAC,IAApB,CAAvC;EACA,MAAM,OAAO,GAAG,0BAA0B,CAAC,OAAO,IAAI,OAAO,CAAC,OAApB,CAA1C;EACA,MAAM,UAAU,GAAG,0BAA0B,CAAC,OAAO,IAAI,OAAO,CAAC,UAApB,CAA7C;EACA,MAAM,UAAU,GAAG,0BAA0B,CAAC,OAAO,IAAI,OAAO,CAAC,UAApB,CAA7C;EACA,MAAM,WAAW,GAAG,0BAA0B,CAAC,OAAO,IAA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L,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,gBAAH,GAAsB,wBAAwB,GAAG,iBAAH,GAAuB,2BAFlE,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 { 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, disableButtonEnhancement = false } = props;\n const child = getTriggerChild(children);\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 contextMenuProps = {\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 triggerChildProps = {\n ...contextMenuProps,\n onClick: useEventCallback(mergeCallbacks(child?.props.onClick, onClick)),\n onKeyDown: useEventCallback(mergeCallbacks(child?.props.onKeyDown, onKeyDown)),\n };\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n triggerChildProps,\n );\n\n return {\n children: applyTriggerPropsToChildren(\n props.children,\n useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n openOnContext ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n ),\n };\n};\n"],"sourceRoot":""}
|
@@ -26,7 +26,8 @@ const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
|
|
26
26
|
|
27
27
|
const usePopoverTrigger_unstable = props => {
|
28
28
|
const {
|
29
|
-
children
|
29
|
+
children,
|
30
|
+
disableButtonEnhancement = false
|
30
31
|
} = props;
|
31
32
|
const child = react_utilities_1.getTriggerChild(children);
|
32
33
|
const open = popoverContext_1.usePopoverContext_unstable(context => context.open);
|
@@ -73,7 +74,7 @@ const usePopoverTrigger_unstable = props => {
|
|
73
74
|
}
|
74
75
|
};
|
75
76
|
|
76
|
-
const
|
77
|
+
const contextMenuProps = { ...triggerAttributes,
|
77
78
|
'aria-expanded': `${open}`,
|
78
79
|
...(child === null || child === void 0 ? void 0 : child.props),
|
79
80
|
onMouseEnter: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onMouseEnter, onMouseEnter)),
|
@@ -81,12 +82,13 @@ const usePopoverTrigger_unstable = props => {
|
|
81
82
|
onContextMenu: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onContextMenu, onContextMenu)),
|
82
83
|
ref: react_utilities_1.useMergedRefs(triggerRef, child === null || child === void 0 ? void 0 : child.ref)
|
83
84
|
};
|
84
|
-
const
|
85
|
+
const triggerChildProps = { ...contextMenuProps,
|
85
86
|
onClick: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onClick, onClick)),
|
86
87
|
onKeyDown: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(child === null || child === void 0 ? void 0 : child.props.onKeyDown, onKeyDown))
|
87
|
-
}
|
88
|
+
};
|
89
|
+
const ariaButtonTriggerChildProps = 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', triggerChildProps);
|
88
90
|
return {
|
89
|
-
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 ?
|
91
|
+
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 ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps))
|
90
92
|
};
|
91
93
|
};
|
92
94
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";;;;;;;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,IAAoD;EAC5F,MAAM;IAAE;
|
1
|
+
{"version":3,"sources":["../../../../../../../../../packages/react-components/react-popover/src/components/PopoverTrigger/usePopoverTrigger.ts"],"names":[],"mappings":";;;;;;;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,IAAoD;EAC5F,MAAM;IAAE,QAAF;IAAY,wBAAwB,GAAG;EAAvC,IAAiD,KAAvD;EACA,MAAM,KAAK,GAAG,iBAAA,CAAA,eAAA,CAAgB,Q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from '@fluentui/react-utilities';\nimport { useModalAttributes } from '@fluentui/react-tabster';\nimport { usePopoverContext_unstable } from '../../popoverContext';\nimport type { 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, disableButtonEnhancement = false } = props;\n const child = getTriggerChild(children);\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 contextMenuProps = {\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 triggerChildProps = {\n ...contextMenuProps,\n onClick: useEventCallback(mergeCallbacks(child?.props.onClick, onClick)),\n onKeyDown: useEventCallback(mergeCallbacks(child?.props.onKeyDown, onKeyDown)),\n };\n\n const ariaButtonTriggerChildProps = useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n triggerChildProps,\n );\n\n return {\n children: applyTriggerPropsToChildren(\n props.children,\n useARIAButtonProps(\n child?.type === 'button' || child?.type === 'a' ? child.type : 'div',\n openOnContext ? contextMenuProps : disableButtonEnhancement ? triggerChildProps : ariaButtonTriggerChildProps,\n ),\n ),\n };\n};\n"],"sourceRoot":""}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-popover",
|
3
|
-
"version": "0.0.0-nightly-
|
3
|
+
"version": "0.0.0-nightly-20221014-0424.1",
|
4
4
|
"description": "Popover component for Fluent UI",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -29,27 +29,27 @@
|
|
29
29
|
"devDependencies": {
|
30
30
|
"@fluentui/eslint-plugin": "*",
|
31
31
|
"@fluentui/react-conformance": "*",
|
32
|
-
"@fluentui/react-conformance-griffel": "0.0.0-nightly-
|
32
|
+
"@fluentui/react-conformance-griffel": "0.0.0-nightly-20221014-0424.1",
|
33
33
|
"@fluentui/scripts": "^1.0.0"
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
|
-
"@fluentui/keyboard-keys": "0.0.0-nightly-
|
37
|
-
"@fluentui/react-aria": "0.0.0-nightly-
|
38
|
-
"@fluentui/react-context-selector": "0.0.0-nightly-
|
39
|
-
"@fluentui/react-portal": "0.0.0-nightly-
|
40
|
-
"@fluentui/react-positioning": "0.0.0-nightly-
|
41
|
-
"@fluentui/react-shared-contexts": "0.0.0-nightly-
|
42
|
-
"@fluentui/react-tabster": "0.0.0-nightly-
|
43
|
-
"@fluentui/react-theme": "0.0.0-nightly-
|
44
|
-
"@fluentui/react-utilities": "0.0.0-nightly-
|
36
|
+
"@fluentui/keyboard-keys": "0.0.0-nightly-20221014-0424.1",
|
37
|
+
"@fluentui/react-aria": "0.0.0-nightly-20221014-0424.1",
|
38
|
+
"@fluentui/react-context-selector": "0.0.0-nightly-20221014-0424.1",
|
39
|
+
"@fluentui/react-portal": "0.0.0-nightly-20221014-0424.1",
|
40
|
+
"@fluentui/react-positioning": "0.0.0-nightly-20221014-0424.1",
|
41
|
+
"@fluentui/react-shared-contexts": "0.0.0-nightly-20221014-0424.1",
|
42
|
+
"@fluentui/react-tabster": "0.0.0-nightly-20221014-0424.1",
|
43
|
+
"@fluentui/react-theme": "0.0.0-nightly-20221014-0424.1",
|
44
|
+
"@fluentui/react-utilities": "0.0.0-nightly-20221014-0424.1",
|
45
45
|
"@griffel/react": "^1.4.0",
|
46
46
|
"tslib": "^2.1.0"
|
47
47
|
},
|
48
48
|
"peerDependencies": {
|
49
|
-
"@types/react": ">=16.8.0 <
|
50
|
-
"@types/react-dom": ">=16.8.0 <
|
51
|
-
"react": ">=16.8.0 <
|
52
|
-
"react-dom": ">=16.8.0 <
|
49
|
+
"@types/react": ">=16.8.0 <19.0.0",
|
50
|
+
"@types/react-dom": ">=16.8.0 <19.0.0",
|
51
|
+
"react": ">=16.8.0 <19.0.0",
|
52
|
+
"react-dom": ">=16.8.0 <19.0.0",
|
53
53
|
"scheduler": "^0.19.0 || ^0.20.0"
|
54
54
|
},
|
55
55
|
"beachball": {},
|