@fluentui/react-positioning 9.5.5 → 9.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. package/.swcrc +30 -0
  2. package/CHANGELOG.json +55 -1
  3. package/CHANGELOG.md +24 -2
  4. package/lib/constants.js.map +1 -1
  5. package/lib/createArrowStyles.js.map +1 -1
  6. package/lib/createPositionManager.js.map +1 -1
  7. package/lib/createVirtualElementFromClick.js +1 -2
  8. package/lib/createVirtualElementFromClick.js.map +1 -1
  9. package/lib/index.js.map +1 -1
  10. package/lib/middleware/coverTarget.js.map +1 -1
  11. package/lib/middleware/flip.js.map +1 -1
  12. package/lib/middleware/index.js.map +1 -1
  13. package/lib/middleware/intersecting.js.map +1 -1
  14. package/lib/middleware/maxSize.js.map +1 -1
  15. package/lib/middleware/offset.js.map +1 -1
  16. package/lib/middleware/shift.js.map +1 -1
  17. package/lib/types.js +1 -1
  18. package/lib/types.js.map +1 -1
  19. package/lib/usePositioning.js +23 -21
  20. package/lib/usePositioning.js.map +1 -1
  21. package/lib/usePositioningMouseTarget.js.map +1 -1
  22. package/lib/utils/debounce.js +1 -2
  23. package/lib/utils/debounce.js.map +1 -1
  24. package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
  25. package/lib/utils/getBoundary.js.map +1 -1
  26. package/lib/utils/getFloatingUIOffset.js.map +1 -1
  27. package/lib/utils/getReactFiberFromNode.js +1 -0
  28. package/lib/utils/getReactFiberFromNode.js.map +1 -1
  29. package/lib/utils/getScrollParent.js +5 -6
  30. package/lib/utils/getScrollParent.js.map +1 -1
  31. package/lib/utils/hasAutoFocusFilter.js +2 -2
  32. package/lib/utils/hasAutoFocusFilter.js.map +1 -1
  33. package/lib/utils/index.js.map +1 -1
  34. package/lib/utils/mergeArrowOffset.js +3 -4
  35. package/lib/utils/mergeArrowOffset.js.map +1 -1
  36. package/lib/utils/parseFloatingUIPlacement.js +1 -2
  37. package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
  38. package/lib/utils/resolvePositioningShorthand.js.map +1 -1
  39. package/lib/utils/toFloatingUIPadding.js.map +1 -1
  40. package/lib/utils/toFloatingUIPlacement.js.map +1 -1
  41. package/lib/utils/toggleScrollListener.js.map +1 -1
  42. package/lib/utils/useCallbackRef.js.map +1 -1
  43. package/lib/utils/writeArrowUpdates.js +1 -2
  44. package/lib/utils/writeArrowUpdates.js.map +1 -1
  45. package/lib/utils/writeContainerupdates.js +4 -4
  46. package/lib/utils/writeContainerupdates.js.map +1 -1
  47. package/lib-commonjs/constants.js +18 -7
  48. package/lib-commonjs/constants.js.map +1 -1
  49. package/lib-commonjs/createArrowStyles.js +60 -88
  50. package/lib-commonjs/createArrowStyles.js.map +1 -1
  51. package/lib-commonjs/createPositionManager.js +103 -117
  52. package/lib-commonjs/createPositionManager.js.map +1 -1
  53. package/lib-commonjs/createVirtualElementFromClick.js +27 -26
  54. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  55. package/lib-commonjs/index.js +24 -51
  56. package/lib-commonjs/index.js.map +1 -1
  57. package/lib-commonjs/middleware/coverTarget.js +34 -37
  58. package/lib-commonjs/middleware/coverTarget.js.map +1 -1
  59. package/lib-commonjs/middleware/flip.js +31 -38
  60. package/lib-commonjs/middleware/flip.js.map +1 -1
  61. package/lib-commonjs/middleware/index.js +10 -9
  62. package/lib-commonjs/middleware/index.js.map +1 -1
  63. package/lib-commonjs/middleware/intersecting.js +24 -22
  64. package/lib-commonjs/middleware/intersecting.js.map +1 -1
  65. package/lib-commonjs/middleware/maxSize.js +34 -40
  66. package/lib-commonjs/middleware/maxSize.js.map +1 -1
  67. package/lib-commonjs/middleware/offset.js +11 -12
  68. package/lib-commonjs/middleware/offset.js.map +1 -1
  69. package/lib-commonjs/middleware/shift.js +29 -37
  70. package/lib-commonjs/middleware/shift.js.map +1 -1
  71. package/lib-commonjs/types.js +5 -2
  72. package/lib-commonjs/types.js.map +1 -1
  73. package/lib-commonjs/usePositioning.js +200 -164
  74. package/lib-commonjs/usePositioning.js.map +1 -1
  75. package/lib-commonjs/usePositioningMouseTarget.js +34 -37
  76. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
  77. package/lib-commonjs/utils/debounce.js +22 -21
  78. package/lib-commonjs/utils/debounce.js.map +1 -1
  79. package/lib-commonjs/utils/fromFloatingUIPlacement.js +30 -35
  80. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
  81. package/lib-commonjs/utils/getBoundary.js +21 -22
  82. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  83. package/lib-commonjs/utils/getFloatingUIOffset.js +23 -35
  84. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
  85. package/lib-commonjs/utils/getReactFiberFromNode.js +45 -41
  86. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  87. package/lib-commonjs/utils/getScrollParent.js +52 -56
  88. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  89. package/lib-commonjs/utils/hasAutoFocusFilter.js +18 -17
  90. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
  91. package/lib-commonjs/utils/index.js +19 -18
  92. package/lib-commonjs/utils/index.js.map +1 -1
  93. package/lib-commonjs/utils/mergeArrowOffset.js +33 -32
  94. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  95. package/lib-commonjs/utils/parseFloatingUIPlacement.js +15 -14
  96. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
  97. package/lib-commonjs/utils/resolvePositioningShorthand.js +63 -61
  98. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  99. package/lib-commonjs/utils/toFloatingUIPadding.js +23 -25
  100. package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
  101. package/lib-commonjs/utils/toFloatingUIPlacement.js +31 -33
  102. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
  103. package/lib-commonjs/utils/toggleScrollListener.js +20 -24
  104. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
  105. package/lib-commonjs/utils/useCallbackRef.js +39 -53
  106. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  107. package/lib-commonjs/utils/writeArrowUpdates.js +19 -24
  108. package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
  109. package/lib-commonjs/utils/writeContainerupdates.js +37 -45
  110. package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
  111. package/package.json +7 -6
  112. package/lib-amd/constants.js +0 -10
  113. package/lib-amd/constants.js.map +0 -1
  114. package/lib-amd/createArrowStyles.js +0 -62
  115. package/lib-amd/createArrowStyles.js.map +0 -1
  116. package/lib-amd/createPositionManager.js +0 -97
  117. package/lib-amd/createPositionManager.js.map +0 -1
  118. package/lib-amd/createVirtualElementFromClick.js +0 -32
  119. package/lib-amd/createVirtualElementFromClick.js.map +0 -1
  120. package/lib-amd/index.js +0 -13
  121. package/lib-amd/index.js.map +0 -1
  122. package/lib-amd/middleware/coverTarget.js +0 -32
  123. package/lib-amd/middleware/coverTarget.js.map +0 -1
  124. package/lib-amd/middleware/flip.js +0 -19
  125. package/lib-amd/middleware/flip.js.map +0 -1
  126. package/lib-amd/middleware/index.js +0 -11
  127. package/lib-amd/middleware/index.js.map +0 -1
  128. package/lib-amd/middleware/intersecting.js +0 -33
  129. package/lib-amd/middleware/intersecting.js.map +0 -1
  130. package/lib-amd/middleware/maxSize.js +0 -33
  131. package/lib-amd/middleware/maxSize.js.map +0 -1
  132. package/lib-amd/middleware/offset.js +0 -14
  133. package/lib-amd/middleware/offset.js.map +0 -1
  134. package/lib-amd/middleware/shift.js +0 -17
  135. package/lib-amd/middleware/shift.js.map +0 -1
  136. package/lib-amd/types.js +0 -5
  137. package/lib-amd/types.js.map +0 -1
  138. package/lib-amd/usePositioning.js +0 -161
  139. package/lib-amd/usePositioning.js.map +0 -1
  140. package/lib-amd/usePositioningMouseTarget.js +0 -39
  141. package/lib-amd/usePositioningMouseTarget.js.map +0 -1
  142. package/lib-amd/utils/debounce.js +0 -27
  143. package/lib-amd/utils/debounce.js.map +0 -1
  144. package/lib-amd/utils/fromFloatingUIPlacement.js +0 -37
  145. package/lib-amd/utils/fromFloatingUIPlacement.js.map +0 -1
  146. package/lib-amd/utils/getBoundary.js +0 -26
  147. package/lib-amd/utils/getBoundary.js.map +0 -1
  148. package/lib-amd/utils/getFloatingUIOffset.js +0 -25
  149. package/lib-amd/utils/getFloatingUIOffset.js.map +0 -1
  150. package/lib-amd/utils/getReactFiberFromNode.js +0 -48
  151. package/lib-amd/utils/getReactFiberFromNode.js.map +0 -1
  152. package/lib-amd/utils/getScrollParent.js +0 -64
  153. package/lib-amd/utils/getScrollParent.js.map +0 -1
  154. package/lib-amd/utils/hasAutoFocusFilter.js +0 -31
  155. package/lib-amd/utils/hasAutoFocusFilter.js.map +0 -1
  156. package/lib-amd/utils/index.js +0 -20
  157. package/lib-amd/utils/index.js.map +0 -1
  158. package/lib-amd/utils/mergeArrowOffset.js +0 -38
  159. package/lib-amd/utils/mergeArrowOffset.js.map +0 -1
  160. package/lib-amd/utils/parseFloatingUIPlacement.js +0 -20
  161. package/lib-amd/utils/parseFloatingUIPlacement.js.map +0 -1
  162. package/lib-amd/utils/resolvePositioningShorthand.js +0 -31
  163. package/lib-amd/utils/resolvePositioningShorthand.js.map +0 -1
  164. package/lib-amd/utils/toFloatingUIPadding.js +0 -25
  165. package/lib-amd/utils/toFloatingUIPadding.js.map +0 -1
  166. package/lib-amd/utils/toFloatingUIPlacement.js +0 -40
  167. package/lib-amd/utils/toFloatingUIPlacement.js.map +0 -1
  168. package/lib-amd/utils/toggleScrollListener.js +0 -26
  169. package/lib-amd/utils/toggleScrollListener.js.map +0 -1
  170. package/lib-amd/utils/useCallbackRef.js +0 -55
  171. package/lib-amd/utils/useCallbackRef.js.map +0 -1
  172. package/lib-amd/utils/writeArrowUpdates.js +0 -21
  173. package/lib-amd/utils/writeArrowUpdates.js.map +0 -1
  174. package/lib-amd/utils/writeContainerupdates.js +0 -41
  175. package/lib-amd/utils/writeContainerupdates.js.map +0 -1
