@fluentui/react-positioning 0.0.0-nightly0bc161458e20220126.1 → 0.0.0-nightly2170ed575f20220223.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 +68 -8
- package/CHANGELOG.md +30 -7
- package/dist/react-positioning.d.ts +46 -35
- package/lib/createArrowStyles.js.map +1 -1
- package/lib/createVirtualElementFromClick.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +28 -7
- package/lib/types.js.map +1 -1
- package/lib/usePopper.d.ts +2 -14
- package/lib/usePopper.js +40 -34
- package/lib/usePopper.js.map +1 -1
- package/lib/usePopperMouseTarget.js.map +1 -1
- package/lib/utils/getBasePlacement.js.map +1 -1
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/positioningHelper.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/createArrowStyles.js.map +1 -1
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types.d.ts +28 -7
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/usePopper.d.ts +2 -14
- package/lib-commonjs/usePopper.js +41 -35
- package/lib-commonjs/usePopper.js.map +1 -1
- package/lib-commonjs/usePopperMouseTarget.js.map +1 -1
- package/lib-commonjs/utils/getBasePlacement.js.map +1 -1
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/positioningHelper.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.json
CHANGED
@@ -2,17 +2,65 @@
|
|
2
2
|
"name": "@fluentui/react-positioning",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "Wed,
|
6
|
-
"tag": "@fluentui/react-positioning_v0.0.0-
|
7
|
-
"version": "0.0.0-
|
5
|
+
"date": "Wed, 23 Feb 2022 04:16:23 GMT",
|
6
|
+
"tag": "@fluentui/react-positioning_v0.0.0-nightly2170ed575f20220223.1",
|
7
|
+
"version": "0.0.0-nightly2170ed575f20220223.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
11
11
|
"author": "email not defined",
|
12
12
|
"package": "@fluentui/react-positioning",
|
13
|
-
"commit": "
|
13
|
+
"commit": "d95e2014fb1257eac783ce505fc7a7652da408c2",
|
14
14
|
"comment": "Release nightly v9"
|
15
15
|
},
|
16
|
+
{
|
17
|
+
"author": "beachball",
|
18
|
+
"package": "@fluentui/react-positioning",
|
19
|
+
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly2170ed575f20220223.1",
|
20
|
+
"commit": "d95e2014fb1257eac783ce505fc7a7652da408c2"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-positioning",
|
25
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly2170ed575f20220223.1",
|
26
|
+
"commit": "d95e2014fb1257eac783ce505fc7a7652da408c2"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"date": "Fri, 18 Feb 2022 13:35:33 GMT",
|
33
|
+
"tag": "@fluentui/react-positioning_v9.0.0-rc.3",
|
34
|
+
"version": "9.0.0-rc.3",
|
35
|
+
"comments": {
|
36
|
+
"prerelease": [
|
37
|
+
{
|
38
|
+
"author": "lingfangao@hotmail.com",
|
39
|
+
"package": "@fluentui/react-positioning",
|
40
|
+
"commit": "1aa9e691fcccd9a64168cea7941c0f1e71fa1d14",
|
41
|
+
"comment": "fix: Source maps contain original source code"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"author": "beachball",
|
45
|
+
"package": "@fluentui/react-positioning",
|
46
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.0.0-rc.3",
|
47
|
+
"commit": "3b9c1e931c23173da3d1af0c696cdc58516ce504"
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"author": "beachball",
|
51
|
+
"package": "@fluentui/react-positioning",
|
52
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0-rc.3",
|
53
|
+
"commit": "3b9c1e931c23173da3d1af0c696cdc58516ce504"
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"date": "Thu, 10 Feb 2022 08:50:40 GMT",
|
60
|
+
"tag": "@fluentui/react-positioning_v9.0.0-rc.1",
|
61
|
+
"version": "9.0.0-rc.1",
|
62
|
+
"comments": {
|
63
|
+
"prerelease": [
|
16
64
|
{
|
17
65
|
"author": "olfedias@microsoft.com",
|
18
66
|
"package": "@fluentui/react-positioning",
|
@@ -37,6 +85,12 @@
|
|
37
85
|
"commit": "523b5785eafd28cf56b677af40274cefe5d42dcb",
|
38
86
|
"comment": "use Griffel packages"
|
39
87
|
},
|
88
|
+
{
|
89
|
+
"author": "lingfangao@hotmail.com",
|
90
|
+
"package": "@fluentui/react-positioning",
|
91
|
+
"commit": "a548a59bd94f9c4b656da3bdd149db7ac2de726f",
|
92
|
+
"comment": "feat: Imperative `setTarget` for `usePopper` and `positioning`"
|
93
|
+
},
|
40
94
|
{
|
41
95
|
"author": "bsunderhus@microsoft.com",
|
42
96
|
"package": "@fluentui/react-positioning",
|
@@ -49,6 +103,12 @@
|
|
49
103
|
"commit": "967d6b74cf0507685a24e0cfaa8c7b9d52a351e1",
|
50
104
|
"comment": "update styles to not use CSS shorthands"
|
51
105
|
},
|
106
|
+
{
|
107
|
+
"author": "lingfangao@hotmail.com",
|
108
|
+
"package": "@fluentui/react-positioning",
|
109
|
+
"commit": "c00913d50e2dd15bbfbb0757cefe43b192ff1d7f",
|
110
|
+
"comment": "Bump Fluent UI packages to 9.0.0-rc"
|
111
|
+
},
|
52
112
|
{
|
53
113
|
"author": "behowell@microsoft.com",
|
54
114
|
"package": "@fluentui/react-positioning",
|
@@ -58,14 +118,14 @@
|
|
58
118
|
{
|
59
119
|
"author": "beachball",
|
60
120
|
"package": "@fluentui/react-positioning",
|
61
|
-
"comment": "Bump @fluentui/react-shared-contexts to
|
62
|
-
"commit": "
|
121
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.0.0-rc.1",
|
122
|
+
"commit": "e6c855f6d9019d6c73668d15fc9bc3a13291a6c8"
|
63
123
|
},
|
64
124
|
{
|
65
125
|
"author": "beachball",
|
66
126
|
"package": "@fluentui/react-positioning",
|
67
|
-
"comment": "Bump @fluentui/react-utilities to
|
68
|
-
"commit": "
|
127
|
+
"comment": "Bump @fluentui/react-utilities to v9.0.0-rc.1",
|
128
|
+
"commit": "e6c855f6d9019d6c73668d15fc9bc3a13291a6c8"
|
69
129
|
}
|
70
130
|
],
|
71
131
|
"none": [
|
package/CHANGELOG.md
CHANGED
@@ -1,26 +1,49 @@
|
|
1
1
|
# Change Log - @fluentui/react-positioning
|
2
2
|
|
3
|
-
This log was last generated on Wed,
|
3
|
+
This log was last generated on Wed, 23 Feb 2022 04:16:23 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-
|
7
|
+
## [0.0.0-nightly2170ed575f20220223.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v0.0.0-nightly2170ed575f20220223.1)
|
8
8
|
|
9
|
-
Wed,
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.0.0-
|
9
|
+
Wed, 23 Feb 2022 04:16:23 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.0.0-rc.3..@fluentui/react-positioning_v0.0.0-nightly2170ed575f20220223.1)
|
11
|
+
|
12
|
+
### Changes
|
13
|
+
|
14
|
+
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/d95e2014fb1257eac783ce505fc7a7652da408c2) by email not defined)
|
15
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly2170ed575f20220223.1 ([commit](https://github.com/microsoft/fluentui/commit/d95e2014fb1257eac783ce505fc7a7652da408c2) by beachball)
|
16
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly2170ed575f20220223.1 ([commit](https://github.com/microsoft/fluentui/commit/d95e2014fb1257eac783ce505fc7a7652da408c2) by beachball)
|
17
|
+
|
18
|
+
## [9.0.0-rc.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.0.0-rc.3)
|
19
|
+
|
20
|
+
Fri, 18 Feb 2022 13:35:33 GMT
|
21
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.0.0-rc.1..@fluentui/react-positioning_v9.0.0-rc.3)
|
22
|
+
|
23
|
+
### Changes
|
24
|
+
|
25
|
+
- fix: Source maps contain original source code ([PR #21690](https://github.com/microsoft/fluentui/pull/21690) by lingfangao@hotmail.com)
|
26
|
+
- Bump @fluentui/react-shared-contexts to v9.0.0-rc.3 ([PR #21800](https://github.com/microsoft/fluentui/pull/21800) by beachball)
|
27
|
+
- Bump @fluentui/react-utilities to v9.0.0-rc.3 ([PR #21800](https://github.com/microsoft/fluentui/pull/21800) by beachball)
|
28
|
+
|
29
|
+
## [9.0.0-rc.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.0.0-rc.1)
|
30
|
+
|
31
|
+
Thu, 10 Feb 2022 08:50:40 GMT
|
32
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.0.0-beta.4..@fluentui/react-positioning_v9.0.0-rc.1)
|
11
33
|
|
12
34
|
### Changes
|
13
35
|
|
14
|
-
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/68e7ec86018b052c1f95cc84d4a0a2fbe361eb7c) by email not defined)
|
15
36
|
- use new types from makeStyles core ([PR #20786](https://github.com/microsoft/fluentui/pull/20786) by olfedias@microsoft.com)
|
16
37
|
- Replacing use of functions in makeStyles with direct use of tokens. ([PR #21051](https://github.com/microsoft/fluentui/pull/21051) by Humberto.Morimoto@microsoft.com)
|
17
38
|
- Fix tooltip arrow's high contrast border in RTL ([PR #21354](https://github.com/microsoft/fluentui/pull/21354) by behowell@microsoft.com)
|
18
39
|
- use Griffel packages ([PR #21421](https://github.com/microsoft/fluentui/pull/21421) by olfedias@microsoft.com)
|
40
|
+
- feat: Imperative `setTarget` for `usePopper` and `positioning` ([PR #21632](https://github.com/microsoft/fluentui/pull/21632) by lingfangao@hotmail.com)
|
19
41
|
- Adds @noflip annotation to data-popper-placement styles ([PR #20845](https://github.com/microsoft/fluentui/pull/20845) by bsunderhus@microsoft.com)
|
20
42
|
- update styles to not use CSS shorthands ([PR #20842](https://github.com/microsoft/fluentui/pull/20842) by olfedias@microsoft.com)
|
43
|
+
- Bump Fluent UI packages to 9.0.0-rc ([PR #21623](https://github.com/microsoft/fluentui/pull/21623) by lingfangao@hotmail.com)
|
21
44
|
- Fix popover arrow styling ([PR #21086](https://github.com/microsoft/fluentui/pull/21086) by behowell@microsoft.com)
|
22
|
-
- Bump @fluentui/react-shared-contexts to
|
23
|
-
- Bump @fluentui/react-utilities to
|
45
|
+
- Bump @fluentui/react-shared-contexts to v9.0.0-rc.1 ([commit](https://github.com/microsoft/fluentui/commit/e6c855f6d9019d6c73668d15fc9bc3a13291a6c8) by beachball)
|
46
|
+
- Bump @fluentui/react-utilities to v9.0.0-rc.1 ([commit](https://github.com/microsoft/fluentui/commit/e6c855f6d9019d6c73668d15fc9bc3a13291a6c8) by beachball)
|
24
47
|
|
25
48
|
## [9.0.0-beta.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.0.0-beta.4)
|
26
49
|
|
@@ -100,42 +100,13 @@ export declare type OffsetFunctionParam = {
|
|
100
100
|
placement: PopperJs.Placement;
|
101
101
|
};
|
102
102
|
|
103
|
-
declare interface PopperOptions
|
104
|
-
/**
|
105
|
-
* If false, delays Popper's creation.
|
106
|
-
* @default true
|
107
|
-
*/
|
108
|
-
enabled?: boolean;
|
109
|
-
onStateUpdate?: (state: Partial<PopperJs.State>) => void;
|
110
|
-
/**
|
111
|
-
* Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')
|
112
|
-
* @default false
|
113
|
-
*/
|
114
|
-
positionFixed?: boolean;
|
115
|
-
/**
|
116
|
-
* When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.
|
117
|
-
* "all" enables this behavior for all axis.
|
118
|
-
*/
|
119
|
-
unstable_disableTether?: boolean | 'all';
|
120
|
-
}
|
121
|
-
|
122
|
-
export declare type PopperRefHandle = {
|
123
|
-
updatePosition: () => void;
|
124
|
-
};
|
125
|
-
|
126
|
-
export declare type PopperVirtualElement = PopperJs.VirtualElement;
|
127
|
-
|
128
|
-
export declare type Position = 'above' | 'below' | 'before' | 'after';
|
129
|
-
|
130
|
-
export declare interface PositioningProps {
|
103
|
+
export declare interface PopperOptions {
|
131
104
|
/** Alignment for the component. Only has an effect if used with the @see position option */
|
132
105
|
align?: Alignment;
|
133
106
|
/** The element which will define the boundaries of the popper position for the flip behavior. */
|
134
107
|
flipBoundary?: Boundary;
|
135
108
|
/** The element which will define the boundaries of the popper position for the overflow behavior. */
|
136
109
|
overflowBoundary?: Boundary;
|
137
|
-
/** An imperative handle to Popper methods. */
|
138
|
-
popperRef?: React_2.Ref<PopperRefHandle>;
|
139
110
|
/**
|
140
111
|
* Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')
|
141
112
|
* and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'
|
@@ -143,6 +114,11 @@ export declare interface PositioningProps {
|
|
143
114
|
* then provided value for 'align' will be ignored and 'center' will be used instead.
|
144
115
|
*/
|
145
116
|
position?: Position;
|
117
|
+
/**
|
118
|
+
* Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')
|
119
|
+
* @default false
|
120
|
+
*/
|
121
|
+
positionFixed?: boolean;
|
146
122
|
/**
|
147
123
|
* Lets you displace a popper element from its reference element.
|
148
124
|
* This can be useful if you need to apply some margin between them or if you need to fine tune the
|
@@ -162,10 +138,6 @@ export declare interface PositioningProps {
|
|
162
138
|
* `height-always` applies `max-height` regardless of overflow, and 'width-always' for always applying `max-width`
|
163
139
|
*/
|
164
140
|
autoSize?: AutoSize;
|
165
|
-
/**
|
166
|
-
* Manual override for popper target. Useful for scenarios where a component accepts user prop to override target
|
167
|
-
*/
|
168
|
-
target?: HTMLElement | PopperVirtualElement | null;
|
169
141
|
/**
|
170
142
|
* Modifies position and alignment to cover the target
|
171
143
|
*/
|
@@ -175,6 +147,37 @@ export declare interface PositioningProps {
|
|
175
147
|
* `position` props, regardless of the size of the component, the reference element or the viewport.
|
176
148
|
*/
|
177
149
|
pinned?: boolean;
|
150
|
+
/**
|
151
|
+
* When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.
|
152
|
+
* "all" enables this behavior for all axis.
|
153
|
+
*/
|
154
|
+
unstable_disableTether?: boolean | 'all';
|
155
|
+
}
|
156
|
+
|
157
|
+
export declare type PopperRefHandle = {
|
158
|
+
/**
|
159
|
+
* Updates the position of the popper imperatively.
|
160
|
+
* Useful when the position of the target changes from other factors than scrolling of window resize.
|
161
|
+
*/
|
162
|
+
updatePosition: () => void;
|
163
|
+
/**
|
164
|
+
* Sets the target and updates positioning imperatively.
|
165
|
+
* Useful for avoiding double renders with the target option.
|
166
|
+
*/
|
167
|
+
setTarget: (target: HTMLElement) => void;
|
168
|
+
};
|
169
|
+
|
170
|
+
export declare type PopperVirtualElement = PopperJs.VirtualElement;
|
171
|
+
|
172
|
+
export declare type Position = 'above' | 'below' | 'before' | 'after';
|
173
|
+
|
174
|
+
export declare interface PositioningProps extends Omit<PopperOptions, 'positionFixed' | 'unstable_disableTether'> {
|
175
|
+
/** An imperative handle to Popper methods. */
|
176
|
+
popperRef?: React_2.Ref<PopperRefHandle>;
|
177
|
+
/**
|
178
|
+
* Manual override for popper target. Useful for scenarios where a component accepts user prop to override target
|
179
|
+
*/
|
180
|
+
target?: HTMLElement | PopperVirtualElement | null;
|
178
181
|
}
|
179
182
|
|
180
183
|
export declare type PositioningShorthand = PositioningProps | PositioningShorthandValue;
|
@@ -191,7 +194,7 @@ export declare function resolvePositioningShorthand(shorthand: PositioningShorth
|
|
191
194
|
* - contains a specific to React fix related to initial positioning when containers have components with managed focus
|
192
195
|
* to avoid focus jumps
|
193
196
|
*/
|
194
|
-
export declare function usePopper(options?:
|
197
|
+
export declare function usePopper(options?: UsePopperOptions): {
|
195
198
|
targetRef: React_2.MutableRefObject<any>;
|
196
199
|
containerRef: React_2.MutableRefObject<any>;
|
197
200
|
arrowRef: React_2.MutableRefObject<any>;
|
@@ -207,4 +210,12 @@ export declare function usePopper(options?: PopperOptions): {
|
|
207
210
|
*/
|
208
211
|
export declare const usePopperMouseTarget: (initialState?: PopperJs.VirtualElement | (() => PopperJs.VirtualElement) | undefined) => readonly [PopperJs.VirtualElement | undefined, (event: React_2.MouseEvent | MouseEvent | undefined | null) => void];
|
209
212
|
|
213
|
+
declare interface UsePopperOptions extends PositioningProps {
|
214
|
+
/**
|
215
|
+
* If false, delays Popper's creation.
|
216
|
+
* @default true
|
217
|
+
*/
|
218
|
+
enabled?: boolean;
|
219
|
+
}
|
220
|
+
|
210
221
|
export { }
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["createArrowStyles.ts"],"names":[],"mappings":"AAAA,SAAS,UAAT,QAA2B,gBAA3B;AACA,SAAS,MAAT,QAAuB,uBAAvB;AAqCA;;;;;;;;;;;;;;;;;;;;;AAqBG;;AACH,OAAM,SAAU,iBAAV,CAA4B,OAA5B,EAA6D;AACjE,QAAM;AACJ,IAAA,WADI;AAEJ,IAAA,WAAW,GAAG,KAFV;AAGJ,IAAA,WAAW,GAAG,OAHV;AAIJ,IAAA,WAAW,GAAG,MAAM,CAAC;AAJjB,MAKF,OALJ;AAOA,SAAO;AACL,IAAA,QAAQ,EAAE,UADL;AAEL,IAAA,eAAe,EAAE,SAFZ;AAGL,IAAA,UAAU,EAAE,QAHP;AAIL,IAAA,MAAM,EAAE,CAAC,CAJJ;AAML,QAAI,WAAW,IAAI,uBAAuB,CAAC,WAAD,CAA1C,CANK;AAQL,eAAW;AACT,MAAA,OAAO,EAAE,IADA;AAET,MAAA,UAAU,EAAE,SAFH;AAGT,MAAA,QAAQ,EAAE,UAHD;AAIT,MAAA,SAAS,EAAE,YAJF;AAKT,MAAA,KAAK,EAAE,SALE;AAMT,MAAA,MAAM,EAAE,SANC;AAOT,MAAA,eAAe,EAAE,SAPR;AAQT,SAAG,UAAU,CAAC,WAAX,CACD,GAAG,WAAW,gBADb,EAED,GAAG,WAAW,gBAFb,EAGD,GAAG,WAAW,gBAHb,CARM;AAaT,SAAG,UAAU,CAAC,YAAX,CAAwB,WAAxB,EAAqC,WAArC,EAAkD,WAAlD,CAbM;AAcT,MAAA,uBAAuB,EAAE,MAAM,CAAC,iBAdvB;AAeT,MAAA,SAAS,EAAE;AAfF,KARN;AA0BL;AACA,+CAA2C;AACzC,MAAA,MAAM,EAAE,IAAI,WAAW,EADkB;AAEzC,iBAAW;AAF8B,KA3BtC;AA+BL,iDAA6C;AAC3C,MAAA,IAAI,EAAE,IAAI,WAAW,gBADsB;AAE3C,iBAAW;AAFgC,KA/BxC;AAmCL,kDAA8C;AAC5C,MAAA,GAAG,EAAE,IAAI,WAAW,EADwB;AAE5C,iBAAW;AAFiC,KAnCzC;AAuCL,gDAA4C;AAC1C,MAAA,KAAK,EAAE,IAAI,WAAW,gBADoB;AAE1C,iBAAW;AAF+B;AAvCvC,GAAP;AA4CD;AAED;;;;;AAKG;;AACH,OAAM,SAAU,uBAAV,CAAkC,WAAlC,EAAqD;AACzD;AACA;AACA,QAAM,UAAU,GAAG,GAAG,QAAQ,WAAW,IAAzC;AACA,SAAO;AAAE,IAAA,KAAK,EAAE,UAAT;AAAqB,IAAA,MAAM,EAAE;AAA7B,GAAP;AACD","sourcesContent":["import { shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\n\n/**\n * Options parameter for the createArrowStyles function\n */\nexport type CreateArrowStylesOptions = {\n /**\n * The height of the arrow from the base to the tip, in px. The base width of the arrow is always twice its height.\n *\n * This can be undefined to leave out the arrow size styles. You must then add styles created by\n * createArrowHeightStyles to set the arrow's size correctly. This can be useful if the arrow can be different sizes.\n */\n arrowHeight: number | undefined;\n\n /**\n * The borderWidth of the arrow. Should be the same borderWidth as the parent element.\n *\n * @defaultvalue 1px\n */\n borderWidth?: GriffelStyle['borderBottomWidth'];\n\n /**\n * The borderStyle for the arrow. Should be the same borderStyle as the parent element.\n *\n * @defaultvalue solid\n */\n borderStyle?: GriffelStyle['borderBottomStyle'];\n\n /**\n * The borderColor of the arrow. Should be the same borderColor as the parent element.\n *\n * @defaultvalue tokens.colorTransparentStroke\n */\n borderColor?: GriffelStyle['borderBottomColor'];\n};\n\n/**\n * Helper that creates a makeStyles rule for an arrow element.\n * For runtime arrow size toggling simply create extra classnames to apply to the arrow element\n *\n * ```ts\n * makeStyles({\n * arrowWithSize: createArrowStyles({ arrowHeight: 6 }),\n *\n * arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),\n * mediumArrow: createArrowHeightStyles(4),\n * smallArrow: createArrowHeightStyles(2),\n * })\n * ...\n *\n * state.arrowWithSize.className = styles.arrowWithSize;\n * state.arrowWithoutSize.className = mergeClasses(\n * styles.arrowWithoutSize,\n * state.smallArrow && styles.smallArrow,\n * state.mediumArrow && styles.mediumArrow,\n * )\n * ```\n */\nexport function createArrowStyles(options: CreateArrowStylesOptions): GriffelStyle {\n const {\n arrowHeight,\n borderWidth = '1px',\n borderStyle = 'solid',\n borderColor = tokens.colorTransparentStroke,\n } = options;\n\n return {\n position: 'absolute',\n backgroundColor: 'inherit',\n visibility: 'hidden',\n zIndex: -1,\n\n ...(arrowHeight && createArrowHeightStyles(arrowHeight)),\n\n ':before': {\n content: '\"\"',\n visibility: 'visible',\n position: 'absolute',\n boxSizing: 'border-box',\n width: 'inherit',\n height: 'inherit',\n backgroundColor: 'inherit',\n ...shorthands.borderRight(\n `${borderWidth} /* @noflip */`,\n `${borderStyle} /* @noflip */`,\n `${borderColor} /* @noflip */`,\n ),\n ...shorthands.borderBottom(borderWidth, borderStyle, borderColor),\n borderBottomRightRadius: tokens.borderRadiusSmall,\n transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',\n },\n\n // Popper sets data-popper-placement on the root element, which is used to align the arrow\n ':global([data-popper-placement^=\"top\"])': {\n bottom: `-${borderWidth}`,\n '--angle': '0',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `-${borderWidth} /* @noflip */`,\n '--angle': '90deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: `-${borderWidth}`,\n '--angle': '180deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `-${borderWidth} /* @noflip */`,\n '--angle': '270deg',\n },\n };\n}\n\n/**\n * Creates CSS styles to size the arrow created by createArrowStyles to the given height.\n *\n * Use this when you need to create classes for several different arrow sizes. If you only need a\n * constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.\n */\nexport function createArrowHeightStyles(arrowHeight: number) {\n // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.\n // Multiply the triangle's height by sqrt(2) to get length of its edges.\n const edgeLength = `${1.414 * arrowHeight}px`;\n return { width: edgeLength, height: edgeLength };\n}\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["createVirtualElementFromClick.ts"],"names":[],"mappings":"AAEA;;;AAGG;AACH,OAAM,SAAU,6BAAV,CAAwC,WAAxC,EAA+D;AACnE,QAAM,IAAI,GAAG,WAAW,CAAC,OAAzB;AACA,QAAM,GAAG,GAAG,WAAW,CAAC,OAAxB;AACA,QAAM,KAAK,GAAG,IAAI,GAAG,CAArB;AACA,QAAM,MAAM,GAAG,GAAG,GAAG,CAArB;;AAEA,WAAS,qBAAT,GAA8B;AAC5B,WAAO;AACL,MAAA,IADK;AAEL,MAAA,GAFK;AAGL,MAAA,KAHK;AAIL,MAAA,MAJK;AAML,MAAA,MAAM,EAAE,CANH;AAOL,MAAA,KAAK,EAAE;AAPF,KAAP;AASD;;AAED,SAAO;AACL,IAAA;AADK,GAAP;AAGD","sourcesContent":["import type { PopperVirtualElement } from './types';\n\n/**\n * Creates a virtual element based on the position of a click event\n * Can be used as a target for popper in scenarios such as context menus\n */\nexport function createVirtualElementFromClick(nativeEvent: MouseEvent): PopperVirtualElement {\n const left = nativeEvent.clientX;\n const top = nativeEvent.clientY;\n const right = left + 1;\n const bottom = top + 1;\n\n function getBoundingClientRect(): ClientRect {\n return {\n left,\n top,\n right,\n bottom,\n\n height: 1,\n width: 1,\n };\n }\n\n return {\n getBoundingClientRect,\n };\n}\n"],"sourceRoot":"../src/"}
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC9E,cAAc,SAAS,CAAC","sourcesContent":["export * from './createVirtualElementFromClick';\nexport * from './createArrowStyles';\nexport * from './usePopper';\nexport * from './usePopperMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\nexport * from './types';\n"]}
|
package/lib/types.d.ts
CHANGED
@@ -12,18 +12,25 @@ export declare type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';
|
|
12
12
|
export declare type AutoSize = 'height' | 'height-always' | 'width' | 'width-always' | 'always' | boolean;
|
13
13
|
export declare type Boundary = PopperJs.Boundary | 'scrollParent' | 'window';
|
14
14
|
export declare type PopperRefHandle = {
|
15
|
+
/**
|
16
|
+
* Updates the position of the popper imperatively.
|
17
|
+
* Useful when the position of the target changes from other factors than scrolling of window resize.
|
18
|
+
*/
|
15
19
|
updatePosition: () => void;
|
20
|
+
/**
|
21
|
+
* Sets the target and updates positioning imperatively.
|
22
|
+
* Useful for avoiding double renders with the target option.
|
23
|
+
*/
|
24
|
+
setTarget: (target: HTMLElement) => void;
|
16
25
|
};
|
17
26
|
export declare type PopperVirtualElement = PopperJs.VirtualElement;
|
18
|
-
export interface
|
27
|
+
export interface PopperOptions {
|
19
28
|
/** Alignment for the component. Only has an effect if used with the @see position option */
|
20
29
|
align?: Alignment;
|
21
30
|
/** The element which will define the boundaries of the popper position for the flip behavior. */
|
22
31
|
flipBoundary?: Boundary;
|
23
32
|
/** The element which will define the boundaries of the popper position for the overflow behavior. */
|
24
33
|
overflowBoundary?: Boundary;
|
25
|
-
/** An imperative handle to Popper methods. */
|
26
|
-
popperRef?: React.Ref<PopperRefHandle>;
|
27
34
|
/**
|
28
35
|
* Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')
|
29
36
|
* and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'
|
@@ -31,6 +38,11 @@ export interface PositioningProps {
|
|
31
38
|
* then provided value for 'align' will be ignored and 'center' will be used instead.
|
32
39
|
*/
|
33
40
|
position?: Position;
|
41
|
+
/**
|
42
|
+
* Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')
|
43
|
+
* @default false
|
44
|
+
*/
|
45
|
+
positionFixed?: boolean;
|
34
46
|
/**
|
35
47
|
* Lets you displace a popper element from its reference element.
|
36
48
|
* This can be useful if you need to apply some margin between them or if you need to fine tune the
|
@@ -50,10 +62,6 @@ export interface PositioningProps {
|
|
50
62
|
* `height-always` applies `max-height` regardless of overflow, and 'width-always' for always applying `max-width`
|
51
63
|
*/
|
52
64
|
autoSize?: AutoSize;
|
53
|
-
/**
|
54
|
-
* Manual override for popper target. Useful for scenarios where a component accepts user prop to override target
|
55
|
-
*/
|
56
|
-
target?: HTMLElement | PopperVirtualElement | null;
|
57
65
|
/**
|
58
66
|
* Modifies position and alignment to cover the target
|
59
67
|
*/
|
@@ -63,6 +71,19 @@ export interface PositioningProps {
|
|
63
71
|
* `position` props, regardless of the size of the component, the reference element or the viewport.
|
64
72
|
*/
|
65
73
|
pinned?: boolean;
|
74
|
+
/**
|
75
|
+
* When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.
|
76
|
+
* "all" enables this behavior for all axis.
|
77
|
+
*/
|
78
|
+
unstable_disableTether?: boolean | 'all';
|
79
|
+
}
|
80
|
+
export interface PositioningProps extends Omit<PopperOptions, 'positionFixed' | 'unstable_disableTether'> {
|
81
|
+
/** An imperative handle to Popper methods. */
|
82
|
+
popperRef?: React.Ref<PopperRefHandle>;
|
83
|
+
/**
|
84
|
+
* Manual override for popper target. Useful for scenarios where a component accepts user prop to override target
|
85
|
+
*/
|
86
|
+
target?: HTMLElement | PopperVirtualElement | null;
|
66
87
|
}
|
67
88
|
export declare type PositioningShorthandValue = 'above' | 'above-start' | 'above-end' | 'below' | 'below-start' | 'below-end' | 'before' | 'before-top' | 'before-bottom' | 'after' | 'after-top' | 'after-bottom';
|
68
89
|
export declare type PositioningShorthand = PositioningProps | PositioningShorthandValue;
|
package/lib/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import * as PopperJs from '@popperjs/core';\nimport * as React from 'react';\n\nexport type OffsetFunctionParam = {\n popper: PopperJs.Rect;\n reference: PopperJs.Rect;\n placement: PopperJs.Placement;\n};\n\nexport type OffsetFunction = (param: OffsetFunctionParam) => [number | null | undefined, number | null | undefined];\n\nexport type Offset = OffsetFunction | [number | null | undefined, number | null | undefined];\n\nexport type Position = 'above' | 'below' | 'before' | 'after';\nexport type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';\n\nexport type AutoSize = 'height' | 'height-always' | 'width' | 'width-always' | 'always' | boolean;\n\nexport type Boundary = PopperJs.Boundary | 'scrollParent' | 'window';\n\nexport type PopperRefHandle = {\n /**\n * Updates the position of the popper imperatively.\n * Useful when the position of the target changes from other factors than scrolling of window resize.\n */\n updatePosition: () => void;\n\n /**\n * Sets the target and updates positioning imperatively.\n * Useful for avoiding double renders with the target option.\n */\n setTarget: (target: HTMLElement) => void;\n};\n\nexport type PopperVirtualElement = PopperJs.VirtualElement;\n\nexport interface PopperOptions {\n /** Alignment for the component. Only has an effect if used with the @see position option */\n align?: Alignment;\n\n /** The element which will define the boundaries of the popper position for the flip behavior. */\n flipBoundary?: Boundary;\n\n /** The element which will define the boundaries of the popper position for the overflow behavior. */\n overflowBoundary?: Boundary;\n\n /**\n * Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')\n * and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'\n * and 'start' | 'end' respectively),\n * then provided value for 'align' will be ignored and 'center' will be used instead.\n */\n position?: Position;\n\n /**\n * Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')\n * @default false\n */\n positionFixed?: boolean;\n\n /**\n * Lets you displace a popper element from its reference element.\n * This can be useful if you need to apply some margin between them or if you need to fine tune the\n * position according to some custom logic.\n */\n offset?: Offset;\n\n /**\n * Defines padding between the corner of the popup element and the arrow.\n * Use to prevent the arrow from overlapping a rounded corner, for example.\n */\n arrowPadding?: number;\n\n /**\n * Applies max-height and max-width on popper to fit it within the available space in viewport.\n * true enables this for both width and height when overflow happens.\n * 'always' applies `max-height`/`max-width` regardless of overflow.\n * 'height' applies `max-height` when overflow happens, and 'width' for `max-width`\n * `height-always` applies `max-height` regardless of overflow, and 'width-always' for always applying `max-width`\n */\n autoSize?: AutoSize;\n\n /**\n * Modifies position and alignment to cover the target\n */\n coverTarget?: boolean;\n\n /**\n * Disables automatic repositioning of the component; it will always be placed according to the values of `align` and\n * `position` props, regardless of the size of the component, the reference element or the viewport.\n */\n pinned?: boolean;\n\n /**\n * When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.\n * \"all\" enables this behavior for all axis.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether?: boolean | 'all';\n}\n\nexport interface PositioningProps\n // \"positionFixed\" & \"unstable_disableTether\" are not exported as public API (yet)\n extends Omit<PopperOptions, 'positionFixed' | 'unstable_disableTether'> {\n /** An imperative handle to Popper methods. */\n popperRef?: React.Ref<PopperRefHandle>;\n\n /**\n * Manual override for popper target. Useful for scenarios where a component accepts user prop to override target\n */\n target?: HTMLElement | PopperVirtualElement | null;\n}\n\nexport type PositioningShorthandValue =\n | 'above'\n | 'above-start'\n | 'above-end'\n | 'below'\n | 'below-start'\n | 'below-end'\n | 'before'\n | 'before-top'\n | 'before-bottom'\n | 'after'\n | 'after-top'\n | 'after-bottom';\n\nexport type PositioningShorthand = PositioningProps | PositioningShorthandValue;\n"]}
|
package/lib/usePopper.d.ts
CHANGED
@@ -1,23 +1,11 @@
|
|
1
|
-
import * as PopperJs from '@popperjs/core';
|
2
1
|
import * as React from 'react';
|
3
2
|
import type { PositioningProps } from './types';
|
4
|
-
interface
|
3
|
+
interface UsePopperOptions extends PositioningProps {
|
5
4
|
/**
|
6
5
|
* If false, delays Popper's creation.
|
7
6
|
* @default true
|
8
7
|
*/
|
9
8
|
enabled?: boolean;
|
10
|
-
onStateUpdate?: (state: Partial<PopperJs.State>) => void;
|
11
|
-
/**
|
12
|
-
* Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')
|
13
|
-
* @default false
|
14
|
-
*/
|
15
|
-
positionFixed?: boolean;
|
16
|
-
/**
|
17
|
-
* When the reference element or the viewport is outside viewport allows a popper element to be fully in viewport.
|
18
|
-
* "all" enables this behavior for all axis.
|
19
|
-
*/
|
20
|
-
unstable_disableTether?: boolean | 'all';
|
21
9
|
}
|
22
10
|
/**
|
23
11
|
* Exposes Popper positioning API via React hook. Contains few important differences between an official "react-popper"
|
@@ -27,7 +15,7 @@ interface PopperOptions extends PositioningProps {
|
|
27
15
|
* - contains a specific to React fix related to initial positioning when containers have components with managed focus
|
28
16
|
* to avoid focus jumps
|
29
17
|
*/
|
30
|
-
export declare function usePopper(options?:
|
18
|
+
export declare function usePopper(options?: UsePopperOptions): {
|
31
19
|
targetRef: React.MutableRefObject<any>;
|
32
20
|
containerRef: React.MutableRefObject<any>;
|
33
21
|
arrowRef: React.MutableRefObject<any>;
|
package/lib/usePopper.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { useEventCallback, useIsomorphicLayoutEffect, useFirstMount, canUseDOM } from '@fluentui/react-utilities';
|
2
2
|
import { useFluent } from '@fluentui/react-shared-contexts';
|
3
|
-
import { getScrollParent, applyRtlToOffset, getPlacement, getReactFiberFromNode, getBoundary, useCallbackRef, getBasePlacement } from './utils/index';
|
4
3
|
import * as PopperJs from '@popperjs/core';
|
5
|
-
import * as React from 'react';
|
4
|
+
import * as React from 'react';
|
5
|
+
import { getScrollParent, applyRtlToOffset, getPlacement, getReactFiberFromNode, getBoundary, useCallbackRef, getBasePlacement } from './utils/index'; //
|
6
6
|
// Dev utils to detect if nodes have "autoFocus" props.
|
7
7
|
//
|
8
8
|
|
@@ -38,27 +38,22 @@ function hasAutofocusFilter(node) {
|
|
38
38
|
|
39
39
|
function usePopperOptions(options, popperOriginalPositionRef) {
|
40
40
|
const {
|
41
|
+
align,
|
41
42
|
arrowPadding,
|
42
43
|
autoSize,
|
43
44
|
coverTarget,
|
44
45
|
flipBoundary,
|
45
46
|
offset,
|
46
|
-
onStateUpdate,
|
47
47
|
overflowBoundary,
|
48
|
+
pinned,
|
49
|
+
position,
|
50
|
+
positionFixed,
|
48
51
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
49
|
-
unstable_disableTether
|
50
|
-
pinned
|
52
|
+
unstable_disableTether
|
51
53
|
} = options;
|
52
54
|
const isRtl = useFluent().dir === 'rtl';
|
53
|
-
const placement = getPlacement(
|
54
|
-
const strategy =
|
55
|
-
const handleStateUpdate = useEventCallback(({
|
56
|
-
state
|
57
|
-
}) => {
|
58
|
-
if (onStateUpdate) {
|
59
|
-
onStateUpdate(state);
|
60
|
-
}
|
61
|
-
});
|
55
|
+
const placement = getPlacement(align, position, isRtl);
|
56
|
+
const strategy = positionFixed ? 'fixed' : 'absolute';
|
62
57
|
const offsetModifier = React.useMemo(() => offset ? {
|
63
58
|
name: 'offset',
|
64
59
|
options: {
|
@@ -150,11 +145,6 @@ function usePopperOptions(options, popperOriginalPositionRef) {
|
|
150
145
|
altBoundary: true,
|
151
146
|
boundary: getBoundary(container, overflowBoundary)
|
152
147
|
}
|
153
|
-
}, {
|
154
|
-
name: 'onUpdate',
|
155
|
-
enabled: true,
|
156
|
-
phase: 'afterWrite',
|
157
|
-
fn: handleStateUpdate
|
158
148
|
}, {
|
159
149
|
// Similar code as popper-maxsize-modifier: https://github.com/atomiks/popper.js/blob/master/src/modifiers/maxSize.js
|
160
150
|
// popper-maxsize-modifier only calculates the max sizes.
|
@@ -250,14 +240,11 @@ function usePopperOptions(options, popperOriginalPositionRef) {
|
|
250
240
|
const popperOptions = {
|
251
241
|
modifiers,
|
252
242
|
placement,
|
253
|
-
strategy
|
254
|
-
onFirstUpdate: state => handleStateUpdate({
|
255
|
-
state
|
256
|
-
})
|
243
|
+
strategy
|
257
244
|
};
|
258
245
|
return popperOptions;
|
259
246
|
}, [arrowPadding, autoSize, coverTarget, flipBoundary, offsetModifier, overflowBoundary, placement, strategy, unstable_disableTether, pinned, // These can be skipped from deps as they will not ever change
|
260
|
-
|
247
|
+
popperOriginalPositionRef]);
|
261
248
|
}
|
262
249
|
/**
|
263
250
|
* Exposes Popper positioning API via React hook. Contains few important differences between an official "react-popper"
|
@@ -278,13 +265,11 @@ export function usePopper(options = {}) {
|
|
278
265
|
const resolvePopperOptions = usePopperOptions(options, popperOriginalPositionRef);
|
279
266
|
const popperInstanceRef = React.useRef(null);
|
280
267
|
const handlePopperUpdate = useEventCallback(() => {
|
281
|
-
var _a;
|
268
|
+
var _a, _b;
|
282
269
|
|
283
270
|
(_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
284
271
|
popperInstanceRef.current = null;
|
285
|
-
const
|
286
|
-
target = targetRef.current
|
287
|
-
} = options;
|
272
|
+
const target = (_b = overrideTargetRef.current) !== null && _b !== void 0 ? _b : targetRef.current;
|
288
273
|
let popperInstance = null;
|
289
274
|
|
290
275
|
if (canUseDOM() && enabled) {
|
@@ -335,14 +320,36 @@ export function usePopper(options = {}) {
|
|
335
320
|
|
336
321
|
const targetRef = useCallbackRef(null, handlePopperUpdate, true);
|
337
322
|
const containerRef = useCallbackRef(null, handlePopperUpdate, true);
|
338
|
-
const arrowRef = useCallbackRef(null, handlePopperUpdate, true);
|
323
|
+
const arrowRef = useCallbackRef(null, handlePopperUpdate, true); // Stores external target from options.target or setTarget
|
324
|
+
|
325
|
+
const overrideTargetRef = useCallbackRef(null, handlePopperUpdate, true);
|
339
326
|
React.useImperativeHandle(options.popperRef, () => ({
|
340
327
|
updatePosition: () => {
|
341
328
|
var _a;
|
342
329
|
|
343
330
|
(_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.update();
|
331
|
+
},
|
332
|
+
setTarget: target => {
|
333
|
+
if (options.target && process.env.NODE_ENV !== 'production') {
|
334
|
+
const err = new Error(); // eslint-disable-next-line no-console
|
335
|
+
|
336
|
+
console.warn('Imperative setTarget should not be used at the same time as target option'); // eslint-disable-next-line no-console
|
337
|
+
|
338
|
+
console.warn(err.stack);
|
339
|
+
}
|
340
|
+
|
341
|
+
overrideTargetRef.current = target;
|
344
342
|
}
|
345
|
-
}),
|
343
|
+
}), // Missing deps:
|
344
|
+
// options.target - only used for a runtime warning
|
345
|
+
// targetRef - Stable between renders
|
346
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
347
|
+
[]);
|
348
|
+
useIsomorphicLayoutEffect(() => {
|
349
|
+
if (options.target) {
|
350
|
+
overrideTargetRef.current = options.target;
|
351
|
+
}
|
352
|
+
}, [options.target, overrideTargetRef]);
|
346
353
|
useIsomorphicLayoutEffect(() => {
|
347
354
|
handlePopperUpdate();
|
348
355
|
return () => {
|
@@ -351,15 +358,14 @@ export function usePopper(options = {}) {
|
|
351
358
|
(_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
352
359
|
popperInstanceRef.current = null;
|
353
360
|
};
|
354
|
-
}, [handlePopperUpdate, options.enabled
|
361
|
+
}, [handlePopperUpdate, options.enabled]);
|
355
362
|
useIsomorphicLayoutEffect(() => {
|
356
|
-
var _a;
|
363
|
+
var _a, _b;
|
357
364
|
|
358
365
|
if (!isFirstMount) {
|
359
|
-
(_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.setOptions(resolvePopperOptions(
|
366
|
+
(_a = popperInstanceRef.current) === null || _a === void 0 ? void 0 : _a.setOptions(resolvePopperOptions((_b = overrideTargetRef.current) !== null && _b !== void 0 ? _b : targetRef.current, containerRef.current, arrowRef.current));
|
360
367
|
}
|
361
368
|
}, // Missing deps:
|
362
|
-
// options.target - The useIsomorphicLayoutEffect before this will create a new popper instance if target changes
|
363
369
|
// isFirstMount - Should never change after mount
|
364
370
|
// arrowRef, containerRef, targetRef - Stable between renders
|
365
371
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|