@fluentui/react-positioning 9.17.1 → 9.17.2

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/dist/index.d.ts +24 -0
  3. package/lib/SafeZoneArea.js +306 -0
  4. package/lib/SafeZoneArea.js.map +1 -0
  5. package/lib/SafeZoneArea.styles.js +34 -0
  6. package/lib/SafeZoneArea.styles.js.map +1 -0
  7. package/lib/index.js +1 -0
  8. package/lib/index.js.map +1 -1
  9. package/lib/useSafeZoneArea.js +145 -0
  10. package/lib/useSafeZoneArea.js.map +1 -0
  11. package/lib-commonjs/PositioningConfigurationContext.js +1 -1
  12. package/lib-commonjs/PositioningConfigurationContext.js.map +1 -1
  13. package/lib-commonjs/SafeZoneArea.js +316 -0
  14. package/lib-commonjs/SafeZoneArea.js.map +1 -0
  15. package/lib-commonjs/SafeZoneArea.styles.js +63 -0
  16. package/lib-commonjs/SafeZoneArea.styles.js.map +1 -0
  17. package/lib-commonjs/constants.js.map +1 -1
  18. package/lib-commonjs/createArrowStyles.js.map +1 -1
  19. package/lib-commonjs/createPositionManager.js.map +1 -1
  20. package/lib-commonjs/createSlideStyles.js.map +1 -1
  21. package/lib-commonjs/createVirtualElementFromClick.js +4 -1
  22. package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
  23. package/lib-commonjs/index.js +4 -0
  24. package/lib-commonjs/index.js.map +1 -1
  25. package/lib-commonjs/middleware/coverTarget.js.map +1 -1
  26. package/lib-commonjs/middleware/flip.js.map +1 -1
  27. package/lib-commonjs/middleware/intersecting.js.map +1 -1
  28. package/lib-commonjs/middleware/matchTargetSize.js.map +1 -1
  29. package/lib-commonjs/middleware/maxSize.js.map +1 -1
  30. package/lib-commonjs/middleware/offset.js.map +1 -1
  31. package/lib-commonjs/middleware/shift.js.map +1 -1
  32. package/lib-commonjs/usePositioning.js.map +1 -1
  33. package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
  34. package/lib-commonjs/usePositioningOptions.js +3 -6
  35. package/lib-commonjs/usePositioningOptions.js.map +1 -1
  36. package/lib-commonjs/useSafeZoneArea.js +156 -0
  37. package/lib-commonjs/useSafeZoneArea.js.map +1 -0
  38. package/lib-commonjs/utils/devtools.js.map +1 -1
  39. package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
  40. package/lib-commonjs/utils/getBoundary.js.map +1 -1
  41. package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
  42. package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
  43. package/lib-commonjs/utils/getScrollParent.js.map +1 -1
  44. package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
  45. package/lib-commonjs/utils/listScrollParents.js.map +1 -1
  46. package/lib-commonjs/utils/mergeArrowOffset.js +9 -1
  47. package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
  48. package/lib-commonjs/utils/normalizeAutoSize.js +5 -1
  49. package/lib-commonjs/utils/normalizeAutoSize.js.map +1 -1
  50. package/lib-commonjs/utils/parseFloatingUIPlacement.js +6 -1
  51. package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
  52. package/lib-commonjs/utils/resolvePositioningShorthand.js +1 -1
  53. package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
  54. package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
  55. package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
  56. package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
  57. package/lib-commonjs/utils/writeArrowUpdates.js +3 -1
  58. package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
  59. package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
  60. package/package.json +5 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/PositioningConfigurationContext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { PositioningConfigurationFn } from './types';\n\n// ---\n\nconst DEFAULT_CONFIGURATION: PositioningConfigurationFn = ({ options }) => {\n return options;\n};\n\n// ---\n\nconst PositioningConfigurationContext = React.createContext<PositioningConfigurationFn | undefined>(undefined);\n\n/**\n * A context provider for the positioning configuration.\n *\n * Accepts a function that takes the positioning options and returns them modified.\n */\nexport const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;\n\nexport const usePositioningConfiguration = (): PositioningConfigurationFn => {\n return React.useContext(PositioningConfigurationContext) ?? DEFAULT_CONFIGURATION;\n};\n"],"names":["PositioningConfigurationProvider","usePositioningConfiguration","DEFAULT_CONFIGURATION","options","PositioningConfigurationContext","React","createContext","undefined","Provider","useContext"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAkBaA,gCAAgC;eAAhCA;;IAEAC,2BAA2B;eAA3BA;;;;iEApBU;AAGvB,MAAM;AAEN,MAAMC,wBAAoD,CAAC,EAAEC,OAAO,EAAE;IACpE,OAAOA;AACT;AAEA,MAAM;AAEN,MAAMC,kCAAkCC,OAAMC,aAAa,CAAyCC;AAO7F,MAAMP,mCAAmCI,gCAAgCI,QAAQ;AAEjF,MAAMP,8BAA8B;QAClCI;IAAP,OAAOA,CAAAA,oBAAAA,OAAMI,UAAU,CAACL,8CAAjBC,+BAAAA,oBAAqDH;AAC9D"}
