@fluentui/react-positioning 9.15.6 → 9.15.8

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,12 +1,30 @@
1
1
  # Change Log - @fluentui/react-positioning
2
2
 
3
- This log was last generated on Tue, 23 Jul 2024 20:09:20 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 10 Sep 2024 10:15:11 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.15.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.15.8)
8
+
9
+ Tue, 10 Sep 2024 10:15:11 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.15.7..@fluentui/react-positioning_v9.15.8)
11
+
12
+ ### Patches
13
+
14
+ - Bump @fluentui/react-utilities to v9.18.14 ([PR #32494](https://github.com/microsoft/fluentui/pull/32494) by beachball)
15
+
16
+ ## [9.15.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.15.7)
17
+
18
+ Tue, 30 Jul 2024 18:47:34 GMT
19
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.15.6..@fluentui/react-positioning_v9.15.7)
20
+
21
+ ### Patches
22
+
23
+ - fix: improve arrow styles implementation ([PR #32092](https://github.com/microsoft/fluentui/pull/32092) by olfedias@microsoft.com)
24
+
7
25
  ## [9.15.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-positioning_v9.15.6)
8
26
 
9
- Tue, 23 Jul 2024 20:09:20 GMT
27
+ Tue, 23 Jul 2024 20:13:14 GMT
10
28
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-positioning_v9.15.5..@fluentui/react-positioning_v9.15.6)
11
29
 
12
30
  ### Patches
package/dist/index.d.ts CHANGED
@@ -14,10 +14,7 @@ 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): {
18
- width: string;
19
- height: string;
20
- };
17
+ export declare function createArrowHeightStyles(arrowHeight: number): GriffelStyle;
21
18
 
22
19
  /**
23
20
  * @internal
@@ -24,40 +24,43 @@ 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',
27
28
  position: 'absolute',
28
- backgroundColor: 'inherit',
29
- visibility: 'hidden',
30
29
  zIndex: -1,
31
30
  ...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)',
32
37
  '::before': {
33
38
  content: '""',
34
- visibility: 'visible',
35
- position: 'absolute',
36
- boxSizing: 'border-box',
37
- width: 'inherit',
38
- height: 'inherit',
39
+ display: 'block',
39
40
  backgroundColor: 'inherit',
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 */'
41
+ margin: `-${borderWidth}`,
42
+ width: '100%',
43
+ height: '100%',
44
+ border: `${borderWidth} ${borderStyle} ${borderColor}`,
45
+ borderBottomLeftRadius: `${tokens.borderRadiusSmall} /* @noflip */`,
46
+ clipPath: 'polygon(0% 0%, 100% 100%, 0% 100%)'
44
47
  },
45
48
  // Popper sets data-popper-placement on the root element, which is used to align the arrow
46
49
  ':global([data-popper-placement^="top"])': {
47
- bottom: `-${borderWidth}`,
48
- '--fui-positioning-angle': '0'
50
+ bottom: 'var(--fui-positioning-arrow-offset)',
51
+ '--fui-positioning-arrow-angle': '-45deg'
49
52
  },
50
53
  ':global([data-popper-placement^="right"])': {
51
- left: `-${borderWidth} /* @noflip */`,
52
- '--fui-positioning-angle': '90deg'
54
+ left: `var(--fui-positioning-arrow-offset) /* @noflip */`,
55
+ '--fui-positioning-arrow-angle': '45deg'
53
56
  },
54
57
  ':global([data-popper-placement^="bottom"])': {
55
- top: `-${borderWidth}`,
56
- '--fui-positioning-angle': '180deg'
58
+ top: 'var(--fui-positioning-arrow-offset)',
59
+ '--fui-positioning-arrow-angle': '135deg'
57
60
  },
58
61
  ':global([data-popper-placement^="left"])': {
59
- right: `-${borderWidth} /* @noflip */`,
60
- '--fui-positioning-angle': '270deg'
62
+ right: `var(--fui-positioning-arrow-offset) /* @noflip */`,
63
+ '--fui-positioning-arrow-angle': '225deg'
61
64
  }
62
65
  };
63
66
  }
