@fluentui/react-positioning 0.0.0-nightly-20240731-0407.1 → 0.0.0-nightly-20240816-2133.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.md
CHANGED
@@ -1,29 +1,20 @@
|
|
1
1
|
# Change Log - @fluentui/react-positioning
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Fri, 16 Aug 2024 21:44:09 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-nightly-
|
7
|
+
## [0.0.0-nightly-20240816-2133.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v0.0.0-nightly-20240816-2133.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.15.
|
9
|
+
Fri, 16 Aug 2024 21:44:09 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.15.6..@fluentui/react-positioning_v0.0.0-nightly-20240816-2133.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
14
|
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
|
15
|
-
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
16
|
-
- Bump @fluentui/react-theme to v0.0.0-nightly-
|
17
|
-
- Bump @fluentui/react-utilities to v0.0.0-nightly-
|
18
|
-
|
19
|
-
## [9.15.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.15.7)
|
20
|
-
|
21
|
-
Tue, 30 Jul 2024 18:47:34 GMT
|
22
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.15.6..@fluentui/react-positioning_v9.15.7)
|
23
|
-
|
24
|
-
### Patches
|
25
|
-
|
26
|
-
- fix: improve arrow styles implementation ([PR #32092](https://github.com/microsoft/fluentui/pull/32092) by olfedias@microsoft.com)
|
15
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20240816-2133.1 ([commit](https://github.com/microsoft/fluentui/commit/7d70de62d1ba4ce393c9c6839e67ecb3f1c3d7f4) by beachball)
|
16
|
+
- Bump @fluentui/react-theme to v0.0.0-nightly-20240816-2133.1 ([commit](https://github.com/microsoft/fluentui/commit/7d70de62d1ba4ce393c9c6839e67ecb3f1c3d7f4) by beachball)
|
17
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly-20240816-2133.1 ([commit](https://github.com/microsoft/fluentui/commit/7d70de62d1ba4ce393c9c6839e67ecb3f1c3d7f4) by beachball)
|
27
18
|
|
28
19
|
## [9.15.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.15.6)
|
29
20
|
|
package/dist/index.d.ts
CHANGED
@@ -14,7 +14,10 @@ export declare type Boundary = HTMLElement | Array<HTMLElement> | 'clippingParen
|
|
14
14
|
* Use this when you need to create classes for several different arrow sizes. If you only need a
|
15
15
|
* constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.
|
16
16
|
*/
|
17
|
-
export declare function createArrowHeightStyles(arrowHeight: number):
|
17
|
+
export declare function createArrowHeightStyles(arrowHeight: number): {
|
18
|
+
width: string;
|
19
|
+
height: string;
|
20
|
+
};
|
18
21
|
|
19
22
|
/**
|
20
23
|
* @internal
|
package/lib/createArrowStyles.js
CHANGED
@@ -24,43 +24,40 @@ import { tokens } from '@fluentui/react-theme';
|
|
24
24
|
*/ export function createArrowStyles(options) {
|
25
25
|
const { arrowHeight, borderWidth = '1px', borderStyle = 'solid', borderColor = tokens.colorTransparentStroke } = options;
|
26
26
|
return {
|
27
|
-
boxSizing: 'border-box',
|
28
27
|
position: 'absolute',
|
28
|
+
backgroundColor: 'inherit',
|
29
|
+
visibility: 'hidden',
|
29
30
|
zIndex: -1,
|
30
31
|
...arrowHeight && createArrowHeightStyles(arrowHeight),
|
31
|
-
backgroundColor: 'inherit',
|
32
|
-
backgroundClip: 'content-box',
|
33
|
-
borderBottomLeftRadius: `${tokens.borderRadiusSmall} /* @noflip */`,
|
34
|
-
transform: 'rotate(var(--fui-positioning-arrow-angle)) /* @noflip */',
|
35
|
-
height: 'var(--fui-positioning-arrow-height)',
|
36
|
-
width: 'var(--fui-positioning-arrow-height)',
|
37
32
|
'::before': {
|
38
33
|
content: '""',
|
39
|
-
|
34
|
+
visibility: 'visible',
|
35
|
+
position: 'absolute',
|
36
|
+
boxSizing: 'border-box',
|
37
|
+
width: 'inherit',
|
38
|
+
height: 'inherit',
|
40
39
|
backgroundColor: 'inherit',
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
borderBottomLeftRadius: `${tokens.borderRadiusSmall} /* @noflip */`,
|
46
|
-
clipPath: 'polygon(0% 0%, 100% 100%, 0% 100%)'
|
40
|
+
borderRight: `${borderWidth} ${borderStyle} ${borderColor} /* @noflip */`,
|
41
|
+
borderBottom: `${borderWidth} ${borderStyle} ${borderColor}`,
|
42
|
+
borderBottomRightRadius: tokens.borderRadiusSmall,
|
43
|
+
transform: 'rotate(var(--fui-positioning-angle)) translate(0, 50%) rotate(45deg) /* @noflip */'
|
47
44
|
},
|
48
45
|
// Popper sets data-popper-placement on the root element, which is used to align the arrow
|
49
46
|
':global([data-popper-placement^="top"])': {
|
50
|
-
bottom:
|
51
|
-
'--fui-positioning-
|
47
|
+
bottom: `-${borderWidth}`,
|
48
|
+
'--fui-positioning-angle': '0'
|
52
49
|
},
|
53
50
|
':global([data-popper-placement^="right"])': {
|
54
|
-
left:
|
55
|
-
'--fui-positioning-
|
51
|
+
left: `-${borderWidth} /* @noflip */`,
|
52
|
+
'--fui-positioning-angle': '90deg'
|
56
53
|
},
|
57
54
|
':global([data-popper-placement^="bottom"])': {
|
58
|
-
top:
|
59
|
-
'--fui-positioning-
|
55
|
+
top: `-${borderWidth}`,
|
56
|
+
'--fui-positioning-angle': '180deg'
|
60
57
|
},
|
61
58
|
':global([data-popper-placement^="left"])': {
|
62
|
-
right:
|
63
|
-
'--fui-positioning-
|
59
|
+
right: `-${borderWidth} /* @noflip */`,
|
60
|
+
'--fui-positioning-angle': '270deg'
|
64
61
|
}
|
65
62
|
};
|
66
63
|
}
|
@@ -73,9 +70,9 @@ import { tokens } from '@fluentui/react-theme';
|
|
73
70
|
*/ export function createArrowHeightStyles(arrowHeight) {
|
74
71
|
// The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.
|
75
72
|
// Multiply the triangle's height by sqrt(2) to get length of its edges.
|
76
|
-
const edgeLength = 1.414 * arrowHeight
|
73
|
+
const edgeLength = `${1.414 * arrowHeight}px`;
|
77
74
|
return {
|
78
|
-
|
79
|
-
|
75
|
+
width: edgeLength,
|
76
|
+
height: edgeLength
|
80
77
|
};
|
81
78
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["createArrowStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\n\n/**\n * @internal\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 * @internal\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
|
1
|
+
{"version":3,"sources":["createArrowStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\n\n/**\n * @internal\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 * @internal\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 borderRight: `${borderWidth} ${borderStyle} ${borderColor} /* @noflip */`,\n borderBottom: `${borderWidth} ${borderStyle} ${borderColor}`,\n borderBottomRightRadius: tokens.borderRadiusSmall,\n transform: 'rotate(var(--fui-positioning-angle)) translate(0, 50%) rotate(45deg) /* @noflip */',\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 '--fui-positioning-angle': '0',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `-${borderWidth} /* @noflip */`,\n '--fui-positioning-angle': '90deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: `-${borderWidth}`,\n '--fui-positioning-angle': '180deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `-${borderWidth} /* @noflip */`,\n '--fui-positioning-angle': '270deg',\n },\n };\n}\n\n/**\n * @internal\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"],"names":["tokens","createArrowStyles","options","arrowHeight","borderWidth","borderStyle","borderColor","colorTransparentStroke","position","backgroundColor","visibility","zIndex","createArrowHeightStyles","content","boxSizing","width","height","borderRight","borderBottom","borderBottomRightRadius","borderRadiusSmall","transform","bottom","left","top","right","edgeLength"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAsC/C;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,SAASC,kBAAkBC,OAAiC;IACjE,MAAM,EACJC,WAAW,EACXC,cAAc,KAAK,EACnBC,cAAc,OAAO,EACrBC,cAAcN,OAAOO,sBAAsB,EAC5C,GAAGL;IAEJ,OAAO;QACLM,UAAU;QACVC,iBAAiB;QACjBC,YAAY;QACZC,QAAQ,CAAC;QAET,GAAIR,eAAeS,wBAAwBT,YAAY;QAEvD,YAAY;YACVU,SAAS;YACTH,YAAY;YACZF,UAAU;YACVM,WAAW;YACXC,OAAO;YACPC,QAAQ;YACRP,iBAAiB;YACjBQ,aAAa,CAAC,EAAEb,YAAY,CAAC,EAAEC,YAAY,CAAC,EAAEC,YAAY,cAAc,CAAC;YACzEY,cAAc,CAAC,EAAEd,YAAY,CAAC,EAAEC,YAAY,CAAC,EAAEC,YAAY,CAAC;YAC5Da,yBAAyBnB,OAAOoB,iBAAiB;YACjDC,WAAW;QACb;QAEA,0FAA0F;QAC1F,2CAA2C;YACzCC,QAAQ,CAAC,CAAC,EAAElB,YAAY,CAAC;YACzB,2BAA2B;QAC7B;QACA,6CAA6C;YAC3CmB,MAAM,CAAC,CAAC,EAAEnB,YAAY,cAAc,CAAC;YACrC,2BAA2B;QAC7B;QACA,8CAA8C;YAC5CoB,KAAK,CAAC,CAAC,EAAEpB,YAAY,CAAC;YACtB,2BAA2B;QAC7B;QACA,4CAA4C;YAC1CqB,OAAO,CAAC,CAAC,EAAErB,YAAY,cAAc,CAAC;YACtC,2BAA2B;QAC7B;IACF;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASQ,wBAAwBT,WAAmB;IACzD,qGAAqG;IACrG,wEAAwE;IACxE,MAAMuB,aAAa,CAAC,EAAE,QAAQvB,YAAY,EAAE,CAAC;IAC7C,OAAO;QAAEY,OAAOW;QAAYV,QAAQU;IAAW;AACjD"}
|
@@ -20,52 +20,49 @@ const _reacttheme = require("@fluentui/react-theme");
|
|
20
20
|
function createArrowStyles(options) {
|
21
21
|
const { arrowHeight, borderWidth = '1px', borderStyle = 'solid', borderColor = _reacttheme.tokens.colorTransparentStroke } = options;
|
22
22
|
return {
|
23
|
-
boxSizing: 'border-box',
|
24
23
|
position: 'absolute',
|
24
|
+
backgroundColor: 'inherit',
|
25
|
+
visibility: 'hidden',
|
25
26
|
zIndex: -1,
|
26
27
|
...arrowHeight && createArrowHeightStyles(arrowHeight),
|
27
|
-
backgroundColor: 'inherit',
|
28
|
-
backgroundClip: 'content-box',
|
29
|
-
borderBottomLeftRadius: `${_reacttheme.tokens.borderRadiusSmall} /* @noflip */`,
|
30
|
-
transform: 'rotate(var(--fui-positioning-arrow-angle)) /* @noflip */',
|
31
|
-
height: 'var(--fui-positioning-arrow-height)',
|
32
|
-
width: 'var(--fui-positioning-arrow-height)',
|
33
28
|
'::before': {
|
34
29
|
content: '""',
|
35
|
-
|
30
|
+
visibility: 'visible',
|
31
|
+
position: 'absolute',
|
32
|
+
boxSizing: 'border-box',
|
33
|
+
width: 'inherit',
|
34
|
+
height: 'inherit',
|
36
35
|
backgroundColor: 'inherit',
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
borderBottomLeftRadius: `${_reacttheme.tokens.borderRadiusSmall} /* @noflip */`,
|
42
|
-
clipPath: 'polygon(0% 0%, 100% 100%, 0% 100%)'
|
36
|
+
borderRight: `${borderWidth} ${borderStyle} ${borderColor} /* @noflip */`,
|
37
|
+
borderBottom: `${borderWidth} ${borderStyle} ${borderColor}`,
|
38
|
+
borderBottomRightRadius: _reacttheme.tokens.borderRadiusSmall,
|
39
|
+
transform: 'rotate(var(--fui-positioning-angle)) translate(0, 50%) rotate(45deg) /* @noflip */'
|
43
40
|
},
|
44
41
|
// Popper sets data-popper-placement on the root element, which is used to align the arrow
|
45
42
|
':global([data-popper-placement^="top"])': {
|
46
|
-
bottom:
|
47
|
-
'--fui-positioning-
|
43
|
+
bottom: `-${borderWidth}`,
|
44
|
+
'--fui-positioning-angle': '0'
|
48
45
|
},
|
49
46
|
':global([data-popper-placement^="right"])': {
|
50
|
-
left:
|
51
|
-
'--fui-positioning-
|
47
|
+
left: `-${borderWidth} /* @noflip */`,
|
48
|
+
'--fui-positioning-angle': '90deg'
|
52
49
|
},
|
53
50
|
':global([data-popper-placement^="bottom"])': {
|
54
|
-
top:
|
55
|
-
'--fui-positioning-
|
51
|
+
top: `-${borderWidth}`,
|
52
|
+
'--fui-positioning-angle': '180deg'
|
56
53
|
},
|
57
54
|
':global([data-popper-placement^="left"])': {
|
58
|
-
right:
|
59
|
-
'--fui-positioning-
|
55
|
+
right: `-${borderWidth} /* @noflip */`,
|
56
|
+
'--fui-positioning-angle': '270deg'
|
60
57
|
}
|
61
58
|
};
|
62
59
|
}
|
63
60
|
function createArrowHeightStyles(arrowHeight) {
|
64
61
|
// The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.
|
65
62
|
// Multiply the triangle's height by sqrt(2) to get length of its edges.
|
66
|
-
const edgeLength = 1.414 * arrowHeight
|
63
|
+
const edgeLength = `${1.414 * arrowHeight}px`;
|
67
64
|
return {
|
68
|
-
|
69
|
-
|
65
|
+
width: edgeLength,
|
66
|
+
height: edgeLength
|
70
67
|
};
|
71
68
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["createArrowStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\n\n/**\n * @internal\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 * @internal\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
|
1
|
+
{"version":3,"sources":["createArrowStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\n\n/**\n * @internal\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 * @internal\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 borderRight: `${borderWidth} ${borderStyle} ${borderColor} /* @noflip */`,\n borderBottom: `${borderWidth} ${borderStyle} ${borderColor}`,\n borderBottomRightRadius: tokens.borderRadiusSmall,\n transform: 'rotate(var(--fui-positioning-angle)) translate(0, 50%) rotate(45deg) /* @noflip */',\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 '--fui-positioning-angle': '0',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `-${borderWidth} /* @noflip */`,\n '--fui-positioning-angle': '90deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: `-${borderWidth}`,\n '--fui-positioning-angle': '180deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `-${borderWidth} /* @noflip */`,\n '--fui-positioning-angle': '270deg',\n },\n };\n}\n\n/**\n * @internal\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"],"names":["createArrowHeightStyles","createArrowStyles","options","arrowHeight","borderWidth","borderStyle","borderColor","tokens","colorTransparentStroke","position","backgroundColor","visibility","zIndex","content","boxSizing","width","height","borderRight","borderBottom","borderBottomRightRadius","borderRadiusSmall","transform","bottom","left","top","right","edgeLength"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAsHgBA,uBAAAA;eAAAA;;IAzDAC,iBAAAA;eAAAA;;;4BA7DO;AA6DhB,SAASA,kBAAkBC,OAAiC;IACjE,MAAM,EACJC,WAAW,EACXC,cAAc,KAAK,EACnBC,cAAc,OAAO,EACrBC,cAAcC,kBAAAA,CAAOC,sBAAsB,EAC5C,GAAGN;IAEJ,OAAO;QACLO,UAAU;QACVC,iBAAiB;QACjBC,YAAY;QACZC,QAAQ,CAAC;QAET,GAAIT,eAAeH,wBAAwBG,YAAY;QAEvD,YAAY;YACVU,SAAS;YACTF,YAAY;YACZF,UAAU;YACVK,WAAW;YACXC,OAAO;YACPC,QAAQ;YACRN,iBAAiB;YACjBO,aAAa,CAAC,EAAEb,YAAY,CAAC,EAAEC,YAAY,CAAC,EAAEC,YAAY,cAAc,CAAC;YACzEY,cAAc,CAAC,EAAEd,YAAY,CAAC,EAAEC,YAAY,CAAC,EAAEC,YAAY,CAAC;YAC5Da,yBAAyBZ,kBAAAA,CAAOa,iBAAiB;YACjDC,WAAW;QACb;QAEA,0FAA0F;QAC1F,2CAA2C;YACzCC,QAAQ,CAAC,CAAC,EAAElB,YAAY,CAAC;YACzB,2BAA2B;QAC7B;QACA,6CAA6C;YAC3CmB,MAAM,CAAC,CAAC,EAAEnB,YAAY,cAAc,CAAC;YACrC,2BAA2B;QAC7B;QACA,8CAA8C;YAC5CoB,KAAK,CAAC,CAAC,EAAEpB,YAAY,CAAC;YACtB,2BAA2B;QAC7B;QACA,4CAA4C;YAC1CqB,OAAO,CAAC,CAAC,EAAErB,YAAY,cAAc,CAAC;YACtC,2BAA2B;QAC7B;IACF;AACF;AASO,SAASJ,wBAAwBG,WAAmB;IACzD,qGAAqG;IACrG,wEAAwE;IACxE,MAAMuB,aAAa,CAAC,EAAE,QAAQvB,YAAY,EAAE,CAAC;IAC7C,OAAO;QAAEY,OAAOW;QAAYV,QAAQU;IAAW;AACjD"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-positioning",
|
3
|
-
"version": "0.0.0-nightly-
|
3
|
+
"version": "0.0.0-nightly-20240816-2133.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",
|
@@ -31,9 +31,9 @@
|
|
31
31
|
"dependencies": {
|
32
32
|
"@floating-ui/dom": "^1.2.0",
|
33
33
|
"@floating-ui/devtools": "0.2.1",
|
34
|
-
"@fluentui/react-shared-contexts": "0.0.0-nightly-
|
35
|
-
"@fluentui/react-theme": "0.0.0-nightly-
|
36
|
-
"@fluentui/react-utilities": "0.0.0-nightly-
|
34
|
+
"@fluentui/react-shared-contexts": "0.0.0-nightly-20240816-2133.1",
|
35
|
+
"@fluentui/react-theme": "0.0.0-nightly-20240816-2133.1",
|
36
|
+
"@fluentui/react-utilities": "0.0.0-nightly-20240816-2133.1",
|
37
37
|
"@griffel/react": "^1.5.22",
|
38
38
|
"@swc/helpers": "^0.5.1"
|
39
39
|
},
|