1
+ {"version":3,"sources":["../src/PositioningConfigurationContext.ts"],"sourcesContent":["import * as React from 'react';\nimport type { PositioningConfigurationFn } from './types';\n\n// ---\n\nconst DEFAULT_CONFIGURATION: PositioningConfigurationFn = ({ options }) => {\n return options;\n};\n\n// ---\n\nconst PositioningConfigurationContext = React.createContext<PositioningConfigurationFn | undefined>(undefined);\n\n/**\n * A context provider for the positioning configuration.\n *\n * Accepts a function that takes the positioning options and returns them modified.\n */\nexport const PositioningConfigurationProvider = PositioningConfigurationContext.Provider;\n\nexport const usePositioningConfiguration = (): PositioningConfigurationFn => {\n return React.useContext(PositioningConfigurationContext) ?? DEFAULT_CONFIGURATION;\n};\n"],"names":["PositioningConfigurationProvider","usePositioningConfiguration","DEFAULT_CONFIGURATION","options","PositioningConfigurationContext","React","createContext","undefined","Provider","useContext"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAkBaA,gCAAAA;eAAAA;;IAEAC,2BAAAA;eAAAA;;;;iEApBU;AAGvB,MAAM;AAEN,MAAMC,wBAAoD,CAAC,EAAEC,OAAO,EAAE;IACpE,OAAOA;AACT;AAEA,MAAM;AAEN,MAAMC,gDAAkCC,OAAMC,aAAa,CAAyCC;AAO7F,MAAMP,mCAAmCI,gCAAgCI,QAAQ;AAEjF,MAAMP,8BAA8B;QAClCI;IAAP,OAAOA,CAAAA,oBAAAA,OAAMI,UAAU,CAACL,gCAAAA,MAAAA,QAAjBC,sBAAAA,KAAAA,IAAAA,oBAAqDH;AAC9D"}
@@ -0,0 +1,316 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
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
+ SafeZoneArea: function() {
13
+ return SafeZoneArea;
14
+ },
15
+ createSafeZoneAreaStateStore: function() {
16
+ return createSafeZoneAreaStateStore;
17
+ }
18
+ });
19
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
20
+ const _react = require("@griffel/react");
21
+ const _reactutilities = require("@fluentui/react-utilities");
22
+ const _react1 = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
23
+ const _shim = require("use-sync-external-store/shim");
24
+ const _SafeZoneAreastyles = require("./SafeZoneArea.styles");
25
+ function createSafeZoneAreaStateStore() {
26
+ let isActive = false;
27
+ const listeners = [];
28
+ return {
29
+ isActive () {
30
+ return isActive;
31
+ },
32
+ toggleActive (newIsActive) {
33
+ isActive = newIsActive;
34
+ listeners.forEach((listener)=>listener(isActive));
35
+ },
36
+ subscribe (listener) {
37
+ listeners.push(listener);
38
+ return ()=>{
39
+ const index = listeners.indexOf(listener);
40
+ if (index > -1) {
41
+ listeners.splice(index, 1);
42
+ }
43
+ };
44
+ }
45
+ };
46
+ }
47
+ const SafeZoneArea = /*#__PURE__*/ _react1.memo((props)=>{
48
+ const { debug, onMouseEnter, onMouseMove, onMouseLeave, stateStore } = props;
49
+ const clipPathId = (0, _reactutilities.useId)();
50
+ const styles = (0, _SafeZoneAreastyles.useStyles)();
51
+ const active = (0, _shim.useSyncExternalStore)(stateStore.subscribe, stateStore.isActive);
52
+ const svgRef = _react1.useRef(null);
53
+ _react1.useImperativeHandle(props.imperativeRef, ()=>({
54
+ updateSVG ({ containerPlacementSide, containerRect, mouseCoordinates, targetRect }) {
55
+ const svgEl = svgRef.current;
56
+ if (!svgEl) {
57
+ return;
58
+ }
59
+ const trianglePathEl = svgEl.children.item(0);
60
+ const debugRectEl = svgEl.children.item(2);
61
+ const clipPathEl = svgEl.children.item(1);
62
+ const clipPathRect = clipPathEl.firstElementChild;
63
+ const SIZE_MULTIPLIER = 0.9;
64
+ let svgStyle;
65
+ let tringlePoints = [];
66
+ let clipPoints = [];
67
+ switch(containerPlacementSide){
68
+ case 'top':
69
+ svgStyle = {
70
+ width: `${containerRect.width}px`,
71
+ height: `${targetRect.bottom - containerRect.bottom}px`,
72
+ transform: `translate(${containerRect.left}px, ${containerRect.bottom}px)`
73
+ };
74
+ tringlePoints = [
75
+ [
76
+ containerRect.width,
77
+ 0
78
+ ],
79
+ [
80
+ mouseCoordinates.x - containerRect.left,
81
+ (mouseCoordinates.y - containerRect.bottom) / SIZE_MULTIPLIER
82
+ ],
83
+ [
84
+ 0,
85
+ 0
86
+ ]
87
+ ];
88
+ clipPoints = [
89
+ [
90
+ 0,
91
+ 0
92
+ ],
93
+ [
94
+ 0,
95
+ targetRect.bottom - containerRect.bottom
96
+ ],
97
+ [
98
+ targetRect.left - containerRect.left,
99
+ targetRect.bottom - containerRect.bottom
100
+ ],
101
+ [
102
+ targetRect.left - containerRect.left,
103
+ targetRect.top - containerRect.bottom
104
+ ],
105
+ [
106
+ targetRect.right - containerRect.left,
107
+ targetRect.top - containerRect.bottom
108
+ ],
109
+ [
110
+ targetRect.right - containerRect.left,
111
+ targetRect.bottom - containerRect.bottom
112
+ ],
113
+ [
114
+ containerRect.width,
115
+ targetRect.bottom - containerRect.bottom
116
+ ],
117
+ [
118
+ containerRect.width,
119
+ 0
120
+ ]
121
+ ];
122
+ break;
123
+ case 'bottom':
124
+ svgStyle = {
125
+ width: `${containerRect.width}px`,
126
+ height: `${containerRect.top - targetRect.top}px`,
127
+ transform: `translate(${containerRect.left}px, ${targetRect.top}px)`
128
+ };
129
+ tringlePoints = [
130
+ [
131
+ containerRect.width,
132
+ containerRect.top - targetRect.top
133
+ ],
134
+ [
135
+ mouseCoordinates.x - containerRect.left,
136
+ (mouseCoordinates.y - targetRect.top) * SIZE_MULTIPLIER
137
+ ],
138
+ [
139
+ 0,
140
+ containerRect.top - targetRect.top
141
+ ]
142
+ ];
143
+ clipPoints = [
144
+ [
145
+ 0,
146
+ 0
147
+ ],
148
+ [
149
+ 0,
150
+ containerRect.top - targetRect.top
151
+ ],
152
+ [
153
+ containerRect.width,
154
+ containerRect.top - targetRect.top
155
+ ],
156
+ [
157
+ containerRect.width,
158
+ 0
159
+ ],
160
+ [
161
+ targetRect.right - containerRect.left,
162
+ 0
163
+ ],
164
+ [
165
+ targetRect.right - containerRect.left,
166
+ targetRect.height
167
+ ],
168
+ [
169
+ targetRect.left - containerRect.left,
170
+ targetRect.height
171
+ ],
172
+ [
173
+ targetRect.left - containerRect.left,
174
+ 0
175
+ ]
176
+ ];
177
+ break;
178
+ case 'left':
179
+ svgStyle = {
180
+ width: `${targetRect.right - containerRect.right}px`,
181
+ height: `${containerRect.height}px`,
182
+ transform: `translate(${containerRect.right}px, ${containerRect.top}px)`
183
+ };
184
+ tringlePoints = [
185
+ [
186
+ (mouseCoordinates.x - containerRect.right) / SIZE_MULTIPLIER,
187
+ mouseCoordinates.y - containerRect.top
188
+ ],
189
+ [
190
+ 0,
191
+ containerRect.height
192
+ ],
193
+ [
194
+ 0,
195
+ 0
196
+ ]
197
+ ];
198
+ clipPoints = [
199
+ [
200
+ 0,
201
+ 0
202
+ ],
203
+ [
204
+ 0,
205
+ containerRect.height
206
+ ],
207
+ [
208
+ targetRect.right - containerRect.right,
209
+ containerRect.height
210
+ ],
211
+ [
212
+ targetRect.right - containerRect.right,
213
+ targetRect.bottom - containerRect.top
214
+ ],
215
+ [
216
+ targetRect.left - containerRect.right,
217
+ targetRect.bottom - containerRect.top
218
+ ],
219
+ [
220
+ targetRect.left - containerRect.right,
221
+ targetRect.top - containerRect.top
222
+ ],
223
+ [
224
+ targetRect.right - containerRect.right,
225
+ targetRect.top - containerRect.top
226
+ ],
227
+ [
228
+ targetRect.right - containerRect.right,
229
+ 0
230
+ ]
231
+ ];
232
+ break;
233
+ default:
234
+ svgStyle = {
235
+ width: `${containerRect.left - targetRect.left}px`,
236
+ height: `${containerRect.height}px`,
237
+ transform: `translate(${targetRect.left}px, ${containerRect.top}px)`
238
+ };
239
+ tringlePoints = [
240
+ [
241
+ (mouseCoordinates.x - targetRect.left) * SIZE_MULTIPLIER,
242
+ mouseCoordinates.y - containerRect.y
243
+ ],
244
+ [
245
+ containerRect.left - targetRect.left,
246
+ containerRect.height
247
+ ],
248
+ [
249
+ containerRect.left - targetRect.left,
250
+ 0
251
+ ]
252
+ ];
253
+ clipPoints = [
254
+ [
255
+ 0,
256
+ 0
257
+ ],
258
+ [
259
+ 0,
260
+ targetRect.top - containerRect.top
261
+ ],
262
+ [
263
+ targetRect.width,
264
+ targetRect.top - containerRect.top
265
+ ],
266
+ [
267
+ targetRect.width,
268
+ targetRect.bottom - containerRect.top
269
+ ],
270
+ [
271
+ 0,
272
+ targetRect.bottom - containerRect.top
273
+ ],
274
+ [
275
+ 0,
276
+ containerRect.height
277
+ ],
278
+ [
279
+ containerRect.left - targetRect.left,
280
+ containerRect.height
281
+ ],
282
+ [
283
+ containerRect.left - targetRect.left,
284
+ 0
285
+ ]
286
+ ];
287
+ break;
288
+ }
289
+ const trianglePath = `M ${tringlePoints.flatMap((p)=>p).join(' ')} z`;
290
+ const clipPath = `M ${clipPoints.flatMap((p)=>p).join(' ')} z`;
291
+ Object.assign(svgEl.style, svgStyle);
292
+ trianglePathEl.setAttributeNS(null, 'd', trianglePath);
293
+ clipPathRect.setAttributeNS(null, 'd', clipPath);
294
+ debugRectEl === null || debugRectEl === void 0 ? void 0 : debugRectEl.setAttributeNS(null, 'd', clipPath);
295
+ }
296
+ }), []);
297
+ return /*#__PURE__*/ _react1.createElement("div", {
298
+ className: (0, _react.mergeClasses)(styles.wrapper, active && styles.wrapperActive),
299
+ "data-safe-zone": ""
300
+ }, active ? /*#__PURE__*/ _react1.createElement("svg", {
301
+ "aria-hidden": true,
302
+ className: styles.svg,
303
+ xmlns: "http://www.w3.org/2000/svg",
304
+ ref: svgRef
305
+ }, /*#__PURE__*/ _react1.createElement("path", {
306
+ className: (0, _react.mergeClasses)(styles.triangle, debug && styles.triangleDebug),
307
+ clipPath: `url(#${clipPathId})`,
308
+ onMouseEnter: onMouseEnter,
309
+ onMouseMove: onMouseMove,
310
+ onMouseLeave: onMouseLeave
311
+ }), /*#__PURE__*/ _react1.createElement("clipPath", {
312
+ id: clipPathId
313
+ }, /*#__PURE__*/ _react1.createElement("path", null)), debug && /*#__PURE__*/ _react1.createElement("path", {
314
+ className: styles.rectDebug
315
+ })) : null);
316
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/SafeZoneArea.tsx"],"sourcesContent":["import { mergeClasses } from '@griffel/react';\nimport { useId } from '@fluentui/react-utilities';\nimport type { Side as PlacementSide } from '@floating-ui/dom';\nimport * as React from 'react';\nimport { useSyncExternalStore } from 'use-sync-external-store/shim';\n\nimport { useStyles } from './SafeZoneArea.styles';\n\nexport type SafeZoneAreaImperativeHandle = {\n updateSVG: (options: {\n containerPlacementSide: PlacementSide;\n containerRect: DOMRect;\n targetRect: DOMRect;\n mouseCoordinates: { x: number; y: number };\n }) => void;\n};\n\nexport type SafeZoneAreaProps = {\n /** Enables debug mode: makes drawn shapes visible. */\n debug: boolean;\n\n /** A reference to the SafeZoneArea imperative handle. */\n imperativeRef: React.Ref<SafeZoneAreaImperativeHandle>;\n\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onMouseEnter: (e: React.MouseEvent) => void;\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onMouseMove: (e: React.MouseEvent) => void;\n // eslint-disable-next-line @nx/workspace-consistent-callback-type\n onMouseLeave: (e: React.MouseEvent) => void;\n\n stateStore: ReturnType<typeof createSafeZoneAreaStateStore>;\n};\n\nexport function createSafeZoneAreaStateStore() {\n let isActive = false;\n const listeners: ((value: boolean) => void)[] = [];\n\n return {\n isActive() {\n return isActive;\n },\n toggleActive(newIsActive: boolean) {\n isActive = newIsActive;\n listeners.forEach(listener => listener(isActive));\n },\n\n subscribe(listener: (value: boolean) => void) {\n listeners.push(listener);\n\n return () => {\n const index = listeners.indexOf(listener);\n\n if (index > -1) {\n listeners.splice(index, 1);\n }\n };\n },\n };\n}\n\n/**\n * A component that renders a safe zone area with SVG shapes. Uses `useSyncExternalStore` to manage its active state\n * to avoid causing re-renders in `useSafeZoneArea()` as the hook might be used in host components like `Menu`.\n *\n * Draws two shapes:\n * - a triangle that points to the target element which is an actual safe zone\n * - a rectangle for a clip path that clips out the target element\n *\n * @internal\n */\nexport const SafeZoneArea = React.memo((props: SafeZoneAreaProps) => {\n const { debug, onMouseEnter, onMouseMove, onMouseLeave, stateStore } = props;\n\n const clipPathId = useId();\n const styles = useStyles();\n\n const active = useSyncExternalStore(stateStore.subscribe, stateStore.isActive);\n const svgRef = React.useRef<SVGSVGElement>(null);\n\n React.useImperativeHandle(\n props.imperativeRef,\n () => ({\n updateSVG({ containerPlacementSide, containerRect, mouseCoordinates, targetRect }) {\n const svgEl = svgRef.current;\n\n if (!svgEl) {\n return;\n }\n\n const trianglePathEl = svgEl.children.item(0) as SVGPathElement;\n const debugRectEl = svgEl.children.item(2) as SVGPathElement | null;\n const clipPathEl = svgEl.children.item(1) as SVGClipPathElement;\n const clipPathRect = clipPathEl.firstElementChild as SVGRectElement;\n\n const SIZE_MULTIPLIER = 0.9;\n\n let svgStyle: Partial<CSSStyleDeclaration>;\n\n let tringlePoints: [number, number][] = [];\n let clipPoints: [number, number][] = [];\n\n switch (containerPlacementSide) {\n case 'top':\n svgStyle = {\n width: `${containerRect.width}px`,\n height: `${targetRect.bottom - containerRect.bottom}px`,\n transform: `translate(${containerRect.left}px, ${containerRect.bottom}px)`,\n };\n\n tringlePoints = [\n [containerRect.width, 0],\n [mouseCoordinates.x - containerRect.left, (mouseCoordinates.y - containerRect.bottom) / SIZE_MULTIPLIER],\n [0, 0],\n ];\n clipPoints = [\n [0, 0],\n [0, targetRect.bottom - containerRect.bottom],\n [targetRect.left - containerRect.left, targetRect.bottom - containerRect.bottom],\n [targetRect.left - containerRect.left, targetRect.top - containerRect.bottom],\n [targetRect.right - containerRect.left, targetRect.top - containerRect.bottom],\n [targetRect.right - containerRect.left, targetRect.bottom - containerRect.bottom],\n [containerRect.width, targetRect.bottom - containerRect.bottom],\n [containerRect.width, 0],\n ];\n\n break;\n\n case 'bottom':\n svgStyle = {\n width: `${containerRect.width}px`,\n height: `${containerRect.top - targetRect.top}px`,\n transform: `translate(${containerRect.left}px, ${targetRect.top}px)`,\n };\n\n tringlePoints = [\n [containerRect.width, containerRect.top - targetRect.top],\n [mouseCoordinates.x - containerRect.left, (mouseCoordinates.y - targetRect.top) * SIZE_MULTIPLIER],\n [0, containerRect.top - targetRect.top],\n ];\n clipPoints = [\n [0, 0],\n [0, containerRect.top - targetRect.top],\n [containerRect.width, containerRect.top - targetRect.top],\n [containerRect.width, 0],\n [targetRect.right - containerRect.left, 0],\n [targetRect.right - containerRect.left, targetRect.height],\n [targetRect.left - containerRect.left, targetRect.height],\n [targetRect.left - containerRect.left, 0],\n ];\n\n break;\n\n case 'left':\n svgStyle = {\n width: `${targetRect.right - containerRect.right}px`,\n height: `${containerRect.height}px`,\n transform: `translate(${containerRect.right}px, ${containerRect.top}px)`,\n };\n\n tringlePoints = [\n [(mouseCoordinates.x - containerRect.right) / SIZE_MULTIPLIER, mouseCoordinates.y - containerRect.top],\n [0, containerRect.height],\n [0, 0],\n ];\n clipPoints = [\n [0, 0],\n [0, containerRect.height],\n [targetRect.right - containerRect.right, containerRect.height],\n [targetRect.right - containerRect.right, targetRect.bottom - containerRect.top],\n [targetRect.left - containerRect.right, targetRect.bottom - containerRect.top],\n [targetRect.left - containerRect.right, targetRect.top - containerRect.top],\n [targetRect.right - containerRect.right, targetRect.top - containerRect.top],\n [targetRect.right - containerRect.right, 0],\n ];\n\n break;\n\n default:\n svgStyle = {\n width: `${containerRect.left - targetRect.left}px`,\n height: `${containerRect.height}px`,\n transform: `translate(${targetRect.left}px, ${containerRect.top}px)`,\n };\n\n tringlePoints = [\n [(mouseCoordinates.x - targetRect.left) * SIZE_MULTIPLIER, mouseCoordinates.y - containerRect.y],\n [containerRect.left - targetRect.left, containerRect.height],\n [containerRect.left - targetRect.left, 0],\n ];\n clipPoints = [\n [0, 0],\n [0, targetRect.top - containerRect.top],\n [targetRect.width, targetRect.top - containerRect.top],\n [targetRect.width, targetRect.bottom - containerRect.top],\n [0, targetRect.bottom - containerRect.top],\n [0, containerRect.height],\n [containerRect.left - targetRect.left, containerRect.height],\n [containerRect.left - targetRect.left, 0],\n ];\n\n break;\n }\n\n const trianglePath = `M ${tringlePoints.flatMap(p => p).join(' ')} z`;\n const clipPath = `M ${clipPoints.flatMap(p => p).join(' ')} z`;\n\n Object.assign(svgEl.style, svgStyle);\n\n trianglePathEl.setAttributeNS(null, 'd', trianglePath);\n clipPathRect.setAttributeNS(null, 'd', clipPath);\n debugRectEl?.setAttributeNS(null, 'd', clipPath);\n },\n }),\n [],\n );\n\n return (\n <div className={mergeClasses(styles.wrapper, active && styles.wrapperActive)} data-safe-zone=\"\">\n {active ? (\n <svg aria-hidden className={styles.svg} xmlns=\"http://www.w3.org/2000/svg\" ref={svgRef}>\n <path\n className={mergeClasses(styles.triangle, debug && styles.triangleDebug)}\n clipPath={`url(#${clipPathId})`}\n onMouseEnter={onMouseEnter}\n onMouseMove={onMouseMove}\n onMouseLeave={onMouseLeave}\n />\n <clipPath id={clipPathId}>\n <path />\n </clipPath>\n\n {debug && <path className={styles.rectDebug} />}\n </svg>\n ) : null}\n </div>\n );\n});\n"],"names":["SafeZoneArea","createSafeZoneAreaStateStore","isActive","listeners","toggleActive","newIsActive","forEach","listener","subscribe","push","index","indexOf","splice","React","memo","props","debug","onMouseEnter","onMouseMove","onMouseLeave","stateStore","clipPathId","useId","styles","useStyles","active","useSyncExternalStore","svgRef","useRef","useImperativeHandle","imperativeRef","updateSVG","containerPlacementSide","containerRect","mouseCoordinates","targetRect","svgEl","current","trianglePathEl","children","item","debugRectEl","clipPathEl","clipPathRect","firstElementChild","SIZE_MULTIPLIER","svgStyle","tringlePoints","clipPoints","width","height","bottom","transform","left","x","y","top","right","trianglePath","flatMap","p","join","clipPath","Object","assign","style","setAttributeNS","createElement","div","className","mergeClasses","wrapper","wrapperActive","data-safe-zone","svg","aria-hidden","xmlns","ref","path","triangle","triangleDebug","id","rectDebug"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAuEaA,YAAA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AI,CAAC,KAAK,EAAE,CAAC;gBAE9DE,OAAOC,MAAM,CAAC5B,MAAM6B,KAAK,EAAEnB;gBAE3BR,eAAe4B,cAAc,CAAC,MAAM,KAAKR;gBACzCf,aAAauB,cAAc,CAAC,MAAM,KAAKJ;gBACvCrB,gBAAAA,QAAAA,gBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,YAAayB,cAAc,CAAC,MAAM,KAAKJ;YACzC;QACF,CAAA,GACA,EAAE;IAGJ,OAAA,WAAA,GACEjD,QAAAsD,aAAA,CAACC,OAAAA;QAAIC,WAAWC,IAAAA,mBAAAA,EAAa/C,OAAOgD,OAAO,EAAE9C,UAAUF,OAAOiD,aAAa;QAAGC,kBAAe;OAC1FhD,SAAAA,WAAAA,GACCZ,QAAAsD,aAAA,CAACO,OAAAA;QAAIC,eAAAA;QAAYN,WAAW9C,OAAOmD,GAAG;QAAEE,OAAM;QAA6BC,KAAKlD;qBAC9Ed,QAAAsD,aAAA,CAACW,QAAAA;QACCT,WAAWC,IAAAA,mBAAAA,EAAa/C,OAAOwD,QAAQ,EAAE/D,SAASO,OAAOyD,aAAa;QACtElB,UAAU,CAAC,KAAK,EAAEzC,WAAW,CAAC,CAAC;QAC/BJ,cAAcA;QACdC,aAAaA;QACbC,cAAcA;sBAEhBN,QAAAsD,aAAA,CAACL,YAAAA;QAASmB,IAAI5D;qBACZR,QAAAsD,aAAA,CAACW,QAAAA,QAGF9D,SAAAA,WAAAA,GAASH,QAAAsD,aAAA,CAACW,QAAAA;QAAKT,WAAW9C,OAAO2D,SAAS;UAE3C;AAGV"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useStyles", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useStyles;
9
+ }
10
+ });
11
+ const _react = require("@griffel/react");
12
+ const useStyles = /*#__PURE__*/ (0, _react.__styles)({
13
+ wrapper: {
14
+ mc9l5x: "fjseox",
15
+ Bqenvij: "fniina8",
16
+ a9b677: "f3tsq5r",
17
+ Bkecrkj: "f1aehjj5"
18
+ },
19
+ wrapperActive: {
20
+ mc9l5x: "ftgm304"
21
+ },
22
+ svg: {
23
+ Bkfmm31: "f1au8mb3",
24
+ Bkecrkj: "f1aehjj5",
25
+ qhf8xq: "f19dog8a",
26
+ Bhzewxz: "f15twtuk",
27
+ oyh7mz: [
28
+ "f1vgc2s3",
29
+ "f1e31b4d"
30
+ ]
31
+ },
32
+ triangle: {
33
+ Bkecrkj: "f1cguypg"
34
+ },
35
+ triangleDebug: {
36
+ Bceei9c: "f7116n6",
37
+ Bkfmm31: "f1xab38x",
38
+ ojy3ng: "f1wle4v7",
39
+ Be5yapy: "f1t0ei4n"
40
+ },
41
+ rectDebug: {
42
+ Bkfmm31: "fyegryc"
43
+ }
44
+ }, {
45
+ d: [
46
+ ".fjseox{display:none;}",
47
+ ".fniina8{height:0;}",
48
+ ".f3tsq5r{width:0;}",
49
+ ".f1aehjj5{pointer-events:none;}",
50
+ ".ftgm304{display:block;}",
51
+ ".f1au8mb3{fill:transparent;}",
52
+ ".f19dog8a{position:fixed;}",
53
+ ".f15twtuk{top:0;}",
54
+ ".f1vgc2s3{left:0;}",
55
+ ".f1e31b4d{right:0;}",
56
+ ".f1cguypg{pointer-events:auto;}",
57
+ ".f7116n6{cursor:crosshair;}",
58
+ ".f1xab38x{fill:color-mix(in srgb, var(--colorPaletteGreenBackground3) 20%, transparent);}",
59
+ ".f1wle4v7{stroke:color-mix(in srgb, var(--colorPaletteGreenBackground3) 60%, transparent);}",
60
+ ".f1t0ei4n{stroke-width:2px;}",
61
+ ".fyegryc{fill:color-mix(in srgb, var(--colorPaletteRedBackground3) 20%, transparent);}"
62
+ ]
63
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SafeZoneArea.styles.js"],"sourcesContent":["import { makeStyles } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nexport const useStyles = makeStyles({\n wrapper: {\n display: 'none',\n height: 0,\n width: 0,\n pointerEvents: 'none'\n },\n wrapperActive: {\n display: 'block'\n },\n svg: {\n fill: 'transparent',\n pointerEvents: 'none',\n position: 'fixed',\n top: 0,\n left: 0\n },\n triangle: {\n pointerEvents: 'auto'\n },\n triangleDebug: {\n cursor: 'crosshair',\n fill: `color-mix(in srgb, ${tokens.colorPaletteGreenBackground3} 20%, transparent)`,\n stroke: `color-mix(in srgb, ${tokens.colorPaletteGreenBackground3} 60%, transparent)`,\n strokeWidth: '2px'\n },\n rectDebug: {\n fill: `color-mix(in srgb, ${tokens.colorPaletteRedBackground3} 20%, transparent)`\n }\n});\n"],"names":["useStyles","__styles","wrapper","mc9l5x","Bqenvij","a9b677","Bkecrkj","wrapperActive","svg","Bkfmm31","qhf8xq","Bhzewxz","oyh7mz","triangle","triangleDebug","Bceei9c","ojy3ng","Be5yapy","rectDebug","d"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAEaA;;;eAAAA;;;uBAFc;AAEpB,MAAMA,YAAS,WAAA,GAAGC,IAAAA,eAAA,EAAA;IAAAC,SAAA;QAAAC,QAAA;QAAAC,SAAA;QAAAC,QAAA;QAAAC,SAAA;IAAA;IAAAC,eAAA;QAAAJ,QAAA;IAAA;IAAAK,KAAA;QAAAC,SAAA;QAAAH,SAAA;QAAAI,QAAA;QAAAC,SAAA;QAAAC,QAAA;YAAA;YAAA;SAAA;IAAA;IAAAC,UAAA;QAAAP,SAAA;IAAA;IAAAQ,eAAA;QAAAC,SAAA;QAAAN,SAAA;QAAAO,QAAA;QAAAC,SAAA;IAAA;IAAAC,WAAA;QAAAT,SAAA;IAAA;AAAA,GAAA;IAAAU,GAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;KAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\nexport const POSITIONING_END_EVENT = 'fui-positioningend';\n"],"names":["DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_PLACEMENT","POSITIONING_END_EVENT"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IACaA,wBAAwB;eAAxBA;;IACAC,uBAAuB;eAAvBA;;IAFAC,6BAA6B;eAA7BA;;IAGAC,0BAA0B;eAA1BA;;IACAC,qBAAqB;eAArBA;;;AAJN,MAAMF,gCAAgC;AACtC,MAAMF,2BAA2B;AACjC,MAAMC,0BAA0B;AAChC,MAAME,6BAA6B;AACnC,MAAMC,wBAAwB"}
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["export const DATA_POSITIONING_INTERSECTING = 'data-popper-is-intersecting';\nexport const DATA_POSITIONING_ESCAPED = 'data-popper-escaped';\nexport const DATA_POSITIONING_HIDDEN = 'data-popper-reference-hidden';\nexport const DATA_POSITIONING_PLACEMENT = 'data-popper-placement';\nexport const POSITIONING_END_EVENT = 'fui-positioningend';\n"],"names":["DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_PLACEMENT","POSITIONING_END_EVENT"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IACaA,wBAAAA;eAAAA;;IACAC,uBAAAA;eAAAA;;IAFAC,6BAAAA;eAAAA;;IAGAC,0BAAAA;eAAAA;;IACAC,qBAAAA;eAAAA;;;AAJN,MAAMF,gCAAgC;AACtC,MAAMF,2BAA2B;AACjC,MAAMC,0BAA0B;AAChC,MAAME,6BAA6B;AACnC,MAAMC,wBAAwB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/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,uBAAuB;eAAvBA;;IAlEAC,iBAAiB;eAAjBA;;;4BA7DO;AA6DhB,SAASA,kBAAkBC,OAAiC;IACjE,MAAM,EACJC,WAAW,EACXC,cAAc,KAAK,EACnBC,cAAc,OAAO,EACrBC,cAAcC,kBAAM,CAACC,sBAAsB,EAC5C,GAAGN;IAEJ,OAAO;QACLO,WAAW;QACXC,UAAU;QACVC,QAAQ,CAAC;QAET,GAAIR,eAAeH,wBAAwBG,YAAY;QAEvDS,iBAAiB;QACjBC,gBAAgB;QAEhBC,wBAAwB,CAAC,EAAEP,kBAAM,CAACQ,iBAAiB,CAAC,cAAc,CAAC;QACnEC,WAAW;QAEXC,QAAQ;QACRC,OAAO;QAEP,YAAY;YACVC,SAAS;YAETC,SAAS;YACTR,iBAAiB;YACjBS,QAAQ,CAAC,CAAC,EAAEjB,YAAY,CAAC;YACzBc,OAAO;YACPD,QAAQ;YAERK,QAAQ,CAAC,EAAElB,YAAY,CAAC,EAAEC,YAAY,CAAC,EAAEC,YAAY,CAAC;YACtDQ,wBAAwB,CAAC,EAAEP,kBAAM,CAACQ,iBAAiB,CAAC,cAAc,CAAC;YAEnEQ,UAAU;QACZ;QAEA,0FAA0F;QAC1F,2CAA2C;YACzCC,QAAQ;YACR,iCAAiC;QACnC;QACA,6CAA6C;YAC3CC,MAAM,CAAC,iDAAiD,CAAC;YACzD,iCAAiC;QACnC;QACA,8CAA8C;YAC5CC,KAAK;YACL,iCAAiC;QACnC;QACA,4CAA4C;YAC1CC,OAAO,CAAC,iDAAiD,CAAC;YAC1D,iCAAiC;QACnC;IACF;AACF;AASO,SAAS3B,wBAAwBG,WAAmB;IACzD,qGAAqG;IACrG,wEAAwE;IACxE,MAAMyB,aAAa,QAAQzB;IAE3B,OAAO;QACL,kCAAkC,CAAC,EAAEyB,WAAW,EAAE,CAAC;QACnD,kCAAkC,CAAC,EAAE,AAACA,aAAa,IAAK,CAAC,EAAE,EAAE,CAAC;IAChE;AACF"}
1
+ {"version":3,"sources":["../src/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,OAAiC;IACjE,MAAM,EACJC,WAAW,EACXC,cAAc,KAAK,EACnBC,cAAc,OAAO,EACrBC,cAAcC,kBAAAA,CAAOC,sBAAsB,EAC5C,GAAGN;IAEJ,OAAO;QACLO,WAAW;QACXC,UAAU;QACVC,QAAQ,CAAC;QAET,GAAIR,eAAeH,wBAAwBG,YAAY;QAEvDS,iBAAiB;QACjBC,gBAAgB;QAEhBC,wBAAwB,CAAC,EAAEP,kBAAAA,CAAOQ,iBAAiB,CAAC,cAAc,CAAC;QACnEC,WAAW;QAEXC,QAAQ;QACRC,OAAO;QAEP,YAAY;YACVC,SAAS;YAETC,SAAS;YACTR,iBAAiB;YACjBS,QAAQ,CAAC,CAAC,EAAEjB,YAAY,CAAC;YACzBc,OAAO;YACPD,QAAQ;YAERK,QAAQ,CAAC,EAAElB,YAAY,CAAC,EAAEC,YAAY,CAAC,EAAEC,YAAY,CAAC;YACtDQ,wBAAwB,CAAC,EAAEP,kBAAAA,CAAOQ,iBAAiB,CAAC,cAAc,CAAC;YAEnEQ,UAAU;QACZ;QAEA,0FAA0F;QAC1F,2CAA2C;YACzCC,QAAQ;YACR,iCAAiC;QACnC;QACA,6CAA6C;YAC3CC,MAAM,CAAC,iDAAiD,CAAC;YACzD,iCAAiC;QACnC;QACA,8CAA8C;YAC5CC,KAAK;YACL,iCAAiC;QACnC;QACA,4CAA4C;YAC1CC,OAAO,CAAC,iDAAiD,CAAC;YAC1D,iCAAiC;QACnC;IACF;AACF;AASO,SAAS3B,wBAAwBG,WAAmB;IACzD,qGAAqG;IACrG,wEAAwE;IACxE,MAAMyB,aAAa,QAAQzB;IAE3B,OAAO;QACL,kCAAkC,CAAC,EAAEyB,WAAW,EAAE,CAAC;QACnD,kCAAkC,CAAC,EAAEA,aAAc,IAAK,CAAC,EAAE,EAAE,CAAC;IAChE;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/createPositionManager.ts"],"sourcesContent":["import { computePosition } from '@floating-ui/dom';\nimport type { Middleware, Placement, Strategy } from '@floating-ui/dom';\nimport { isHTMLElement } from '@fluentui/react-utilities';\nimport type { PositionManager, TargetElement } from './types';\nimport { debounce, writeArrowUpdates, writeContainerUpdates } from './utils';\nimport { listScrollParents } from './utils/listScrollParents';\nimport { POSITIONING_END_EVENT } from './constants';\nimport { createResizeObserver } from './utils/createResizeObserver';\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 * Modifies whether popover is positioned using transform.\n * @default true\n */\n useTransform?: boolean;\n /**\n * Disables the resize observer that updates position on target or dimension change\n */\n disableUpdateOnResize?: boolean;\n}\n\n/**\n * @internal\n * @returns manager that handles positioning out of the react lifecycle\n */\nexport function createPositionManager(options: PositionManagerOptions): PositionManager {\n let isDestroyed = false;\n const {\n container,\n target,\n arrow,\n strategy,\n middleware,\n placement,\n useTransform = true,\n disableUpdateOnResize = false,\n } = options;\n const targetWindow = container.ownerDocument.defaultView;\n if (!target || !container || !targetWindow) {\n return {\n updatePosition: () => undefined,\n dispose: () => undefined,\n };\n }\n\n // When the dimensions of the target or the container change - trigger a position update\n const resizeObserver = disableUpdateOnResize\n ? null\n : createResizeObserver(targetWindow, entries => {\n // If content rect dimensions to go 0 -> very likely that `display: none` is being used to hide the element\n // In this case don't update and let users update imperatively\n const shouldUpdateOnResize = entries.every(entry => {\n return entry.contentRect.width > 0 && entry.contentRect.height > 0;\n });\n\n if (shouldUpdateOnResize) {\n updatePosition();\n }\n });\n\n let isFirstUpdate = true;\n const scrollParents: Set<HTMLElement> = new Set<HTMLElement>();\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 listScrollParents(container).forEach(scrollParent => scrollParents.add(scrollParent));\n if (isHTMLElement(target)) {\n listScrollParents(target).forEach(scrollParent => scrollParents.add(scrollParent));\n }\n\n scrollParents.forEach(scrollParent => {\n scrollParent.addEventListener('scroll', updatePosition, { passive: true });\n });\n\n resizeObserver?.observe(container);\n if (isHTMLElement(target)) {\n resizeObserver?.observe(target);\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 useTransform,\n });\n\n container.dispatchEvent(new CustomEvent(POSITIONING_END_EVENT));\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 scrollParents.clear();\n\n resizeObserver?.disconnect();\n };\n\n if (targetWindow) {\n targetWindow.addEventListener('scroll', updatePosition, { passive: true });\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"],"names":["createPositionManager","options","isDestroyed","container","target","arrow","strategy","middleware","placement","useTransform","disableUpdateOnResize","targetWindow","ownerDocument","defaultView","updatePosition","undefined","dispose","resizeObserver","createResizeObserver","entries","shouldUpdateOnResize","every","entry","contentRect","width","height","isFirstUpdate","scrollParents","Set","Object","assign","style","position","left","top","margin","forceUpdate","listScrollParents","forEach","scrollParent","add","isHTMLElement","addEventListener","passive","observe","computePosition","then","x","y","middlewareData","computedPlacement","writeArrowUpdates","writeContainerUpdates","coordinates","lowPPI","devicePixelRatio","dispatchEvent","CustomEvent","POSITIONING_END_EVENT","catch","err","process","env","NODE_ENV","console","error","debounce","removeEventListener","clear","disconnect"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAkDgBA;;;eAAAA;;;qBAlDgB;gCAEF;uBAEqC;mCACjC;2BACI;sCACD;AA2C9B,SAASA,sBAAsBC,OAA+B;IACnE,IAAIC,cAAc;IAClB,MAAM,EACJC,SAAS,EACTC,MAAM,EACNC,KAAK,EACLC,QAAQ,EACRC,UAAU,EACVC,SAAS,EACTC,eAAe,IAAI,EACnBC,wBAAwB,KAAK,EAC9B,GAAGT;IACJ,MAAMU,eAAeR,UAAUS,aAAa,CAACC,WAAW;IACxD,IAAI,CAACT,UAAU,CAACD,aAAa,CAACQ,cAAc;QAC1C,OAAO;YACLG,gBAAgB,IAAMC;YACtBC,SAAS,IAAMD;QACjB;IACF;IAEA,wFAAwF;IACxF,MAAME,iBAAiBP,wBACnB,OACAQ,IAAAA,0CAAoB,EAACP,cAAcQ,CAAAA;QACjC,2GAA2G;QAC3G,8DAA8D;QAC9D,MAAMC,uBAAuBD,QAAQE,KAAK,CAACC,CAAAA;YACzC,OAAOA,MAAMC,WAAW,CAACC,KAAK,GAAG,KAAKF,MAAMC,WAAW,CAACE,MAAM,GAAG;QACnE;QAEA,IAAIL,sBAAsB;YACxBN;QACF;IACF;IAEJ,IAAIY,gBAAgB;IACpB,MAAMC,gBAAkC,IAAIC;IAE5C,oFAAoF;IACpF,gGAAgG;IAChGC,OAAOC,MAAM,CAAC3B,UAAU4B,KAAK,EAAE;QAAEC,UAAU;QAASC,MAAM;QAAGC,KAAK;QAAGC,QAAQ;IAAE;IAE/E,MAAM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AACC,CAAAA;YACL,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;QACF;IACJ;IAEA,MAAM9C,iBAAiBoD,IAAAA,eAAQ,EAAC,IAAM9B;IAEtC,MAAMpB,UAAU;QACdd,cAAc;QAEd,IAAIS,cAAc;YAChBA,aAAawD,mBAAmB,CAAC,UAAUrD;YAC3CH,aAAawD,mBAAmB,CAAC,UAAUrD;QAC7C;QAEAa,cAAcW,OAAO,CAACC,CAAAA;YACpBA,aAAa4B,mBAAmB,CAAC,UAAUrD;QAC7C;QACAa,cAAcyC,KAAK;QAEnBnD,2BAAAA,qCAAAA,eAAgBoD,UAAU;IAC5B;IAEA,IAAI1D,cAAc;QAChBA,aAAa+B,gBAAgB,CAAC,UAAU5B,gBAAgB;YAAE6B,SAAS;QAAK;QACxEhC,aAAa+B,gBAAgB,CAAC,UAAU5B;IAC1C;IAEA,wCAAwC;IACxCA;IAEA,OAAO;QACLA;QACAE;IACF;AACF"}
1
+ {"version":3,"sources":["../src/createPositionManager.ts"],"sourcesContent":["import { computePosition } from '@floating-ui/dom';\nimport type { Middleware, Placement, Strategy } from '@floating-ui/dom';\nimport { isHTMLElement } from '@fluentui/react-utilities';\nimport type { PositionManager, TargetElement } from './types';\nimport { debounce, writeArrowUpdates, writeContainerUpdates } from './utils';\nimport { listScrollParents } from './utils/listScrollParents';\nimport { POSITIONING_END_EVENT } from './constants';\nimport { createResizeObserver } from './utils/createResizeObserver';\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 * Modifies whether popover is positioned using transform.\n * @default true\n */\n useTransform?: boolean;\n /**\n * Disables the resize observer that updates position on target or dimension change\n */\n disableUpdateOnResize?: boolean;\n}\n\n/**\n * @internal\n * @returns manager that handles positioning out of the react lifecycle\n */\nexport function createPositionManager(options: PositionManagerOptions): PositionManager {\n let isDestroyed = false;\n const {\n container,\n target,\n arrow,\n strategy,\n middleware,\n placement,\n useTransform = true,\n disableUpdateOnResize = false,\n } = options;\n const targetWindow = container.ownerDocument.defaultView;\n if (!target || !container || !targetWindow) {\n return {\n updatePosition: () => undefined,\n dispose: () => undefined,\n };\n }\n\n // When the dimensions of the target or the container change - trigger a position update\n const resizeObserver = disableUpdateOnResize\n ? null\n : createResizeObserver(targetWindow, entries => {\n // If content rect dimensions to go 0 -> very likely that `display: none` is being used to hide the element\n // In this case don't update and let users update imperatively\n const shouldUpdateOnResize = entries.every(entry => {\n return entry.contentRect.width > 0 && entry.contentRect.height > 0;\n });\n\n if (shouldUpdateOnResize) {\n updatePosition();\n }\n });\n\n let isFirstUpdate = true;\n const scrollParents: Set<HTMLElement> = new Set<HTMLElement>();\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 listScrollParents(container).forEach(scrollParent => scrollParents.add(scrollParent));\n if (isHTMLElement(target)) {\n listScrollParents(target).forEach(scrollParent => scrollParents.add(scrollParent));\n }\n\n scrollParents.forEach(scrollParent => {\n scrollParent.addEventListener('scroll', updatePosition, { passive: true });\n });\n\n resizeObserver?.observe(container);\n if (isHTMLElement(target)) {\n resizeObserver?.observe(target);\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 useTransform,\n });\n\n container.dispatchEvent(new CustomEvent(POSITIONING_END_EVENT));\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 scrollParents.clear();\n\n resizeObserver?.disconnect();\n };\n\n if (targetWindow) {\n targetWindow.addEventListener('scroll', updatePosition, { passive: true });\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"],"names":["createPositionManager","options","isDestroyed","container","target","arrow","strategy","middleware","placement","useTransform","disableUpdateOnResize","targetWindow","ownerDocument","defaultView","updatePosition","undefined","dispose","resizeObserver","createResizeObserver","entries","shouldUpdateOnResize","every","entry","contentRect","width","height","isFirstUpdate","scrollParents","Set","Object","assign","style","position","left","top","margin","forceUpdate","listScrollParents","forEach","scrollParent","add","isHTMLElement","addEventListener","passive","observe","computePosition","then","x","y","middlewareData","computedPlacement","writeArrowUpdates","writeContainerUpdates","coordinates","lowPPI","devicePixelRatio","dispatchEvent","CustomEvent","POSITIONING_END_EVENT","catch","err","process","env","NODE_ENV","console","error","debounce","removeEventListener","clear","disconnect"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAkDgBA;;;eAAAA;;;qBAlDgB;gCAEF;uBAEqC;mCACjC;2BACI;sCACD;AA2C9B,SAASA,sBAAsBC,OAA+B;IACnE,IAAIC,cAAc;IAClB,MAAM,EACJC,SAAS,EACTC,MAAM,EACNC,KAAK,EACLC,QAAQ,EACRC,UAAU,EACVC,SAAS,EACTC,eAAe,IAAI,EACnBC,wBAAwB,KAAK,EAC9B,GAAGT;IACJ,MAAMU,eAAeR,UAAUS,aAAa,CAACC,WAAW;IACxD,IAAI,CAACT,UAAU,CAACD,aAAa,CAACQ,cAAc;QAC1C,OAAO;YACLG,gBAAgB,IAAMC;YACtBC,SAAS,IAAMD;QACjB;IACF;IAEA,wFAAwF;IACxF,MAAME,iBAAiBP,wBACnB,OACAQ,IAAAA,0CAAAA,EAAqBP,cAAcQ,CAAAA;QACjC,2GAA2G;QAC3G,8DAA8D;QAC9D,MAAMC,uBAAuBD,QAAQE,KAAK,CAACC,CAAAA;YACzC,OAAOA,MAAMC,WAAW,CAACC,KAAK,GAAG,KAAKF,MAAMC,WAAW,CAACE,MAAM,GAAG;QACnE;QAEA,IAAIL,sBAAsB;YACxBN;QACF;IACF;IAEJ,IAAIY,gBAAgB;IACpB,MAAMC,gBAAkC,IAAIC;IAE5C,oFAAoF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0C;gBACXG,aAAa;oBAAEN;oBAAGC;gBAAE;gBACpBM,QAAQ,AAAC3C,CAAAA,CAAAA,iBAAAA,QAAAA,iBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,aAAc4C,gBAAgB,AAAhBA,KAAoB,CAAA,KAAM;gBACjDjD;gBACAG;YACF;YAEAN,UAAUqD,aAAa,CAAC,IAAIC,YAAYC,gCAAAA;QAC1C,GACCC,KAAK,CAACC,CAAAA;YACL,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;QACF;IACJ;IAEA,MAAM9C,iBAAiBoD,IAAAA,eAAAA,EAAS,IAAM9B;IAEtC,MAAMpB,UAAU;QACdd,cAAc;QAEd,IAAIS,cAAc;YAChBA,aAAawD,mBAAmB,CAAC,UAAUrD;YAC3CH,aAAawD,mBAAmB,CAAC,UAAUrD;QAC7C;QAEAa,cAAcW,OAAO,CAACC,CAAAA;YACpBA,aAAa4B,mBAAmB,CAAC,UAAUrD;QAC7C;QACAa,cAAcyC,KAAK;QAEnBnD,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgBoD,UAAU;IAC5B;IAEA,IAAI1D,cAAc;QAChBA,aAAa+B,gBAAgB,CAAC,UAAU5B,gBAAgB;YAAE6B,SAAS;QAAK;QACxEhC,aAAa+B,gBAAgB,CAAC,UAAU5B;IAC1C;IAEA,wCAAwC;IACxCA;IAEA,OAAO;QACLA;QACAE;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/createSlideStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\nimport { DATA_POSITIONING_PLACEMENT } from './constants';\n\n/**\n * Creates animation styles so that positioned elements slide in from the main axis\n * @param mainAxis - distance than the element sides for\n * @returns Griffel styles to spread to a slot\n */\nexport function createSlideStyles(mainAxis: number): GriffelStyle {\n // With 'accumulate' animation composition, these opacity keyframes are added onto the default opacity of 1.\n const fadeIn = {\n from: {\n opacity: -1, // becomes opacity: 0\n },\n to: {\n opacity: 0, // becomes opacity: 1\n },\n };\n\n const slideDistanceVarX = '--fui-positioning-slide-distance-x';\n const slideDistanceVarY = '--fui-positioning-slide-distance-y';\n\n return {\n // NOTE: there was a previous attempt to give fadeIn a separate composition mode:\n // animationComposition: 'replace, accumulate',\n // but somehow this was linked to a performance regression observed in Teams (bug #4255933)\n animationComposition: 'accumulate',\n animationDuration: tokens.durationSlower,\n animationTimingFunction: tokens.curveDecelerateMid,\n [slideDistanceVarX]: `0px`,\n [slideDistanceVarY]: `${mainAxis}px`,\n [`&[${DATA_POSITIONING_PLACEMENT}^=right]`]: {\n [slideDistanceVarX]: `-${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=bottom]`]: {\n [slideDistanceVarX]: '0px',\n [slideDistanceVarY]: `-${mainAxis}px`,\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=left]`]: {\n [slideDistanceVarX]: `${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n animationName: [\n fadeIn,\n {\n from: {\n transform: `translate(var(${slideDistanceVarX}), var(${slideDistanceVarY}))`,\n },\n to: {},\n },\n ],\n\n // Note: at-rules have more specificity in Griffel\n '@media(prefers-reduced-motion)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationDuration: '1ms',\n animationName: fadeIn,\n },\n },\n\n // Tested in Firefox 79\n '@supports not (animation-composition: accumulate)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationName: fadeIn,\n },\n },\n };\n}\n"],"names":["createSlideStyles","mainAxis","fadeIn","from","opacity","to","slideDistanceVarX","slideDistanceVarY","animationComposition","animationDuration","tokens","durationSlower","animationTimingFunction","curveDecelerateMid","DATA_POSITIONING_PLACEMENT","animationName","transform"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BASgBA;;;eAAAA;;;4BATO;2BAEoB;AAOpC,SAASA,kBAAkBC,QAAgB;IAChD,4GAA4G;IAC5G,MAAMC,SAAS;QACbC,MAAM;YACJC,SAAS,CAAC;QACZ;QACAC,IAAI;YACFD,SAAS;QACX;IACF;IAEA,MAAME,oBAAoB;IAC1B,MAAMC,oBAAoB;IAE1B,OAAO;QACL,iFAAiF;QACjF,iDAAiD;QACjD,2FAA2F;QAC3FC,sBAAsB;QACtBC,mBAAmBC,kBAAM,CAACC,cAAc;QACxCC,yBAAyBF,kBAAM,CAACG,kBAAkB;QAClD,CAACP,kBAAkB,EAAE,CAAC,GAAG,CAAC;QAC1B,CAACC,kBAAkB,EAAE,CAAC,EAAEN,SAAS,EAAE,CAAC;QACpC,CAAC,CAAC,EAAE,EAAEa,qCAA0B,CAAC,QAAQ,CAAC,CAAC,EAAE;YAC3C,CAACR,kBAAkB,EAAE,CAAC,CAAC,EAAEL,SAAS,EAAE,CAAC;YACrC,CAACM,kBAAkB,EAAE;QACvB;QAEA,CAAC,CAAC,EAAE,EAAEO,qCAA0B,CAAC,SAAS,CAAC,CAAC,EAAE;YAC5C,CAACR,kBAAkB,EAAE;YACrB,CAACC,kBAAkB,EAAE,CAAC,CAAC,EAAEN,SAAS,EAAE,CAAC;QACvC;QAEA,CAAC,CAAC,EAAE,EAAEa,qCAA0B,CAAC,OAAO,CAAC,CAAC,EAAE;YAC1C,CAACR,kBAAkB,EAAE,CAAC,EAAEL,SAAS,EAAE,CAAC;YACpC,CAACM,kBAAkB,EAAE;QACvB;QAEAQ,eAAe;YACbb;YACA;gBACEC,MAAM;oBACJa,WAAW,CAAC,cAAc,EAAEV,kBAAkB,OAAO,EAAEC,kBAAkB,EAAE,CAAC;gBAC9E;gBACAF,IAAI,CAAC;YACP;SACD;QAED,kDAAkD;QAClD,kCAAkC;YAChC,CAAC,CAAC,EAAE,EAAES,qCAA0B,CAAC,CAAC,CAAC,CAAC,EAAE;gBACpCL,mBAAmB;gBACnBM,eAAeb;YACjB;QACF;QAEA,uBAAuB;QACvB,qDAAqD;YACnD,CAAC,CAAC,EAAE,EAAEY,qCAA0B,CAAC,CAAC,CAAC,CAAC,EAAE;gBACpCC,eAAeb;YACjB;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../src/createSlideStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport type { GriffelStyle } from '@griffel/react';\nimport { DATA_POSITIONING_PLACEMENT } from './constants';\n\n/**\n * Creates animation styles so that positioned elements slide in from the main axis\n * @param mainAxis - distance than the element sides for\n * @returns Griffel styles to spread to a slot\n */\nexport function createSlideStyles(mainAxis: number): GriffelStyle {\n // With 'accumulate' animation composition, these opacity keyframes are added onto the default opacity of 1.\n const fadeIn = {\n from: {\n opacity: -1, // becomes opacity: 0\n },\n to: {\n opacity: 0, // becomes opacity: 1\n },\n };\n\n const slideDistanceVarX = '--fui-positioning-slide-distance-x';\n const slideDistanceVarY = '--fui-positioning-slide-distance-y';\n\n return {\n // NOTE: there was a previous attempt to give fadeIn a separate composition mode:\n // animationComposition: 'replace, accumulate',\n // but somehow this was linked to a performance regression observed in Teams (bug #4255933)\n animationComposition: 'accumulate',\n animationDuration: tokens.durationSlower,\n animationTimingFunction: tokens.curveDecelerateMid,\n [slideDistanceVarX]: `0px`,\n [slideDistanceVarY]: `${mainAxis}px`,\n [`&[${DATA_POSITIONING_PLACEMENT}^=right]`]: {\n [slideDistanceVarX]: `-${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=bottom]`]: {\n [slideDistanceVarX]: '0px',\n [slideDistanceVarY]: `-${mainAxis}px`,\n },\n\n [`&[${DATA_POSITIONING_PLACEMENT}^=left]`]: {\n [slideDistanceVarX]: `${mainAxis}px`,\n [slideDistanceVarY]: '0px',\n },\n\n animationName: [\n fadeIn,\n {\n from: {\n transform: `translate(var(${slideDistanceVarX}), var(${slideDistanceVarY}))`,\n },\n to: {},\n },\n ],\n\n // Note: at-rules have more specificity in Griffel\n '@media(prefers-reduced-motion)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationDuration: '1ms',\n animationName: fadeIn,\n },\n },\n\n // Tested in Firefox 79\n '@supports not (animation-composition: accumulate)': {\n [`&[${DATA_POSITIONING_PLACEMENT}]`]: {\n animationName: fadeIn,\n },\n },\n };\n}\n"],"names":["createSlideStyles","mainAxis","fadeIn","from","opacity","to","slideDistanceVarX","slideDistanceVarY","animationComposition","animationDuration","tokens","durationSlower","animationTimingFunction","curveDecelerateMid","DATA_POSITIONING_PLACEMENT","animationName","transform"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BASgBA;;;eAAAA;;;4BATO;2BAEoB;AAOpC,SAASA,kBAAkBC,QAAgB;IAChD,4GAA4G;IAC5G,MAAMC,SAAS;QACbC,MAAM;YACJC,SAAS,CAAC;QACZ;QACAC,IAAI;YACFD,SAAS;QACX;IACF;IAEA,MAAME,oBAAoB;IAC1B,MAAMC,oBAAoB;IAE1B,OAAO;QACL,iFAAiF;QACjF,iDAAiD;QACjD,2FAA2F;QAC3FC,sBAAsB;QACtBC,mBAAmBC,kBAAAA,CAAOC,cAAc;QACxCC,yBAAyBF,kBAAAA,CAAOG,kBAAkB;QAClD,CAACP,kBAAkB,EAAE,CAAC,GAAG,CAAC;QAC1B,CAACC,kBAAkB,EAAE,CAAC,EAAEN,SAAS,EAAE,CAAC;QACpC,CAAC,CAAC,EAAE,EAAEa,qCAAAA,CAA2B,QAAQ,CAAC,CAAC,EAAE;YAC3C,CAACR,kBAAkB,EAAE,CAAC,CAAC,EAAEL,SAAS,EAAE,CAAC;YACrC,CAACM,kBAAkB,EAAE;QACvB;QAEA,CAAC,CAAC,EAAE,EAAEO,qCAAAA,CAA2B,SAAS,CAAC,CAAC,EAAE;YAC5C,CAACR,kBAAkB,EAAE;YACrB,CAACC,kBAAkB,EAAE,CAAC,CAAC,EAAEN,SAAS,EAAE,CAAC;QACvC;QAEA,CAAC,CAAC,EAAE,EAAEa,qCAAAA,CAA2B,OAAO,CAAC,CAAC,EAAE;YAC1C,CAACR,kBAAkB,EAAE,CAAC,EAAEL,SAAS,EAAE,CAAC;YACpC,CAACM,kBAAkB,EAAE;QACvB;QAEAQ,eAAe;YACbb;YACA;gBACEC,MAAM;oBACJa,WAAW,CAAC,cAAc,EAAEV,kBAAkB,OAAO,EAAEC,kBAAkB,EAAE,CAAC;gBAC9E;gBACAF,IAAI,CAAC;YACP;SACD;QAED,kDAAkD;QAClD,kCAAkC;YAChC,CAAC,CAAC,EAAE,EAAES,qCAAAA,CAA2B,CAAC,CAAC,CAAC,EAAE;gBACpCL,mBAAmB;gBACnBM,eAAeb;YACjB;QACF;QAEA,uBAAuB;QACvB,qDAAqD;YACnD,CAAC,CAAC,EAAE,EAAEY,qCAAAA,CAA2B,CAAC,CAAC,CAAC,EAAE;gBACpCC,eAAeb;YACjB;QACF;IACF;AACF"}
@@ -1,4 +1,7 @@
1
- "use strict";
1
+ /**
2
+ * Creates a virtual element based on the position of a click event
3
+ * Can be used as a target for popper in scenarios such as context menus
4
+ */ "use strict";
2
5
  Object.defineProperty(exports, "__esModule", {
3
6
  value: true
4
7
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../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"],"names":["createVirtualElementFromClick","nativeEvent","left","clientX","top","clientY","right","bottom","getBoundingClientRect","x","y","height","width"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAMgBA;;;eAAAA;;;AAAT,SAASA,8BAA8BC,WAAuB;IACnE,MAAMC,OAAOD,YAAYE,OAAO;IAChC,MAAMC,MAAMH,YAAYI,OAAO;IAC/B,MAAMC,QAAQJ,OAAO;IACrB,MAAMK,SAASH,MAAM;IAErB,SAASI;QACP,OAAO;YACLN;YACAE;YACAE;YACAC;YACAE,GAAGP;YACHQ,GAAGN;YACHO,QAAQ;YACRC,OAAO;QACT;IACF;IAEA,OAAO;QACLJ;IACF;AACF"}
1
+ {"version":3,"sources":["../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"],"names":["createVirtualElementFromClick","nativeEvent","left","clientX","top","clientY","right","bottom","getBoundingClientRect","x","y","height","width"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA;;;CAGC;;;;+BACeA;;;eAAAA;;;AAAT,SAASA,8BAA8BC,WAAuB;IACnE,MAAMC,OAAOD,YAAYE,OAAO;IAChC,MAAMC,MAAMH,YAAYI,OAAO;IAC/B,MAAMC,QAAQJ,OAAO;IACrB,MAAMK,SAASH,MAAM;IAErB,SAASI;QACP,OAAO;YACLN;YACAE;YACAE;YACAC;YACAE,GAAGP;YACHQ,GAAGN;YACHO,QAAQ;YACRC,OAAO;QACT;IACF;IAEA,OAAO;QACLJ;IACF;AACF"}
@@ -35,6 +35,9 @@ _export(exports, {
35
35
  },
36
36
  usePositioningMouseTarget: function() {
37
37
  return _usePositioningMouseTarget.usePositioningMouseTarget;
38
+ },
39
+ useSafeZoneArea: function() {
40
+ return _useSafeZoneArea.useSafeZoneArea;
38
41
  }
39
42
  });
40
43
  const _createVirtualElementFromClick = require("./createVirtualElementFromClick");
@@ -43,4 +46,5 @@ const _createSlideStyles = require("./createSlideStyles");
43
46
  const _PositioningConfigurationContext = require("./PositioningConfigurationContext");
44
47
  const _usePositioning = require("./usePositioning");
45
48
  const _usePositioningMouseTarget = require("./usePositioningMouseTarget");
49
+ const _useSafeZoneArea = require("./useSafeZoneArea");
46
50
  const _index = require("./utils/index");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport { createSlideStyles } from './createSlideStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\n\nexport { PositioningConfigurationProvider } from './PositioningConfigurationContext';\n\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\n\nexport type {\n Alignment,\n AutoSize,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningBoundary,\n PositioningImperativeRef,\n PositioningProps,\n PositioningRect,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n SetVirtualMouseTarget,\n PositioningConfigurationFn,\n PositioningConfigurationFnOptions,\n} from './types';\n"],"names":["PositioningConfigurationProvider","createArrowHeightStyles","createArrowStyles","createSlideStyles","createVirtualElementFromClick","mergeArrowOffset","resolvePositioningShorthand","usePositioning","usePositioningMouseTarget"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAKSA,gCAAgC;eAAhCA,iEAAgC;;IAJhCC,uBAAuB;eAAvBA,0CAAuB;;IAAEC,iBAAiB;eAAjBA,oCAAiB;;IAC1CC,iBAAiB;eAAjBA,oCAAiB;;IAFjBC,6BAA6B;eAA7BA,4DAA6B;;IASAC,gBAAgB;eAAhBA,uBAAgB;;IAA7CC,2BAA2B;eAA3BA,kCAA2B;;IAF3BC,cAAc;eAAdA,8BAAc;;IACdC,yBAAyB;eAAzBA,oDAAyB;;;+CARY;mCACa;mCACzB;iDAGe;gCAElB;2CACW;uBACoB"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport { createSlideStyles } from './createSlideStyles';\nexport type { CreateArrowStylesOptions } from './createArrowStyles';\n\nexport { PositioningConfigurationProvider } from './PositioningConfigurationContext';\n\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { useSafeZoneArea } from './useSafeZoneArea';\nexport type { SafeBufferAreaOptions } from './useSafeZoneArea';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\n\nexport type {\n Alignment,\n AutoSize,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n Boundary,\n Offset,\n OffsetFunction,\n OffsetFunctionParam,\n OffsetObject,\n OffsetShorthand,\n Position,\n PositioningBoundary,\n PositioningImperativeRef,\n PositioningProps,\n PositioningRect,\n PositioningShorthand,\n PositioningShorthandValue,\n PositioningVirtualElement,\n SetVirtualMouseTarget,\n PositioningConfigurationFn,\n PositioningConfigurationFnOptions,\n} from './types';\n"],"names":["PositioningConfigurationProvider","createArrowHeightStyles","createArrowStyles","createSlideStyles","createVirtualElementFromClick","mergeArrowOffset","resolvePositioningShorthand","usePositioning","usePositioningMouseTarget","useSafeZoneArea"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAKSA,gCAAgC;eAAhCA,iEAAgC;;IAJhCC,uBAAuB;eAAvBA,0CAAuB;;IAAEC,iBAAiB;eAAjBA,oCAAiB;;IAC1CC,iBAAiB;eAAjBA,oCAAiB;;IAFjBC,6BAA6B;eAA7BA,4DAA6B;;IAWAC,gBAAgB;eAAhBA,uBAAgB;;IAA7CC,2BAA2B;eAA3BA,kCAA2B;;IAJ3BC,cAAc;eAAdA,8BAAc;;IACdC,yBAAyB;eAAzBA,oDAAyB;;IACzBC,eAAe;eAAfA,gCAAe;;;+CATsB;mCACa;mCACzB;iDAGe;gCAElB;2CACW;iCACV;uBAE8B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/middleware/coverTarget.ts"],"sourcesContent":["import type { Middleware } from '@floating-ui/dom';\nimport { parseFloatingUIPlacement } from '../utils/index';\n\nexport function coverTarget(): Middleware {\n return {\n name: 'coverTarget',\n fn: middlewareArguments => {\n const { placement, rects, x, y } = middlewareArguments;\n const basePlacement = parseFloatingUIPlacement(placement).side;\n const newCoords = { x, y };\n\n switch (basePlacement) {\n case 'bottom':\n newCoords.y -= rects.reference.height;\n break;\n case 'top':\n newCoords.y += rects.reference.height;\n break;\n case 'left':\n newCoords.x += rects.reference.width;\n break;\n case 'right':\n newCoords.x -= rects.reference.width;\n break;\n }\n\n return newCoords;\n },\n };\n}\n"],"names":["coverTarget","name","fn","middlewareArguments","placement","rects","x","y","basePlacement","parseFloatingUIPlacement","side","newCoords","reference","height","width"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAGgBA;;;eAAAA;;;uBAFyB;AAElC,SAASA;IACd,OAAO;QACLC,MAAM;QACNC,IAAIC,CAAAA;YACF,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAEC,CAAC,EAAEC,CAAC,EAAE,GAAGJ;YACnC,MAAMK,gBAAgBC,IAAAA,+BAAwB,EAACL,WAAWM,IAAI;YAC9D,MAAMC,YAAY;gBAAEL;gBAAGC;YAAE;YAEzB,OAAQC;gBACN,KAAK;oBACHG,UAAUJ,CAAC,IAAIF,MAAMO,SAAS,CAACC,MAAM;oBACrC;gBACF,KAAK;oBACHF,UAAUJ,CAAC,IAAIF,MAAMO,SAAS,CAACC,MAAM;oBACrC;gBACF,KAAK;oBACHF,UAAUL,CAAC,IAAID,MAAMO,SAAS,CAACE,KAAK;oBACpC;gBACF,KAAK;oBACHH,UAAUL,CAAC,IAAID,MAAMO,SAAS,CAACE,KAAK;oBACpC;YACJ;YAEA,OAAOH;QACT;IACF;AACF"}
1
+ {"version":3,"sources":["../src/middleware/coverTarget.ts"],"sourcesContent":["import type { Middleware } from '@floating-ui/dom';\nimport { parseFloatingUIPlacement } from '../utils/index';\n\nexport function coverTarget(): Middleware {\n return {\n name: 'coverTarget',\n fn: middlewareArguments => {\n const { placement, rects, x, y } = middlewareArguments;\n const basePlacement = parseFloatingUIPlacement(placement).side;\n const newCoords = { x, y };\n\n switch (basePlacement) {\n case 'bottom':\n newCoords.y -= rects.reference.height;\n break;\n case 'top':\n newCoords.y += rects.reference.height;\n break;\n case 'left':\n newCoords.x += rects.reference.width;\n break;\n case 'right':\n newCoords.x -= rects.reference.width;\n break;\n }\n\n return newCoords;\n },\n };\n}\n"],"names":["coverTarget","name","fn","middlewareArguments","placement","rects","x","y","basePlacement","parseFloatingUIPlacement","side","newCoords","reference","height","width"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAGgBA;;;eAAAA;;;uBAFyB;AAElC,SAASA;IACd,OAAO;QACLC,MAAM;QACNC,IAAIC,CAAAA;YACF,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAEC,CAAC,EAAEC,CAAC,EAAE,GAAGJ;YACnC,MAAMK,gBAAgBC,IAAAA,+BAAAA,EAAyBL,WAAWM,IAAI;YAC9D,MAAMC,YAAY;gBAAEL;gBAAGC;YAAE;YAEzB,OAAQC;gBACN,KAAK;oBACHG,UAAUJ,CAAC,IAAIF,MAAMO,SAAS,CAACC,MAAM;oBACrC;gBACF,KAAK;oBACHF,UAAUJ,CAAC,IAAIF,MAAMO,SAAS,CAACC,MAAM;oBACrC;gBACF,KAAK;oBACHF,UAAUL,CAAC,IAAID,MAAMO,SAAS,CAACE,KAAK;oBACpC;gBACF,KAAK;oBACHH,UAAUL,CAAC,IAAID,MAAMO,SAAS,CAACE,KAAK;oBACpC;YACJ;YAEA,OAAOH;QACT;IACF;AACF"}