@fluentui/react-positioning 9.5.14 → 9.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +77 -1
- package/CHANGELOG.md +33 -2
- package/dist/index.d.ts +14 -2
- package/lib/constants.js +0 -1
- package/lib/constants.js.map +1 -1
- package/lib/createArrowStyles.js +47 -55
- package/lib/createArrowStyles.js.map +1 -1
- package/lib/createPositionManager.js +95 -108
- package/lib/createPositionManager.js.map +1 -1
- package/lib/createSlideStyles.js +59 -0
- package/lib/createSlideStyles.js.map +1 -0
- package/lib/createVirtualElementFromClick.js +18 -19
- package/lib/createVirtualElementFromClick.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/middleware/coverTarget.js +26 -32
- package/lib/middleware/coverTarget.js.map +1 -1
- package/lib/middleware/flip.js +22 -32
- package/lib/middleware/flip.js.map +1 -1
- package/lib/middleware/index.js +0 -1
- package/lib/middleware/index.js.map +1 -1
- package/lib/middleware/intersecting.js +16 -17
- package/lib/middleware/intersecting.js.map +1 -1
- package/lib/middleware/maxSize.js +25 -34
- package/lib/middleware/maxSize.js.map +1 -1
- package/lib/middleware/offset.js +3 -5
- package/lib/middleware/offset.js.map +1 -1
- package/lib/middleware/shift.js +21 -30
- package/lib/middleware/shift.js.map +1 -1
- package/lib/types.js +0 -1
- package/lib/types.js.map +1 -1
- package/lib/usePositioning.js +188 -154
- package/lib/usePositioning.js.map +1 -1
- package/lib/usePositioningMouseTarget.js +24 -23
- package/lib/usePositioningMouseTarget.js.map +1 -1
- package/lib/utils/debounce.js +13 -14
- package/lib/utils/debounce.js.map +1 -1
- package/lib/utils/fromFloatingUIPlacement.js +23 -28
- package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib/utils/getBoundary.js +14 -16
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getFloatingUIOffset.js +16 -27
- package/lib/utils/getFloatingUIOffset.js.map +1 -1
- package/lib/utils/getReactFiberFromNode.js +36 -37
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js +35 -42
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/hasAutoFocusFilter.js +9 -11
- package/lib/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib/utils/index.js +0 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.js +24 -25
- package/lib/utils/mergeArrowOffset.js.map +1 -1
- package/lib/utils/parseFloatingUIPlacement.js +6 -7
- package/lib/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.js +55 -56
- package/lib/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib/utils/toFloatingUIPadding.js +16 -21
- package/lib/utils/toFloatingUIPadding.js.map +1 -1
- package/lib/utils/toFloatingUIPlacement.js +25 -27
- package/lib/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib/utils/toggleScrollListener.js +12 -14
- package/lib/utils/toggleScrollListener.js.map +1 -1
- package/lib/utils/useCallbackRef.js +30 -32
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib/utils/writeArrowUpdates.js +10 -17
- package/lib/utils/writeArrowUpdates.js.map +1 -1
- package/lib/utils/writeContainerupdates.js +39 -39
- package/lib/utils/writeContainerupdates.js.map +1 -1
- package/lib-commonjs/constants.js +1 -3
- package/lib-commonjs/constants.js.map +1 -1
- package/lib-commonjs/createArrowStyles.js +1 -3
- package/lib-commonjs/createArrowStyles.js.map +1 -1
- package/lib-commonjs/createPositionManager.js +4 -5
- package/lib-commonjs/createPositionManager.js.map +1 -1
- package/lib-commonjs/createSlideStyles.js +63 -0
- package/lib-commonjs/createSlideStyles.js.map +1 -0
- package/lib-commonjs/createVirtualElementFromClick.js +1 -3
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -1
- package/lib-commonjs/index.js +2 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/middleware/coverTarget.js +1 -3
- package/lib-commonjs/middleware/coverTarget.js.map +1 -1
- package/lib-commonjs/middleware/flip.js +1 -3
- package/lib-commonjs/middleware/flip.js.map +1 -1
- package/lib-commonjs/middleware/index.js +0 -3
- package/lib-commonjs/middleware/index.js.map +1 -1
- package/lib-commonjs/middleware/intersecting.js +1 -3
- package/lib-commonjs/middleware/intersecting.js.map +1 -1
- package/lib-commonjs/middleware/maxSize.js +1 -3
- package/lib-commonjs/middleware/maxSize.js.map +1 -1
- package/lib-commonjs/middleware/offset.js +1 -3
- package/lib-commonjs/middleware/offset.js.map +1 -1
- package/lib-commonjs/middleware/shift.js +1 -3
- package/lib-commonjs/middleware/shift.js.map +1 -1
- package/lib-commonjs/types.js +0 -3
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/usePositioning.js +6 -6
- package/lib-commonjs/usePositioning.js.map +1 -1
- package/lib-commonjs/usePositioningMouseTarget.js +1 -3
- package/lib-commonjs/usePositioningMouseTarget.js.map +1 -1
- package/lib-commonjs/utils/debounce.js +1 -3
- package/lib-commonjs/utils/debounce.js.map +1 -1
- package/lib-commonjs/utils/fromFloatingUIPlacement.js +1 -3
- package/lib-commonjs/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/getBoundary.js +1 -3
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getFloatingUIOffset.js +1 -3
- package/lib-commonjs/utils/getFloatingUIOffset.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js +1 -3
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js +1 -3
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/hasAutoFocusFilter.js +1 -3
- package/lib-commonjs/utils/hasAutoFocusFilter.js.map +1 -1
- package/lib-commonjs/utils/index.js +0 -3
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.js +1 -3
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -1
- package/lib-commonjs/utils/parseFloatingUIPlacement.js +1 -3
- package/lib-commonjs/utils/parseFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.js +1 -3
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPadding.js +1 -3
- package/lib-commonjs/utils/toFloatingUIPadding.js.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPlacement.js +1 -3
- package/lib-commonjs/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib-commonjs/utils/toggleScrollListener.js +1 -3
- package/lib-commonjs/utils/toggleScrollListener.js.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.js +1 -3
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/utils/writeArrowUpdates.js +1 -3
- package/lib-commonjs/utils/writeArrowUpdates.js.map +1 -1
- package/lib-commonjs/utils/writeContainerupdates.js +12 -5
- package/lib-commonjs/utils/writeContainerupdates.js.map +1 -1
- package/package.json +5 -5
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["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 */ export function createArrowStyles(options) {\n const { arrowHeight , borderWidth ='1px' , borderStyle ='solid' , borderColor =tokens.colorTransparentStroke } = 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 */ export 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"],"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":";;;;;;;;;;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 +10,7 @@ const _dom = require("@floating-ui/dom");
|
|
10
10
|
const _utils = require("./utils");
|
11
11
|
const _reactUtilities = require("@fluentui/react-utilities");
|
12
12
|
function createPositionManager(options) {
|
13
|
-
const { container , target , arrow , strategy , middleware , placement } = options;
|
13
|
+
const { container , target , arrow , strategy , middleware , placement , useTransform =true } = options;
|
14
14
|
let isDestroyed = false;
|
15
15
|
if (!target || !container) {
|
16
16
|
return {
|
@@ -71,7 +71,8 @@ function createPositionManager(options) {
|
|
71
71
|
y
|
72
72
|
},
|
73
73
|
lowPPI: ((targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.devicePixelRatio) || 1) <= 1,
|
74
|
-
strategy
|
74
|
+
strategy,
|
75
|
+
useTransform
|
75
76
|
});
|
76
77
|
}).catch((err)=>{
|
77
78
|
// https://github.com/floating-ui/floating-ui/issues/1845
|
@@ -108,6 +109,4 @@ function createPositionManager(options) {
|
|
108
109
|
updatePosition,
|
109
110
|
dispose
|
110
111
|
};
|
111
|
-
}
|
112
|
-
|
113
|
-
//# sourceMappingURL=createPositionManager.js.map
|
112
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["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 */ export function createPositionManager(options) {\n const { container , target , arrow , strategy , middleware , placement , useTransform =true } = 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(({ 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 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 useTransform\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"],"names":["createPositionManager","options","container","target","arrow","strategy","middleware","placement","useTransform","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":";;;;+BAMoBA;;aAAAA;;qBANY;uBACoD;gCACtD;AAInB,SAASA,sBAAsBC,OAAO,EAAE;IAC/C,MAAM,EAAEC,UAAS,EAAGC,OAAM,EAAGC,MAAK,EAAGC,SAAQ,EAAGC,WAAU,EAAGC,UAAS,EAAGC,cAAc,IAAI,CAAA,EAAG,GAAGP;IACjG,IAAIQ,cAAc,KAAK;IACvB,IAAI,CAACN,UAAU,CAACD,WAAW;QACvB,OAAO;YACHQ,gBAAgB,IAAIC;YACpBC,SAAS,IAAID;QACjB;IACJ,CAAC;IACD,IAAIE,gBAAgB,IAAI;IACxB,MAAMC,gBAAgB,IAAIC;IAC1B,MAAMC,eAAed,UAAUe,aAAa,CAACC,WAAW;IACxD,oFAAoF;IACpF,gGAAgG;IAChGC,OAAOC,MAAM,CAAClB,UAAUmB,KAAK,EAAE;QAC3BC,UAAU;QACVC,MAAM;QACNC,KAAK;QACLC,QAAQ;IACZ;IACA,MAAMC,cAAc,IAAI;QACpB,8CAA8C;QAC9C,qCAAqC;QACrC,IAAIjB,aAAa;YACb;QACJ,CAAC;QACD,IAAII,eAAe;YACfC,cAAca,GAAG,CAACC,IAAAA,sBAAe,EAAC1B;YAClC,IAAI2B,IAAAA,6BAAa,EAAC1B,SAAS;gBACvBW,cAAca,GAAG,CAACC,IAAAA,sBAAe,EAACzB;YACtC,CAAC;YACDW,cAAcgB,OAAO,CAAC,CAACC,eAAe;gBAClCA,aAAaC,gBAAgB,CAAC,UAAUtB;YAC5C;YACAG,gBAAgB,KAAK;QAC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AgB,CAAC,UAAUtB;QACxCM,aAAagB,gBAAgB,CAAC,UAAUtB;IAC5C,CAAC;IACD,wCAAwC;IACxCA;IACA,OAAO;QACHA;QACAE;IACJ;AACJ"}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "createSlideStyles", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>createSlideStyles
|
8
|
+
});
|
9
|
+
const _reactTheme = require("@fluentui/react-theme");
|
10
|
+
const _constants = require("./constants");
|
11
|
+
function createSlideStyles(mainAxis) {
|
12
|
+
const fadeIn = {
|
13
|
+
from: {
|
14
|
+
opacity: 0
|
15
|
+
},
|
16
|
+
to: {
|
17
|
+
opacity: 1
|
18
|
+
}
|
19
|
+
};
|
20
|
+
const slideDistanceVarX = '--slide-distance-x';
|
21
|
+
const slideDistanceVarY = '--slide-distance-y';
|
22
|
+
return {
|
23
|
+
animationComposition: 'accumulate',
|
24
|
+
animationDuration: _reactTheme.tokens.durationSlower,
|
25
|
+
animationTimingFunction: _reactTheme.tokens.curveDecelerateMid,
|
26
|
+
[slideDistanceVarX]: `0px`,
|
27
|
+
[slideDistanceVarY]: `${mainAxis}px`,
|
28
|
+
[`&[${_constants.DATA_POSITIONING_PLACEMENT}^=right]`]: {
|
29
|
+
[slideDistanceVarX]: `-${mainAxis}px`,
|
30
|
+
[slideDistanceVarY]: '0px'
|
31
|
+
},
|
32
|
+
[`&[${_constants.DATA_POSITIONING_PLACEMENT}^=bottom]`]: {
|
33
|
+
[slideDistanceVarX]: '0px',
|
34
|
+
[slideDistanceVarY]: `-${mainAxis}px`
|
35
|
+
},
|
36
|
+
[`&[${_constants.DATA_POSITIONING_PLACEMENT}^=left]`]: {
|
37
|
+
[slideDistanceVarX]: `${mainAxis}px`,
|
38
|
+
[slideDistanceVarY]: '0px'
|
39
|
+
},
|
40
|
+
animationName: [
|
41
|
+
fadeIn,
|
42
|
+
{
|
43
|
+
from: {
|
44
|
+
transform: `translate(var(${slideDistanceVarX}), var(${slideDistanceVarY}))`
|
45
|
+
},
|
46
|
+
to: {}
|
47
|
+
}
|
48
|
+
],
|
49
|
+
// Note: at-rules have more specificity in Griffel
|
50
|
+
'@media(prefers-reduced-motion)': {
|
51
|
+
[`&[${_constants.DATA_POSITIONING_PLACEMENT}]`]: {
|
52
|
+
animationDuration: '1ms',
|
53
|
+
animationName: fadeIn
|
54
|
+
}
|
55
|
+
},
|
56
|
+
// Tested in Firefox 79
|
57
|
+
'@supports not (animation-composition: accumulate)': {
|
58
|
+
[`&[${_constants.DATA_POSITIONING_PLACEMENT}]`]: {
|
59
|
+
animationName: fadeIn
|
60
|
+
}
|
61
|
+
}
|
62
|
+
};
|
63
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["createSlideStyles.js"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport { DATA_POSITIONING_PLACEMENT } from './constants';\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 */ export function createSlideStyles(mainAxis) {\n const fadeIn = {\n from: {\n opacity: 0\n },\n to: {\n opacity: 1\n }\n };\n const slideDistanceVarX = '--slide-distance-x';\n const slideDistanceVarY = '--slide-distance-y';\n return {\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 [`&[${DATA_POSITIONING_PLACEMENT}^=bottom]`]: {\n [slideDistanceVarX]: '0px',\n [slideDistanceVarY]: `-${mainAxis}px`\n },\n [`&[${DATA_POSITIONING_PLACEMENT}^=left]`]: {\n [slideDistanceVarX]: `${mainAxis}px`,\n [slideDistanceVarY]: '0px'\n },\n animationName: [\n fadeIn,\n {\n from: {\n transform: `translate(var(${slideDistanceVarX}), var(${slideDistanceVarY}))`\n },\n to: {}\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 // 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"],"mappings":";;;;+BAMoBA;;aAAAA;;4BANG;2BACoB;AAKhC,SAASA,kBAAkBC,QAAQ,EAAE;IAC5C,MAAMC,SAAS;QACXC,MAAM;YACFC,SAAS;QACb;QACAC,IAAI;YACAD,SAAS;QACb;IACJ;IACA,MAAME,oBAAoB;IAC1B,MAAMC,oBAAoB;IAC1B,OAAO;QACHC,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;YACzC,CAACR,kBAAkB,EAAE,CAAC,CAAC,EAAEL,SAAS,EAAE,CAAC;YACrC,CAACM,kBAAkB,EAAE;QACzB;QACA,CAAC,CAAC,EAAE,EAAEO,qCAA0B,CAAC,SAAS,CAAC,CAAC,EAAE;YAC1C,CAACR,kBAAkB,EAAE;YACrB,CAACC,kBAAkB,EAAE,CAAC,CAAC,EAAEN,SAAS,EAAE,CAAC;QACzC;QACA,CAAC,CAAC,EAAE,EAAEa,qCAA0B,CAAC,OAAO,CAAC,CAAC,EAAE;YACxC,CAACR,kBAAkB,EAAE,CAAC,EAAEL,SAAS,EAAE,CAAC;YACpC,CAACM,kBAAkB,EAAE;QACzB;QACAQ,eAAe;YACXb;YACA;gBACIC,MAAM;oBACFa,WAAW,CAAC,cAAc,EAAEV,kBAAkB,OAAO,EAAEC,kBAAkB,EAAE,CAAC;gBAChF;gBACAF,IAAI,CAAC;YACT;SACH;QACD,kDAAkD;QAClD,kCAAkC;YAC9B,CAAC,CAAC,EAAE,EAAES,qCAA0B,CAAC,CAAC,CAAC,CAAC,EAAE;gBAClCL,mBAAmB;gBACnBM,eAAeb;YACnB;QACJ;QACA,uBAAuB;QACvB,qDAAqD;YACjD,CAAC,CAAC,EAAE,EAAEY,qCAA0B,CAAC,CAAC,CAAC,CAAC,EAAE;gBAClCC,eAAeb;YACnB;QACJ;IACJ;AACJ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["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"],"names":["createVirtualElementFromClick","nativeEvent","left","clientX","top","clientY","right","bottom","getBoundingClientRect","x","y","height","width"],"mappings":"AAAA;;;CAGC;;;;+BAAmBA;;aAAAA;;AAAT,SAASA,8BAA8BC,WAAW,EAAE;IAC3D,MAAMC,OAAOD,YAAYE,OAAO;IAChC,MAAMC,MAAMH,YAAYI,OAAO;IAC/B,MAAMC,QAAQJ,OAAO;IACrB,MAAMK,SAASH,MAAM;IACrB,SAASI,wBAAwB;QAC7B,OAAO;YACHN;YACAE;YACAE;YACAC;YACAE,GAAGP;YACHQ,GAAGN;YACHO,QAAQ;YACRC,OAAO;QACX;IACJ;IACA,OAAO;QACHJ;IACJ;AACJ"}
|
package/lib-commonjs/index.js
CHANGED
@@ -12,6 +12,7 @@ _export(exports, {
|
|
12
12
|
createVirtualElementFromClick: ()=>_createVirtualElementFromClick.createVirtualElementFromClick,
|
13
13
|
createArrowHeightStyles: ()=>_createArrowStyles.createArrowHeightStyles,
|
14
14
|
createArrowStyles: ()=>_createArrowStyles.createArrowStyles,
|
15
|
+
createSlideStyles: ()=>_createSlideStyles.createSlideStyles,
|
15
16
|
usePositioning: ()=>_usePositioning.usePositioning,
|
16
17
|
usePositioningMouseTarget: ()=>_usePositioningMouseTarget.usePositioningMouseTarget,
|
17
18
|
resolvePositioningShorthand: ()=>_index.resolvePositioningShorthand,
|
@@ -19,9 +20,7 @@ _export(exports, {
|
|
19
20
|
});
|
20
21
|
const _createVirtualElementFromClick = require("./createVirtualElementFromClick");
|
21
22
|
const _createArrowStyles = require("./createArrowStyles");
|
23
|
+
const _createSlideStyles = require("./createSlideStyles");
|
22
24
|
const _usePositioning = require("./usePositioning");
|
23
25
|
const _usePositioningMouseTarget = require("./usePositioningMouseTarget");
|
24
26
|
const _index = require("./utils/index");
|
25
|
-
//# sourceMappingURL=index.js.map
|
26
|
-
|
27
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export { createVirtualElementFromClick } from './createVirtualElementFromClick';\nexport { createArrowHeightStyles, createArrowStyles } from './createArrowStyles';\nexport { createSlideStyles } from './createSlideStyles';\nexport { usePositioning } from './usePositioning';\nexport { usePositioningMouseTarget } from './usePositioningMouseTarget';\nexport { resolvePositioningShorthand, mergeArrowOffset } from './utils/index';\n"],"names":["createVirtualElementFromClick","createArrowHeightStyles","createArrowStyles","createSlideStyles","usePositioning","usePositioningMouseTarget","resolvePositioningShorthand","mergeArrowOffset"],"mappings":";;;;;;;;;;;IAASA,6BAA6B,MAA7BA,4DAA6B;IAC7BC,uBAAuB,MAAvBA,0CAAuB;IAAEC,iBAAiB,MAAjBA,oCAAiB;IAC1CC,iBAAiB,MAAjBA,oCAAiB;IACjBC,cAAc,MAAdA,8BAAc;IACdC,yBAAyB,MAAzBA,oDAAyB;IACzBC,2BAA2B,MAA3BA,kCAA2B;IAAEC,gBAAgB,MAAhBA,uBAAgB;;+CALR;mCACa;mCACzB;gCACH;2CACW;uBACoB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["coverTarget.js"],"sourcesContent":["import { parseFloatingUIPlacement } from '../utils/index';\nexport function coverTarget() {\n return {\n name: 'coverTarget',\n fn: (middlewareArguments)=>{\n const { placement , rects , x , y } = middlewareArguments;\n const basePlacement = parseFloatingUIPlacement(placement).side;\n const newCoords = {\n x,\n 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 return newCoords;\n }\n };\n}\n"],"names":["coverTarget","name","fn","middlewareArguments","placement","rects","x","y","basePlacement","parseFloatingUIPlacement","side","newCoords","reference","height","width"],"mappings":";;;;+BACgBA;;aAAAA;;uBADyB;AAClC,SAASA,cAAc;IAC1B,OAAO;QACHC,MAAM;QACNC,IAAI,CAACC,sBAAsB;YACvB,MAAM,EAAEC,UAAS,EAAGC,MAAK,EAAGC,EAAC,EAAGC,EAAC,EAAG,GAAGJ;YACvC,MAAMK,gBAAgBC,IAAAA,+BAAwB,EAACL,WAAWM,IAAI;YAC9D,MAAMC,YAAY;gBACdL;gBACAC;YACJ;YACA,OAAOC;gBACH,KAAK;oBACDG,UAAUJ,CAAC,IAAIF,MAAMO,SAAS,CAACC,MAAM;oBACrC,KAAM;gBACV,KAAK;oBACDF,UAAUJ,CAAC,IAAIF,MAAMO,SAAS,CAACC,MAAM;oBACrC,KAAM;gBACV,KAAK;oBACDF,UAAUL,CAAC,IAAID,MAAMO,SAAS,CAACE,KAAK;oBACpC,KAAM;gBACV,KAAK;oBACDH,UAAUL,CAAC,IAAID,MAAMO,SAAS,CAACE,KAAK;oBACpC,KAAM;YACd;YACA,OAAOH;QACX;IACJ;AACJ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["flip.js"],"sourcesContent":["import { flip as baseFlip } from '@floating-ui/dom';\nimport { getBoundary, resolvePositioningShorthand, toFloatingUIPlacement } from '../utils/index';\nexport function flip(options) {\n const { hasScrollableElement , flipBoundary , container , fallbackPositions =[] , isRtl } = options;\n const fallbackPlacements = fallbackPositions.reduce((acc, shorthand)=>{\n const { position , align } = resolvePositioningShorthand(shorthand);\n const placement = toFloatingUIPlacement(align, position, isRtl);\n if (placement) {\n acc.push(placement);\n }\n return acc;\n }, []);\n return baseFlip({\n ...hasScrollableElement && {\n boundary: 'clippingAncestors'\n },\n ...flipBoundary && {\n altBoundary: true,\n boundary: getBoundary(container, flipBoundary)\n },\n fallbackStrategy: 'bestFit',\n ...fallbackPlacements.length && {\n fallbackPlacements\n }\n });\n}\n"],"names":["flip","options","hasScrollableElement","flipBoundary","container","fallbackPositions","isRtl","fallbackPlacements","reduce","acc","shorthand","position","align","resolvePositioningShorthand","placement","toFloatingUIPlacement","push","baseFlip","boundary","altBoundary","getBoundary","fallbackStrategy","length"],"mappings":";;;;+BAEgBA;;aAAAA;;qBAFiB;uBAC+C;AACzE,SAASA,KAAKC,OAAO,EAAE;IAC1B,MAAM,EAAEC,qBAAoB,EAAGC,aAAY,EAAGC,UAAS,EAAGC,mBAAmB,EAAE,CAAA,EAAGC,MAAK,EAAG,GAAGL;IAC7F,MAAMM,qBAAqBF,kBAAkBG,MAAM,CAAC,CAACC,KAAKC,YAAY;QAClE,MAAM,EAAEC,SAAQ,EAAGC,MAAK,EAAG,GAAGC,IAAAA,kCAA2B,EAACH;QAC1D,MAAMI,YAAYC,IAAAA,4BAAqB,EAACH,OAAOD,UAAUL;QACzD,IAAIQ,WAAW;YACXL,IAAIO,IAAI,CAACF;QACb,CAAC;QACD,OAAOL;IACX,GAAG,EAAE;IACL,OAAOQ,IAAAA,SAAQ,EAAC;QACZ,GAAGf,wBAAwB;YACvBgB,UAAU;QACd,CAAC;QACD,GAAGf,gBAAgB;YACfgB,aAAa,IAAI;YACjBD,UAAUE,IAAAA,kBAAW,EAAChB,WAAWD;QACrC,CAAC;QACDkB,kBAAkB;QAClB,GAAGd,mBAAmBe,MAAM,IAAI;YAC5Bf;QACJ,CAAC;IACL;AACJ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './coverTarget';\nexport * from './flip';\nexport * from './intersecting';\nexport * from './maxSize';\nexport * from './offset';\nexport * from './shift';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;oBACA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["intersecting.js"],"sourcesContent":["import { detectOverflow } from '@floating-ui/dom';\nexport function intersecting() {\n return {\n name: 'intersectionObserver',\n fn: async (middlewareArguments)=>{\n const floatingRect = middlewareArguments.rects.floating;\n const altOverflow = await detectOverflow(middlewareArguments, {\n altBoundary: true\n });\n const isIntersectingTop = altOverflow.top < floatingRect.height && altOverflow.top > 0;\n const isIntersectingBottom = altOverflow.bottom < floatingRect.height && altOverflow.bottom > 0;\n const isIntersecting = isIntersectingTop || isIntersectingBottom;\n return {\n data: {\n intersecting: isIntersecting\n }\n };\n }\n };\n}\n"],"names":["intersecting","name","fn","middlewareArguments","floatingRect","rects","floating","altOverflow","detectOverflow","altBoundary","isIntersectingTop","top","height","isIntersectingBottom","bottom","isIntersecting","data"],"mappings":";;;;+BACgBA;;aAAAA;;qBADe;AACxB,SAASA,eAAe;IAC3B,OAAO;QACHC,MAAM;QACNC,IAAI,OAAOC,sBAAsB;YAC7B,MAAMC,eAAeD,oBAAoBE,KAAK,CAACC,QAAQ;YACvD,MAAMC,cAAc,MAAMC,IAAAA,mBAAc,EAACL,qBAAqB;gBAC1DM,aAAa,IAAI;YACrB;YACA,MAAMC,oBAAoBH,YAAYI,GAAG,GAAGP,aAAaQ,MAAM,IAAIL,YAAYI,GAAG,GAAG;YACrF,MAAME,uBAAuBN,YAAYO,MAAM,GAAGV,aAAaQ,MAAM,IAAIL,YAAYO,MAAM,GAAG;YAC9F,MAAMC,iBAAiBL,qBAAqBG;YAC5C,OAAO;gBACHG,MAAM;oBACFhB,cAAce;gBAClB;YACJ;QACJ;IACJ;AACJ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["maxSize.js"],"sourcesContent":["import { size } from '@floating-ui/dom';\nimport { getBoundary } from '../utils/getBoundary';\nexport function maxSize(autoSize, options) {\n const { container , overflowBoundary } = options;\n return size({\n ...overflowBoundary && {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary)\n },\n apply ({ availableHeight , availableWidth , elements , rects }) {\n const applyMaxWidth = autoSize === 'always' || autoSize === 'width-always' || rects.floating.width > availableWidth && (autoSize === true || autoSize === 'width');\n const applyMaxHeight = autoSize === 'always' || autoSize === 'height-always' || rects.floating.height > availableHeight && (autoSize === true || autoSize === 'height');\n if (applyMaxHeight) {\n Object.assign(elements.floating.style, {\n maxHeight: `${availableHeight}px`,\n boxSizing: 'border-box',\n overflowY: 'auto'\n });\n }\n if (applyMaxWidth) {\n Object.assign(elements.floating.style, {\n maxWidth: `${availableWidth}px`,\n boxSizing: 'border-box',\n overflowX: 'auto'\n });\n }\n }\n });\n}\n"],"names":["maxSize","autoSize","options","container","overflowBoundary","size","altBoundary","boundary","getBoundary","apply","availableHeight","availableWidth","elements","rects","applyMaxWidth","floating","width","applyMaxHeight","height","Object","assign","style","maxHeight","boxSizing","overflowY","maxWidth","overflowX"],"mappings":";;;;+BAEgBA;;aAAAA;;qBAFK;6BACO;AACrB,SAASA,QAAQC,QAAQ,EAAEC,OAAO,EAAE;IACvC,MAAM,EAAEC,UAAS,EAAGC,iBAAgB,EAAG,GAAGF;IAC1C,OAAOG,IAAAA,SAAI,EAAC;QACR,GAAGD,oBAAoB;YACnBE,aAAa,IAAI;YACjBC,UAAUC,IAAAA,wBAAW,EAACL,WAAWC;QACrC,CAAC;QACDK,OAAO,EAAEC,gBAAe,EAAGC,eAAc,EAAGC,SAAQ,EAAGC,MAAK,EAAG,EAAE;YAC7D,MAAMC,gBAAgBb,aAAa,YAAYA,aAAa,kBAAkBY,MAAME,QAAQ,CAACC,KAAK,GAAGL,kBAAmBV,CAAAA,aAAa,IAAI,IAAIA,aAAa,OAAM;YAChK,MAAMgB,iBAAiBhB,aAAa,YAAYA,aAAa,mBAAmBY,MAAME,QAAQ,CAACG,MAAM,GAAGR,mBAAoBT,CAAAA,aAAa,IAAI,IAAIA,aAAa,QAAO;YACrK,IAAIgB,gBAAgB;gBAChBE,OAAOC,MAAM,CAACR,SAASG,QAAQ,CAACM,KAAK,EAAE;oBACnCC,WAAW,CAAC,EAAEZ,gBAAgB,EAAE,CAAC;oBACjCa,WAAW;oBACXC,WAAW;gBACf;YACJ,CAAC;YACD,IAAIV,eAAe;gBACfK,OAAOC,MAAM,CAACR,SAASG,QAAQ,CAACM,KAAK,EAAE;oBACnCI,UAAU,CAAC,EAAEd,eAAe,EAAE,CAAC;oBAC/BY,WAAW;oBACXG,WAAW;gBACf;YACJ,CAAC;QACL;IACJ;AACJ"}
|
@@ -11,6 +11,4 @@ const _getFloatingUIOffset = require("../utils/getFloatingUIOffset");
|
|
11
11
|
function offset(offsetValue) {
|
12
12
|
const floatingUIOffset = (0, _getFloatingUIOffset.getFloatingUIOffset)(offsetValue);
|
13
13
|
return (0, _dom.offset)(floatingUIOffset);
|
14
|
-
}
|
15
|
-
|
16
|
-
//# sourceMappingURL=offset.js.map
|
14
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["offset.js"],"sourcesContent":["import { offset as baseOffset } from '@floating-ui/dom';\nimport { getFloatingUIOffset } from '../utils/getFloatingUIOffset';\n/**\n * Wraps floating UI offset middleware to to transform offset value\n */ export function offset(offsetValue) {\n const floatingUIOffset = getFloatingUIOffset(offsetValue);\n return baseOffset(floatingUIOffset);\n}\n"],"names":["offset","offsetValue","floatingUIOffset","getFloatingUIOffset","baseOffset"],"mappings":";;;;+BAIoBA;;aAAAA;;qBAJiB;qCACD;AAGzB,SAASA,OAAOC,WAAW,EAAE;IACpC,MAAMC,mBAAmBC,IAAAA,wCAAmB,EAACF;IAC7C,OAAOG,IAAAA,WAAU,EAACF;AACtB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["shift.js"],"sourcesContent":["import { shift as baseShift, limitShift } from '@floating-ui/dom';\nimport { getBoundary, toFloatingUIPadding } from '../utils/index';\n/**\n * Wraps the floating UI shift middleware for easier usage of our options\n */ export function shift(options) {\n const { hasScrollableElement , disableTether , overflowBoundary , container , overflowBoundaryPadding , isRtl } = options;\n return baseShift({\n ...hasScrollableElement && {\n boundary: 'clippingAncestors'\n },\n ...disableTether && {\n crossAxis: disableTether === 'all',\n limiter: limitShift({\n crossAxis: disableTether !== 'all',\n mainAxis: false\n })\n },\n ...overflowBoundaryPadding && {\n padding: toFloatingUIPadding(overflowBoundaryPadding, isRtl)\n },\n ...overflowBoundary && {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary)\n }\n });\n}\n"],"names":["shift","options","hasScrollableElement","disableTether","overflowBoundary","container","overflowBoundaryPadding","isRtl","baseShift","boundary","crossAxis","limiter","limitShift","mainAxis","padding","toFloatingUIPadding","altBoundary","getBoundary"],"mappings":";;;;+BAIoBA;;aAAAA;;qBAJ2B;uBACE;AAGtC,SAASA,MAAMC,OAAO,EAAE;IAC/B,MAAM,EAAEC,qBAAoB,EAAGC,cAAa,EAAGC,iBAAgB,EAAGC,UAAS,EAAGC,wBAAuB,EAAGC,MAAK,EAAG,GAAGN;IACnH,OAAOO,IAAAA,UAAS,EAAC;QACb,GAAGN,wBAAwB;YACvBO,UAAU;QACd,CAAC;QACD,GAAGN,iBAAiB;YAChBO,WAAWP,kBAAkB;YAC7BQ,SAASC,IAAAA,eAAU,EAAC;gBAChBF,WAAWP,kBAAkB;gBAC7BU,UAAU,KAAK;YACnB;QACJ,CAAC;QACD,GAAGP,2BAA2B;YAC1BQ,SAASC,IAAAA,0BAAmB,EAACT,yBAAyBC;QAC1D,CAAC;QACD,GAAGH,oBAAoB;YACnBY,aAAa,IAAI;YACjBP,UAAUQ,IAAAA,kBAAW,EAACZ,WAAWD;QACrC,CAAC;IACL;AACJ"}
|
package/lib-commonjs/types.js
CHANGED
@@ -4,6 +4,3 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
6
6
|
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
7
|
-
//# sourceMappingURL=types.js.map
|
8
|
-
|
9
|
-
//# sourceMappingURL=types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;6DAAuB"}
|
@@ -143,7 +143,7 @@ function usePositioning(options) {
|
|
143
143
|
};
|
144
144
|
}
|
145
145
|
function usePositioningOptions(options) {
|
146
|
-
const { align , arrowPadding , autoSize , coverTarget , flipBoundary , offset , overflowBoundary , pinned , position , unstable_disableTether: disableTether , positionFixed , overflowBoundaryPadding , fallbackPositions } = options;
|
146
|
+
const { align , arrowPadding , autoSize , coverTarget , flipBoundary , offset , overflowBoundary , pinned , position , unstable_disableTether: disableTether , positionFixed , overflowBoundaryPadding , fallbackPositions , useTransform } = options;
|
147
147
|
const { dir } = (0, _reactSharedContexts.useFluent_unstable)();
|
148
148
|
const isRtl = dir === 'rtl';
|
149
149
|
const strategy = positionFixed ? 'fixed' : 'absolute';
|
@@ -187,7 +187,8 @@ function usePositioningOptions(options) {
|
|
187
187
|
return {
|
188
188
|
placement,
|
189
189
|
middleware,
|
190
|
-
strategy
|
190
|
+
strategy,
|
191
|
+
useTransform
|
191
192
|
};
|
192
193
|
}, [
|
193
194
|
align,
|
@@ -203,8 +204,7 @@ function usePositioningOptions(options) {
|
|
203
204
|
position,
|
204
205
|
strategy,
|
205
206
|
overflowBoundaryPadding,
|
206
|
-
fallbackPositions
|
207
|
+
fallbackPositions,
|
208
|
+
useTransform
|
207
209
|
]);
|
208
|
-
}
|
209
|
-
|
210
|
-
//# sourceMappingURL=usePositioning.js.map
|
210
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../lib/usePositioning.js"],"sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport { shift as shiftMiddleware, flip as flipMiddleware, coverTarget as coverTargetMiddleware, maxSize as maxSizeMiddleware, offset as offsetMiddleware, intersecting as intersectingMiddleware } from './middleware';\nimport { createPositionManager } from './createPositionManager';\n/**\n * @internal\n */\nexport function usePositioning(options) {\n const managerRef = React.useRef(null);\n const targetRef = React.useRef(null);\n const overrideTargetRef = React.useRef(null);\n const containerRef = React.useRef(null);\n const arrowRef = React.useRef(null);\n const {\n enabled = true\n } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(() => {\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n var _overrideTargetRef_current;\n const target = (_overrideTargetRef_current = overrideTargetRef.current) !== null && _overrideTargetRef_current !== void 0 ? _overrideTargetRef_current : targetRef.current;\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current)\n });\n }\n }, [enabled, resolvePositioningOptions]);\n const setOverrideTarget = useEventCallback(target => {\n overrideTargetRef.current = target;\n updatePositionManager();\n });\n React.useImperativeHandle(options.positioningRef, () => {\n return {\n updatePosition: () => {\n var _managerRef_current;\n return (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.updatePosition();\n },\n setTarget: target => {\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n setOverrideTarget(target);\n }\n };\n }, [options.target, setOverrideTarget]);\n useIsomorphicLayoutEffect(() => {\n var _options_target;\n setOverrideTarget((_options_target = options.target) !== null && _options_target !== void 0 ? _options_target : null);\n }, [options.target, setOverrideTarget]);\n useIsomorphicLayoutEffect(() => {\n updatePositionManager();\n }, [updatePositionManager]);\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n var _contentNode_ownerDocument;\n const contentNode = containerRef.current;\n const treeWalker = (_contentNode_ownerDocument = contentNode.ownerDocument) === null || _contentNode_ownerDocument === void 0 ? void 0 : _contentNode_ownerDocument.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter\n });\n while (treeWalker.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(['<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial', 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills', '\"autoFocus\" behavior to solve inconsistencies between different browsers:', 'https://github.com/facebook/react/issues/11851#issuecomment-351787078', '\\n', 'However, \".focus()\" in this case occurs before any other React effects will be executed', '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really', 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by', '\"Popper\".', `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`, 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md', '\\n', 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use', '\"ref.current.focus\" in React.useEffect():', 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element'].join(' '));\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n const setTarget = useCallbackRef(null, target => {\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n const setContainer = useCallbackRef(null, container => {\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n const setArrow = useCallbackRef(null, arrow => {\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n // Let users use callback refs so they feel like 'normal' DOM refs\n return {\n targetRef: setTarget,\n containerRef: setContainer,\n arrowRef: setArrow\n };\n}\nfunction usePositioningOptions(options) {\n const {\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n flipBoundary,\n offset,\n overflowBoundary,\n pinned,\n position,\n unstable_disableTether: disableTether,\n positionFixed,\n overflowBoundaryPadding,\n fallbackPositions\n } = options;\n const {\n dir\n } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy = positionFixed ? 'fixed' : 'absolute';\n return React.useCallback((container, arrow) => {\n const hasScrollableElement = hasScrollParent(container);\n const middleware = [offset && offsetMiddleware(offset), coverTarget && coverTargetMiddleware(), !pinned && flipMiddleware({\n container,\n flipBoundary,\n hasScrollableElement,\n isRtl,\n fallbackPositions\n }), shiftMiddleware({\n container,\n hasScrollableElement,\n overflowBoundary,\n disableTether,\n overflowBoundaryPadding,\n isRtl\n }), autoSize && maxSizeMiddleware(autoSize, {\n container,\n overflowBoundary\n }), intersectingMiddleware(), arrow && arrowMiddleware({\n element: arrow,\n padding: arrowPadding\n }), hideMiddleware({\n strategy: 'referenceHidden'\n }), hideMiddleware({\n strategy: 'escaped'\n })].filter(Boolean);\n const placement = toFloatingUIPlacement(align, position, isRtl);\n return {\n placement,\n middleware,\n strategy\n };\n }, [align, arrowPadding, autoSize, coverTarget, disableTether, flipBoundary, isRtl, offset, overflowBoundary, pinned, position, strategy, overflowBoundaryPadding, fallbackPositions]);\n}\n//# sourceMappingURL=usePositioning.js.map"],"names":["usePositioning","options","managerRef","React","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","_overrideTargetRef_current","target","canUseDOM","createPositionManager","container","arrow","setOverrideTarget","useEventCallback","useImperativeHandle","positioningRef","updatePosition","_managerRef_current","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useIsomorphicLayoutEffect","_options_target","useEffect","_contentNode_ownerDocument","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","hasAutofocusFilter","nextNode","node","currentNode","join","useCallbackRef","setContainer","setArrow","align","arrowPadding","autoSize","coverTarget","flipBoundary","offset","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","overflowBoundaryPadding","fallbackPositions","dir","useFluent","isRtl","strategy","hasScrollableElement","hasScrollParent","middleware","offsetMiddleware","coverTargetMiddleware","flipMiddleware","shiftMiddleware","maxSizeMiddleware","intersectingMiddleware","arrowMiddleware","element","padding","hideMiddleware","filter","Boolean","placement","toFloatingUIPlacement"],"mappings":";;;;+BAUgBA;;aAAAA;;;qBAViD;qCACjB;gCACuB;6DAChD;uBACoE;4BAC8G;uCACnK;AAI/B,SAASA,eAAeC,OAAO,EAAE;IACtC,MAAMC,aAAaC,OAAMC,MAAM,CAAC,IAAI;IACpC,MAAMC,YAAYF,OAAMC,MAAM,CAAC,IAAI;IACnC,MAAME,oBAAoBH,OAAMC,MAAM,CAAC,IAAI;IAC3C,MAAMG,eAAeJ,OAAMC,MAAM,CAAC,IAAI;IACtC,MAAMI,WAAWL,OAAMC,MAAM,CAAC,IAAI;IAClC,MAAM,EACJK,SAAU,IAAI,CAAA,EACf,GAAGR;IACJ,MAAMS,4BAA4BC,sBAAsBV;IACxD,MAAMW,wBAAwBT,OAAMU,WAAW,CAAC,IAAM;QACpD,IAAIX,WAAWY,OAAO,EAAE;YACtBZ,WAAWY,OAAO,CAACC,OAAO;QAC5B,CAAC;QACDb,WAAWY,OAAO,GAAG,IAAI;QACzB,IAAIE;QACJ,MAAMC,SAAS,AAACD,CAAAA,6BAA6BV,kBAAkBQ,OAAO,AAAD,MAAO,IAAI,IAAIE,+BAA+B,KAAK,IAAIA,6BAA6BX,UAAUS,OAAO;QAC1K,IAAIL,WAAWS,IAAAA,yBAAS,OAAMD,UAAUV,aAAaO,OAAO,EAAE;YAC5DZ,WAAWY,OAAO,GAAGK,IAAAA,4CAAqB,EAAC;gBACzCC,WAAWb,aAAaO,OAAO;gBAC/BG;gBACAI,OAAOb,SAASM,OAAO;gBACvB,GAAGJ,0BAA0BH,aAAaO,OAAO,EAAEN,SAASM,OAAO,CAAC;YACtE;QACF,CAAC;IACH,GAAG;QAACL;QAASC;KAA0B;IACvC,MAAMY,oBAAoBC,IAAAA,gCAAgB,EAACN,CAAAA,SAAU;QACnDX,kBAAkBQ,OAAO,GAAGG;QAC5BL;IACF;IACAT,OAAMqB,mBAAmB,CAACvB,QAAQwB,cAAc,EA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GAAGC,IAAAA,uCAAS;IACb,MAAMC,QAAQF,QAAQ;IACtB,MAAMG,WAAWN,gBAAgB,UAAU,UAAU;IACrD,OAAOhE,OAAMU,WAAW,CAAC,CAACO,WAAWC,QAAU;QAC7C,MAAMqD,uBAAuBC,IAAAA,sBAAe,EAACvD;QAC7C,MAAMwD,aAAa;YAACf,UAAUgB,IAAAA,kBAAgB,EAAChB;YAASF,eAAemB,IAAAA,uBAAqB;YAAI,CAACf,UAAUgB,IAAAA,gBAAc,EAAC;gBACxH3D;gBACAwC;gBACAc;gBACAF;gBACAH;YACF;YAAIW,IAAAA,iBAAe,EAAC;gBAClB5D;gBACAsD;gBACAZ;gBACAI;gBACAE;gBACAI;YACF;YAAId,YAAYuB,IAAAA,mBAAiB,EAACvB,UAAU;gBAC1CtC;gBACA0C;YACF;YAAIoB,IAAAA,wBAAsB;YAAI7D,SAAS8D,IAAAA,UAAe,EAAC;gBACrDC,SAAS/D;gBACTgE,SAAS5B;YACX;YAAI6B,IAAAA,SAAc,EAAC;gBACjBb,UAAU;YACZ;YAAIa,IAAAA,SAAc,EAAC;gBACjBb,UAAU;YACZ;SAAG,CAACc,MAAM,CAACC;QACX,MAAMC,YAAYC,IAAAA,4BAAqB,EAAClC,OAAOQ,UAAUQ;QACzD,OAAO;YACLiB;YACAb;YACAH;QACF;IACF,GAAG;QAACjB;QAAOC;QAAcC;QAAUC;QAAaO;QAAeN;QAAcY;QAAOX;QAAQC;QAAkBC;QAAQC;QAAUS;QAAUL;QAAyBC;KAAkB;AACvL,EACA,0CAA0C"}
|
1
|
+
{"version":3,"sources":["usePositioning.js"],"sourcesContent":["import { hide as hideMiddleware, arrow as arrowMiddleware } from '@floating-ui/dom';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { canUseDOM, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport { useCallbackRef, toFloatingUIPlacement, hasAutofocusFilter, hasScrollParent } from './utils';\nimport { shift as shiftMiddleware, flip as flipMiddleware, coverTarget as coverTargetMiddleware, maxSize as maxSizeMiddleware, offset as offsetMiddleware, intersecting as intersectingMiddleware } from './middleware';\nimport { createPositionManager } from './createPositionManager';\n/**\n * @internal\n */ export function usePositioning(options) {\n const managerRef = React.useRef(null);\n const targetRef = React.useRef(null);\n const overrideTargetRef = React.useRef(null);\n const containerRef = React.useRef(null);\n const arrowRef = React.useRef(null);\n const { enabled =true } = options;\n const resolvePositioningOptions = usePositioningOptions(options);\n const updatePositionManager = React.useCallback(()=>{\n if (managerRef.current) {\n managerRef.current.dispose();\n }\n managerRef.current = null;\n var _overrideTargetRef_current;\n const target = (_overrideTargetRef_current = overrideTargetRef.current) !== null && _overrideTargetRef_current !== void 0 ? _overrideTargetRef_current : targetRef.current;\n if (enabled && canUseDOM() && target && containerRef.current) {\n managerRef.current = createPositionManager({\n container: containerRef.current,\n target,\n arrow: arrowRef.current,\n ...resolvePositioningOptions(containerRef.current, arrowRef.current)\n });\n }\n }, [\n enabled,\n resolvePositioningOptions\n ]);\n const setOverrideTarget = useEventCallback((target)=>{\n overrideTargetRef.current = target;\n updatePositionManager();\n });\n React.useImperativeHandle(options.positioningRef, ()=>{\n return {\n updatePosition: ()=>{\n var _managerRef_current;\n return (_managerRef_current = managerRef.current) === null || _managerRef_current === void 0 ? void 0 : _managerRef_current.updatePosition();\n },\n setTarget: (target)=>{\n if (options.target && process.env.NODE_ENV !== 'production') {\n const err = new Error();\n // eslint-disable-next-line no-console\n console.warn('Imperative setTarget should not be used at the same time as target option');\n // eslint-disable-next-line no-console\n console.warn(err.stack);\n }\n setOverrideTarget(target);\n }\n };\n }, [\n options.target,\n setOverrideTarget\n ]);\n useIsomorphicLayoutEffect(()=>{\n var _options_target;\n setOverrideTarget((_options_target = options.target) !== null && _options_target !== void 0 ? _options_target : null);\n }, [\n options.target,\n setOverrideTarget\n ]);\n useIsomorphicLayoutEffect(()=>{\n updatePositionManager();\n }, [\n updatePositionManager\n ]);\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(()=>{\n if (containerRef.current) {\n var _contentNode_ownerDocument;\n const contentNode = containerRef.current;\n const treeWalker = (_contentNode_ownerDocument = contentNode.ownerDocument) === null || _contentNode_ownerDocument === void 0 ? void 0 : _contentNode_ownerDocument.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter\n });\n while(treeWalker.nextNode()){\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn([\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element'\n ].join(' '));\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n const setTarget = useCallbackRef(null, (target)=>{\n if (targetRef.current !== target) {\n targetRef.current = target;\n updatePositionManager();\n }\n });\n const setContainer = useCallbackRef(null, (container)=>{\n if (containerRef.current !== container) {\n containerRef.current = container;\n updatePositionManager();\n }\n });\n const setArrow = useCallbackRef(null, (arrow)=>{\n if (arrowRef.current !== arrow) {\n arrowRef.current = arrow;\n updatePositionManager();\n }\n });\n // Let users use callback refs so they feel like 'normal' DOM refs\n return {\n targetRef: setTarget,\n containerRef: setContainer,\n arrowRef: setArrow\n };\n}\nfunction usePositioningOptions(options) {\n const { align , arrowPadding , autoSize , coverTarget , flipBoundary , offset , overflowBoundary , pinned , position , unstable_disableTether: disableTether , positionFixed , overflowBoundaryPadding , fallbackPositions , useTransform } = options;\n const { dir } = useFluent();\n const isRtl = dir === 'rtl';\n const strategy = positionFixed ? 'fixed' : 'absolute';\n return React.useCallback((container, arrow)=>{\n const hasScrollableElement = hasScrollParent(container);\n const middleware = [\n offset && offsetMiddleware(offset),\n coverTarget && coverTargetMiddleware(),\n !pinned && flipMiddleware({\n container,\n flipBoundary,\n hasScrollableElement,\n isRtl,\n fallbackPositions\n }),\n shiftMiddleware({\n container,\n hasScrollableElement,\n overflowBoundary,\n disableTether,\n overflowBoundaryPadding,\n isRtl\n }),\n autoSize && maxSizeMiddleware(autoSize, {\n container,\n overflowBoundary\n }),\n intersectingMiddleware(),\n arrow && arrowMiddleware({\n element: arrow,\n padding: arrowPadding\n }),\n hideMiddleware({\n strategy: 'referenceHidden'\n }),\n hideMiddleware({\n strategy: 'escaped'\n })\n ].filter(Boolean);\n const placement = toFloatingUIPlacement(align, position, isRtl);\n return {\n placement,\n middleware,\n strategy,\n useTransform\n };\n }, [\n align,\n arrowPadding,\n autoSize,\n coverTarget,\n disableTether,\n flipBoundary,\n isRtl,\n offset,\n overflowBoundary,\n pinned,\n position,\n strategy,\n overflowBoundaryPadding,\n fallbackPositions,\n useTransform\n ]);\n}\n"],"names":["usePositioning","options","managerRef","React","useRef","targetRef","overrideTargetRef","containerRef","arrowRef","enabled","resolvePositioningOptions","usePositioningOptions","updatePositionManager","useCallback","current","dispose","_overrideTargetRef_current","target","canUseDOM","createPositionManager","container","arrow","setOverrideTarget","useEventCallback","useImperativeHandle","positioningRef","updatePosition","_managerRef_current","setTarget","process","env","NODE_ENV","err","Error","console","warn","stack","useIsomorphicLayoutEffect","_options_target","useEffect","_contentNode_ownerDocument","contentNode","treeWalker","ownerDocument","createTreeWalker","NodeFilter","SHOW_ELEMENT","acceptNode","hasAutofocusFilter","nextNode","node","currentNode","join","useCallbackRef","setContainer","setArrow","align","arrowPadding","autoSize","coverTarget","flipBoundary","offset","overflowBoundary","pinned","position","unstable_disableTether","disableTether","positionFixed","overflowBoundaryPadding","fallbackPositions","useTransform","dir","useFluent","isRtl","strategy","hasScrollableElement","hasScrollParent","middleware","offsetMiddleware","coverTargetMiddleware","flipMiddleware","shiftMiddleware","maxSizeMiddleware","intersectingMiddleware","arrowMiddleware","element","padding","hideMiddleware","filter","Boolean","placement","toFloatingUIPlacement"],"mappings":";;;;+BASoBA;;aAAAA;;;qBAT6C;qCACjB;gCACuB;6DAChD;uBACoE;4BAC8G;uCACnK;AAG3B,SAASA,eAAeC,OAAO,EAAE;IACxC,MAAMC,aAAaC,OAAMC,MAAM,CAAC,IAAI;IACpC,MAAMC,YAAYF,OAAMC,MAAM,CAAC,IAAI;IACnC,MAAME,oBAAoBH,OAAMC,MAAM,CAAC,IAAI;IAC3C,MAAMG,eAAeJ,OAAMC,MAAM,CAAC,IAAI;IACtC,MAAMI,WAAWL,OAAMC,MAAM,CAAC,IAAI;IAClC,MAAM,EAAEK,SAAS,IAAI,CAAA,EAAG,GAAGR;IAC3B,MAAMS,4BAA4BC,sBAAsBV;IACxD,MAAMW,wBAAwBT,OAAMU,WAAW,CAAC,IAAI;QAChD,IAAIX,WAAWY,OAAO,EAAE;YACpBZ,WAAWY,OAAO,CAACC,OAAO;QAC9B,CAAC;QACDb,WAAWY,OAAO,GAAG,IAAI;QACzB,IAAIE;QACJ,MAAMC,SAAS,AAACD,CAAAA,6BAA6BV,kBAAkBQ,OAAO,AAAD,MAAO,IAAI,IAAIE,+BAA+B,KAAK,IAAIA,6BAA6BX,UAAUS,OA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YACAb;YACAH;YACAJ;QACJ;IACJ,GAAG;QACCd;QACAC;QACAC;QACAC;QACAO;QACAN;QACAa;QACAZ;QACAC;QACAC;QACAC;QACAU;QACAN;QACAC;QACAC;KACH;AACL"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["usePositioningMouseTarget.js"],"sourcesContent":["import * as React from 'react';\nimport { createVirtualElementFromClick } from './createVirtualElementFromClick';\n/**\n * @internal\n * A state hook that manages a popper virtual element from mouseevents.\n * Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)\n * React synthetic events are not persisted by this hook\n *\n * @param initialState - initializes a user provided state similare to useState\n * @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events\n */ export const usePositioningMouseTarget = (initialState)=>{\n const [virtualElement, setVirtualElement] = React.useState(initialState);\n const setVirtualMouseTarget = (event)=>{\n if (event === undefined || event === null) {\n setVirtualElement(undefined);\n return;\n }\n let mouseevent;\n if (!(event instanceof MouseEvent)) {\n mouseevent = event.nativeEvent;\n } else {\n mouseevent = event;\n }\n if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.error('usePositioningMouseTarget should only be used with MouseEvent');\n }\n const contextTarget = createVirtualElementFromClick(mouseevent);\n setVirtualElement(contextTarget);\n };\n return [\n virtualElement,\n setVirtualMouseTarget\n ];\n};\n"],"names":["usePositioningMouseTarget","initialState","virtualElement","setVirtualElement","React","useState","setVirtualMouseTarget","event","undefined","mouseevent","MouseEvent","nativeEvent","process","env","NODE_ENV","console","error","contextTarget","createVirtualElementFromClick"],"mappings":";;;;+BAUiBA;;aAAAA;;;6DAVM;+CACuB;AASnC,MAAMA,4BAA4B,CAACC,eAAe;IACzD,MAAM,CAACC,gBAAgBC,kBAAkB,GAAGC,OAAMC,QAAQ,CAACJ;IAC3D,MAAMK,wBAAwB,CAACC,QAAQ;QACnC,IAAIA,UAAUC,aAAaD,UAAU,IAAI,EAAE;YACvCJ,kBAAkBK;YAClB;QACJ,CAAC;QACD,IAAIC;QACJ,IAAI,CAAEF,CAAAA,iBAAiBG,UAAS,GAAI;YAChCD,aAAaF,MAAMI,WAAW;QAClC,OAAO;YACHF,aAAaF;QACjB,CAAC;QACD,IAAI,CAAEE,CAAAA,sBAAsBC,UAAS,KAAME,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YAC9E,sCAAsC;YACtCC,QAAQC,KAAK,CAAC;QAClB,CAAC;QACD,MAAMC,gBAAgBC,IAAAA,4DAA6B,EAACT;QACpDN,kBAAkBc;IACtB;IACA,OAAO;QACHf;QACAI;KACH;AACL"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["debounce.js"],"sourcesContent":["/**\n * Promise microtask debouncer used by Popper.js v2\n * This is no longer exported in Floating UI (Popper.js v3)\n * https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js\n * @param fn function that will be debounced\n */ export function debounce(fn) {\n let pending;\n return ()=>{\n if (!pending) {\n pending = new Promise((resolve)=>{\n Promise.resolve().then(()=>{\n pending = undefined;\n resolve(fn());\n });\n });\n }\n return pending;\n };\n}\n"],"names":["debounce","fn","pending","Promise","resolve","then","undefined"],"mappings":"AAAA;;;;;CAKC;;;;+BAAmBA;;aAAAA;;AAAT,SAASA,SAASC,EAAE,EAAE;IAC7B,IAAIC;IACJ,OAAO,IAAI;QACP,IAAI,CAACA,SAAS;YACVA,UAAU,IAAIC,QAAQ,CAACC,UAAU;gBAC7BD,QAAQC,OAAO,GAAGC,IAAI,CAAC,IAAI;oBACvBH,UAAUI;oBACVF,QAAQH;gBACZ;YACJ;QACJ,CAAC;QACD,OAAOC;IACX;AACJ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["fromFloatingUIPlacement.js"],"sourcesContent":["import { parseFloatingUIPlacement } from './parseFloatingUIPlacement';\nconst getPositionMap = ()=>({\n top: 'above',\n bottom: 'below',\n right: 'after',\n left: 'before'\n });\n// Floating UI automatically flips alignment\n// https://github.com/floating-ui/floating-ui/issues/1563\nconst getAlignmentMap = (position)=>{\n if (position === 'above' || position === 'below') {\n return {\n start: 'start',\n end: 'end'\n };\n }\n return {\n start: 'top',\n end: 'bottom'\n };\n};\n/**\n * Maps Floating UI placement to positioning values\n * @see positioningHelper.test.ts for expected placement values\n */ export const fromFloatingUIPlacement = (placement)=>{\n const { side , alignment: floatingUIAlignment } = parseFloatingUIPlacement(placement);\n const position = getPositionMap()[side];\n const alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];\n return {\n position,\n alignment\n };\n};\n"],"names":["fromFloatingUIPlacement","getPositionMap","top","bottom","right","left","getAlignmentMap","position","start","end","placement","side","alignment","floatingUIAlignment","parseFloatingUIPlacement"],"mappings":";;;;+BAwBiBA;;aAAAA;;0CAxBwB;AACzC,MAAMC,iBAAiB,IAAK,CAAA;QACpBC,KAAK;QACLC,QAAQ;QACRC,OAAO;QACPC,MAAM;IACV,CAAA;AACJ,4CAA4C;AAC5C,yDAAyD;AACzD,MAAMC,kBAAkB,CAACC,WAAW;IAChC,IAAIA,aAAa,WAAWA,aAAa,SAAS;QAC9C,OAAO;YACHC,OAAO;YACPC,KAAK;QACT;IACJ,CAAC;IACD,OAAO;QACHD,OAAO;QACPC,KAAK;IACT;AACJ;AAIW,MAAMT,0BAA0B,CAACU,YAAY;IACpD,MAAM,EAAEC,KAAI,EAAGC,WAAWC,oBAAmB,EAAG,GAAGC,IAAAA,kDAAwB,EAACJ;IAC5E,MAAMH,WAAWN,gBAAgB,CAACU,KAAK;IACvC,MAAMC,YAAYC,uBAAuBP,gBAAgBC,SAAS,CAACM,oBAAoB;IACvF,OAAO;QACHN;QACAK;IACJ;AACJ"}
|