@@ -70,9 +73,9 @@ import { tokens } from '@fluentui/react-theme';
70
73
  */ export function createArrowHeightStyles(arrowHeight) {
71
74
  // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.
72
75
  // Multiply the triangle's height by sqrt(2) to get length of its edges.
73
- const edgeLength = `${1.414 * arrowHeight}px`;
76
+ const edgeLength = 1.414 * arrowHeight;
74
77
  return {
75
- width: edgeLength,
76
- height: edgeLength
78
+ '--fui-positioning-arrow-height': `${edgeLength}px`,
79
+ '--fui-positioning-arrow-offset': `${edgeLength / 2 * -1}px`
77
80
  };
78
81
  }
@@ -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 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"}
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 boxSizing: 'border-box',\n position: 'absolute',\n zIndex: -1,\n\n ...(arrowHeight && createArrowHeightStyles(arrowHeight)),\n\n backgroundColor: 'inherit',\n backgroundClip: 'content-box',\n\n borderBottomLeftRadius: `${tokens.borderRadiusSmall} /* @noflip */`,\n transform: 'rotate(var(--fui-positioning-arrow-angle)) /* @noflip */',\n\n height: 'var(--fui-positioning-arrow-height)',\n width: 'var(--fui-positioning-arrow-height)',\n\n '::before': {\n content: '\"\"',\n\n display: 'block',\n backgroundColor: 'inherit',\n margin: `-${borderWidth}`,\n width: '100%',\n height: '100%',\n\n border: `${borderWidth} ${borderStyle} ${borderColor}`,\n borderBottomLeftRadius: `${tokens.borderRadiusSmall} /* @noflip */`,\n\n clipPath: 'polygon(0% 0%, 100% 100%, 0% 100%)',\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: 'var(--fui-positioning-arrow-offset)',\n '--fui-positioning-arrow-angle': '-45deg',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `var(--fui-positioning-arrow-offset) /* @noflip */`,\n '--fui-positioning-arrow-angle': '45deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: 'var(--fui-positioning-arrow-offset)',\n '--fui-positioning-arrow-angle': '135deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `var(--fui-positioning-arrow-offset) /* @noflip */`,\n '--fui-positioning-arrow-angle': '225deg',\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): GriffelStyle {\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;\n\n return {\n '--fui-positioning-arrow-height': `${edgeLength}px`,\n '--fui-positioning-arrow-offset': `${(edgeLength / 2) * -1}px`,\n };\n}\n"],"names":["tokens","createArrowStyles","options","arrowHeight","borderWidth","borderStyle","borderColor","colorTransparentStroke","boxSizing","position","zIndex","createArrowHeightStyles","backgroundColor","backgroundClip","borderBottomLeftRadius","borderRadiusSmall","transform","height","width","content","display","margin","border","clipPath","bottom","left","top","right","edgeLength"],"rangeMappings":";;;;;;;;;;;;;;;;;;;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CAAC;QACnD,kCAAkC,CAAC,EAAE,AAACA,aAAa,IAAK,CAAC,EAAE,EAAE,CAAC;IAChE;AACF"}
@@ -20,49 +20,52 @@ 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',
23
24
  position: 'absolute',
24
- backgroundColor: 'inherit',
25
- visibility: 'hidden',
26
25
  zIndex: -1,
27
26
  ...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)',
28
33
  '::before': {
29
34
  content: '""',
30
- visibility: 'visible',
31
- position: 'absolute',
32
- boxSizing: 'border-box',
33
- width: 'inherit',
34
- height: 'inherit',
35
+ display: 'block',
35
36
  backgroundColor: 'inherit',
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 */'
37
+ margin: `-${borderWidth}`,
38
+ width: '100%',
39
+ height: '100%',
40
+ border: `${borderWidth} ${borderStyle} ${borderColor}`,
41
+ borderBottomLeftRadius: `${_reacttheme.tokens.borderRadiusSmall} /* @noflip */`,
42
+ clipPath: 'polygon(0% 0%, 100% 100%, 0% 100%)'
40
43
  },
41
44
  // Popper sets data-popper-placement on the root element, which is used to align the arrow
42
45
  ':global([data-popper-placement^="top"])': {
43
- bottom: `-${borderWidth}`,
44
- '--fui-positioning-angle': '0'
46
+ bottom: 'var(--fui-positioning-arrow-offset)',
47
+ '--fui-positioning-arrow-angle': '-45deg'
45
48
  },
