@fluentui/react-positioning 0.0.0-nightlyd3bf09bf8120211201.1 → 0.0.0-nightlyd45ba4664620220211.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +79 -14
- package/CHANGELOG.md +24 -9
- package/dist/react-positioning.d.ts +95 -45
- package/lib/createArrowStyles.d.ts +46 -9
- package/lib/createArrowStyles.js +42 -28
- package/lib/createArrowStyles.js.map +1 -1
- package/lib/types.d.ts +28 -7
- package/lib/usePopper.d.ts +2 -14
- package/lib/usePopper.js +40 -34
- package/lib/usePopper.js.map +1 -1
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/positioningHelper.d.ts +2 -2
- package/lib-commonjs/createArrowStyles.d.ts +46 -9
- package/lib-commonjs/createArrowStyles.js +46 -29
- package/lib-commonjs/createArrowStyles.js.map +1 -1
- package/lib-commonjs/types.d.ts +28 -7
- 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/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/positioningHelper.d.ts +2 -2
- package/package.json +6 -7
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/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
|
package/lib/usePopper.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/usePopper.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,EAA2B,yBAA3B,EAAsD,aAAtD,EAAqE,SAArE,QAAsF,2BAAtF;AACA,SAAS,SAAT,QAA0B,iCAA1B;AACA,SACE,eADF,EAEE,gBAFF,EAGE,YAHF,EAIE,qBAJF,EAKE,WALF,EAME,cANF,EAOE,gBAPF,QAQO,eARP
|
1
|
+
{"version":3,"sources":["../src/usePopper.ts"],"names":[],"mappings":"AAAA,SAAS,gBAAT,EAA2B,yBAA3B,EAAsD,aAAtD,EAAqE,SAArE,QAAsF,2BAAtF;AACA,SAAS,SAAT,QAA0B,iCAA1B;AACA,OAAO,KAAK,QA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E,2EAHF,EAIE,uEAJF,EAKE,IALF,EAME,yFANF,EAOE,oGAPF,EAQE,kGARF,EASE,WATF,EAUE,4FAVF,EAWE,6FAXF,EAYE,IAZF,EAaE,2FAbF,EAcE,2CAdF,EAeE,8EAfF,EAgBE,IAhBF,CAgBO,GAhBP,CADF;AAmBD;AACF,OAhCkB,CAiCnB;AACA;AACA;;AACD,KApCD,EAoCG,EApCH;AAqCD;;AAED,SAAO;AAAE,IAAA,SAAF;AAAa,IAAA,YAAb;AAA2B,IAAA;AAA3B,GAAP;AACD","sourceRoot":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/getScrollParent.ts"],"names":[],"mappings":"AAAA;;;;AAIG;AACH,OAAO,MAAM,aAAa,GAAI,IAAD,IAAmC;AAC9D,MAAI,IAAI,CAAC,QAAL,KAAkB,MAAtB,EAA8B;AAC5B,WAAO,IAAP;AACD,GAH6D,CAI9D;;;AACA,SAAO,IAAI,CAAC,UAAL,IAAoB,IAAY,CAAC,IAAxC;AACD,CANM;AAQP;;;;AAIG;;AACH,MAAM,wBAAwB,GAAI,IAAD,IAAoD;;;AACnF,MAAI,IAAI,CAAC,QAAL,KAAkB,CAAtB,EAAyB;AACvB,WAAO,EAAP;AACD;;AAED,QAAM,MAAM,
|
1
|
+
{"version":3,"sources":["../../src/utils/getScrollParent.ts"],"names":[],"mappings":"AAAA;;;;AAIG;AACH,OAAO,MAAM,aAAa,GAAI,IAAD,IAAmC;AAC9D,MAAI,IAAI,CAAC,QAAL,KAAkB,MAAtB,EAA8B;AAC5B,WAAO,IAAP;AACD,GAH6D,CAI9D;;;AACA,SAAO,IAAI,CAAC,UAAL,IAAoB,IAAY,CAAC,IAAxC;AACD,CANM;AAQP;;;;AAIG;;AACH,MAAM,wBAAwB,GAAI,IAAD,IAAoD;;;AACnF,MAAI,IAAI,CAAC,QAAL,KAAkB,CAAtB,EAAyB;AACvB,WAAO,EAAP;AACD;;AAED,QAAM,MAAM,GAAG,CAAA,EAAA,GAAA,IAAI,CAAC,aAAL,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,WAAnC;AACA,SAAO,MAAO,CAAC,gBAAR,CAAyB,IAAzB,EAA+B,IAA/B,CAAP;AACD,CAPD;AASA;;;;AAIG;;;AACH,OAAO,MAAM,eAAe,GAAI,IAAD,IAAqD;AAClF;AACA,QAAM,UAAU,GAAG,IAAI,IAAI,aAAa,CAAC,IAAD,CAAxC,CAFkF,CAGlF;;AACA,MAAI,CAAC,UAAL,EAAiB,OAAO,QAAQ,CAAC,IAAhB;;AAEjB,UAAQ,UAAU,CAAC,QAAnB;AACE,SAAK,MAAL;AACA,SAAK,MAAL;AACE,aAAO,UAAU,CAAC,aAAX,CAA0B,IAAjC;;AACF,SAAK,WAAL;AACE,aAAS,UAAmC,CAAC,IAA7C;AALJ,GANkF,CAclF;;;AACA,QAAM;AAAE,IAAA,QAAF;AAAY,IAAA,SAAZ;AAAuB,IAAA;AAAvB,MAAqC,wBAAwB,CAAC,UAAD,CAAnE;;AACA,MAAI,wBAAwB,IAAxB,CAA6B,QAAS,GAAG,SAAZ,GAAyB,SAAtD,CAAJ,EAAsE;AACpE,WAAO,UAAP;AACD;;AAED,SAAO,eAAe,CAAC,UAAD,CAAtB;AACD,CArBM","sourceRoot":""}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as PopperJs from '@popperjs/core';
|
2
|
-
import type { Offset } from '../types';
|
2
|
+
import type { Alignment, Offset, Position } from '../types';
|
3
3
|
/**
|
4
4
|
* @see positioninHelper.test.ts for expected placement values
|
5
5
|
*/
|
6
|
-
export declare const getPlacement: (align?:
|
6
|
+
export declare const getPlacement: (align?: Alignment | undefined, position?: Position | undefined, rtl?: boolean | undefined) => PopperJs.Placement;
|
7
7
|
export declare const applyRtlToOffset: (offset: Offset | undefined) => Offset | undefined;
|
@@ -1,27 +1,64 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type { GriffelStyle } from '@griffel/react';
|
2
|
+
/**
|
3
|
+
* Options parameter for the createArrowStyles function
|
4
|
+
*/
|
5
|
+
export declare type CreateArrowStylesOptions = {
|
6
|
+
/**
|
7
|
+
* The height of the arrow from the base to the tip, in px. The base width of the arrow is always twice its height.
|
8
|
+
*
|
9
|
+
* This can be undefined to leave out the arrow size styles. You must then add styles created by
|
10
|
+
* createArrowHeightStyles to set the arrow's size correctly. This can be useful if the arrow can be different sizes.
|
11
|
+
*/
|
12
|
+
arrowHeight: number | undefined;
|
13
|
+
/**
|
14
|
+
* The borderWidth of the arrow. Should be the same borderWidth as the parent element.
|
15
|
+
*
|
16
|
+
* @defaultvalue 1px
|
17
|
+
*/
|
18
|
+
borderWidth?: GriffelStyle['borderBottomWidth'];
|
19
|
+
/**
|
20
|
+
* The borderStyle for the arrow. Should be the same borderStyle as the parent element.
|
21
|
+
*
|
22
|
+
* @defaultvalue solid
|
23
|
+
*/
|
24
|
+
borderStyle?: GriffelStyle['borderBottomStyle'];
|
25
|
+
/**
|
26
|
+
* The borderColor of the arrow. Should be the same borderColor as the parent element.
|
27
|
+
*
|
28
|
+
* @defaultvalue tokens.colorTransparentStroke
|
29
|
+
*/
|
30
|
+
borderColor?: GriffelStyle['borderBottomColor'];
|
31
|
+
};
|
3
32
|
/**
|
4
33
|
* Helper that creates a makeStyles rule for an arrow element.
|
5
34
|
* For runtime arrow size toggling simply create extra classnames to apply to the arrow element
|
6
35
|
*
|
7
36
|
* ```ts
|
8
37
|
* makeStyles({
|
9
|
-
* arrowWithSize: createArrowStyles(
|
38
|
+
* arrowWithSize: createArrowStyles({ arrowHeight: 6 }),
|
10
39
|
*
|
11
|
-
* arrowWithoutSize: createArrowStyles(),
|
12
|
-
* mediumArrow:
|
13
|
-
* smallArrow:
|
40
|
+
* arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),
|
41
|
+
* mediumArrow: createArrowHeightStyles(4),
|
42
|
+
* smallArrow: createArrowHeightStyles(2),
|
14
43
|
* })
|
15
44
|
* ...
|
16
45
|
*
|
17
|
-
* state.arrowWithSize.className = styles.arrowWithSize
|
46
|
+
* state.arrowWithSize.className = styles.arrowWithSize;
|
18
47
|
* state.arrowWithoutSize.className = mergeClasses(
|
19
48
|
* styles.arrowWithoutSize,
|
20
49
|
* state.smallArrow && styles.smallArrow,
|
21
50
|
* state.mediumArrow && styles.mediumArrow,
|
22
51
|
* )
|
23
52
|
* ```
|
53
|
+
*/
|
54
|
+
export declare function createArrowStyles(options: CreateArrowStylesOptions): GriffelStyle;
|
55
|
+
/**
|
56
|
+
* Creates CSS styles to size the arrow created by createArrowStyles to the given height.
|
24
57
|
*
|
25
|
-
*
|
58
|
+
* Use this when you need to create classes for several different arrow sizes. If you only need a
|
59
|
+
* constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.
|
26
60
|
*/
|
27
|
-
export declare function
|
61
|
+
export declare function createArrowHeightStyles(arrowHeight: number): {
|
62
|
+
width: string;
|
63
|
+
height: string;
|
64
|
+
};
|
@@ -3,81 +3,98 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.createArrowStyles = void 0;
|
6
|
+
exports.createArrowHeightStyles = exports.createArrowStyles = void 0;
|
7
7
|
|
8
|
-
const
|
8
|
+
const react_1 = /*#__PURE__*/require("@griffel/react");
|
9
|
+
|
10
|
+
const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
|
9
11
|
/**
|
10
12
|
* Helper that creates a makeStyles rule for an arrow element.
|
11
13
|
* For runtime arrow size toggling simply create extra classnames to apply to the arrow element
|
12
14
|
*
|
13
15
|
* ```ts
|
14
16
|
* makeStyles({
|
15
|
-
* arrowWithSize: createArrowStyles(
|
17
|
+
* arrowWithSize: createArrowStyles({ arrowHeight: 6 }),
|
16
18
|
*
|
17
|
-
* arrowWithoutSize: createArrowStyles(),
|
18
|
-
* mediumArrow:
|
19
|
-
* smallArrow:
|
19
|
+
* arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),
|
20
|
+
* mediumArrow: createArrowHeightStyles(4),
|
21
|
+
* smallArrow: createArrowHeightStyles(2),
|
20
22
|
* })
|
21
23
|
* ...
|
22
24
|
*
|
23
|
-
* state.arrowWithSize.className = styles.arrowWithSize
|
25
|
+
* state.arrowWithSize.className = styles.arrowWithSize;
|
24
26
|
* state.arrowWithoutSize.className = mergeClasses(
|
25
27
|
* styles.arrowWithoutSize,
|
26
28
|
* state.smallArrow && styles.smallArrow,
|
27
29
|
* state.mediumArrow && styles.mediumArrow,
|
28
30
|
* )
|
29
31
|
* ```
|
30
|
-
*
|
31
|
-
* @param size - dimensions of the square arrow element in pixels.
|
32
32
|
*/
|
33
33
|
|
34
34
|
|
35
|
-
function createArrowStyles(
|
36
|
-
|
35
|
+
function createArrowStyles(options) {
|
36
|
+
const {
|
37
|
+
arrowHeight,
|
38
|
+
borderWidth = '1px',
|
39
|
+
borderStyle = 'solid',
|
40
|
+
borderColor = react_theme_1.tokens.colorTransparentStroke
|
41
|
+
} = options;
|
42
|
+
return {
|
37
43
|
position: 'absolute',
|
38
44
|
backgroundColor: 'inherit',
|
39
45
|
visibility: 'hidden',
|
40
46
|
zIndex: -1,
|
41
|
-
...(
|
42
|
-
aspectRatio: '1',
|
43
|
-
width: `${size}px`
|
44
|
-
}),
|
47
|
+
...(arrowHeight && createArrowHeightStyles(arrowHeight)),
|
45
48
|
':before': {
|
46
49
|
content: '""',
|
47
|
-
|
50
|
+
visibility: 'visible',
|
48
51
|
position: 'absolute',
|
52
|
+
boxSizing: 'border-box',
|
49
53
|
width: 'inherit',
|
50
54
|
height: 'inherit',
|
51
55
|
backgroundColor: 'inherit',
|
52
|
-
|
53
|
-
|
56
|
+
...react_1.shorthands.borderRight(`${borderWidth} /* @noflip */`, `${borderStyle} /* @noflip */`, `${borderColor} /* @noflip */`),
|
57
|
+
...react_1.shorthands.borderBottom(borderWidth, borderStyle, borderColor),
|
58
|
+
borderBottomRightRadius: react_theme_1.tokens.borderRadiusSmall,
|
54
59
|
transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)'
|
55
60
|
},
|
56
|
-
':global([data-popper-placement])': {
|
57
|
-
':before': { // Special border for High Contrast mode
|
58
|
-
...react_make_styles_1.shorthands.borderRight('1px', 'solid', 'transparent'),
|
59
|
-
...react_make_styles_1.shorthands.borderBottom('1px', 'solid', 'transparent')
|
60
|
-
}
|
61
|
-
},
|
62
61
|
// Popper sets data-popper-placement on the root element, which is used to align the arrow
|
63
62
|
':global([data-popper-placement^="top"])': {
|
64
|
-
bottom:
|
63
|
+
bottom: `-${borderWidth}`,
|
65
64
|
'--angle': '0'
|
66
65
|
},
|
67
66
|
':global([data-popper-placement^="right"])': {
|
68
|
-
left:
|
67
|
+
left: `-${borderWidth} /* @noflip */`,
|
69
68
|
'--angle': '90deg'
|
70
69
|
},
|
71
70
|
':global([data-popper-placement^="bottom"])': {
|
72
|
-
top:
|
71
|
+
top: `-${borderWidth}`,
|
73
72
|
'--angle': '180deg'
|
74
73
|
},
|
75
74
|
':global([data-popper-placement^="left"])': {
|
76
|
-
right:
|
75
|
+
right: `-${borderWidth} /* @noflip */`,
|
77
76
|
'--angle': '270deg'
|
78
77
|
}
|
79
|
-
}
|
78
|
+
};
|
80
79
|
}
|
81
80
|
|
82
81
|
exports.createArrowStyles = createArrowStyles;
|
82
|
+
/**
|
83
|
+
* Creates CSS styles to size the arrow created by createArrowStyles to the given height.
|
84
|
+
*
|
85
|
+
* Use this when you need to create classes for several different arrow sizes. If you only need a
|
86
|
+
* constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.
|
87
|
+
*/
|
88
|
+
|
89
|
+
function createArrowHeightStyles(arrowHeight) {
|
90
|
+
// The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.
|
91
|
+
// Multiply the triangle's height by sqrt(2) to get length of its edges.
|
92
|
+
const edgeLength = `${1.414 * arrowHeight}px`;
|
93
|
+
return {
|
94
|
+
width: edgeLength,
|
95
|
+
height: edgeLength
|
96
|
+
};
|
97
|
+
}
|
98
|
+
|
99
|
+
exports.createArrowHeightStyles = createArrowHeightStyles;
|
83
100
|
//# sourceMappingURL=createArrowStyles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/createArrowStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,
|
1
|
+
{"version":3,"sources":["../src/createArrowStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;AAqCA;;;;;;;;;;;;;;;;;;;;;AAqBG;;;AACH,SAAgB,iBAAhB,CAAkC,OAAlC,EAAmE;AACjE,QAAM;AACJ,IAAA,WADI;AAEJ,IAAA,WAAW,GAAG,KAFV;AAGJ,IAAA,WAAW,GAAG,OAHV;AAIJ,IAAA,WAAW,GAAG,aAAA,CAAA,MAAA,CAAO;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,OAAA,CAAA,UAAA,CAAW,WAAX,CACD,GAAG,WAAW,gBADb,EAED,GAAG,WAAW,gBAFb,EAGD,GAAG,WAAW,gBAHb,CARM;AAaT,SAAG,OAAA,CAAA,UAAA,CAAW,YAAX,CAAwB,WAAxB,EAAqC,WAArC,EAAkD,WAAlD,CAbM;AAcT,MAAA,uBAAuB,EAAE,aAAA,CAAA,MAAA,CAAO,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;;AApDD,OAAA,CAAA,iBAAA,GAAA,iBAAA;AAsDA;;;;;AAKG;;AACH,SAAgB,uBAAhB,CAAwC,WAAxC,EAA2D;AACzD;AACA;AACA,QAAM,UAAU,GAAG,GAAG,QAAQ,WAAW,IAAzC;AACA,SAAO;AAAE,IAAA,KAAK,EAAE,UAAT;AAAqB,IAAA,MAAM,EAAE;AAA7B,GAAP;AACD;;AALD,OAAA,CAAA,uBAAA,GAAA,uBAAA","sourceRoot":""}
|
package/lib-commonjs/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;
|
@@ -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>;
|