@fluentui/react-positioning 9.75.0-experimental.css-modules.20261031-810ab07afb.0 → 9.75.1-experimental.positioning-engine.20261103-19efe125d1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -7
- package/README.md +130 -7
- package/lib/PositioningConfigurationContext.js +1 -2
- package/lib/PositioningConfigurationContext.js.map +1 -1
- package/lib/createPositionManager.js +74 -82
- package/lib/createPositionManager.js.map +1 -1
- package/lib/engine/computePosition.js +258 -0
- package/lib/engine/computePosition.js.map +1 -0
- package/lib/engine/index.js +260 -0
- package/lib/engine/index.js.map +1 -0
- package/lib/engine/platform.js +209 -0
- package/lib/engine/platform.js.map +1 -0
- package/lib/middleware/flip.js +1 -1
- package/lib/middleware/flip.js.map +1 -1
- package/lib/middleware/intersecting.js +1 -1
- package/lib/middleware/intersecting.js.map +1 -1
- package/lib/middleware/maxSize.js +1 -1
- package/lib/middleware/maxSize.js.map +1 -1
- package/lib/middleware/offset.js +1 -1
- package/lib/middleware/offset.js.map +1 -1
- package/lib/middleware/shift.js +1 -1
- package/lib/middleware/shift.js.map +1 -1
- package/lib/usePositioning.js +38 -48
- package/lib/usePositioning.js.map +1 -1
- package/lib/usePositioning.raster.js +45 -0
- package/lib/usePositioning.raster.js.map +1 -0
- package/lib/usePositioningOptions.js +25 -117
- package/lib/usePositioningOptions.js.map +1 -1
- package/lib/utils/createResizeObserver.js +2 -2
- package/lib/utils/createResizeObserver.js.map +1 -1
- package/lib/utils/debounce.js +6 -13
- package/lib/utils/debounce.js.map +1 -1
- package/lib/utils/fromFloatingUIPlacement.js +10 -29
- package/lib/utils/fromFloatingUIPlacement.js.map +1 -1
- package/lib/utils/getBoundary.js +8 -17
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/index.js +0 -2
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/listScrollParents.js +12 -20
- package/lib/utils/listScrollParents.js.map +1 -1
- package/lib/utils/normalizeAutoSize.js +15 -22
- package/lib/utils/normalizeAutoSize.js.map +1 -1
- package/lib/utils/toFloatingUIPlacement.js +9 -26
- package/lib/utils/toFloatingUIPlacement.js.map +1 -1
- package/lib/utils/useCallbackRef.js +1 -10
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/PositioningConfigurationContext.cjs +1 -2
- package/lib-commonjs/PositioningConfigurationContext.cjs.map +1 -1
- package/lib-commonjs/createPositionManager.cjs +72 -80
- package/lib-commonjs/createPositionManager.cjs.map +1 -1
- package/lib-commonjs/engine/computePosition.cjs +265 -0
- package/lib-commonjs/engine/computePosition.cjs.map +1 -0
- package/lib-commonjs/engine/index.cjs +290 -0
- package/lib-commonjs/engine/index.cjs.map +1 -0
- package/lib-commonjs/engine/platform.cjs +264 -0
- package/lib-commonjs/engine/platform.cjs.map +1 -0
- package/lib-commonjs/middleware/flip.cjs +6 -6
- package/lib-commonjs/middleware/flip.cjs.map +1 -1
- package/lib-commonjs/middleware/intersecting.cjs +2 -2
- package/lib-commonjs/middleware/intersecting.cjs.map +1 -1
- package/lib-commonjs/middleware/maxSize.cjs +4 -4
- package/lib-commonjs/middleware/maxSize.cjs.map +1 -1
- package/lib-commonjs/middleware/offset.cjs +2 -2
- package/lib-commonjs/middleware/offset.cjs.map +1 -1
- package/lib-commonjs/middleware/shift.cjs +7 -7
- package/lib-commonjs/middleware/shift.cjs.map +1 -1
- package/lib-commonjs/usePositioning.cjs +37 -46
- package/lib-commonjs/usePositioning.cjs.map +1 -1
- package/lib-commonjs/usePositioning.raster.cjs +49 -0
- package/lib-commonjs/usePositioning.raster.cjs.map +1 -0
- package/lib-commonjs/usePositioningOptions.cjs +24 -112
- package/lib-commonjs/usePositioningOptions.cjs.map +1 -1
- package/lib-commonjs/utils/createResizeObserver.cjs +2 -2
- package/lib-commonjs/utils/createResizeObserver.cjs.map +1 -1
- package/lib-commonjs/utils/debounce.cjs +6 -13
- package/lib-commonjs/utils/debounce.cjs.map +1 -1
- package/lib-commonjs/utils/fromFloatingUIPlacement.cjs +21 -32
- package/lib-commonjs/utils/fromFloatingUIPlacement.cjs.map +1 -1
- package/lib-commonjs/utils/getBoundary.cjs +8 -17
- package/lib-commonjs/utils/getBoundary.cjs.map +1 -1
- package/lib-commonjs/utils/index.cjs +0 -8
- package/lib-commonjs/utils/index.cjs.map +1 -1
- package/lib-commonjs/utils/listScrollParents.cjs +12 -20
- package/lib-commonjs/utils/listScrollParents.cjs.map +1 -1
- package/lib-commonjs/utils/normalizeAutoSize.cjs +26 -25
- package/lib-commonjs/utils/normalizeAutoSize.cjs.map +1 -1
- package/lib-commonjs/utils/toFloatingUIPlacement.cjs +13 -27
- package/lib-commonjs/utils/toFloatingUIPlacement.cjs.map +1 -1
- package/lib-commonjs/utils/useCallbackRef.cjs +1 -9
- package/lib-commonjs/utils/useCallbackRef.cjs.map +1 -1
- package/package.json +5 -9
- package/lib/Arrow.module.css +0 -45
- package/lib/hooks/useSafeZoneArea/SafeZoneArea.module.css +0 -28
- package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js +0 -9
- package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.css.js.map +0 -1
- package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js +0 -9
- package/lib/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.js.map +0 -1
- package/lib/utils/writeArrowUpdates.js +0 -13
- package/lib/utils/writeArrowUpdates.js.map +0 -1
- package/lib/utils/writeContainerupdates.js +0 -43
- package/lib/utils/writeContainerupdates.js.map +0 -1
- package/lib-commonjs/Arrow.module.css +0 -45
- package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.module.css +0 -28
- package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs +0 -20
- package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.css.cjs.map +0 -1
- package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs +0 -20
- package/lib-commonjs/hooks/useSafeZoneArea/SafeZoneArea.styles.raw.css.cjs.map +0 -1
- package/lib-commonjs/utils/writeArrowUpdates.cjs +0 -23
- package/lib-commonjs/utils/writeArrowUpdates.cjs.map +0 -1
- package/lib-commonjs/utils/writeContainerupdates.cjs +0 -51
- package/lib-commonjs/utils/writeContainerupdates.cjs.map +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { webLightTheme as theme } from "@fluentui/react-theme";
|
|
2
|
+
import "./usePositioning.geometry.cy.js";
|
|
3
|
+
// Paint the otherwise transparent geometry fixtures without changing their layout.
|
|
4
|
+
beforeEach(()=>{
|
|
5
|
+
cy.document().then((doc)=>{
|
|
6
|
+
const sheet = doc.createElement('style');
|
|
7
|
+
sheet.dataset.positioningRaster = '';
|
|
8
|
+
sheet.textContent = `
|
|
9
|
+
[data-enabled] { background: ${theme.colorNeutralBackground1}; }
|
|
10
|
+
[data-target] {
|
|
11
|
+
background: ${theme.colorBrandBackground2};
|
|
12
|
+
outline: ${theme.strokeWidthThin} solid ${theme.colorBrandStroke1};
|
|
13
|
+
}
|
|
14
|
+
[data-floating] {
|
|
15
|
+
background: ${theme.colorNeutralBackground2};
|
|
16
|
+
outline: ${theme.strokeWidthThin} solid ${theme.colorNeutralStroke1};
|
|
17
|
+
border-radius: ${theme.borderRadiusMedium};
|
|
18
|
+
box-shadow: ${theme.shadow8};
|
|
19
|
+
}
|
|
20
|
+
[data-arrow] { background: ${theme.colorBrandBackground}; }
|
|
21
|
+
[data-target]::after, [data-floating]::after {
|
|
22
|
+
position: absolute;
|
|
23
|
+
inset: 0;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
color: ${theme.colorNeutralForeground1};
|
|
26
|
+
font: ${theme.fontSizeBase300} ${theme.fontFamilyBase};
|
|
27
|
+
}
|
|
28
|
+
[data-target]::after { content: 'Target'; }
|
|
29
|
+
[data-floating]::after { content: 'Positioned surface'; }
|
|
30
|
+
[data-boundary] { outline: ${theme.strokeWidthThin} solid ${theme.colorNeutralStroke2}; }
|
|
31
|
+
`;
|
|
32
|
+
doc.head.appendChild(sheet);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
afterEach(()=>{
|
|
36
|
+
cy.document().then((doc)=>{
|
|
37
|
+
if (doc.querySelector('[data-enabled]')) {
|
|
38
|
+
cy.get('[data-enabled]').first().screenshot(Cypress.currentTest.title, {
|
|
39
|
+
overwrite: true,
|
|
40
|
+
scale: false
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
cy.get('style[data-positioning-raster]').invoke('remove');
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/usePositioning.raster.tsx"],"sourcesContent":["import { webLightTheme as theme } from '@fluentui/react-theme';\nimport './usePositioning.geometry.cy';\n\n// Paint the otherwise transparent geometry fixtures without changing their layout.\nbeforeEach(() => {\n cy.document().then(doc => {\n const sheet = doc.createElement('style');\n sheet.dataset.positioningRaster = '';\n sheet.textContent = `\n [data-enabled] { background: ${theme.colorNeutralBackground1}; }\n [data-target] {\n background: ${theme.colorBrandBackground2};\n outline: ${theme.strokeWidthThin} solid ${theme.colorBrandStroke1};\n }\n [data-floating] {\n background: ${theme.colorNeutralBackground2};\n outline: ${theme.strokeWidthThin} solid ${theme.colorNeutralStroke1};\n border-radius: ${theme.borderRadiusMedium};\n box-shadow: ${theme.shadow8};\n }\n [data-arrow] { background: ${theme.colorBrandBackground}; }\n [data-target]::after, [data-floating]::after {\n position: absolute;\n inset: 0;\n overflow: hidden;\n color: ${theme.colorNeutralForeground1};\n font: ${theme.fontSizeBase300} ${theme.fontFamilyBase};\n }\n [data-target]::after { content: 'Target'; }\n [data-floating]::after { content: 'Positioned surface'; }\n [data-boundary] { outline: ${theme.strokeWidthThin} solid ${theme.colorNeutralStroke2}; }\n `;\n doc.head.appendChild(sheet);\n });\n});\n\nafterEach(() => {\n cy.document().then(doc => {\n if (doc.querySelector('[data-enabled]')) {\n cy.get('[data-enabled]').first().screenshot(Cypress.currentTest.title, { overwrite: true, scale: false });\n }\n });\n cy.get('style[data-positioning-raster]').invoke('remove');\n});\n"],"names":["webLightTheme","theme","beforeEach","cy","document","then","doc","sheet","createElement","dataset","positioningRaster","textContent","colorNeutralBackground1","colorBrandBackground2","strokeWidthThin","colorBrandStroke1","colorNeutralBackground2","colorNeutralStroke1","borderRadiusMedium","shadow8","colorBrandBackground","colorNeutralForeground1","fontSizeBase300","fontFamilyBase","colorNeutralStroke2","head","appendChild","afterEach","querySelector","get","first","screenshot","Cypress","currentTest","title","overwrite","scale","invoke"],"mappings":"AAAA,SAASA,iBAAiBC,KAAK,QAAQ,wBAAwB;AAC/D,OAAO,kCAA+B;AAEtC,mFAAmF;AACnFC,WAAW;IACTC,GAAGC,QAAQ,GAAGC,IAAI,CAACC,CAAAA;QACjB,MAAMC,QAAQD,IAAIE,aAAa,CAAC;QAChCD,MAAME,OAAO,CAACC,iBAAiB,GAAG;QAClCH,MAAMI,WAAW,GAAG,CAAC;mCACU,EAAEV,MAAMW,uBAAuB,CAAC;;oBAE/C,EAAEX,MAAMY,qBAAqB,CAAC;iBACjC,EAAEZ,MAAMa,eAAe,CAAC,OAAO,EAAEb,MAAMc,iBAAiB,CAAC;;;oBAGtD,EAAEd,MAAMe,uBAAuB,CAAC;iBACnC,EAAEf,MAAMa,eAAe,CAAC,OAAO,EAAEb,MAAMgB,mBAAmB,CAAC;uBACrD,EAAEhB,MAAMiB,kBAAkB,CAAC;oBAC9B,EAAEjB,MAAMkB,OAAO,CAAC;;iCAEH,EAAElB,MAAMmB,oBAAoB,CAAC;;;;;eAK/C,EAAEnB,MAAMoB,uBAAuB,CAAC;cACjC,EAAEpB,MAAMqB,eAAe,CAAC,CAAC,EAAErB,MAAMsB,cAAc,CAAC;;;;iCAI7B,EAAEtB,MAAMa,eAAe,CAAC,OAAO,EAAEb,MAAMuB,mBAAmB,CAAC;IACxF,CAAC;QACDlB,IAAImB,IAAI,CAACC,WAAW,CAACnB;IACvB;AACF;AAEAoB,UAAU;IACRxB,GAAGC,QAAQ,GAAGC,IAAI,CAACC,CAAAA;QACjB,IAAIA,IAAIsB,aAAa,CAAC,mBAAmB;YACvCzB,GAAG0B,GAAG,CAAC,kBAAkBC,KAAK,GAAGC,UAAU,CAACC,QAAQC,WAAW,CAACC,KAAK,EAAE;gBAAEC,WAAW;gBAAMC,OAAO;YAAM;QACzG;IACF;IACAjC,GAAG0B,GAAG,CAAC,kCAAkCQ,MAAM,CAAC;AAClD"}
|
|
@@ -1,132 +1,40 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { devtools } from "@floating-ui/devtools";
|
|
3
|
-
import { hide as hideMiddleware, arrow as arrowMiddleware } from "@floating-ui/dom";
|
|
4
2
|
import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts";
|
|
5
3
|
import * as React from "react";
|
|
6
|
-
import {
|
|
7
|
-
import { toFloatingUIPlacement, hasScrollParent, normalizeAutoSize } from "./utils/index.js";
|
|
8
|
-
import { devtoolsCallback } from "./utils/devtools.js";
|
|
4
|
+
import { toFloatingUIPlacement } from "./utils/index.js";
|
|
9
5
|
import { usePositioningConfiguration } from "./PositioningConfigurationContext.js";
|
|
10
6
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
7
|
+
* Options passed to the configuration function. Callbacks and refs are intentionally absent so that
|
|
8
|
+
* rerenders that only change them do not recreate the position manager.
|
|
9
|
+
*/ const OPTION_KEYS = ('align arrowPadding autoSize coverTarget disableUpdateOnResize fallbackPositions flipBoundary matchTargetSize ' + 'offset overflowBoundary overflowBoundaryPadding pinned position shiftToCoverTarget strategy unstable_disableTether ' + 'useTransform').split(' ');
|
|
10
|
+
/** Keep callback/ref rerenders out of the manager lifecycle, including removed options. */ export function usePositioningOptions(options) {
|
|
11
|
+
const isRtl = useFluent().dir === 'rtl';
|
|
12
|
+
const configFn = usePositioningConfiguration();
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
14
|
+
const { positionFixed } = options;
|
|
15
|
+
const values = OPTION_KEYS.map((key)=>options[key]);
|
|
18
16
|
return React.useCallback((container, arrow)=>{
|
|
19
|
-
|
|
17
|
+
const resolved = configFn({
|
|
20
18
|
container,
|
|
21
19
|
arrow,
|
|
22
|
-
options:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
offset,
|
|
27
|
-
strategy,
|
|
28
|
-
coverTarget,
|
|
29
|
-
flipBoundary,
|
|
30
|
-
overflowBoundary,
|
|
31
|
-
useTransform,
|
|
32
|
-
overflowBoundaryPadding,
|
|
33
|
-
pinned,
|
|
34
|
-
arrowPadding,
|
|
35
|
-
align,
|
|
36
|
-
fallbackPositions,
|
|
37
|
-
shiftToCoverTarget,
|
|
38
|
-
position,
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
40
|
-
unstable_disableTether
|
|
41
|
-
}
|
|
20
|
+
options: Object.fromEntries(OPTION_KEYS.map((key, index)=>[
|
|
21
|
+
key,
|
|
22
|
+
values[index]
|
|
23
|
+
]))
|
|
42
24
|
});
|
|
43
|
-
}, [
|
|
44
|
-
autoSize,
|
|
45
|
-
disableUpdateOnResize,
|
|
46
|
-
matchTargetSize,
|
|
47
|
-
offset,
|
|
48
|
-
strategy,
|
|
49
|
-
coverTarget,
|
|
50
|
-
flipBoundary,
|
|
51
|
-
overflowBoundary,
|
|
52
|
-
useTransform,
|
|
53
|
-
overflowBoundaryPadding,
|
|
54
|
-
pinned,
|
|
55
|
-
arrowPadding,
|
|
56
|
-
align,
|
|
57
|
-
fallbackPositions,
|
|
58
|
-
shiftToCoverTarget,
|
|
59
|
-
position,
|
|
60
|
-
unstable_disableTether,
|
|
61
|
-
configFn
|
|
62
|
-
]);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* @internal
|
|
66
|
-
*/ export function usePositioningOptions(options) {
|
|
67
|
-
const { dir, targetDocument } = useFluent();
|
|
68
|
-
const isRtl = dir === 'rtl';
|
|
69
|
-
const configFn = usePositioningConfigFn(usePositioningConfiguration(), options);
|
|
70
|
-
const { // eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
71
|
-
positionFixed } = options;
|
|
72
|
-
return React.useCallback((container, arrow)=>{
|
|
73
|
-
const hasScrollableElement = hasScrollParent(container);
|
|
74
|
-
const optionsAfterEnhancement = configFn(container, arrow);
|
|
75
|
-
const { autoSize, disableUpdateOnResize, matchTargetSize, offset, coverTarget, flipBoundary, overflowBoundary, useTransform, overflowBoundaryPadding, pinned, position, arrowPadding, strategy, align, fallbackPositions, shiftToCoverTarget, // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
76
|
-
unstable_disableTether } = optionsAfterEnhancement;
|
|
77
|
-
const normalizedAutoSize = normalizeAutoSize(autoSize);
|
|
78
|
-
const middleware = [
|
|
79
|
-
normalizedAutoSize && resetMaxSizeMiddleware(normalizedAutoSize),
|
|
80
|
-
matchTargetSize && matchTargetSizeMiddleware(),
|
|
81
|
-
offset && offsetMiddleware(offset),
|
|
82
|
-
coverTarget && coverTargetMiddleware(),
|
|
83
|
-
!pinned && flipMiddleware({
|
|
84
|
-
container,
|
|
85
|
-
flipBoundary,
|
|
86
|
-
hasScrollableElement,
|
|
87
|
-
isRtl,
|
|
88
|
-
fallbackPositions
|
|
89
|
-
}),
|
|
90
|
-
shiftMiddleware({
|
|
91
|
-
container,
|
|
92
|
-
hasScrollableElement,
|
|
93
|
-
overflowBoundary,
|
|
94
|
-
disableTether: unstable_disableTether,
|
|
95
|
-
overflowBoundaryPadding,
|
|
96
|
-
isRtl,
|
|
97
|
-
shiftToCoverTarget
|
|
98
|
-
}),
|
|
99
|
-
normalizedAutoSize && maxSizeMiddleware(normalizedAutoSize, {
|
|
100
|
-
container,
|
|
101
|
-
overflowBoundary,
|
|
102
|
-
overflowBoundaryPadding,
|
|
103
|
-
isRtl
|
|
104
|
-
}),
|
|
105
|
-
intersectingMiddleware(),
|
|
106
|
-
arrow && arrowMiddleware({
|
|
107
|
-
element: arrow,
|
|
108
|
-
padding: arrowPadding
|
|
109
|
-
}),
|
|
110
|
-
hideMiddleware({
|
|
111
|
-
strategy: 'referenceHidden'
|
|
112
|
-
}),
|
|
113
|
-
hideMiddleware({
|
|
114
|
-
strategy: 'escaped'
|
|
115
|
-
}),
|
|
116
|
-
process.env.NODE_ENV !== 'production' && targetDocument && devtools(targetDocument, devtoolsCallback(optionsAfterEnhancement))
|
|
117
|
-
].filter(Boolean);
|
|
118
|
-
const placement = toFloatingUIPlacement(align, position, isRtl);
|
|
119
25
|
return {
|
|
120
|
-
placement,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
26
|
+
placement: toFloatingUIPlacement(resolved.align, resolved.position, isRtl),
|
|
27
|
+
options: resolved,
|
|
28
|
+
isRtl,
|
|
29
|
+
// Preserve the baseline precedence: an explicit absolute strategy also resolves to fixed.
|
|
30
|
+
strategy: resolved.strategy || positionFixed ? 'fixed' : 'absolute'
|
|
125
31
|
};
|
|
126
|
-
},
|
|
32
|
+
}, // `values` has a fixed length, so the dependencies are still the individual option values
|
|
33
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo
|
|
34
|
+
[
|
|
127
35
|
configFn,
|
|
128
36
|
isRtl,
|
|
129
|
-
|
|
130
|
-
|
|
37
|
+
positionFixed,
|
|
38
|
+
...values
|
|
131
39
|
]);
|
|
132
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/usePositioningOptions.ts"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/usePositioningOptions.ts"],"sourcesContent":["'use client';\n\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport * as React from 'react';\nimport type { PositioningOptions, PositioningPlacement } from './types';\nimport { toFloatingUIPlacement } from './utils';\nimport { usePositioningConfiguration } from './PositioningConfigurationContext';\n\n/**\n * Options passed to the configuration function. Callbacks and refs are intentionally absent so that\n * rerenders that only change them do not recreate the position manager.\n */\nconst OPTION_KEYS = (\n 'align arrowPadding autoSize coverTarget disableUpdateOnResize fallbackPositions flipBoundary matchTargetSize ' +\n 'offset overflowBoundary overflowBoundaryPadding pinned position shiftToCoverTarget strategy unstable_disableTether ' +\n 'useTransform'\n).split(' ') as (keyof PositioningOptions)[];\n\n/** Keep callback/ref rerenders out of the manager lifecycle, including removed options. */\nexport function usePositioningOptions(options: PositioningOptions): (\n container: HTMLElement,\n arrow: HTMLElement | null,\n) => {\n placement: PositioningPlacement | undefined;\n /** The positioning options resolved by the configuration context */\n options: PositioningOptions;\n strategy: 'absolute' | 'fixed';\n isRtl: boolean;\n} {\n const isRtl = useFluent().dir === 'rtl';\n const configFn = usePositioningConfiguration();\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const { positionFixed } = options;\n const values = OPTION_KEYS.map(key => options[key]);\n return React.useCallback(\n (container: HTMLElement, arrow: HTMLElement | null) => {\n const resolved = configFn({\n container,\n arrow,\n options: Object.fromEntries(OPTION_KEYS.map((key, index) => [key, values[index]])),\n });\n return {\n placement: toFloatingUIPlacement(resolved.align, resolved.position, isRtl),\n options: resolved,\n isRtl,\n // Preserve the baseline precedence: an explicit absolute strategy also resolves to fixed.\n strategy: resolved.strategy || positionFixed ? ('fixed' as const) : ('absolute' as const),\n };\n },\n // `values` has a fixed length, so the dependencies are still the individual option values\n // eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo\n [configFn, isRtl, positionFixed, ...values],\n );\n}\n"],"names":["useFluent_unstable","useFluent","React","toFloatingUIPlacement","usePositioningConfiguration","OPTION_KEYS","split","usePositioningOptions","options","isRtl","dir","configFn","positionFixed","values","map","key","useCallback","container","arrow","resolved","Object","fromEntries","index","placement","align","position","strategy"],"mappings":"AAAA;AAEA,SAASA,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,YAAYC,WAAW,QAAQ;AAE/B,SAASC,qBAAqB,QAAQ,mBAAU;AAChD,SAASC,2BAA2B,QAAQ,uCAAoC;AAEhF;;;CAGC,GACD,MAAMC,cAAc,AAClB,CAAA,kHACA,wHACA,cAAa,EACbC,KAAK,CAAC;AAER,yFAAyF,GACzF,OAAO,SAASC,sBAAsBC,OAA2B;IAU/D,MAAMC,QAAQR,YAAYS,GAAG,KAAK;IAClC,MAAMC,WAAWP;IACjB,4DAA4D;IAC5D,MAAM,EAAEQ,aAAa,EAAE,GAAGJ;IAC1B,MAAMK,SAASR,YAAYS,GAAG,CAACC,CAAAA,MAAOP,OAAO,CAACO,IAAI;IAClD,OAAOb,MAAMc,WAAW,CACtB,CAACC,WAAwBC;QACvB,MAAMC,WAAWR,SAAS;YACxBM;YACAC;YACAV,SAASY,OAAOC,WAAW,CAAChB,YAAYS,GAAG,CAAC,CAACC,KAAKO,QAAU;oBAACP;oBAAKF,MAAM,CAACS,MAAM;iBAAC;QAClF;QACA,OAAO;YACLC,WAAWpB,sBAAsBgB,SAASK,KAAK,EAAEL,SAASM,QAAQ,EAAEhB;YACpED,SAASW;YACTV;YACA,0FAA0F;YAC1FiB,UAAUP,SAASO,QAAQ,IAAId,gBAAiB,UAAqB;QACvE;IACF,GACA,0FAA0F;IAC1F,6EAA6E;IAC7E;QAACD;QAAUF;QAAOG;WAAkBC;KAAO;AAE/C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const createResizeObserver = (targetWindow, callback)=>{
|
|
2
2
|
// https://github.com/jsdom/jsdom/issues/3368
|
|
3
3
|
// Add the polyfill here so it is not needed for all unit tests that leverage positioning
|
|
4
4
|
if (process.env.NODE_ENV === 'test') {
|
|
@@ -15,4 +15,4 @@ export function createResizeObserver(targetWindow, callback) {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
return new targetWindow.ResizeObserver(callback);
|
|
18
|
-
}
|
|
18
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/createResizeObserver.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../../src/utils/createResizeObserver.ts"],"sourcesContent":["export const createResizeObserver = (\n targetWindow: Window & typeof globalThis,\n callback: ResizeObserverCallback,\n): ResizeObserver => {\n // https://github.com/jsdom/jsdom/issues/3368\n // Add the polyfill here so it is not needed for all unit tests that leverage positioning\n if (process.env.NODE_ENV === 'test') {\n targetWindow.ResizeObserver = class ResizeObserver {\n public observe() {\n // do nothing\n }\n public unobserve() {\n // do nothing\n }\n public disconnect() {\n // do nothing\n }\n };\n }\n\n return new targetWindow.ResizeObserver(callback);\n};\n"],"names":["createResizeObserver","targetWindow","callback","process","env","NODE_ENV","ResizeObserver","observe","unobserve","disconnect"],"mappings":"AAAA,OAAO,MAAMA,uBAAuB,CAClCC,cACAC;IAEA,6CAA6C;IAC7C,yFAAyF;IACzF,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,QAAQ;QACnCJ,aAAaK,cAAc,GAAG,MAAMA;YAC3BC,UAAU;YACf,aAAa;YACf;YACOC,YAAY;YACjB,aAAa;YACf;YACOC,aAAa;YAClB,aAAa;YACf;QACF;IACF;IAEA,OAAO,IAAIR,aAAaK,cAAc,CAACJ;AACzC,EAAE"}
|
package/lib/utils/debounce.js
CHANGED
|
@@ -3,17 +3,10 @@
|
|
|
3
3
|
* This is no longer exported in Floating UI (Popper.js v3)
|
|
4
4
|
* https://github.com/floating-ui/floating-ui/blob/v2.x/src/utils/debounce.js
|
|
5
5
|
* @param fn function that will be debounced
|
|
6
|
-
*/ export
|
|
6
|
+
*/ export const debounce = (fn)=>{
|
|
7
7
|
let pending;
|
|
8
|
-
return ()=>{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
resolve(fn());
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return pending;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
8
|
+
return ()=>pending || (pending = Promise.resolve().then(()=>{
|
|
9
|
+
pending = undefined;
|
|
10
|
+
return fn();
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/debounce.ts"],"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 */\nexport
|
|
1
|
+
{"version":3,"sources":["../../src/utils/debounce.ts"],"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 */\nexport const debounce = <T>(fn: () => T): (() => Promise<T>) => {\n let pending: Promise<T> | undefined;\n return () =>\n (pending ||= Promise.resolve().then(() => {\n pending = undefined;\n return fn();\n }));\n};\n"],"names":["debounce","fn","pending","Promise","resolve","then","undefined"],"mappings":"AAAA;;;;;CAKC,GACD,OAAO,MAAMA,WAAW,CAAIC;IAC1B,IAAIC;IACJ,OAAO,IACJA,YAAAA,UAAYC,QAAQC,OAAO,GAAGC,IAAI,CAAC;YAClCH,UAAUI;YACV,OAAOL;QACT;AACJ,EAAE"}
|
|
@@ -1,33 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
left: 'before'
|
|
7
|
-
});
|
|
8
|
-
// Floating UI automatically flips alignment
|
|
9
|
-
// https://github.com/floating-ui/floating-ui/issues/1563
|
|
10
|
-
const getAlignmentMap = (position)=>{
|
|
11
|
-
if (position === 'above' || position === 'below') {
|
|
12
|
-
return {
|
|
13
|
-
start: 'start',
|
|
14
|
-
end: 'end'
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
start: 'top',
|
|
19
|
-
end: 'bottom'
|
|
20
|
-
};
|
|
1
|
+
const POSITIONS = {
|
|
2
|
+
top: 'above',
|
|
3
|
+
bottom: 'below',
|
|
4
|
+
left: 'before',
|
|
5
|
+
right: 'after'
|
|
21
6
|
};
|
|
7
|
+
/** Maps the side and the alignment of a Floating UI placement to positioning values */ export const toPositioningValues = (side, alignment)=>({
|
|
8
|
+
position: POSITIONS[side],
|
|
9
|
+
alignment: alignment && (side === 'top' || side === 'bottom' ? alignment : alignment === 'start' ? 'top' : 'bottom')
|
|
10
|
+
});
|
|
22
11
|
/**
|
|
23
12
|
* Maps Floating UI placement to positioning values
|
|
24
13
|
* @see positioningHelper.test.ts for expected placement values
|
|
25
|
-
*/ export const fromFloatingUIPlacement = (placement)=>
|
|
26
|
-
const { side, alignment: floatingUIAlignment } = parseFloatingUIPlacement(placement);
|
|
27
|
-
const position = getPositionMap()[side];
|
|
28
|
-
const alignment = floatingUIAlignment && getAlignmentMap(position)[floatingUIAlignment];
|
|
29
|
-
return {
|
|
30
|
-
position,
|
|
31
|
-
alignment
|
|
32
|
-
};
|
|
33
|
-
};
|
|
14
|
+
*/ export const fromFloatingUIPlacement = (placement)=>toPositioningValues(...placement.split('-'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/fromFloatingUIPlacement.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/utils/fromFloatingUIPlacement.ts"],"sourcesContent":["import type { Placement, Side } from '@floating-ui/dom';\nimport type { Alignment, Position } from '../types';\n\nconst POSITIONS: Record<Side, Position> = { top: 'above', bottom: 'below', left: 'before', right: 'after' };\n\n/** Maps the side and the alignment of a Floating UI placement to positioning values */\nexport const toPositioningValues = (side: Side, alignment?: string): { position: Position; alignment?: Alignment } => ({\n position: POSITIONS[side],\n alignment: (alignment &&\n (side === 'top' || side === 'bottom' ? alignment : alignment === 'start' ? 'top' : 'bottom')) as Alignment,\n});\n\n/**\n * Maps Floating UI placement to positioning values\n * @see positioningHelper.test.ts for expected placement values\n */\nexport const fromFloatingUIPlacement = (placement: Placement): { position: Position; alignment?: Alignment } =>\n toPositioningValues(...(placement.split('-') as [Side, string?]));\n"],"names":["POSITIONS","top","bottom","left","right","toPositioningValues","side","alignment","position","fromFloatingUIPlacement","placement","split"],"mappings":"AAGA,MAAMA,YAAoC;IAAEC,KAAK;IAASC,QAAQ;IAASC,MAAM;IAAUC,OAAO;AAAQ;AAE1G,qFAAqF,GACrF,OAAO,MAAMC,sBAAsB,CAACC,MAAYC,YAAuE,CAAA;QACrHC,UAAUR,SAAS,CAACM,KAAK;QACzBC,WAAYA,aACTD,CAAAA,SAAS,SAASA,SAAS,WAAWC,YAAYA,cAAc,UAAU,QAAQ,QAAO;IAC9F,CAAA,EAAG;AAEH;;;CAGC,GACD,OAAO,MAAME,0BAA0B,CAACC,YACtCL,uBAAwBK,UAAUC,KAAK,CAAC,MAA0B"}
|
package/lib/utils/getBoundary.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getRoot } from "../engine/platform.js";
|
|
2
|
+
import { listScrollParents } from "./listScrollParents.js";
|
|
2
3
|
/**
|
|
3
4
|
* Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
|
|
4
|
-
*/ export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
if (boundary === 'scrollParent') {
|
|
12
|
-
let boundariesNode = getScrollParent(element);
|
|
13
|
-
if (boundariesNode.nodeName === 'BODY') {
|
|
14
|
-
boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
|
15
|
-
}
|
|
16
|
-
return boundariesNode;
|
|
17
|
-
}
|
|
18
|
-
return boundary;
|
|
19
|
-
}
|
|
5
|
+
*/ export const getBoundary = (element, boundary)=>{
|
|
6
|
+
const root = element ? getRoot(element) : undefined;
|
|
7
|
+
// The closest scroll parent, the root when it's the body
|
|
8
|
+
const scrollParent = boundary === 'scrollParent' && element && listScrollParents(element)[0];
|
|
9
|
+
return boundary === 'clippingParents' ? 'clippingAncestors' : boundary === 'window' || boundary === 'scrollParent' ? scrollParent && scrollParent.nodeName !== 'BODY' && scrollParent || root : boundary;
|
|
10
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/getBoundary.ts"],"sourcesContent":["import type { Boundary as FloatingUIBoundary } from '@floating-ui/dom';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/utils/getBoundary.ts"],"sourcesContent":["import type { Boundary as FloatingUIBoundary } from '@floating-ui/dom';\n\nimport { getRoot } from '../engine/platform';\nimport { listScrollParents } from './listScrollParents';\nimport type { PositioningBoundary } from '../types';\n\n/**\n * Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.\n */\nexport const getBoundary = (\n element: HTMLElement | null,\n boundary?: PositioningBoundary,\n): FloatingUIBoundary | undefined => {\n const root = element ? getRoot(element) : undefined;\n // The closest scroll parent, the root when it's the body\n const scrollParent = boundary === 'scrollParent' && element && listScrollParents(element)[0];\n\n return boundary === 'clippingParents'\n ? 'clippingAncestors'\n : boundary === 'window' || boundary === 'scrollParent'\n ? (scrollParent && scrollParent.nodeName !== 'BODY' && scrollParent) || root\n : boundary;\n};\n"],"names":["getRoot","listScrollParents","getBoundary","element","boundary","root","undefined","scrollParent","nodeName"],"mappings":"AAEA,SAASA,OAAO,QAAQ,wBAAqB;AAC7C,SAASC,iBAAiB,QAAQ,yBAAsB;AAGxD;;CAEC,GACD,OAAO,MAAMC,cAAc,CACzBC,SACAC;IAEA,MAAMC,OAAOF,UAAUH,QAAQG,WAAWG;IAC1C,yDAAyD;IACzD,MAAMC,eAAeH,aAAa,kBAAkBD,WAAWF,kBAAkBE,QAAQ,CAAC,EAAE;IAE5F,OAAOC,aAAa,oBAChB,sBACAA,aAAa,YAAYA,aAAa,iBACtC,AAACG,gBAAgBA,aAAaC,QAAQ,KAAK,UAAUD,gBAAiBF,OACtED;AACN,EAAE"}
|
package/lib/utils/index.js
CHANGED
|
@@ -11,6 +11,4 @@ export { useCallbackRef } from "./useCallbackRef.js";
|
|
|
11
11
|
export { debounce } from "./debounce.js";
|
|
12
12
|
export { toggleScrollListener } from "./toggleScrollListener.js";
|
|
13
13
|
export { hasAutofocusFilter } from "./hasAutoFocusFilter.js";
|
|
14
|
-
export { writeArrowUpdates } from "./writeArrowUpdates.js";
|
|
15
|
-
export { writeContainerUpdates } from "./writeContainerupdates.js";
|
|
16
14
|
export { normalizeAutoSize } from "./normalizeAutoSize.js";
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export { parseFloatingUIPlacement } from './parseFloatingUIPlacement';\nexport { getBoundary } from './getBoundary';\nexport type { Fiber, HookType } from './getReactFiberFromNode';\nexport { getReactFiberFromNode } from './getReactFiberFromNode';\nexport { getParentNode, getScrollParent, hasScrollParent } from './getScrollParent';\nexport { mergeArrowOffset } from './mergeArrowOffset';\nexport { toFloatingUIPadding } from './toFloatingUIPadding';\nexport { toFloatingUIPlacement } from './toFloatingUIPlacement';\nexport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\nexport { resolvePositioningShorthand } from './resolvePositioningShorthand';\nexport { useCallbackRef } from './useCallbackRef';\nexport { debounce } from './debounce';\nexport { toggleScrollListener } from './toggleScrollListener';\nexport { hasAutofocusFilter } from './hasAutoFocusFilter';\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export { parseFloatingUIPlacement } from './parseFloatingUIPlacement';\nexport { getBoundary } from './getBoundary';\nexport type { Fiber, HookType } from './getReactFiberFromNode';\nexport { getReactFiberFromNode } from './getReactFiberFromNode';\nexport { getParentNode, getScrollParent, hasScrollParent } from './getScrollParent';\nexport { mergeArrowOffset } from './mergeArrowOffset';\nexport { toFloatingUIPadding } from './toFloatingUIPadding';\nexport { toFloatingUIPlacement } from './toFloatingUIPlacement';\nexport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\nexport { resolvePositioningShorthand } from './resolvePositioningShorthand';\nexport { useCallbackRef } from './useCallbackRef';\nexport { debounce } from './debounce';\nexport { toggleScrollListener } from './toggleScrollListener';\nexport { hasAutofocusFilter } from './hasAutoFocusFilter';\nexport { normalizeAutoSize } from './normalizeAutoSize';\n"],"names":["parseFloatingUIPlacement","getBoundary","getReactFiberFromNode","getParentNode","getScrollParent","hasScrollParent","mergeArrowOffset","toFloatingUIPadding","toFloatingUIPlacement","fromFloatingUIPlacement","resolvePositioningShorthand","useCallbackRef","debounce","toggleScrollListener","hasAutofocusFilter","normalizeAutoSize"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,gCAA6B;AACtE,SAASC,WAAW,QAAQ,mBAAgB;AAE5C,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAASC,aAAa,EAAEC,eAAe,EAAEC,eAAe,QAAQ,uBAAoB;AACpF,SAASC,gBAAgB,QAAQ,wBAAqB;AACtD,SAASC,mBAAmB,QAAQ,2BAAwB;AAC5D,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAASC,uBAAuB,QAAQ,+BAA4B;AACpE,SAASC,2BAA2B,QAAQ,mCAAgC;AAC5E,SAASC,cAAc,QAAQ,sBAAmB;AAClD,SAASC,QAAQ,QAAQ,gBAAa;AACtC,SAASC,oBAAoB,QAAQ,4BAAyB;AAC9D,SAASC,kBAAkB,QAAQ,0BAAuB;AAC1D,SAASC,iBAAiB,QAAQ,yBAAsB"}
|
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { findAncestor } from "../engine/platform.js";
|
|
2
|
+
/** Lists the scroll parents of the node, the closest first, up to and including the body of its document */ export const listScrollParents = (node)=>{
|
|
3
|
+
const body = node.ownerDocument.body;
|
|
3
4
|
const scrollParents = [];
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (node.ownerDocument.body === scrollParent) {
|
|
8
|
-
scrollParents.push(scrollParent);
|
|
9
|
-
break;
|
|
5
|
+
findAncestor(node, (parent, { overflow, overflowX, overflowY })=>{
|
|
6
|
+
if (parent !== body && /auto|scroll|overlay/.test(overflow + overflowY + overflowX)) {
|
|
7
|
+
scrollParents.push(parent);
|
|
10
8
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
scrollParents.push(scrollParent);
|
|
19
|
-
cur = scrollParent;
|
|
20
|
-
}
|
|
21
|
-
return scrollParents;
|
|
22
|
-
}
|
|
9
|
+
});
|
|
10
|
+
return [
|
|
11
|
+
...scrollParents,
|
|
12
|
+
body
|
|
13
|
+
];
|
|
14
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/listScrollParents.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/utils/listScrollParents.ts"],"sourcesContent":["import { findAncestor } from '../engine/platform';\n\n/** Lists the scroll parents of the node, the closest first, up to and including the body of its document */\nexport const listScrollParents = (node: HTMLElement): HTMLElement[] => {\n const body = node.ownerDocument.body;\n const scrollParents: HTMLElement[] = [];\n\n findAncestor(node, (parent, { overflow, overflowX, overflowY }) => {\n if (parent !== body && /auto|scroll|overlay/.test(overflow + overflowY + overflowX)) {\n scrollParents.push(parent as HTMLElement);\n }\n });\n\n return [...scrollParents, body];\n};\n"],"names":["findAncestor","listScrollParents","node","body","ownerDocument","scrollParents","parent","overflow","overflowX","overflowY","test","push"],"mappings":"AAAA,SAASA,YAAY,QAAQ,wBAAqB;AAElD,0GAA0G,GAC1G,OAAO,MAAMC,oBAAoB,CAACC;IAChC,MAAMC,OAAOD,KAAKE,aAAa,CAACD,IAAI;IACpC,MAAME,gBAA+B,EAAE;IAEvCL,aAAaE,MAAM,CAACI,QAAQ,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,SAAS,EAAE;QAC5D,IAAIH,WAAWH,QAAQ,sBAAsBO,IAAI,CAACH,WAAWE,YAAYD,YAAY;YACnFH,cAAcM,IAAI,CAACL;QACrB;IACF;IAEA,OAAO;WAAID;QAAeF;KAAK;AACjC,EAAE"}
|
|
@@ -3,26 +3,19 @@
|
|
|
3
3
|
* Now options 'always'/'height-always'/'width-always' are obsolete.
|
|
4
4
|
* This function maps them to true/'height'/'width'
|
|
5
5
|
*/ export const normalizeAutoSize = (autoSize)=>{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return {
|
|
22
|
-
applyMaxWidth: false,
|
|
23
|
-
applyMaxHeight: true
|
|
24
|
-
};
|
|
25
|
-
default:
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
6
|
+
const dimensions = getAutoSizeDimensions(autoSize);
|
|
7
|
+
return dimensions.length ? {
|
|
8
|
+
applyMaxWidth: dimensions.includes('width'),
|
|
9
|
+
applyMaxHeight: dimensions.includes('height')
|
|
10
|
+
} : false;
|
|
11
|
+
};
|
|
12
|
+
export const getAutoSizeDimensions = (autoSize)=>{
|
|
13
|
+
// 'width-always' and 'height-always' are obsolete aliases of 'width' and 'height'
|
|
14
|
+
const dimension = /^(width|height)(-always)?$/.exec(String(autoSize));
|
|
15
|
+
return autoSize === true || autoSize === 'always' ? [
|
|
16
|
+
'width',
|
|
17
|
+
'height'
|
|
18
|
+
] : dimension ? [
|
|
19
|
+
dimension[1]
|
|
20
|
+
] : [];
|
|
28
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/normalizeAutoSize.ts"],"sourcesContent":["import type { NormalizedAutoSize, PositioningOptions } from '../types';\n\n/**\n * AutoSizes contains many options from historic implementation.\n * Now options 'always'/'height-always'/'width-always' are obsolete.\n * This function maps them to true/'height'/'width'\n */\nexport const normalizeAutoSize = (autoSize?: PositioningOptions['autoSize']): NormalizedAutoSize | false => {\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/normalizeAutoSize.ts"],"sourcesContent":["import type { NormalizedAutoSize, PositioningOptions } from '../types';\n\n/**\n * AutoSizes contains many options from historic implementation.\n * Now options 'always'/'height-always'/'width-always' are obsolete.\n * This function maps them to true/'height'/'width'\n */\nexport const normalizeAutoSize = (autoSize?: PositioningOptions['autoSize']): NormalizedAutoSize | false => {\n const dimensions = getAutoSizeDimensions(autoSize);\n return dimensions.length\n ? {\n applyMaxWidth: dimensions.includes('width'),\n applyMaxHeight: dimensions.includes('height'),\n }\n : false;\n};\n\nexport const getAutoSizeDimensions = (autoSize?: PositioningOptions['autoSize']): ('width' | 'height')[] => {\n // 'width-always' and 'height-always' are obsolete aliases of 'width' and 'height'\n const dimension = /^(width|height)(-always)?$/.exec(String(autoSize));\n return autoSize === true || autoSize === 'always' ? ['width', 'height'] : dimension ? [dimension[1] as 'width'] : [];\n};\n"],"names":["normalizeAutoSize","autoSize","dimensions","getAutoSizeDimensions","length","applyMaxWidth","includes","applyMaxHeight","dimension","exec","String"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,MAAMA,oBAAoB,CAACC;IAChC,MAAMC,aAAaC,sBAAsBF;IACzC,OAAOC,WAAWE,MAAM,GACpB;QACEC,eAAeH,WAAWI,QAAQ,CAAC;QACnCC,gBAAgBL,WAAWI,QAAQ,CAAC;IACtC,IACA;AACN,EAAE;AAEF,OAAO,MAAMH,wBAAwB,CAACF;IACpC,kFAAkF;IAClF,MAAMO,YAAY,6BAA6BC,IAAI,CAACC,OAAOT;IAC3D,OAAOA,aAAa,QAAQA,aAAa,WAAW;QAAC;QAAS;KAAS,GAAGO,YAAY;QAACA,SAAS,CAAC,EAAE;KAAY,GAAG,EAAE;AACtH,EAAE"}
|
|
@@ -1,32 +1,15 @@
|
|
|
1
|
-
const getPositionMap = (rtl)=>({
|
|
2
|
-
above: 'top',
|
|
3
|
-
below: 'bottom',
|
|
4
|
-
before: rtl ? 'right' : 'left',
|
|
5
|
-
after: rtl ? 'left' : 'right'
|
|
6
|
-
});
|
|
7
|
-
// Floating UI automatically flips alignment
|
|
8
|
-
// https://github.com/floating-ui/floating-ui/issues/1563
|
|
9
|
-
const getAlignmentMap = ()=>({
|
|
10
|
-
start: 'start',
|
|
11
|
-
end: 'end',
|
|
12
|
-
top: 'start',
|
|
13
|
-
bottom: 'end',
|
|
14
|
-
center: undefined
|
|
15
|
-
});
|
|
16
|
-
const shouldAlignToCenter = (p, a)=>{
|
|
17
|
-
const positionedVertically = p === 'above' || p === 'below';
|
|
18
|
-
const alignedVertically = a === 'top' || a === 'bottom';
|
|
19
|
-
return positionedVertically && alignedVertically || !positionedVertically && !alignedVertically;
|
|
20
|
-
};
|
|
21
1
|
/**
|
|
22
2
|
* Maps internal positioning values to Floating UI placement
|
|
23
3
|
* @see positioningHelper.test.ts for expected placement values
|
|
24
4
|
*/ export const toFloatingUIPlacement = (align, position, rtl)=>{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
if (!position) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
const block = position === 'above' || position === 'below';
|
|
9
|
+
const side = block ? position === 'above' ? 'top' : 'bottom' : position === 'before' !== !!rtl ? 'left' : 'right';
|
|
10
|
+
const alignedVertically = align === 'top' || align === 'bottom';
|
|
11
|
+
if (!align || align === 'center' || block === alignedVertically) {
|
|
12
|
+
return side;
|
|
30
13
|
}
|
|
31
|
-
return
|
|
14
|
+
return `${side}-${align === 'start' || align === 'top' ? 'start' : 'end'}`;
|
|
32
15
|
};
|