@@ -1,95 +1,67 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ createArrowStyles: ()=>createArrowStyles,
13
+ createArrowHeightStyles: ()=>createArrowHeightStyles
5
14
  });
6
- exports.createArrowHeightStyles = exports.createArrowStyles = void 0;
7
- const react_1 = /*#__PURE__*/require("@griffel/react");
8
- const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
9
- /**
10
- * @internal
11
- * Helper that creates a makeStyles rule for an arrow element.
12
- * For runtime arrow size toggling simply create extra classnames to apply to the arrow element
13
- *
14
- * ```ts
15
- * makeStyles({
16
- * arrowWithSize: createArrowStyles({ arrowHeight: 6 }),
17
- *
18
- * arrowWithoutSize: createArrowStyles({ arrowHeight: undefined }),
19
- * mediumArrow: createArrowHeightStyles(4),
20
- * smallArrow: createArrowHeightStyles(2),
21
- * })
22
- * ...
23
- *
24
- * state.arrowWithSize.className = styles.arrowWithSize;
25
- * state.arrowWithoutSize.className = mergeClasses(
26
- * styles.arrowWithoutSize,
27
- * state.smallArrow && styles.smallArrow,
28
- * state.mediumArrow && styles.mediumArrow,
29
- * )
30
- * ```
31
- */
15
+ const _react = require("@griffel/react");
16
+ const _reactTheme = require("@fluentui/react-theme");
32
17
  function createArrowStyles(options) {
33
- const {
34
- arrowHeight,
35
- borderWidth = '1px',
36
- borderStyle = 'solid',
37
- borderColor = react_theme_1.tokens.colorTransparentStroke
38
- } = options;
39
- return {
40
- position: 'absolute',
41
- backgroundColor: 'inherit',
42
- visibility: 'hidden',
43
- zIndex: -1,
44
- ...(arrowHeight && createArrowHeightStyles(arrowHeight)),
45
- '::before': {
46
- content: '""',
47
- visibility: 'visible',
48
- position: 'absolute',
49
- boxSizing: 'border-box',
50
- width: 'inherit',
51
- height: 'inherit',
52
- backgroundColor: 'inherit',
53
- ...react_1.shorthands.borderRight(`${borderWidth} /* @noflip */`, `${borderStyle} /* @noflip */`, `${borderColor} /* @noflip */`),
54
- ...react_1.shorthands.borderBottom(borderWidth, borderStyle, borderColor),
55
- borderBottomRightRadius: react_theme_1.tokens.borderRadiusSmall,
56
- transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)'
57
- },
58
- // Popper sets data-popper-placement on the root element, which is used to align the arrow
59
- ':global([data-popper-placement^="top"])': {
60
- bottom: `-${borderWidth}`,
61
- '--angle': '0'
62
- },
63
- ':global([data-popper-placement^="right"])': {
64
- left: `-${borderWidth} /* @noflip */`,
65
- '--angle': '90deg'
66
- },
67
- ':global([data-popper-placement^="bottom"])': {
68
- top: `-${borderWidth}`,
69
- '--angle': '180deg'
70
- },
71
- ':global([data-popper-placement^="left"])': {
72
- right: `-${borderWidth} /* @noflip */`,
73
- '--angle': '270deg'
74
- }
75
- };
18
+ const { arrowHeight , borderWidth ='1px' , borderStyle ='solid' , borderColor =_reactTheme.tokens.colorTransparentStroke } = options;
19
+ return {
20
+ position: 'absolute',
21
+ backgroundColor: 'inherit',
22
+ visibility: 'hidden',
23
+ zIndex: -1,
24
+ ...arrowHeight && createArrowHeightStyles(arrowHeight),
25
+ '::before': {
26
+ content: '""',
27
+ visibility: 'visible',
28
+ position: 'absolute',
29
+ boxSizing: 'border-box',
30
+ width: 'inherit',
31
+ height: 'inherit',
32
+ backgroundColor: 'inherit',
33
+ ..._react.shorthands.borderRight(`${borderWidth} /* @noflip */`, `${borderStyle} /* @noflip */`, `${borderColor} /* @noflip */`),
34
+ ..._react.shorthands.borderBottom(borderWidth, borderStyle, borderColor),
35
+ borderBottomRightRadius: _reactTheme.tokens.borderRadiusSmall,
36
+ transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)'
37
+ },
38
+ // Popper sets data-popper-placement on the root element, which is used to align the arrow
39
+ ':global([data-popper-placement^="top"])': {
40
+ bottom: `-${borderWidth}`,
41
+ '--angle': '0'
42
+ },
43
+ ':global([data-popper-placement^="right"])': {
44
+ left: `-${borderWidth} /* @noflip */`,
45
+ '--angle': '90deg'
46
+ },
47
+ ':global([data-popper-placement^="bottom"])': {
48
+ top: `-${borderWidth}`,
49
+ '--angle': '180deg'
50
+ },
51
+ ':global([data-popper-placement^="left"])': {
52
+ right: `-${borderWidth} /* @noflip */`,
53
+ '--angle': '270deg'
54
+ }
55
+ };
76
56
  }
