@digdir/designsystemet-react 0.58.0 → 0.59.1-alpha.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/dist/cjs/components/Alert/Alert.js +2 -2
- package/dist/cjs/components/Button/Button.js +1 -2
- package/dist/cjs/components/DropdownMenu/DropdownMenuContent.js +4 -4
- package/dist/cjs/components/DropdownMenu/DropdownMenuTrigger.js +1 -1
- package/dist/cjs/components/Modal/ModalDialog.js +1 -1
- package/dist/cjs/components/Popover/PopoverContent.js +6 -6
- package/dist/cjs/components/Popover/PopoverTrigger.js +1 -1
- package/dist/cjs/components/SkipLink/SkipLink.js +1 -2
- package/dist/cjs/components/Tooltip/Tooltip.js +6 -6
- package/dist/cjs/components/form/Checkbox/Checkbox.js +1 -1
- package/dist/cjs/components/form/Combobox/Combobox.js +60 -177
- package/dist/cjs/components/form/Combobox/ComboboxContext.js +8 -0
- package/dist/cjs/components/form/Combobox/ComboboxIdContext.js +42 -0
- package/dist/cjs/components/form/Combobox/Custom/Custom.js +14 -9
- package/dist/cjs/components/form/Combobox/Empty/Empty.js +4 -4
- package/dist/cjs/components/form/Combobox/Option/Option.js +15 -33
- package/dist/cjs/components/form/Combobox/Option/useComboboxOption.js +47 -0
- package/dist/cjs/components/form/Combobox/internal/ComboboxChips.js +14 -6
- package/dist/cjs/components/form/Combobox/internal/ComboboxClearButton.js +4 -4
- package/dist/cjs/components/form/Combobox/internal/ComboboxInput.js +40 -35
- package/dist/cjs/components/form/Combobox/internal/ComboboxNative.js +2 -2
- package/dist/cjs/components/form/Combobox/useCombobox.js +46 -32
- package/dist/cjs/components/form/Combobox/useComboboxKeyboard.js +79 -0
- package/dist/cjs/components/form/Combobox/useFloatingCombobox.js +78 -0
- package/dist/cjs/components/form/Search/Search.js +1 -1
- package/dist/cjs/node_modules/@floating-ui/utils/{dom/dist → dist}/floating-ui.utils.dom.js +7 -4
- package/dist/cjs/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +5 -0
- package/dist/cjs/{node_modules → packages/react/node_modules}/@floating-ui/core/dist/floating-ui.core.js +40 -16
- package/dist/cjs/{node_modules → packages/react/node_modules}/@floating-ui/dom/dist/floating-ui.dom.js +83 -31
- package/dist/cjs/{node_modules → packages/react/node_modules}/@floating-ui/react/dist/floating-ui.react.js +307 -157
- package/dist/cjs/{node_modules/@floating-ui/react/utils → packages/react/node_modules/@floating-ui/react}/dist/floating-ui.react.utils.js +9 -4
- package/dist/cjs/{node_modules → packages/react/node_modules}/@floating-ui/react-dom/dist/floating-ui.react-dom.js +22 -18
- package/dist/{esm → cjs/packages/react}/node_modules/tabbable/dist/index.esm.js +59 -13
- package/dist/cjs/react-css-modules.css +0 -315
- package/dist/cjs/utilities/RovingTabIndex/RovingTabindexItem.js +1 -1
- package/dist/cjs/utilities/RovingTabIndex/RovingTabindexRoot.js +1 -1
- package/dist/esm/components/Alert/Alert.js +2 -2
- package/dist/esm/components/Button/Button.js +1 -2
- package/dist/esm/components/DropdownMenu/DropdownMenuContent.js +3 -3
- package/dist/esm/components/DropdownMenu/DropdownMenuTrigger.js +1 -1
- package/dist/esm/components/Modal/ModalDialog.js +1 -1
- package/dist/esm/components/Popover/PopoverContent.js +4 -4
- package/dist/esm/components/Popover/PopoverTrigger.js +1 -1
- package/dist/esm/components/SkipLink/SkipLink.js +1 -2
- package/dist/esm/components/Tooltip/Tooltip.js +4 -4
- package/dist/esm/components/form/Checkbox/Checkbox.js +1 -1
- package/dist/esm/components/form/Combobox/Combobox.js +65 -182
- package/dist/esm/components/form/Combobox/ComboboxContext.js +6 -0
- package/dist/esm/components/form/Combobox/ComboboxIdContext.js +35 -0
- package/dist/esm/components/form/Combobox/Custom/Custom.js +13 -8
- package/dist/esm/components/form/Combobox/Empty/Empty.js +3 -3
- package/dist/esm/components/form/Combobox/Option/Option.js +15 -33
- package/dist/esm/components/form/Combobox/Option/useComboboxOption.js +45 -0
- package/dist/esm/components/form/Combobox/internal/ComboboxChips.js +13 -5
- package/dist/esm/components/form/Combobox/internal/ComboboxClearButton.js +3 -3
- package/dist/esm/components/form/Combobox/internal/ComboboxInput.js +39 -34
- package/dist/esm/components/form/Combobox/internal/ComboboxNative.js +2 -2
- package/dist/esm/components/form/Combobox/useCombobox.js +46 -32
- package/dist/esm/components/form/Combobox/useComboboxKeyboard.js +77 -0
- package/dist/esm/components/form/Combobox/useFloatingCombobox.js +76 -0
- package/dist/esm/components/form/Search/Search.js +1 -1
- package/dist/esm/node_modules/@floating-ui/utils/{dom/dist → dist}/floating-ui.utils.dom.js +7 -4
- package/dist/esm/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +5 -0
- package/dist/esm/{node_modules → packages/react/node_modules}/@floating-ui/core/dist/floating-ui.core.js +40 -16
- package/dist/esm/{node_modules → packages/react/node_modules}/@floating-ui/dom/dist/floating-ui.dom.js +82 -30
- package/dist/esm/{node_modules → packages/react/node_modules}/@floating-ui/react/dist/floating-ui.react.js +282 -135
- package/dist/esm/{node_modules/@floating-ui/react/utils → packages/react/node_modules/@floating-ui/react}/dist/floating-ui.react.utils.js +9 -5
- package/dist/esm/{node_modules → packages/react/node_modules}/@floating-ui/react-dom/dist/floating-ui.react-dom.js +19 -14
- package/dist/{cjs → esm/packages/react}/node_modules/tabbable/dist/index.esm.js +55 -15
- package/dist/esm/react-css-modules.css +0 -315
- package/dist/esm/utilities/RovingTabIndex/RovingTabindexItem.js +1 -1
- package/dist/esm/utilities/RovingTabIndex/RovingTabindexRoot.js +1 -1
- package/dist/types/components/Alert/Alert.d.ts +12 -0
- package/dist/types/components/Alert/Alert.d.ts.map +1 -1
- package/dist/types/components/Button/Button.d.ts.map +1 -1
- package/dist/types/components/SkipLink/SkipLink.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/Combobox.d.ts +104 -39
- package/dist/types/components/form/Combobox/Combobox.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/ComboboxContext.d.ts +48 -0
- package/dist/types/components/form/Combobox/ComboboxContext.d.ts.map +1 -0
- package/dist/types/components/form/Combobox/ComboboxIdContext.d.ts +19 -0
- package/dist/types/components/form/Combobox/ComboboxIdContext.d.ts.map +1 -0
- package/dist/types/components/form/Combobox/Custom/Custom.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/Option/Option.d.ts +2 -2
- package/dist/types/components/form/Combobox/Option/Option.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/Option/useComboboxOption.d.ts +14 -0
- package/dist/types/components/form/Combobox/Option/useComboboxOption.d.ts.map +1 -0
- package/dist/types/components/form/Combobox/internal/ComboboxChips.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/internal/ComboboxInput.d.ts +0 -1
- package/dist/types/components/form/Combobox/internal/ComboboxInput.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/internal/ComboboxNative.d.ts +3 -1
- package/dist/types/components/form/Combobox/internal/ComboboxNative.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/useCombobox.d.ts +13 -5
- package/dist/types/components/form/Combobox/useCombobox.d.ts.map +1 -1
- package/dist/types/components/form/Combobox/useComboboxKeyboard.d.ts +20 -0
- package/dist/types/components/form/Combobox/useComboboxKeyboard.d.ts.map +1 -0
- package/dist/types/components/form/Combobox/useFloatingCombobox.d.ts +41 -0
- package/dist/types/components/form/Combobox/useFloatingCombobox.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/cjs/components/Button/Button.module.css.js +0 -6
- package/dist/cjs/components/SkipLink/SkipLink.module.css.js +0 -6
- package/dist/cjs/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -6
- package/dist/cjs/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dom/dist/floating-ui.utils.dom.js +0 -68
- package/dist/esm/components/Button/Button.module.css.js +0 -4
- package/dist/esm/components/SkipLink/SkipLink.module.css.js +0 -4
- package/dist/esm/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -4
- package/dist/esm/node_modules/@floating-ui/react/node_modules/@floating-ui/utils/dom/dist/floating-ui.utils.dom.js +0 -57
|
@@ -12,7 +12,7 @@ function getNodeName(node) {
|
|
|
12
12
|
}
|
|
13
13
|
function getWindow(node) {
|
|
14
14
|
var _node$ownerDocument;
|
|
15
|
-
return (node == null
|
|
15
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
16
16
|
}
|
|
17
17
|
function getDocumentElement(node) {
|
|
18
18
|
var _ref;
|
|
@@ -111,18 +111,21 @@ function getNearestOverflowAncestor(node) {
|
|
|
111
111
|
}
|
|
112
112
|
return getNearestOverflowAncestor(parentNode);
|
|
113
113
|
}
|
|
114
|
-
function getOverflowAncestors(node, list) {
|
|
114
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
115
115
|
var _node$ownerDocument2;
|
|
116
116
|
if (list === void 0) {
|
|
117
117
|
list = [];
|
|
118
118
|
}
|
|
119
|
+
if (traverseIframes === void 0) {
|
|
120
|
+
traverseIframes = true;
|
|
121
|
+
}
|
|
119
122
|
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
120
123
|
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
121
124
|
const win = getWindow(scrollableAncestor);
|
|
122
125
|
if (isBody) {
|
|
123
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
126
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
|
|
124
127
|
}
|
|
125
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
128
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
exports.getComputedStyle = getComputedStyle;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var floatingUi_utils = require('
|
|
4
|
+
var floatingUi_utils = require('../../../../../../node_modules/@floating-ui/utils/dist/floating-ui.utils.js');
|
|
5
5
|
|
|
6
6
|
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
7
7
|
let {
|
|
@@ -61,7 +61,7 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Computes the `x` and `y` coordinates that will place the floating element
|
|
64
|
-
* next to a reference element
|
|
64
|
+
* next to a given reference element.
|
|
65
65
|
*
|
|
66
66
|
* This export does not have any `platform` interface logic. You will need to
|
|
67
67
|
* write one for the platform you are using Floating UI with.
|
|
@@ -139,7 +139,6 @@ const computePosition = async (reference, floating, config) => {
|
|
|
139
139
|
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
140
140
|
}
|
|
141
141
|
i = -1;
|
|
142
|
-
continue;
|
|
143
142
|
}
|
|
144
143
|
}
|
|
145
144
|
return {
|
|
@@ -202,6 +201,7 @@ async function detectOverflow(state, options) {
|
|
|
202
201
|
y: 1
|
|
203
202
|
};
|
|
204
203
|
const elementClientRect = floatingUi_utils.rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
204
|
+
elements,
|
|
205
205
|
rect,
|
|
206
206
|
offsetParent,
|
|
207
207
|
strategy
|
|
@@ -229,7 +229,8 @@ const arrow = options => ({
|
|
|
229
229
|
placement,
|
|
230
230
|
rects,
|
|
231
231
|
platform,
|
|
232
|
-
elements
|
|
232
|
+
elements,
|
|
233
|
+
middlewareData
|
|
233
234
|
} = state;
|
|
234
235
|
// Since `element` is required, we don't Partial<> the type.
|
|
235
236
|
const {
|
|
@@ -277,16 +278,20 @@ const arrow = options => ({
|
|
|
277
278
|
|
|
278
279
|
// If the reference is small enough that the arrow's padding causes it to
|
|
279
280
|
// to point to nothing for an aligned placement, adjust the offset of the
|
|
280
|
-
// floating element itself.
|
|
281
|
-
//
|
|
282
|
-
const shouldAddOffset = floatingUi_utils.getAlignment(placement) != null && center
|
|
283
|
-
const alignmentOffset = shouldAddOffset ? center < min$1 ? min$1
|
|
281
|
+
// floating element itself. To ensure `shift()` continues to take action,
|
|
282
|
+
// a single reset is performed when this is true.
|
|
283
|
+
const shouldAddOffset = !middlewareData.arrow && floatingUi_utils.getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
284
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
284
285
|
return {
|
|
285
|
-
[axis]: coords[axis]
|
|
286
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
286
287
|
data: {
|
|
287
288
|
[axis]: offset,
|
|
288
|
-
centerOffset: center - offset
|
|
289
|
-
|
|
289
|
+
centerOffset: center - offset - alignmentOffset,
|
|
290
|
+
...(shouldAddOffset && {
|
|
291
|
+
alignmentOffset
|
|
292
|
+
})
|
|
293
|
+
},
|
|
294
|
+
reset: shouldAddOffset
|
|
290
295
|
};
|
|
291
296
|
}
|
|
292
297
|
});
|
|
@@ -305,7 +310,7 @@ const flip = function (options) {
|
|
|
305
310
|
name: 'flip',
|
|
306
311
|
options,
|
|
307
312
|
async fn(state) {
|
|
308
|
-
var _middlewareData$flip;
|
|
313
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
309
314
|
const {
|
|
310
315
|
placement,
|
|
311
316
|
middlewareData,
|
|
@@ -323,6 +328,14 @@ const flip = function (options) {
|
|
|
323
328
|
flipAlignment = true,
|
|
324
329
|
...detectOverflowOptions
|
|
325
330
|
} = floatingUi_utils.evaluate(options, state);
|
|
331
|
+
|
|
332
|
+
// If a reset by the arrow was caused due to an alignment offset being
|
|
333
|
+
// added, we should skip any logic now since `flip()` has already done its
|
|
334
|
+
// work.
|
|
335
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
|
336
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
337
|
+
return {};
|
|
338
|
+
}
|
|
326
339
|
const side = floatingUi_utils.getSide(placement);
|
|
327
340
|
const isBasePlacement = floatingUi_utils.getSide(initialPlacement) === initialPlacement;
|
|
328
341
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
@@ -400,6 +413,7 @@ const flip = function (options) {
|
|
|
400
413
|
|
|
401
414
|
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
402
415
|
// Derivable.
|
|
416
|
+
|
|
403
417
|
async function convertValueToCoords(state, options) {
|
|
404
418
|
const {
|
|
405
419
|
placement,
|
|
@@ -413,8 +427,6 @@ async function convertValueToCoords(state, options) {
|
|
|
413
427
|
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
414
428
|
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
415
429
|
const rawValue = floatingUi_utils.evaluate(options, state);
|
|
416
|
-
|
|
417
|
-
// eslint-disable-next-line prefer-const
|
|
418
430
|
let {
|
|
419
431
|
mainAxis,
|
|
420
432
|
crossAxis,
|
|
@@ -456,15 +468,27 @@ const offset = function (options) {
|
|
|
456
468
|
name: 'offset',
|
|
457
469
|
options,
|
|
458
470
|
async fn(state) {
|
|
471
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
459
472
|
const {
|
|
460
473
|
x,
|
|
461
|
-
y
|
|
474
|
+
y,
|
|
475
|
+
placement,
|
|
476
|
+
middlewareData
|
|
462
477
|
} = state;
|
|
463
478
|
const diffCoords = await convertValueToCoords(state, options);
|
|
479
|
+
|
|
480
|
+
// If the placement is the same and the arrow caused an alignment offset
|
|
481
|
+
// then we don't need to change the positioning coordinates.
|
|
482
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
483
|
+
return {};
|
|
484
|
+
}
|
|
464
485
|
return {
|
|
465
486
|
x: x + diffCoords.x,
|
|
466
487
|
y: y + diffCoords.y,
|
|
467
|
-
data:
|
|
488
|
+
data: {
|
|
489
|
+
...diffCoords,
|
|
490
|
+
placement
|
|
491
|
+
}
|
|
468
492
|
};
|
|
469
493
|
}
|
|
470
494
|
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var floatingUi_core = require('../../core/dist/floating-ui.core.js');
|
|
5
|
-
var floatingUi_utils = require('
|
|
6
|
-
var floatingUi_utils_dom = require('
|
|
5
|
+
var floatingUi_utils = require('../../../../../../node_modules/@floating-ui/utils/dist/floating-ui.utils.js');
|
|
6
|
+
var floatingUi_utils_dom = require('../../../../../../node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js');
|
|
7
7
|
|
|
8
8
|
function getCssDimensions(element) {
|
|
9
9
|
const css = floatingUi_utils_dom.getComputedStyle(element);
|
|
@@ -106,8 +106,9 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
106
106
|
if (domElement) {
|
|
107
107
|
const win = floatingUi_utils_dom.getWindow(domElement);
|
|
108
108
|
const offsetWin = offsetParent && floatingUi_utils_dom.isElement(offsetParent) ? floatingUi_utils_dom.getWindow(offsetParent) : offsetParent;
|
|
109
|
-
let
|
|
110
|
-
|
|
109
|
+
let currentWin = win;
|
|
110
|
+
let currentIFrame = currentWin.frameElement;
|
|
111
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
111
112
|
const iframeScale = getScale(currentIFrame);
|
|
112
113
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
113
114
|
const css = floatingUi_utils_dom.getComputedStyle(currentIFrame);
|
|
@@ -119,7 +120,8 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
119
120
|
height *= iframeScale.y;
|
|
120
121
|
x += left;
|
|
121
122
|
y += top;
|
|
122
|
-
|
|
123
|
+
currentWin = floatingUi_utils_dom.getWindow(currentIFrame);
|
|
124
|
+
currentIFrame = currentWin.frameElement;
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
return floatingUi_utils.rectToClientRect({
|
|
@@ -130,15 +132,28 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
130
132
|
});
|
|
131
133
|
}
|
|
132
134
|
|
|
135
|
+
const topLayerSelectors = [':popover-open', ':modal'];
|
|
136
|
+
function isTopLayer(floating) {
|
|
137
|
+
return topLayerSelectors.some(selector => {
|
|
138
|
+
try {
|
|
139
|
+
return floating.matches(selector);
|
|
140
|
+
} catch (e) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
133
146
|
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
134
147
|
let {
|
|
148
|
+
elements,
|
|
135
149
|
rect,
|
|
136
150
|
offsetParent,
|
|
137
151
|
strategy
|
|
138
152
|
} = _ref;
|
|
139
|
-
const
|
|
153
|
+
const isFixed = strategy === 'fixed';
|
|
140
154
|
const documentElement = floatingUi_utils_dom.getDocumentElement(offsetParent);
|
|
141
|
-
|
|
155
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
156
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
142
157
|
return rect;
|
|
143
158
|
}
|
|
144
159
|
let scroll = {
|
|
@@ -147,7 +162,8 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
147
162
|
};
|
|
148
163
|
let scale = floatingUi_utils.createCoords(1);
|
|
149
164
|
const offsets = floatingUi_utils.createCoords(0);
|
|
150
|
-
|
|
165
|
+
const isOffsetParentAnElement = floatingUi_utils_dom.isHTMLElement(offsetParent);
|
|
166
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
151
167
|
if (floatingUi_utils_dom.getNodeName(offsetParent) !== 'body' || floatingUi_utils_dom.isOverflowElement(documentElement)) {
|
|
152
168
|
scroll = floatingUi_utils_dom.getNodeScroll(offsetParent);
|
|
153
169
|
}
|
|
@@ -273,7 +289,7 @@ function getClippingElementAncestors(element, cache) {
|
|
|
273
289
|
if (cachedResult) {
|
|
274
290
|
return cachedResult;
|
|
275
291
|
}
|
|
276
|
-
let result = floatingUi_utils_dom.getOverflowAncestors(element).filter(el => floatingUi_utils_dom.isElement(el) && floatingUi_utils_dom.getNodeName(el) !== 'body');
|
|
292
|
+
let result = floatingUi_utils_dom.getOverflowAncestors(element, [], false).filter(el => floatingUi_utils_dom.isElement(el) && floatingUi_utils_dom.getNodeName(el) !== 'body');
|
|
277
293
|
let currentContainingBlockComputedStyle = null;
|
|
278
294
|
const elementIsFixed = floatingUi_utils_dom.getComputedStyle(element).position === 'fixed';
|
|
279
295
|
let currentNode = elementIsFixed ? floatingUi_utils_dom.getParentNode(element) : element;
|
|
@@ -328,7 +344,14 @@ function getClippingRect(_ref) {
|
|
|
328
344
|
}
|
|
329
345
|
|
|
330
346
|
function getDimensions(element) {
|
|
331
|
-
|
|
347
|
+
const {
|
|
348
|
+
width,
|
|
349
|
+
height
|
|
350
|
+
} = getCssDimensions(element);
|
|
351
|
+
return {
|
|
352
|
+
width,
|
|
353
|
+
height
|
|
354
|
+
};
|
|
332
355
|
}
|
|
333
356
|
|
|
334
357
|
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
@@ -353,9 +376,11 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
|
353
376
|
offsets.x = getWindowScrollBarX(documentElement);
|
|
354
377
|
}
|
|
355
378
|
}
|
|
379
|
+
const x = rect.left + scroll.scrollLeft - offsets.x;
|
|
380
|
+
const y = rect.top + scroll.scrollTop - offsets.y;
|
|
356
381
|
return {
|
|
357
|
-
x
|
|
358
|
-
y
|
|
382
|
+
x,
|
|
383
|
+
y,
|
|
359
384
|
width: rect.width,
|
|
360
385
|
height: rect.height
|
|
361
386
|
};
|
|
@@ -375,7 +400,7 @@ function getTrueOffsetParent(element, polyfill) {
|
|
|
375
400
|
// such as table ancestors and cross browser bugs.
|
|
376
401
|
function getOffsetParent(element, polyfill) {
|
|
377
402
|
const window = floatingUi_utils_dom.getWindow(element);
|
|
378
|
-
if (!floatingUi_utils_dom.isHTMLElement(element)) {
|
|
403
|
+
if (!floatingUi_utils_dom.isHTMLElement(element) || isTopLayer(element)) {
|
|
379
404
|
return window;
|
|
380
405
|
}
|
|
381
406
|
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
@@ -388,20 +413,15 @@ function getOffsetParent(element, polyfill) {
|
|
|
388
413
|
return offsetParent || floatingUi_utils_dom.getContainingBlock(element) || window;
|
|
389
414
|
}
|
|
390
415
|
|
|
391
|
-
const getElementRects = async function (
|
|
392
|
-
let {
|
|
393
|
-
reference,
|
|
394
|
-
floating,
|
|
395
|
-
strategy
|
|
396
|
-
} = _ref;
|
|
416
|
+
const getElementRects = async function (data) {
|
|
397
417
|
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
398
418
|
const getDimensionsFn = this.getDimensions;
|
|
399
419
|
return {
|
|
400
|
-
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
420
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
401
421
|
floating: {
|
|
402
422
|
x: 0,
|
|
403
423
|
y: 0,
|
|
404
|
-
...(await getDimensionsFn(floating))
|
|
424
|
+
...(await getDimensionsFn(data.floating))
|
|
405
425
|
}
|
|
406
426
|
};
|
|
407
427
|
};
|
|
@@ -429,8 +449,9 @@ function observeMove(element, onMove) {
|
|
|
429
449
|
let timeoutId;
|
|
430
450
|
const root = floatingUi_utils_dom.getDocumentElement(element);
|
|
431
451
|
function cleanup() {
|
|
452
|
+
var _io;
|
|
432
453
|
clearTimeout(timeoutId);
|
|
433
|
-
io
|
|
454
|
+
(_io = io) == null || _io.disconnect();
|
|
434
455
|
io = null;
|
|
435
456
|
}
|
|
436
457
|
function refresh(skip, threshold) {
|
|
@@ -536,7 +557,8 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
536
557
|
resizeObserver.unobserve(floating);
|
|
537
558
|
cancelAnimationFrame(reobserveFrame);
|
|
538
559
|
reobserveFrame = requestAnimationFrame(() => {
|
|
539
|
-
|
|
560
|
+
var _resizeObserver;
|
|
561
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
540
562
|
});
|
|
541
563
|
}
|
|
542
564
|
update();
|
|
@@ -561,12 +583,13 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
561
583
|
}
|
|
562
584
|
update();
|
|
563
585
|
return () => {
|
|
586
|
+
var _resizeObserver2;
|
|
564
587
|
ancestors.forEach(ancestor => {
|
|
565
588
|
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
566
589
|
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
567
590
|
});
|
|
568
|
-
cleanupIo
|
|
569
|
-
resizeObserver
|
|
591
|
+
cleanupIo == null || cleanupIo();
|
|
592
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
570
593
|
resizeObserver = null;
|
|
571
594
|
if (animationFrame) {
|
|
572
595
|
cancelAnimationFrame(frameId);
|
|
@@ -574,10 +597,39 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
574
597
|
};
|
|
575
598
|
}
|
|
576
599
|
|
|
600
|
+
/**
|
|
601
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
602
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
603
|
+
* @see https://floating-ui.com/docs/shift
|
|
604
|
+
*/
|
|
605
|
+
const shift = floatingUi_core.shift;
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
609
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
610
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
611
|
+
* @see https://floating-ui.com/docs/flip
|
|
612
|
+
*/
|
|
613
|
+
const flip = floatingUi_core.flip;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Provides data that allows you to change the size of the floating element —
|
|
617
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
618
|
+
* width of the reference element.
|
|
619
|
+
* @see https://floating-ui.com/docs/size
|
|
620
|
+
*/
|
|
621
|
+
const size = floatingUi_core.size;
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Provides data to position an inner element of the floating element so that it
|
|
625
|
+
* appears centered to the reference element.
|
|
626
|
+
* @see https://floating-ui.com/docs/arrow
|
|
627
|
+
*/
|
|
628
|
+
const arrow = floatingUi_core.arrow;
|
|
629
|
+
|
|
577
630
|
/**
|
|
578
631
|
* Computes the `x` and `y` coordinates that will place the floating element
|
|
579
|
-
* next to a reference element
|
|
580
|
-
* strategy.
|
|
632
|
+
* next to a given reference element.
|
|
581
633
|
*/
|
|
582
634
|
const computePosition = (reference, floating, options) => {
|
|
583
635
|
// This caches the expensive `getClippingElementAncestors` function so that
|
|
@@ -598,13 +650,13 @@ const computePosition = (reference, floating, options) => {
|
|
|
598
650
|
});
|
|
599
651
|
};
|
|
600
652
|
|
|
601
|
-
exports.arrow = floatingUi_core.arrow;
|
|
602
653
|
exports.detectOverflow = floatingUi_core.detectOverflow;
|
|
603
|
-
exports.flip = floatingUi_core.flip;
|
|
604
654
|
exports.offset = floatingUi_core.offset;
|
|
605
|
-
exports.shift = floatingUi_core.shift;
|
|
606
|
-
exports.size = floatingUi_core.size;
|
|
607
655
|
exports.getOverflowAncestors = floatingUi_utils_dom.getOverflowAncestors;
|
|
656
|
+
exports.arrow = arrow;
|
|
608
657
|
exports.autoUpdate = autoUpdate;
|
|
609
658
|
exports.computePosition = computePosition;
|
|
659
|
+
exports.flip = flip;
|
|
610
660
|
exports.platform = platform;
|
|
661
|
+
exports.shift = shift;
|
|
662
|
+
exports.size = size;
|