@fluentui/react-positioning 0.0.0-nightly89deee5b2a20211210.1 → 0.0.0-nightly8c37bdfa2420220107.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +24 -12
- package/CHANGELOG.md +11 -9
- package/dist/react-positioning.d.ts +49 -10
- package/lib/createArrowStyles.d.ts +46 -9
- package/lib/createArrowStyles.js +41 -27
- package/lib/createArrowStyles.js.map +1 -1
- package/lib-commonjs/createArrowStyles.d.ts +46 -9
- package/lib-commonjs/createArrowStyles.js +45 -28
- package/lib-commonjs/createArrowStyles.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.json
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
"name": "@fluentui/react-positioning",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "Fri,
|
6
|
-
"tag": "@fluentui/react-positioning_v0.0.0-
|
7
|
-
"version": "0.0.0-
|
5
|
+
"date": "Fri, 07 Jan 2022 04:18:18 GMT",
|
6
|
+
"tag": "@fluentui/react-positioning_v0.0.0-nightly8c37bdfa2420220107.1",
|
7
|
+
"version": "0.0.0-nightly8c37bdfa2420220107.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": "a20e14c113697b61a1d2c17539c4e1e708ca7d44",
|
14
14
|
"comment": "Release nightly v9"
|
15
15
|
},
|
16
16
|
{
|
@@ -19,6 +19,12 @@
|
|
19
19
|
"commit": "a76afe26daad901ff5458ffdda7e66e600d5bcac",
|
20
20
|
"comment": "use new types from makeStyles core"
|
21
21
|
},
|
22
|
+
{
|
23
|
+
"author": "Humberto.Morimoto@microsoft.com",
|
24
|
+
"package": "@fluentui/react-positioning",
|
25
|
+
"commit": "db6526ee2d04991e4473174969e3795299b52f9e",
|
26
|
+
"comment": "Replacing use of functions in makeStyles with direct use of tokens."
|
27
|
+
},
|
22
28
|
{
|
23
29
|
"author": "bsunderhus@microsoft.com",
|
24
30
|
"package": "@fluentui/react-positioning",
|
@@ -31,29 +37,35 @@
|
|
31
37
|
"commit": "967d6b74cf0507685a24e0cfaa8c7b9d52a351e1",
|
32
38
|
"comment": "update styles to not use CSS shorthands"
|
33
39
|
},
|
40
|
+
{
|
41
|
+
"author": "behowell@microsoft.com",
|
42
|
+
"package": "@fluentui/react-positioning",
|
43
|
+
"commit": "09804275c7f346db54c33d4ff347bffc33676014",
|
44
|
+
"comment": "Fix popover arrow styling"
|
45
|
+
},
|
34
46
|
{
|
35
47
|
"author": "beachball",
|
36
48
|
"package": "@fluentui/react-positioning",
|
37
|
-
"comment": "Bump @fluentui/react-make-styles to v0.0.0-
|
38
|
-
"commit": "
|
49
|
+
"comment": "Bump @fluentui/react-make-styles to v0.0.0-nightly8c37bdfa2420220107.1",
|
50
|
+
"commit": "a20e14c113697b61a1d2c17539c4e1e708ca7d44"
|
39
51
|
},
|
40
52
|
{
|
41
53
|
"author": "beachball",
|
42
54
|
"package": "@fluentui/react-positioning",
|
43
|
-
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-
|
44
|
-
"commit": "
|
55
|
+
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly8c37bdfa2420220107.1",
|
56
|
+
"commit": "a20e14c113697b61a1d2c17539c4e1e708ca7d44"
|
45
57
|
},
|
46
58
|
{
|
47
59
|
"author": "beachball",
|
48
60
|
"package": "@fluentui/react-positioning",
|
49
|
-
"comment": "Bump @fluentui/react-utilities to v0.0.0-
|
50
|
-
"commit": "
|
61
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly8c37bdfa2420220107.1",
|
62
|
+
"commit": "a20e14c113697b61a1d2c17539c4e1e708ca7d44"
|
51
63
|
},
|
52
64
|
{
|
53
65
|
"author": "beachball",
|
54
66
|
"package": "@fluentui/react-positioning",
|
55
|
-
"comment": "Bump @fluentui/babel-make-styles to v0.0.0-
|
56
|
-
"commit": "
|
67
|
+
"comment": "Bump @fluentui/babel-make-styles to v0.0.0-nightly8c37bdfa2420220107.1",
|
68
|
+
"commit": "a20e14c113697b61a1d2c17539c4e1e708ca7d44"
|
57
69
|
}
|
58
70
|
]
|
59
71
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,24 +1,26 @@
|
|
1
1
|
# Change Log - @fluentui/react-positioning
|
2
2
|
|
3
|
-
This log was last generated on Fri,
|
3
|
+
This log was last generated on Fri, 07 Jan 2022 04:18:18 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-
|
7
|
+
## [0.0.0-nightly8c37bdfa2420220107.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v0.0.0-nightly8c37bdfa2420220107.1)
|
8
8
|
|
9
|
-
Fri,
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.0.0-beta.4..@fluentui/react-positioning_v0.0.0-
|
9
|
+
Fri, 07 Jan 2022 04:18:18 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.0.0-beta.4..@fluentui/react-positioning_v0.0.0-nightly8c37bdfa2420220107.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
|
-
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/
|
14
|
+
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/a20e14c113697b61a1d2c17539c4e1e708ca7d44) by email not defined)
|
15
15
|
- use new types from makeStyles core ([PR #20786](https://github.com/microsoft/fluentui/pull/20786) by olfedias@microsoft.com)
|
16
|
+
- 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)
|
16
17
|
- Adds @noflip annotation to data-popper-placement styles ([PR #20845](https://github.com/microsoft/fluentui/pull/20845) by bsunderhus@microsoft.com)
|
17
18
|
- update styles to not use CSS shorthands ([PR #20842](https://github.com/microsoft/fluentui/pull/20842) by olfedias@microsoft.com)
|
18
|
-
-
|
19
|
-
- Bump @fluentui/react-
|
20
|
-
- Bump @fluentui/react-
|
21
|
-
- Bump @fluentui/
|
19
|
+
- Fix popover arrow styling ([PR #21086](https://github.com/microsoft/fluentui/pull/21086) by behowell@microsoft.com)
|
20
|
+
- Bump @fluentui/react-make-styles to v0.0.0-nightly8c37bdfa2420220107.1 ([commit](https://github.com/microsoft/fluentui/commit/a20e14c113697b61a1d2c17539c4e1e708ca7d44) by beachball)
|
21
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly8c37bdfa2420220107.1 ([commit](https://github.com/microsoft/fluentui/commit/a20e14c113697b61a1d2c17539c4e1e708ca7d44) by beachball)
|
22
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly8c37bdfa2420220107.1 ([commit](https://github.com/microsoft/fluentui/commit/a20e14c113697b61a1d2c17539c4e1e708ca7d44) by beachball)
|
23
|
+
- Bump @fluentui/babel-make-styles to v0.0.0-nightly8c37bdfa2420220107.1 ([commit](https://github.com/microsoft/fluentui/commit/a20e14c113697b61a1d2c17539c4e1e708ca7d44) by beachball)
|
22
24
|
|
23
25
|
## [9.0.0-beta.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.0.0-beta.4)
|
24
26
|
|
@@ -1,7 +1,6 @@
|
|
1
|
-
import type {
|
1
|
+
import type { MakeStylesStyle } from '@fluentui/react-make-styles';
|
2
2
|
import * as PopperJs from '@popperjs/core';
|
3
3
|
import * as React_2 from 'react';
|
4
|
-
import type { Theme } from '@fluentui/react-theme';
|
5
4
|
|
6
5
|
export declare type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';
|
7
6
|
|
@@ -9,31 +8,71 @@ export declare type AutoSize = 'height' | 'height-always' | 'width' | 'width-alw
|
|
9
8
|
|
10
9
|
export declare type Boundary = PopperJs.Boundary | 'scrollParent' | 'window';
|
11
10
|
|
11
|
+
/**
|
12
|
+
* Creates CSS styles to size the arrow created by createArrowStyles to the given height.
|
13
|
+
*
|
14
|
+
* Use this when you need to create classes for several different arrow sizes. If you only need a
|
15
|
+
* constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.
|
16
|
+
*/
|
17
|
+
export declare function createArrowHeightStyles(arrowHeight: number): {
|
18
|
+
width: string;
|
19
|
+
height: string;
|
20
|
+
};
|
21
|
+
|
12
22
|
/**
|
13
23
|
* Helper that creates a makeStyles rule for an arrow element.
|
14
24
|
* For runtime arrow size toggling simply create extra classnames to apply to the arrow element
|
15
25
|
*
|
16
26
|
* ```ts
|
17
27
|
* makeStyles({
|
18
|
-
* arrowWithSize: createArrowStyles(
|
28
|
+
* arrowWithSize: createArrowStyles({ arrowHeight: 6 }),
|
19
29
|
*
|
20
|
-
* arrowWithoutSize: createArrowStyles(),
|
21
|
-
* mediumArrow:
|
22
|
-
* smallArrow:
|
30
|
+
* arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),
|
31
|
+
* mediumArrow: createArrowHeightStyles(4),
|
32
|
+
* smallArrow: createArrowHeightStyles(2),
|
23
33
|
* })
|
24
34
|
* ...
|
25
35
|
*
|
26
|
-
* state.arrowWithSize.className = styles.arrowWithSize
|
36
|
+
* state.arrowWithSize.className = styles.arrowWithSize;
|
27
37
|
* state.arrowWithoutSize.className = mergeClasses(
|
28
38
|
* styles.arrowWithoutSize,
|
29
39
|
* state.smallArrow && styles.smallArrow,
|
30
40
|
* state.mediumArrow && styles.mediumArrow,
|
31
41
|
* )
|
32
42
|
* ```
|
33
|
-
*
|
34
|
-
* @param size - dimensions of the square arrow element in pixels.
|
35
43
|
*/
|
36
|
-
export declare function createArrowStyles(
|
44
|
+
export declare function createArrowStyles(options: CreateArrowStylesOptions): MakeStylesStyle;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Options parameter for the createArrowStyles function
|
48
|
+
*/
|
49
|
+
export declare type CreateArrowStylesOptions = {
|
50
|
+
/**
|
51
|
+
* The height of the arrow from the base to the tip, in px. The base width of the arrow is always twice its height.
|
52
|
+
*
|
53
|
+
* This can be undefined to leave out the arrow size styles. You must then add styles created by
|
54
|
+
* createArrowHeightStyles to set the arrow's size correctly. This can be useful if the arrow can be different sizes.
|
55
|
+
*/
|
56
|
+
arrowHeight: number | undefined;
|
57
|
+
/**
|
58
|
+
* The borderWidth of the arrow. Should be the same borderWidth as the parent element.
|
59
|
+
*
|
60
|
+
* @defaultvalue 1px
|
61
|
+
*/
|
62
|
+
borderWidth?: MakeStylesStyle['borderBottomWidth'];
|
63
|
+
/**
|
64
|
+
* The borderStyle for the arrow. Should be the same borderStyle as the parent element.
|
65
|
+
*
|
66
|
+
* @defaultvalue solid
|
67
|
+
*/
|
68
|
+
borderStyle?: MakeStylesStyle['borderBottomStyle'];
|
69
|
+
/**
|
70
|
+
* The borderColor of the arrow. Should be the same borderColor as the parent element.
|
71
|
+
*
|
72
|
+
* @defaultvalue tokens.colorTransparentStroke
|
73
|
+
*/
|
74
|
+
borderColor?: MakeStylesStyle['borderBottomColor'];
|
75
|
+
};
|
37
76
|
|
38
77
|
/**
|
39
78
|
* Creates a virtual element based on the position of a click event
|
@@ -1,27 +1,64 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type { MakeStylesStyle } from '@fluentui/react-make-styles';
|
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?: MakeStylesStyle['borderBottomWidth'];
|
19
|
+
/**
|
20
|
+
* The borderStyle for the arrow. Should be the same borderStyle as the parent element.
|
21
|
+
*
|
22
|
+
* @defaultvalue solid
|
23
|
+
*/
|
24
|
+
borderStyle?: MakeStylesStyle['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?: MakeStylesStyle['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): MakeStylesStyle;
|
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
|
+
};
|
package/lib/createArrowStyles.js
CHANGED
@@ -1,73 +1,87 @@
|
|
1
1
|
import { shorthands } from '@fluentui/react-make-styles';
|
2
|
+
import { tokens } from '@fluentui/react-theme';
|
2
3
|
/**
|
3
4
|
* Helper that creates a makeStyles rule for an arrow element.
|
4
5
|
* For runtime arrow size toggling simply create extra classnames to apply to the arrow element
|
5
6
|
*
|
6
7
|
* ```ts
|
7
8
|
* makeStyles({
|
8
|
-
* arrowWithSize: createArrowStyles(
|
9
|
+
* arrowWithSize: createArrowStyles({ arrowHeight: 6 }),
|
9
10
|
*
|
10
|
-
* arrowWithoutSize: createArrowStyles(),
|
11
|
-
* mediumArrow:
|
12
|
-
* smallArrow:
|
11
|
+
* arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),
|
12
|
+
* mediumArrow: createArrowHeightStyles(4),
|
13
|
+
* smallArrow: createArrowHeightStyles(2),
|
13
14
|
* })
|
14
15
|
* ...
|
15
16
|
*
|
16
|
-
* state.arrowWithSize.className = styles.arrowWithSize
|
17
|
+
* state.arrowWithSize.className = styles.arrowWithSize;
|
17
18
|
* state.arrowWithoutSize.className = mergeClasses(
|
18
19
|
* styles.arrowWithoutSize,
|
19
20
|
* state.smallArrow && styles.smallArrow,
|
20
21
|
* state.mediumArrow && styles.mediumArrow,
|
21
22
|
* )
|
22
23
|
* ```
|
23
|
-
*
|
24
|
-
* @param size - dimensions of the square arrow element in pixels.
|
25
24
|
*/
|
26
25
|
|
27
|
-
export function createArrowStyles(
|
28
|
-
|
26
|
+
export function createArrowStyles(options) {
|
27
|
+
const {
|
28
|
+
arrowHeight,
|
29
|
+
borderWidth = '1px',
|
30
|
+
borderStyle = 'solid',
|
31
|
+
borderColor = tokens.colorTransparentStroke
|
32
|
+
} = options;
|
33
|
+
return {
|
29
34
|
position: 'absolute',
|
30
35
|
backgroundColor: 'inherit',
|
31
36
|
visibility: 'hidden',
|
32
37
|
zIndex: -1,
|
33
|
-
...(
|
34
|
-
aspectRatio: '1',
|
35
|
-
width: `${size}px`
|
36
|
-
}),
|
38
|
+
...(arrowHeight && createArrowHeightStyles(arrowHeight)),
|
37
39
|
':before': {
|
38
40
|
content: '""',
|
39
|
-
|
41
|
+
visibility: 'visible',
|
40
42
|
position: 'absolute',
|
43
|
+
boxSizing: 'border-box',
|
41
44
|
width: 'inherit',
|
42
45
|
height: 'inherit',
|
43
46
|
backgroundColor: 'inherit',
|
44
|
-
|
45
|
-
|
47
|
+
...shorthands.borderRight(borderWidth, borderStyle, borderColor),
|
48
|
+
...shorthands.borderBottom(borderWidth, borderStyle, borderColor),
|
49
|
+
borderBottomRightRadius: tokens.borderRadiusSmall,
|
46
50
|
transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)'
|
47
51
|
},
|
48
|
-
':global([data-popper-placement])': {
|
49
|
-
':before': { // Special border for High Contrast mode
|
50
|
-
...shorthands.borderRight('1px', 'solid', 'transparent'),
|
51
|
-
...shorthands.borderBottom('1px', 'solid', 'transparent')
|
52
|
-
}
|
53
|
-
},
|
54
52
|
// Popper sets data-popper-placement on the root element, which is used to align the arrow
|
55
53
|
':global([data-popper-placement^="top"])': {
|
56
|
-
bottom:
|
54
|
+
bottom: `-${borderWidth}`,
|
57
55
|
'--angle': '0'
|
58
56
|
},
|
59
57
|
':global([data-popper-placement^="right"])': {
|
60
|
-
left:
|
58
|
+
left: `-${borderWidth} /* @noflip */`,
|
61
59
|
'--angle': '90deg'
|
62
60
|
},
|
63
61
|
':global([data-popper-placement^="bottom"])': {
|
64
|
-
top:
|
62
|
+
top: `-${borderWidth}`,
|
65
63
|
'--angle': '180deg'
|
66
64
|
},
|
67
65
|
':global([data-popper-placement^="left"])': {
|
68
|
-
right:
|
66
|
+
right: `-${borderWidth} /* @noflip */`,
|
69
67
|
'--angle': '270deg'
|
70
68
|
}
|
71
|
-
}
|
69
|
+
};
|
70
|
+
}
|
71
|
+
/**
|
72
|
+
* Creates CSS styles to size the arrow created by createArrowStyles to the given height.
|
73
|
+
*
|
74
|
+
* Use this when you need to create classes for several different arrow sizes. If you only need a
|
75
|
+
* constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.
|
76
|
+
*/
|
77
|
+
|
78
|
+
export function createArrowHeightStyles(arrowHeight) {
|
79
|
+
// The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.
|
80
|
+
// Multiply the triangle's height by sqrt(2) to get length of its edges.
|
81
|
+
const edgeLength = `${1.414 * arrowHeight}px`;
|
82
|
+
return {
|
83
|
+
width: edgeLength,
|
84
|
+
height: edgeLength
|
85
|
+
};
|
72
86
|
}
|
73
87
|
//# sourceMappingURL=createArrowStyles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/createArrowStyles.ts"],"names":[],"mappings":"AAAA,SAAS,UAAT,QAA2B,6BAA3B;
|
1
|
+
{"version":3,"sources":["../src/createArrowStyles.ts"],"names":[],"mappings":"AAAA,SAAS,UAAT,QAA2B,6BAA3B;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,CAAuB,WAAvB,EAAoC,WAApC,EAAiD,WAAjD,CARM;AAST,SAAG,UAAU,CAAC,YAAX,CAAwB,WAAxB,EAAqC,WAArC,EAAkD,WAAlD,CATM;AAUT,MAAA,uBAAuB,EAAE,MAAM,CAAC,iBAVvB;AAWT,MAAA,SAAS,EAAE;AAXF,KARN;AAsBL;AACA,+CAA2C;AACzC,MAAA,MAAM,EAAE,IAAI,WAAW,EADkB;AAEzC,iBAAW;AAF8B,KAvBtC;AA2BL,iDAA6C;AAC3C,MAAA,IAAI,EAAE,IAAI,WAAW,gBADsB;AAE3C,iBAAW;AAFgC,KA3BxC;AA+BL,kDAA8C;AAC5C,MAAA,GAAG,EAAE,IAAI,WAAW,EADwB;AAE5C,iBAAW;AAFiC,KA/BzC;AAmCL,gDAA4C;AAC1C,MAAA,KAAK,EAAE,IAAI,WAAW,gBADoB;AAE1C,iBAAW;AAF+B;AAnCvC,GAAP;AAwCD;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","sourceRoot":""}
|
@@ -1,27 +1,64 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type { MakeStylesStyle } from '@fluentui/react-make-styles';
|
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?: MakeStylesStyle['borderBottomWidth'];
|
19
|
+
/**
|
20
|
+
* The borderStyle for the arrow. Should be the same borderStyle as the parent element.
|
21
|
+
*
|
22
|
+
* @defaultvalue solid
|
23
|
+
*/
|
24
|
+
borderStyle?: MakeStylesStyle['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?: MakeStylesStyle['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): MakeStylesStyle;
|
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
8
|
const react_make_styles_1 = /*#__PURE__*/require("@fluentui/react-make-styles");
|
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_make_styles_1.shorthands.borderRight(borderWidth, borderStyle, borderColor),
|
57
|
+
...react_make_styles_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,mBAAA,gBAAA,OAAA,CAAA,6BAAA,CAAA;
|
1
|
+
{"version":3,"sources":["../src/createArrowStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,mBAAA,gBAAA,OAAA,CAAA,6BAAA,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,mBAAA,CAAA,UAAA,CAAW,WAAX,CAAuB,WAAvB,EAAoC,WAApC,EAAiD,WAAjD,CARM;AAST,SAAG,mBAAA,CAAA,UAAA,CAAW,YAAX,CAAwB,WAAxB,EAAqC,WAArC,EAAkD,WAAlD,CATM;AAUT,MAAA,uBAAuB,EAAE,aAAA,CAAA,MAAA,CAAO,iBAVvB;AAWT,MAAA,SAAS,EAAE;AAXF,KARN;AAsBL;AACA,+CAA2C;AACzC,MAAA,MAAM,EAAE,IAAI,WAAW,EADkB;AAEzC,iBAAW;AAF8B,KAvBtC;AA2BL,iDAA6C;AAC3C,MAAA,IAAI,EAAE,IAAI,WAAW,gBADsB;AAE3C,iBAAW;AAFgC,KA3BxC;AA+BL,kDAA8C;AAC5C,MAAA,GAAG,EAAE,IAAI,WAAW,EADwB;AAE5C,iBAAW;AAFiC,KA/BzC;AAmCL,gDAA4C;AAC1C,MAAA,KAAK,EAAE,IAAI,WAAW,gBADoB;AAE1C,iBAAW;AAF+B;AAnCvC,GAAP;AAwCD;;AAhDD,OAAA,CAAA,iBAAA,GAAA,iBAAA;AAkDA;;;;;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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-positioning",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-nightly8c37bdfa2420220107.1",
|
4
4
|
"description": "A react wrapper around Popper.js for Fluent UI",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -30,12 +30,12 @@
|
|
30
30
|
"@types/react-dom": "16.9.10",
|
31
31
|
"react": "16.8.6",
|
32
32
|
"react-dom": "16.8.6",
|
33
|
-
"@fluentui/babel-make-styles": "0.0.0-
|
33
|
+
"@fluentui/babel-make-styles": "0.0.0-nightly8c37bdfa2420220107.1"
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
|
-
"@fluentui/react-make-styles": "0.0.0-
|
37
|
-
"@fluentui/react-shared-contexts": "0.0.0-
|
38
|
-
"@fluentui/react-utilities": "0.0.0-
|
36
|
+
"@fluentui/react-make-styles": "0.0.0-nightly8c37bdfa2420220107.1",
|
37
|
+
"@fluentui/react-shared-contexts": "0.0.0-nightly8c37bdfa2420220107.1",
|
38
|
+
"@fluentui/react-utilities": "0.0.0-nightly8c37bdfa2420220107.1",
|
39
39
|
"@popperjs/core": "~2.4.3",
|
40
40
|
"tslib": "^2.1.0"
|
41
41
|
},
|