77
- exports.createArrowStyles = createArrowStyles;
78
- /**
79
- * @internal
80
- * Creates CSS styles to size the arrow created by createArrowStyles to the given height.
81
- *
82
- * Use this when you need to create classes for several different arrow sizes. If you only need a
83
- * constant arrow size, you can pass the `arrowHeight` param to createArrowStyles instead.
84
- */
85
57
  function createArrowHeightStyles(arrowHeight) {
86
- // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.
87
- // Multiply the triangle's height by sqrt(2) to get length of its edges.
88
- const edgeLength = `${1.414 * arrowHeight}px`;
89
- return {
90
- width: edgeLength,
91
- height: edgeLength
92
- };
93
- }
94
- exports.createArrowHeightStyles = createArrowHeightStyles;
58
+ // The arrow is a square rotated 45 degrees to have its bottom and right edges form a right triangle.
59
+ // Multiply the triangle's height by sqrt(2) to get length of its edges.
60
+ const edgeLength = `${1.414 * arrowHeight}px`;
61
+ return {
62
+ width: edgeLength,
63
+ height: edgeLength
64
+ };
65
+ } //# sourceMappingURL=createArrowStyles.js.map
66
+
95
67
  //# sourceMappingURL=createArrowStyles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["react_1","require","react_theme_1","createArrowStyles","options","arrowHeight","borderWidth","borderStyle","borderColor","tokens","colorTransparentStroke","position","backgroundColor","visibility","zIndex","createArrowHeightStyles","content","boxSizing","width","height","shorthands","borderRight","borderBottom","borderBottomRightRadius","borderRadiusSmall","transform","bottom","left","top","right","exports","edgeLength"],"sources":["../src/packages/react-components/react-positioning/src/createArrowStyles.ts"],"sourcesContent":["import { shorthands } from '@griffel/react';\nimport { 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 ...shorthands.borderRight(\n `${borderWidth} /* @noflip */`,\n `${borderStyle} /* @noflip */`,\n `${borderColor} /* @noflip */`,\n ),\n ...shorthands.borderBottom(borderWidth, borderStyle, borderColor),\n borderBottomRightRadius: tokens.borderRadiusSmall,\n transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)',\n },\n\n // Popper sets data-popper-placement on the root element, which is used to align the arrow\n ':global([data-popper-placement^=\"top\"])': {\n bottom: `-${borderWidth}`,\n '--angle': '0',\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `-${borderWidth} /* @noflip */`,\n '--angle': '90deg',\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: `-${borderWidth}`,\n '--angle': '180deg',\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `-${borderWidth} /* @noflip */`,\n '--angle': '270deg',\n },\n };\n}\n\n/**\n * @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"],"mappings":";;;;;;AAAA,MAAAA,OAAA,gBAAAC,OAAA;AACA,MAAAC,aAAA,gBAAAD,OAAA;AAsCA;;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgBE,iBAAiBA,CAACC,OAAiC;EACjE,MAAM;IACJC,WAAW;IACXC,WAAW,GAAG,KAAK;IACnBC,WAAW,GAAG,OAAO;IACrBC,WAAW,GAAGN,aAAA,CAAAO,MAAM,CAACC;EAAsB,CAC5C,GAAGN,OAAO;EAEX,OAAO;IACLO,QAAQ,EAAE,UAAU;IAC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,CAAE;AAClD;AALAD,OAAA,CAAAf,uBAAA,GAAAA,uBAAA"}