46
49
  ':global([data-popper-placement^="right"])': {
47
- left: `-${borderWidth} /* @noflip */`,
48
- '--fui-positioning-angle': '90deg'
50
+ left: `var(--fui-positioning-arrow-offset) /* @noflip */`,
51
+ '--fui-positioning-arrow-angle': '45deg'
49
52
  },
50
53
  ':global([data-popper-placement^="bottom"])': {
51
- top: `-${borderWidth}`,
52
- '--fui-positioning-angle': '180deg'
54
+ top: 'var(--fui-positioning-arrow-offset)',
55
+ '--fui-positioning-arrow-angle': '135deg'
53
56
  },
54
57
  ':global([data-popper-placement^="left"])': {
55
- right: `-${borderWidth} /* @noflip */`,
56
- '--fui-positioning-angle': '270deg'
58
+ right: `var(--fui-positioning-arrow-offset) /* @noflip */`,
59
+ '--fui-positioning-arrow-angle': '225deg'
57
60
  }
58
61
  };
59
62
  }
60
63
  function createArrowHeightStyles(arrowHeight) {
61
64
  // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.
62
65
  // Multiply the triangle's height by sqrt(2) to get length of its edges.
63
- const edgeLength = `${1.414 * arrowHeight}px`;
66
+ const edgeLength = 1.414 * arrowHeight;
64
67
  return {
65
- width: edgeLength,
66
- height: edgeLength
68
+ '--fui-positioning-arrow-height': `${edgeLength}px`,
69
+ '--fui-positioning-arrow-offset': `${edgeLength / 2 * -1}px`
67
70
  };
68
71
  }
@@ -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 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"}
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 boxSizing: 'border-box',\n position: 'absolute',\n zIndex: -1,\n\n ...(arrowHeight && createArrowHeightStyles(arrowHeight)),\n\n backgroundColor: 'inherit',\n backgroundClip: 'content-box',\n\n borderBottomLeftRadius: `${tokens.borderRadiusSmall} /* @noflip */`,\n transform: 'rotate(var(--fui-positioning-arrow-angle)) /* @noflip */',\n\n height: 'var(--fui-positioning-arrow-height)',\n width: 'var(--fui-positioning-arrow-height)',\n\n '::before': {\n content: '\"\"',\n\n display: 'block',\n backgroundColor: 'inherit',\n margin: `-${borderWidth}`,\n width: '100%',\n height: '100%',\n\n border: `${borderWidth} ${borderStyle} ${borderColor}`,\n borderBottomLeftRadius: `${tokens.borderRadiusSmall} /* @noflip */`,\n\n clipPath: 'polygon(0% 0%, 100% 100%, 0% 100%)',\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: 'var(--fui-positioning-arrow-offset)',\n '--fui-positioning-arrow-angle': '-45deg',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `var(--fui-positioning-arrow-offset) /* @noflip */`,\n '--fui-positioning-arrow-angle': '45deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: 'var(--fui-positioning-arrow-offset)',\n '--fui-positioning-arrow-angle': '135deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `var(--fui-positioning-arrow-offset) /* @noflip */`,\n '--fui-positioning-arrow-angle': '225deg',\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): GriffelStyle {\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;\n\n return {\n '--fui-positioning-arrow-height': `${edgeLength}px`,\n '--fui-positioning-arrow-offset': `${(edgeLength / 2) * -1}px`,\n };\n}\n"],"names":["createArrowHeightStyles","createArrowStyles","options","arrowHeight","borderWidth","borderStyle","borderColor","tokens","colorTransparentStroke","boxSizing","position","zIndex","backgroundColor","backgroundClip","borderBottomLeftRadius","borderRadiusSmall","transform","height","width","content","display","margin","border","clipPath","bottom","left","top","right","edgeLength"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IA+HgBA,uBAAAA;eAAAA;;IAlEAC,iBAAAA;eAAAA;;;4BA7DO;AA6DhB,SAASA,kBAAkBC,OA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.8",
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",
@@ -33,7 +33,7 @@
33
33
  "@floating-ui/devtools": "0.2.1",
34
34
  "@fluentui/react-shared-contexts": "^9.20.0",
35
35
  "@fluentui/react-theme": "^9.1.19",
36
- "@fluentui/react-utilities": "^9.18.13",
36
+ "@fluentui/react-utilities": "^9.18.14",
37
37
  "@griffel/react": "^1.5.22",
38
38
  "@swc/helpers": "^0.5.1"
39
39
  },