1
+ {"version":3,"sources":["../lib/createArrowStyles.js"],"sourcesContent":["import { shorthands } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\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) {\n const {\n arrowHeight,\n borderWidth = '1px',\n borderStyle = 'solid',\n borderColor = tokens.colorTransparentStroke\n } = options;\n return {\n position: 'absolute',\n backgroundColor: 'inherit',\n visibility: 'hidden',\n zIndex: -1,\n ...(arrowHeight && createArrowHeightStyles(arrowHeight)),\n '::before': {\n content: '\"\"',\n visibility: 'visible',\n position: 'absolute',\n boxSizing: 'border-box',\n width: 'inherit',\n height: 'inherit',\n backgroundColor: 'inherit',\n ...shorthands.borderRight(`${borderWidth} /* @noflip */`, `${borderStyle} /* @noflip */`, `${borderColor} /* @noflip */`),\n ...shorthands.borderBottom(borderWidth, borderStyle, borderColor),\n borderBottomRightRadius: tokens.borderRadiusSmall,\n transform: 'rotate(var(--angle)) translate(0, 50%) rotate(45deg)'\n },\n // Popper sets data-popper-placement on the root element, which is used to align the arrow\n ':global([data-popper-placement^=\"top\"])': {\n bottom: `-${borderWidth}`,\n '--angle': '0'\n },\n ':global([data-popper-placement^=\"right\"])': {\n left: `-${borderWidth} /* @noflip */`,\n '--angle': '90deg'\n },\n ':global([data-popper-placement^=\"bottom\"])': {\n top: `-${borderWidth}`,\n '--angle': '180deg'\n },\n ':global([data-popper-placement^=\"left\"])': {\n right: `-${borderWidth} /* @noflip */`,\n '--angle': '270deg'\n }\n };\n}\n/**\n * @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) {\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 {\n width: edgeLength,\n height: edgeLength\n };\n}\n//# sourceMappingURL=createArrowStyles.js.map"],"names":["createArrowStyles","createArrowHeightStyles","options","arrowHeight","borderWidth","borderStyle","borderColor","tokens","colorTransparentStroke","position","backgroundColor","visibility","zIndex","content","boxSizing","width","height","shorthands","borderRight","borderBottom","borderBottomRightRadius","borderRadiusSmall","transform","bottom","left","top","right","edgeLength"],"mappings":";;;;;;;;;;;IAyBgBA,iBAAiB,MAAjBA;IAoDAC,uBAAuB,MAAvBA;;uBA7EW;4BACJ;AAwBhB,SAASD,kBAAkBE,OAAO,EAAE;IACzC,MAAM,EACJC,YAAW,EACXC,aAAc,MAAK,EACnBC,aAAc,QAAO,EACrBC,aAAcC,kBAAM,CAACC,sBAAsB,CAAA,EAC5C,GAAGN;IACJ,OAAO;QACLO,UAAU;QACVC,iBAAiB;QACjBC,YAAY;QACZC,QAAQ,CAAC;QACT,GAAIT,eAAeF,wBAAwBE,YAAY;QACvD,YAAY;YACVU,SAAS;YACTF,YAAY;YACZF,UAAU;YACVK,WAAW;YACXC,OAAO;YACPC,QAAQ;YACRN,iBAAiB;YACjB,GAAGO,iBAAU,CAACC,WAAW,CAAC,CAAC,EAAEd,YAAY,cAAc,CAAC,EAAE,CAAC,EAAEC,YAAY,cAAc,CAAC,EAAE,CAAC,EAAEC,YAAY,cAAc,CAAC,CAAC;YACzH,GAAGW,iBAAU,CAACE,YAAY,CAACf,aAAaC,aAAaC,YAAY;YACjEc,yBAAyBb,kBAAM,CAACc,iBAAiB;YACjDC,WAAW;QACb;QACA,0FAA0F;QAC1F,2CAA2C;YACzCC,QAAQ,CAAC,CAAC,EAAEnB,YAAY,CAAC;YACzB,WAAW;QACb;QACA,6CAA6C;YAC3CoB,MAAM,CAAC,CAAC,EAAEpB,YAAY,cAAc,CAAC;YACrC,WAAW;QACb;QACA,8CAA8C;YAC5CqB,KAAK,CAAC,CAAC,EAAErB,YAAY,CAAC;YACtB,WAAW;QACb;QACA,4CAA4C;YAC1CsB,OAAO,CAAC,CAAC,EAAEtB,YAAY,cAAc,CAAC;YACtC,WAAW;QACb;IACF;AACF;AAQO,SAASH,wBAAwBE,WAAW,EAAE;IACnD,qGAAqG;IACrG,wEAAwE;IACxE,MAAMwB,aAAa,CAAC,EAAE,QAAQxB,YAAY,EAAE,CAAC;IAC7C,OAAO;QACLY,OAAOY;QACPX,QAAQW;IACV;AACF,EACA,6CAA6C"}
@@ -1,127 +1,113 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "createPositionManager", {
6
+ enumerable: true,
7
+ get: ()=>createPositionManager
5
8
  });
6
- exports.createPositionManager = void 0;
7
- const dom_1 = /*#__PURE__*/require("@floating-ui/dom");
8
- const utils_1 = /*#__PURE__*/require("./utils");
9
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
10
- /**
11
- * @internal
12
- * @returns manager that handles positioning out of the react lifecycle
13
- */
9
+ const _dom = require("@floating-ui/dom");
10
+ const _utils = require("./utils");
11
+ const _reactUtilities = require("@fluentui/react-utilities");
14
12
  function createPositionManager(options) {
15
- const {
16
- container,
17
- target,
18
- arrow,
19
- strategy,
20
- middleware,
21
- placement
22
- } = options;
23
- let isDestroyed = false;
24
- if (!target || !container) {
25
- return {
26
- updatePosition: () => undefined,
27
- dispose: () => undefined
28
- };
29
- }
30
- let isFirstUpdate = true;
31
- const scrollParents = new Set();
32
- const targetWindow = container.ownerDocument.defaultView;
33
- // When the container is first resolved, set position `fixed` to avoid scroll jumps.
34
- // Without this scroll jumps can occur when the element is rendered initially and receives focus
35
- Object.assign(container.style, {
36
- position: 'fixed',
37
- left: 0,
38
- top: 0,
39
- margin: 0
40
- });
41
- const forceUpdate = () => {
42
- // debounced update can still occur afterwards
43
- // early return to avoid memory leaks
44
- if (isDestroyed) {
45
- return;
46
- }
47
- if (isFirstUpdate) {
48
- scrollParents.add(utils_1.getScrollParent(container));
49
- if (react_utilities_1.isHTMLElement(target)) {
50
- scrollParents.add(utils_1.getScrollParent(target));
51
- }
52
- scrollParents.forEach(scrollParent => {
53
- scrollParent.addEventListener('scroll', updatePosition);
54
- });
55
- isFirstUpdate = false;
13
+ const { container , target , arrow , strategy , middleware , placement } = options;
14
+ let isDestroyed = false;
15
+ if (!target || !container) {
16
+ return {
17
+ updatePosition: ()=>undefined,
18
+ dispose: ()=>undefined
19
+ };
56
20
  }
21
+ let isFirstUpdate = true;
22
+ const scrollParents = new Set();
23
+ const targetWindow = container.ownerDocument.defaultView;
24
+ // When the container is first resolved, set position `fixed` to avoid scroll jumps.
25
+ // Without this scroll jumps can occur when the element is rendered initially and receives focus
57
26
  Object.assign(container.style, {
58
- position: strategy
59
- });
60
- dom_1.computePosition(target, container, {
61
- placement,
62
- middleware,
63
- strategy
64
- }).then(({
65
- x,
66
- y,
67
- middlewareData,
68
- placement: computedPlacement
69
- }) => {
70
- // Promise can still resolve after destruction
71
- // early return to avoid applying outdated position
72
- if (isDestroyed) {
73
- return;
74
- }
75
- utils_1.writeArrowUpdates({
76
- arrow,
77
- middlewareData
78
- });
79
- utils_1.writeContainerUpdates({
80
- container,
81
- middlewareData,
82
- placement: computedPlacement,
83
- coordinates: {
84
- x,
85
- y
86
- },
87
- lowPPI: ((targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.devicePixelRatio) || 1) <= 1,
88
- strategy
89
- });
90
- }).catch(err => {
91
- // https://github.com/floating-ui/floating-ui/issues/1845
92
- // FIXME for node > 14
93
- // node 15 introduces promise rejection which means that any components
94
- // tests need to be `it('', async () => {})` otherwise there can be race conditions with
95
- // JSDOM being torn down before this promise is resolved so globals like `window` and `document` don't exist
96
- // Unless all tests that ever use `usePositioning` are turned into async tests, any logging during testing
97
- // will actually be counter productive
98
- if (process.env.NODE_ENV === 'development') {
99
- // eslint-disable-next-line no-console
100
- console.error('[usePositioning]: Failed to calculate position', err);
101
- }
27
+ position: 'fixed',
28
+ left: 0,
29
+ top: 0,
30
+ margin: 0
102
31
  });
103
- };
104
- const updatePosition = utils_1.debounce(() => forceUpdate());
105
- const dispose = () => {
106
- isDestroyed = true;
32
+ const forceUpdate = ()=>{
33
+ // debounced update can still occur afterwards
34
+ // early return to avoid memory leaks
35
+ if (isDestroyed) {
36
+ return;
37
+ }
38
+ if (isFirstUpdate) {
39
+ scrollParents.add((0, _utils.getScrollParent)(container));
40
+ if ((0, _reactUtilities.isHTMLElement)(target)) {
41
+ scrollParents.add((0, _utils.getScrollParent)(target));
42
+ }
43
+ scrollParents.forEach((scrollParent)=>{
44
+ scrollParent.addEventListener('scroll', updatePosition);
45
+ });
46
+ isFirstUpdate = false;
47
+ }
48
+ Object.assign(container.style, {
49
+ position: strategy
50
+ });
51
+ (0, _dom.computePosition)(target, container, {
52
+ placement,
53
+ middleware,
54
+ strategy
55
+ }).then(({ x , y , middlewareData , placement: computedPlacement })=>{
56
+ // Promise can still resolve after destruction
57
+ // early return to avoid applying outdated position
58
+ if (isDestroyed) {
59
+ return;
60
+ }
61
+ (0, _utils.writeArrowUpdates)({
62
+ arrow,
63
+ middlewareData
64
+ });
65
+ (0, _utils.writeContainerUpdates)({
66
+ container,
67
+ middlewareData,
68
+ placement: computedPlacement,
69
+ coordinates: {
70
+ x,
71
+ y
72
+ },
73
+ lowPPI: ((targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.devicePixelRatio) || 1) <= 1,
74
+ strategy
75
+ });
76
+ }).catch((err)=>{
77
+ // https://github.com/floating-ui/floating-ui/issues/1845
78
+ // FIXME for node > 14
79
+ // node 15 introduces promise rejection which means that any components
80
+ // tests need to be `it('', async () => {})` otherwise there can be race conditions with
81
+ // JSDOM being torn down before this promise is resolved so globals like `window` and `document` don't exist
82
+ // Unless all tests that ever use `usePositioning` are turned into async tests, any logging during testing
83
+ // will actually be counter productive
84
+ if (process.env.NODE_ENV === 'development') {
85
+ // eslint-disable-next-line no-console
86
+ console.error('[usePositioning]: Failed to calculate position', err);
87
+ }
88
+ });
89
+ };
90
+ const updatePosition = (0, _utils.debounce)(()=>forceUpdate());
91
+ const dispose = ()=>{
92
+ isDestroyed = true;
93
+ if (targetWindow) {
94
+ targetWindow.removeEventListener('scroll', updatePosition);
95
+ targetWindow.removeEventListener('resize', updatePosition);
96
+ }
97
+ scrollParents.forEach((scrollParent)=>{
98
+ scrollParent.removeEventListener('scroll', updatePosition);
99
+ });
100
+ };
107
101
  if (targetWindow) {
108
- targetWindow.removeEventListener('scroll', updatePosition);
109
- targetWindow.removeEventListener('resize', updatePosition);
102
+ targetWindow.addEventListener('scroll', updatePosition);
103
+ targetWindow.addEventListener('resize', updatePosition);
110
104
  }
111
- scrollParents.forEach(scrollParent => {
112
- scrollParent.removeEventListener('scroll', updatePosition);
113
- });
114
- };
115
- if (targetWindow) {
116
- targetWindow.addEventListener('scroll', updatePosition);
117
- targetWindow.addEventListener('resize', updatePosition);
118
- }
119
- // Update the position on initialization
120
- updatePosition();
121
- return {
122
- updatePosition,
123
- dispose
124
- };
125
- }
126
- exports.createPositionManager = createPositionManager;
105
+ // Update the position on initialization
106
+ updatePosition();
107
+ return {
108
+ updatePosition,
109
+ dispose
110
+ };
111
+ } //# sourceMappingURL=createPositionManager.js.map
112
+
127
113
  //# sourceMappingURL=createPositionManager.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["dom_1","require","utils_1","react_utilities_1","createPositionManager","options","container","target","arrow","strategy","middleware","placement","isDestroyed","updatePosition","undefined","dispose","isFirstUpdate","scrollParents","Set","targetWindow","ownerDocument","defaultView","Object","assign","style","position","left","top","margin","forceUpdate","add","getScrollParent","isHTMLElement","forEach","scrollParent","addEventListener","computePosition","then","x","y","middlewareData","computedPlacement","writeArrowUpdates","writeContainerUpdates","coordinates","lowPPI","devicePixelRatio","catch","err","process","env","NODE_ENV","console","error","debounce","removeEventListener","exports"],"sources":["../src/packages/react-components/react-positioning/src/createPositionManager.ts"],"sourcesContent":["import { computePosition } from '@floating-ui/dom';\nimport type { Middleware, Placement, Strategy } from '@floating-ui/dom';\nimport type { PositionManager, TargetElement } from './types';\nimport { debounce, writeArrowUpdates, writeContainerUpdates, getScrollParent } from './utils';\nimport { isHTMLElement } from '@fluentui/react-utilities';\n\ninterface PositionManagerOptions {\n /**\n * The positioned element\n */\n container: HTMLElement;\n /**\n * Element that the container will be anchored to\n */\n target: TargetElement;\n /**\n * Arrow that points from the container to the target\n */\n arrow: HTMLElement | null;\n /**\n * The value of the css `position` property\n * @default absolute\n */\n strategy: Strategy;\n /**\n * [Floating UI middleware](https://floating-ui.com/docs/middleware)\n */\n middleware: Middleware[];\n /**\n * [Floating UI placement](https://floating-ui.com/docs/computePosition#placement)\n */\n placement?: Placement;\n}\n\n/**\n * @internal\n * @returns manager that handles positioning out of the react lifecycle\n */\nexport function createPositionManager(options: PositionManagerOptions): PositionManager {\n const { container, target, arrow, strategy, middleware, placement } = options;\n let isDestroyed = false;\n if (!target || !container) {\n return {\n updatePosition: () => undefined,\n dispose: () => undefined,\n };\n }\n\n let isFirstUpdate = true;\n const scrollParents: Set<HTMLElement> = new Set<HTMLElement>();\n const targetWindow = container.ownerDocument.defaultView;\n\n // When the container is first resolved, set position `fixed` to avoid scroll jumps.\n // Without this scroll jumps can occur when the element is rendered initially and receives focus\n Object.assign(container.style, { position: 'fixed', left: 0, top: 0, margin: 0 });\n\n const forceUpdate = () => {\n // debounced update can still occur afterwards\n // early return to avoid memory leaks\n if (isDestroyed) {\n return;\n }\n\n if (isFirstUpdate) {\n scrollParents.add(getScrollParent(container));\n if (isHTMLElement(target)) {\n scrollParents.add(getScrollParent(target));\n }\n\n scrollParents.forEach(scrollParent => {\n scrollParent.addEventListener('scroll', updatePosition);\n });\n\n isFirstUpdate = false;\n }\n\n Object.assign(container.style, { position: strategy });\n computePosition(target, container, { placement, middleware, strategy })\n .then(({ x, y, middlewareData, placement: computedPlacement }) => {\n // Promise can still resolve after destruction\n // early return to avoid applying outdated position\n if (isDestroyed) {\n return;\n }\n\n writeArrowUpdates({ arrow, middlewareData });\n writeContainerUpdates({\n container,\n middlewareData,\n placement: computedPlacement,\n coordinates: { x, y },\n lowPPI: (targetWindow?.devicePixelRatio || 1) <= 1,\n strategy,\n });\n })\n .catch(err => {\n // https://github.com/floating-ui/floating-ui/issues/1845\n // FIXME for node > 14\n // node 15 introduces promise rejection which means that any components\n // tests need to be `it('', async () => {})` otherwise there can be race conditions with\n // JSDOM being torn down before this promise is resolved so globals like `window` and `document` don't exist\n // Unless all tests that ever use `usePositioning` are turned into async tests, any logging during testing\n // will actually be counter productive\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error('[usePositioning]: Failed to calculate position', err);\n }\n });\n };\n\n const updatePosition = debounce(() => forceUpdate());\n\n const dispose = () => {\n isDestroyed = true;\n\n if (targetWindow) {\n targetWindow.removeEventListener('scroll', updatePosition);\n targetWindow.removeEventListener('resize', updatePosition);\n }\n\n scrollParents.forEach(scrollParent => {\n scrollParent.removeEventListener('scroll', updatePosition);\n });\n };\n\n if (targetWindow) {\n targetWindow.addEventListener('scroll', updatePosition);\n targetWindow.addEventListener('resize', updatePosition);\n }\n\n // Update the position on initialization\n updatePosition();\n\n return {\n updatePosition,\n dispose,\n };\n}\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AAGA,MAAAC,OAAA,gBAAAD,OAAA;AAC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A,YAAY,CAACqB,mBAAmB,CAAC,QAAQ,EAAE1C,cAAc,CAAC;IAC5D,CAAC,CAAC;EACJ,CAAC;EAED,IAAIM,YAAY,EAAE;IAChBA,YAAY,CAACgB,gBAAgB,CAAC,QAAQ,EAAEtB,cAAc,CAAC;IACvDM,YAAY,CAACgB,gBAAgB,CAAC,QAAQ,EAAEtB,cAAc,CAAC;;EAGzD;EACAA,cAAc,EAAE;EAEhB,OAAO;IACLA,cAAc;IACdE;GACD;AACH;AAnGAyC,OAAA,CAAApD,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"sources":["../lib/createPositionManager.js"],"sourcesContent":["import { computePosition } from '@floating-ui/dom';\nimport { debounce, writeArrowUpdates, writeContainerUpdates, getScrollParent } from './utils';\nimport { isHTMLElement } from '@fluentui/react-utilities';\n/**\n * @internal\n * @returns manager that handles positioning out of the react lifecycle\n */\nexport function createPositionManager(options) {\n const {\n container,\n target,\n arrow,\n strategy,\n middleware,\n placement\n } = options;\n let isDestroyed = false;\n if (!target || !container) {\n return {\n updatePosition: () => undefined,\n dispose: () => undefined\n };\n }\n let isFirstUpdate = true;\n const scrollParents = new Set();\n const targetWindow = container.ownerDocument.defaultView;\n // When the container is first resolved, set position `fixed` to avoid scroll jumps.\n // Without this scroll jumps can occur when the element is rendered initially and receives focus\n Object.assign(container.style, {\n position: 'fixed',\n left: 0,\n top: 0,\n margin: 0\n });\n const forceUpdate = () => {\n // debounced update can still occur afterwards\n // early return to avoid memory leaks\n if (isDestroyed) {\n return;\n }\n if (isFirstUpdate) {\n scrollParents.add(getScrollParent(container));\n if (isHTMLElement(target)) {\n scrollParents.add(getScrollParent(target));\n }\n scrollParents.forEach(scrollParent => {\n scrollParent.addEventListener('scroll', updatePosition);\n });\n isFirstUpdate = false;\n }\n Object.assign(container.style, {\n position: strategy\n });\n computePosition(target, container, {\n placement,\n middleware,\n strategy\n }).then(({\n x,\n y,\n middlewareData,\n placement: computedPlacement\n }) => {\n // Promise can still resolve after destruction\n // early return to avoid applying outdated position\n if (isDestroyed) {\n return;\n }\n writeArrowUpdates({\n arrow,\n middlewareData\n });\n writeContainerUpdates({\n container,\n middlewareData,\n placement: computedPlacement,\n coordinates: {\n x,\n y\n },\n lowPPI: ((targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.devicePixelRatio) || 1) <= 1,\n strategy\n });\n }).catch(err => {\n // https://github.com/floating-ui/floating-ui/issues/1845\n // FIXME for node > 14\n // node 15 introduces promise rejection which means that any components\n // tests need to be `it('', async () => {})` otherwise there can be race conditions with\n // JSDOM being torn down before this promise is resolved so globals like `window` and `document` don't exist\n // Unless all tests that ever use `usePositioning` are turned into async tests, any logging during testing\n // will actually be counter productive\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.error('[usePositioning]: Failed to calculate position', err);\n }\n });\n };\n const updatePosition = debounce(() => forceUpdate());\n const dispose = () => {\n isDestroyed = true;\n if (targetWindow) {\n targetWindow.removeEventListener('scroll', updatePosition);\n targetWindow.removeEventListener('resize', updatePosition);\n }\n scrollParents.forEach(scrollParent => {\n scrollParent.removeEventListener('scroll', updatePosition);\n });\n };\n if (targetWindow) {\n targetWindow.addEventListener('scroll', updatePosition);\n targetWindow.addEventListener('resize', updatePosition);\n }\n // Update the position on initialization\n updatePosition();\n return {\n updatePosition,\n dispose\n };\n}\n//# sourceMappingURL=createPositionManager.js.map"],"names":["createPositionManager","options","container","target","arrow","strategy","middleware","placement","isDestroyed","updatePosition","undefined","dispose","isFirstUpdate","scrollParents","Set","targetWindow","ownerDocument","defaultView","Object","assign","style","position","left","top","margin","forceUpdate","add","getScrollParent","isHTMLElement","forEach","scrollParent","addEventListener","computePosition","then","x","y","middlewareData","computedPlacement","writeArrowUpdates","writeContainerUpdates","coordinates","lowPPI","devicePixelRatio","catch","err","process","env","NODE_ENV","console","error","debounce","removeEventListener"],"mappings":";;;;+BAOgBA;;aAAAA;;qBAPgB;uBACoD;gCACtD;AAKvB,SAASA,sBAAsBC,OAA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C;gBACpBrC;gBACAkC;gBACA7B,WAAW8B;gBACXG,aAAa;oBACXN;oBACAC;gBACF;gBACAM,QAAQ,AAAC,CAAA,AAAC1B,CAAAA,iBAAiB,IAAI,IAAIA,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAa2B,gBAAgB,AAAD,KAAM,CAAA,KAAM;gBAC9GrC;YACF;QACF,GAAGsC,KAAK,CAACC,CAAAA,MAAO;YACd,yDAAyD;YACzD,sBAAsB;YACtB,uEAAuE;YACvE,wFAAwF;YACxF,4GAA4G;YAC5G,0GAA0G;YAC1G,sCAAsC;YACtC,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;gBAC1C,sCAAsC;gBACtCC,QAAQC,KAAK,CAAC,kDAAkDL;YAClE,CAAC;QACH;IACF;IACA,MAAMnC,iBAAiByC,IAAAA,eAAQ,EAAC,IAAMzB;IACtC,MAAMd,UAAU,IAAM;QACpBH,cAAc,IAAI;QAClB,IAAIO,cAAc;YAChBA,aAAaoC,mBAAmB,CAAC,UAAU1C;YAC3CM,aAAaoC,mBAAmB,CAAC,UAAU1C;QAC7C,CAAC;QACDI,cAAcgB,OAAO,CAACC,CAAAA,eAAgB;YACpCA,aAAaqB,mBAAmB,CAAC,UAAU1C;QAC7C;IACF;IACA,IAAIM,cAAc;QAChBA,aAAagB,gBAAgB,CAAC,UAAUtB;QACxCM,aAAagB,gBAAgB,CAAC,UAAUtB;IAC1C,CAAC;IACD,wCAAwC;IACxCA;IACA,OAAO;QACLA;QACAE;IACF;AACF,EACA,iDAAiD"}
@@ -1,33 +1,34 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createVirtualElementFromClick = void 0;
7
1
  /**
8
2
  * Creates a virtual element based on the position of a click event
9
3
  * Can be used as a target for popper in scenarios such as context menus
10
- */
4
+ */ "use strict";
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "createVirtualElementFromClick", {
9
+ enumerable: true,
10
+ get: ()=>createVirtualElementFromClick
11
+ });
11
12
  function createVirtualElementFromClick(nativeEvent) {
12
- const left = nativeEvent.clientX;
13
- const top = nativeEvent.clientY;
14
- const right = left + 1;
15
- const bottom = top + 1;
16
- function getBoundingClientRect() {
13
+ const left = nativeEvent.clientX;
14
+ const top = nativeEvent.clientY;
15
+ const right = left + 1;
16
+ const bottom = top + 1;
17
+ function getBoundingClientRect() {
18
+ return {
19
+ left,
20
+ top,
21
+ right,
22
+ bottom,
23
+ x: left,
24
+ y: top,
25
+ height: 1,
26
+ width: 1
27
+ };
28
+ }
17
29
  return {
18
- left,
19
- top,
20
- right,
21
- bottom,
22
- x: left,
23
- y: top,
24
- height: 1,
25
- width: 1
30
+ getBoundingClientRect
26
31
  };
27
- }
28
- return {
29
- getBoundingClientRect
30
- };
31
- }
32
- exports.createVirtualElementFromClick = createVirtualElementFromClick;
32
+ } //# sourceMappingURL=createVirtualElementFromClick.js.map
33
+
33
34
  //# sourceMappingURL=createVirtualElementFromClick.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createVirtualElementFromClick","nativeEvent","left","clientX","top","clientY","right","bottom","getBoundingClientRect","x","y","height","width","exports"],"sources":["../src/packages/react-components/react-positioning/src/createVirtualElementFromClick.ts"],"sourcesContent":["import type { PositioningVirtualElement } from './types';\n\n/**\n * Creates a virtual element based on the position of a click event\n * Can be used as a target for popper in scenarios such as context menus\n */\nexport function createVirtualElementFromClick(nativeEvent: MouseEvent): PositioningVirtualElement {\n const left = nativeEvent.clientX;\n const top = nativeEvent.clientY;\n const right = left + 1;\n const bottom = top + 1;\n\n function getBoundingClientRect() {\n return {\n left,\n top,\n right,\n bottom,\n x: left,\n y: top,\n height: 1,\n width: 1,\n };\n }\n\n return {\n getBoundingClientRect,\n };\n}\n"],"mappings":";;;;;;AAEA;;;;AAIA,SAAgBA,6BAA6BA,CAACC,WAAuB;EACnE,MAAMC,IAAI,GAAGD,WAAW,CAACE,OAAO;EAChC,MAAMC,GAAG,GAAGH,WAAW,CAACI,OAAO;EAC/B,MAAMC,KAAK,GAAGJ,IAAI,GAAG,CAAC;EACtB,MAAMK,MAAM,GAAGH,GAAG,GAAG,CAAC;EAEtB,SAASI,qBAAqBA,CAAA;IAC5B,OAAO;MACLN,IAAI;MACJE,GAAG;MACHE,KAAK;MACLC,MAAM;MACNE,CAAC,EAAEP,IAAI;MACPQ,CAAC,EAAEN,GAAG;MACNO,MAAM,EAAE,CAAC;MACTC,KAAK,EAAE;KACR;EACH;EAEA,OAAO;IACLJ;GACD;AACH;AAtBAK,OAAA,CAAAb,6BAAA,GAAAA,6BAAA"}
1
+ {"version":3,"sources":["../lib/createVirtualElementFromClick.js"],"sourcesContent":["/**\n * Creates a virtual element based on the position of a click event\n * Can be used as a target for popper in scenarios such as context menus\n */export function createVirtualElementFromClick(nativeEvent) {\n const left = nativeEvent.clientX;\n const top = nativeEvent.clientY;\n const right = left + 1;\n const bottom = top + 1;\n function getBoundingClientRect() {\n return {\n left,\n top,\n right,\n bottom,\n x: left,\n y: top,\n height: 1,\n width: 1\n };\n }\n return {\n getBoundingClientRect\n };\n}\n//# sourceMappingURL=createVirtualElementFromClick.js.map"],"names":["createVirtualElementFromClick","nativeEvent","left","clientX","top","clientY","right","bottom","getBoundingClientRect","x","y","height","width"],"mappings":"AAAA;;;CAGC;;;;+BAAkBA;;aAAAA;;AAAT,SAASA,8BAA8BC,WAAW,EAAE;IAC5D,MAAMC,OAAOD,YAAYE,OAAO;IAChC,MAAMC,MAAMH,YAAYI,OAAO;IAC/B,MAAMC,QAAQJ,OAAO;IACrB,MAAMK,SAASH,MAAM;IACrB,SAASI,wBAAwB;QAC/B,OAAO;YACLN;YACAE;YACAE;YACAC;YACAE,GAAGP;YACHQ,GAAGN;YACHO,QAAQ;YACRC,OAAO;QACT;IACF;IACA,OAAO;QACLJ;IACF;AACF,EACA,yDAAyD"}
@@ -1,54 +1,27 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mergeArrowOffset = exports.resolvePositioningShorthand = exports.usePositioningMouseTarget = exports.usePositioning = exports.createArrowStyles = exports.createArrowHeightStyles = exports.createVirtualElementFromClick = void 0;
7
- var createVirtualElementFromClick_1 = /*#__PURE__*/require("./createVirtualElementFromClick");
8
- Object.defineProperty(exports, "createVirtualElementFromClick", {
9
- enumerable: true,
10
- get: function () {
11
- return createVirtualElementFromClick_1.createVirtualElementFromClick;
12
- }
13
- });
14
- var createArrowStyles_1 = /*#__PURE__*/require("./createArrowStyles");
15
- Object.defineProperty(exports, "createArrowHeightStyles", {
16
- enumerable: true,
17
- get: function () {
18
- return createArrowStyles_1.createArrowHeightStyles;
19
- }
20
- });
21
- Object.defineProperty(exports, "createArrowStyles", {
22
- enumerable: true,
23
- get: function () {
24
- return createArrowStyles_1.createArrowStyles;
25
- }
26
- });
27
- var usePositioning_1 = /*#__PURE__*/require("./usePositioning");
28
- Object.defineProperty(exports, "usePositioning", {
29
- enumerable: true,
30
- get: function () {
31
- return usePositioning_1.usePositioning;
32
- }
33
- });
34
- var usePositioningMouseTarget_1 = /*#__PURE__*/require("./usePositioningMouseTarget");
35
- Object.defineProperty(exports, "usePositioningMouseTarget", {
36
- enumerable: true,
37
- get: function () {
38
- return usePositioningMouseTarget_1.usePositioningMouseTarget;
39
- }
40
- });
41
- var index_1 = /*#__PURE__*/require("./utils/index");
42
- Object.defineProperty(exports, "resolvePositioningShorthand", {
43
- enumerable: true,
44
- get: function () {
45
- return index_1.resolvePositioningShorthand;
46
- }
47
- });
48
- Object.defineProperty(exports, "mergeArrowOffset", {
49
- enumerable: true,
50
- get: function () {
51
- return index_1.mergeArrowOffset;
52
- }
53
- });
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ createVirtualElementFromClick: ()=>_createVirtualElementFromClick.createVirtualElementFromClick,
13
+ createArrowHeightStyles: ()=>_createArrowStyles.createArrowHeightStyles,
14
+ createArrowStyles: ()=>_createArrowStyles.createArrowStyles,
15
+ usePositioning: ()=>_usePositioning.usePositioning,
16
+ usePositioningMouseTarget: ()=>_usePositioningMouseTarget.usePositioningMouseTarget,
17
+ resolvePositioningShorthand: ()=>_index.resolvePositioningShorthand,
18
+ mergeArrowOffset: ()=>_index.mergeArrowOffset
19
+ });
20
+ const _createVirtualElementFromClick = require("./createVirtualElementFromClick");
21
+ const _createArrowStyles = require("./createArrowStyles");
22
+ const _usePositioning = require("./usePositioning");
23
+ const _usePositioningMouseTarget = require("./usePositioningMouseTarget");
24
+ const _index = require("./utils/index");
25
+ //# sourceMappingURL=index.js.map
26
+
54
27
  //# sourceMappingURL=index.js.map