nsw-design-system 3.17.2 → 3.17.4
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/js/main.js
CHANGED
|
@@ -1118,7 +1118,6 @@
|
|
|
1118
1118
|
this.element.setAttribute('aria-label', this.ariaLabel);
|
|
1119
1119
|
const itemsArray = Array.from(this.items);
|
|
1120
1120
|
itemsArray.forEach((element, index) => {
|
|
1121
|
-
element.setAttribute('role', 'group');
|
|
1122
1121
|
element.setAttribute('aria-roledescription', 'slide');
|
|
1123
1122
|
element.setAttribute('aria-label', `${index + 1} of ${itemsArray.length}`);
|
|
1124
1123
|
element.setAttribute('data-index', index);
|
|
@@ -1856,6 +1855,8 @@
|
|
|
1856
1855
|
this.showMoreContent = this.element.querySelectorAll(`.${this.prefix}${this.allClass}`);
|
|
1857
1856
|
this.showMoreButtons = this.element.querySelectorAll(`.${this.prefix}${this.moreClass}`);
|
|
1858
1857
|
this.focusableElements = 'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])';
|
|
1858
|
+
// Get default selected option
|
|
1859
|
+
this.selectedOption = this.element.querySelector('option[selected]');
|
|
1859
1860
|
// Accordion arrays
|
|
1860
1861
|
this.buttons = [];
|
|
1861
1862
|
this.content = [];
|
|
@@ -2003,11 +2004,23 @@
|
|
|
2003
2004
|
if (this.options.length > 0) {
|
|
2004
2005
|
this.options.forEach(input => {
|
|
2005
2006
|
const option = input;
|
|
2006
|
-
if (option.type === 'text'
|
|
2007
|
+
if (option.type === 'text') {
|
|
2007
2008
|
option.value = '';
|
|
2009
|
+
} else if (option.type === 'select-one') {
|
|
2010
|
+
if (this.selectedOption) {
|
|
2011
|
+
console.log(Array.from(option.options).indexOf(this.selectedOption));
|
|
2012
|
+
option.selectedIndex = Array.from(option.options).indexOf(this.selectedOption);
|
|
2013
|
+
} else {
|
|
2014
|
+
option.selectedIndex = 0;
|
|
2015
|
+
}
|
|
2016
|
+
} else if (option.type === 'checkbox') {
|
|
2017
|
+
if (option.defaultChecked) {
|
|
2018
|
+
option.checked = true;
|
|
2019
|
+
} else {
|
|
2020
|
+
option.checked = false;
|
|
2021
|
+
}
|
|
2008
2022
|
} else if (!option.parentElement.classList.contains('js-multi-select__option')) {
|
|
2009
2023
|
option.value = false;
|
|
2010
|
-
option.checked = false;
|
|
2011
2024
|
}
|
|
2012
2025
|
});
|
|
2013
2026
|
}
|
|
@@ -2700,7 +2713,7 @@
|
|
|
2700
2713
|
* appears centered to the reference element.
|
|
2701
2714
|
* @see https://floating-ui.com/docs/arrow
|
|
2702
2715
|
*/
|
|
2703
|
-
const arrow = options => ({
|
|
2716
|
+
const arrow$1 = options => ({
|
|
2704
2717
|
name: 'arrow',
|
|
2705
2718
|
options,
|
|
2706
2719
|
async fn(state) {
|
|
@@ -2836,7 +2849,7 @@
|
|
|
2836
2849
|
* clipping boundary. Alternative to `autoPlacement`.
|
|
2837
2850
|
* @see https://floating-ui.com/docs/flip
|
|
2838
2851
|
*/
|
|
2839
|
-
const flip = function (options) {
|
|
2852
|
+
const flip$1 = function (options) {
|
|
2840
2853
|
if (options === void 0) {
|
|
2841
2854
|
options = {};
|
|
2842
2855
|
}
|
|
@@ -2987,7 +3000,7 @@
|
|
|
2987
3000
|
* object may be passed.
|
|
2988
3001
|
* @see https://floating-ui.com/docs/offset
|
|
2989
3002
|
*/
|
|
2990
|
-
const offset = function (value) {
|
|
3003
|
+
const offset$1 = function (value) {
|
|
2991
3004
|
if (value === void 0) {
|
|
2992
3005
|
value = 0;
|
|
2993
3006
|
}
|
|
@@ -3017,7 +3030,7 @@
|
|
|
3017
3030
|
* keep it in view when it will overflow the clipping boundary.
|
|
3018
3031
|
* @see https://floating-ui.com/docs/shift
|
|
3019
3032
|
*/
|
|
3020
|
-
const shift = function (options) {
|
|
3033
|
+
const shift$1 = function (options) {
|
|
3021
3034
|
if (options === void 0) {
|
|
3022
3035
|
options = {};
|
|
3023
3036
|
}
|
|
@@ -3088,7 +3101,7 @@
|
|
|
3088
3101
|
/**
|
|
3089
3102
|
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
3090
3103
|
*/
|
|
3091
|
-
const limitShift = function (options) {
|
|
3104
|
+
const limitShift$1 = function (options) {
|
|
3092
3105
|
if (options === void 0) {
|
|
3093
3106
|
options = {};
|
|
3094
3107
|
}
|
|
@@ -3154,44 +3167,50 @@
|
|
|
3154
3167
|
};
|
|
3155
3168
|
};
|
|
3156
3169
|
|
|
3170
|
+
/**
|
|
3171
|
+
* Custom positioning reference element.
|
|
3172
|
+
* @see https://floating-ui.com/docs/virtual-elements
|
|
3173
|
+
*/
|
|
3174
|
+
const min = Math.min;
|
|
3175
|
+
const max = Math.max;
|
|
3176
|
+
const round = Math.round;
|
|
3177
|
+
const createCoords = v => ({
|
|
3178
|
+
x: v,
|
|
3179
|
+
y: v
|
|
3180
|
+
});
|
|
3181
|
+
|
|
3182
|
+
function getNodeName(node) {
|
|
3183
|
+
if (isNode(node)) {
|
|
3184
|
+
return (node.nodeName || '').toLowerCase();
|
|
3185
|
+
}
|
|
3186
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
3187
|
+
// returning `#document` an infinite loop won't occur.
|
|
3188
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
3189
|
+
return '#document';
|
|
3190
|
+
}
|
|
3157
3191
|
function getWindow(node) {
|
|
3158
3192
|
var _node$ownerDocument;
|
|
3159
|
-
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
3193
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
3160
3194
|
}
|
|
3161
|
-
function
|
|
3162
|
-
|
|
3195
|
+
function getDocumentElement(node) {
|
|
3196
|
+
var _ref;
|
|
3197
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
3163
3198
|
}
|
|
3164
3199
|
function isNode(value) {
|
|
3165
|
-
return value instanceof getWindow(value).Node;
|
|
3166
|
-
}
|
|
3167
|
-
function getNodeName(node) {
|
|
3168
|
-
return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
|
|
3200
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
3169
3201
|
}
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
if (uaString) {
|
|
3173
|
-
return uaString;
|
|
3174
|
-
}
|
|
3175
|
-
const uaData = navigator.userAgentData;
|
|
3176
|
-
if (uaData && Array.isArray(uaData.brands)) {
|
|
3177
|
-
uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
|
|
3178
|
-
return uaString;
|
|
3179
|
-
}
|
|
3180
|
-
return navigator.userAgent;
|
|
3202
|
+
function isElement(value) {
|
|
3203
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
3181
3204
|
}
|
|
3182
3205
|
function isHTMLElement(value) {
|
|
3183
|
-
return value instanceof getWindow(value).HTMLElement;
|
|
3184
|
-
}
|
|
3185
|
-
function isElement(value) {
|
|
3186
|
-
return value instanceof getWindow(value).Element;
|
|
3206
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
3187
3207
|
}
|
|
3188
|
-
function isShadowRoot(
|
|
3208
|
+
function isShadowRoot(value) {
|
|
3189
3209
|
// Browsers without `ShadowRoot` support.
|
|
3190
3210
|
if (typeof ShadowRoot === 'undefined') {
|
|
3191
3211
|
return false;
|
|
3192
3212
|
}
|
|
3193
|
-
|
|
3194
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
3213
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
3195
3214
|
}
|
|
3196
3215
|
function isOverflowElement(element) {
|
|
3197
3216
|
const {
|
|
@@ -3205,44 +3224,99 @@
|
|
|
3205
3224
|
function isTableElement(element) {
|
|
3206
3225
|
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
3207
3226
|
}
|
|
3227
|
+
function isTopLayer(element) {
|
|
3228
|
+
return [':popover-open', ':modal'].some(selector => {
|
|
3229
|
+
try {
|
|
3230
|
+
return element.matches(selector);
|
|
3231
|
+
} catch (e) {
|
|
3232
|
+
return false;
|
|
3233
|
+
}
|
|
3234
|
+
});
|
|
3235
|
+
}
|
|
3208
3236
|
function isContainingBlock(element) {
|
|
3209
|
-
|
|
3210
|
-
const isFirefox = /firefox/i.test(getUAString());
|
|
3237
|
+
const webkit = isWebKit();
|
|
3211
3238
|
const css = getComputedStyle$1(element);
|
|
3212
|
-
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
|
|
3213
3239
|
|
|
3214
|
-
// This is non-exhaustive but covers the most common CSS properties that
|
|
3215
|
-
// create a containing block.
|
|
3216
3240
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
3217
|
-
return css.transform !== 'none' || css.perspective !== 'none' || (
|
|
3218
|
-
// Add type check for old browsers.
|
|
3219
|
-
const contain = css.contain;
|
|
3220
|
-
return contain != null ? contain.includes(value) : false;
|
|
3221
|
-
});
|
|
3241
|
+
return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
|
|
3222
3242
|
}
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
return
|
|
3243
|
+
function getContainingBlock(element) {
|
|
3244
|
+
let currentNode = getParentNode(element);
|
|
3245
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
3246
|
+
if (isTopLayer(currentNode)) {
|
|
3247
|
+
return null;
|
|
3248
|
+
}
|
|
3249
|
+
if (isContainingBlock(currentNode)) {
|
|
3250
|
+
return currentNode;
|
|
3251
|
+
}
|
|
3252
|
+
currentNode = getParentNode(currentNode);
|
|
3253
|
+
}
|
|
3254
|
+
return null;
|
|
3255
|
+
}
|
|
3256
|
+
function isWebKit() {
|
|
3257
|
+
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
3258
|
+
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
3239
3259
|
}
|
|
3240
3260
|
function isLastTraversableNode(node) {
|
|
3241
3261
|
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
3242
3262
|
}
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3263
|
+
function getComputedStyle$1(element) {
|
|
3264
|
+
return getWindow(element).getComputedStyle(element);
|
|
3265
|
+
}
|
|
3266
|
+
function getNodeScroll(element) {
|
|
3267
|
+
if (isElement(element)) {
|
|
3268
|
+
return {
|
|
3269
|
+
scrollLeft: element.scrollLeft,
|
|
3270
|
+
scrollTop: element.scrollTop
|
|
3271
|
+
};
|
|
3272
|
+
}
|
|
3273
|
+
return {
|
|
3274
|
+
scrollLeft: element.scrollX,
|
|
3275
|
+
scrollTop: element.scrollY
|
|
3276
|
+
};
|
|
3277
|
+
}
|
|
3278
|
+
function getParentNode(node) {
|
|
3279
|
+
if (getNodeName(node) === 'html') {
|
|
3280
|
+
return node;
|
|
3281
|
+
}
|
|
3282
|
+
const result =
|
|
3283
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
3284
|
+
node.assignedSlot ||
|
|
3285
|
+
// DOM Element detected.
|
|
3286
|
+
node.parentNode ||
|
|
3287
|
+
// ShadowRoot detected.
|
|
3288
|
+
isShadowRoot(node) && node.host ||
|
|
3289
|
+
// Fallback.
|
|
3290
|
+
getDocumentElement(node);
|
|
3291
|
+
return isShadowRoot(result) ? result.host : result;
|
|
3292
|
+
}
|
|
3293
|
+
function getNearestOverflowAncestor(node) {
|
|
3294
|
+
const parentNode = getParentNode(node);
|
|
3295
|
+
if (isLastTraversableNode(parentNode)) {
|
|
3296
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
3297
|
+
}
|
|
3298
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
3299
|
+
return parentNode;
|
|
3300
|
+
}
|
|
3301
|
+
return getNearestOverflowAncestor(parentNode);
|
|
3302
|
+
}
|
|
3303
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
3304
|
+
var _node$ownerDocument2;
|
|
3305
|
+
if (list === void 0) {
|
|
3306
|
+
list = [];
|
|
3307
|
+
}
|
|
3308
|
+
if (traverseIframes === void 0) {
|
|
3309
|
+
traverseIframes = true;
|
|
3310
|
+
}
|
|
3311
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
3312
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
3313
|
+
const win = getWindow(scrollableAncestor);
|
|
3314
|
+
if (isBody) {
|
|
3315
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
|
|
3316
|
+
}
|
|
3317
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3246
3320
|
function getCssDimensions(element) {
|
|
3247
3321
|
const css = getComputedStyle$1(element);
|
|
3248
3322
|
// In testing environments, the `width` and `height` properties are empty
|
|
@@ -3260,29 +3334,25 @@
|
|
|
3260
3334
|
return {
|
|
3261
3335
|
width,
|
|
3262
3336
|
height,
|
|
3263
|
-
|
|
3337
|
+
$: shouldFallback
|
|
3264
3338
|
};
|
|
3265
3339
|
}
|
|
3266
3340
|
function unwrapElement(element) {
|
|
3267
3341
|
return !isElement(element) ? element.contextElement : element;
|
|
3268
3342
|
}
|
|
3269
|
-
const FALLBACK_SCALE = {
|
|
3270
|
-
x: 1,
|
|
3271
|
-
y: 1
|
|
3272
|
-
};
|
|
3273
3343
|
function getScale(element) {
|
|
3274
3344
|
const domElement = unwrapElement(element);
|
|
3275
3345
|
if (!isHTMLElement(domElement)) {
|
|
3276
|
-
return
|
|
3346
|
+
return createCoords(1);
|
|
3277
3347
|
}
|
|
3278
3348
|
const rect = domElement.getBoundingClientRect();
|
|
3279
3349
|
const {
|
|
3280
3350
|
width,
|
|
3281
3351
|
height,
|
|
3282
|
-
|
|
3352
|
+
$
|
|
3283
3353
|
} = getCssDimensions(domElement);
|
|
3284
|
-
let x = (
|
|
3285
|
-
let y = (
|
|
3354
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
3355
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
3286
3356
|
|
|
3287
3357
|
// 0, NaN, or Infinity should always fallback to 1.
|
|
3288
3358
|
|
|
@@ -3297,8 +3367,27 @@
|
|
|
3297
3367
|
y
|
|
3298
3368
|
};
|
|
3299
3369
|
}
|
|
3370
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
3371
|
+
function getVisualOffsets(element) {
|
|
3372
|
+
const win = getWindow(element);
|
|
3373
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
3374
|
+
return noOffsets;
|
|
3375
|
+
}
|
|
3376
|
+
return {
|
|
3377
|
+
x: win.visualViewport.offsetLeft,
|
|
3378
|
+
y: win.visualViewport.offsetTop
|
|
3379
|
+
};
|
|
3380
|
+
}
|
|
3381
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
3382
|
+
if (isFixed === void 0) {
|
|
3383
|
+
isFixed = false;
|
|
3384
|
+
}
|
|
3385
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
3386
|
+
return false;
|
|
3387
|
+
}
|
|
3388
|
+
return isFixed;
|
|
3389
|
+
}
|
|
3300
3390
|
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
3301
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
3302
3391
|
if (includeScale === void 0) {
|
|
3303
3392
|
includeScale = false;
|
|
3304
3393
|
}
|
|
@@ -3307,7 +3396,7 @@
|
|
|
3307
3396
|
}
|
|
3308
3397
|
const clientRect = element.getBoundingClientRect();
|
|
3309
3398
|
const domElement = unwrapElement(element);
|
|
3310
|
-
let scale =
|
|
3399
|
+
let scale = createCoords(1);
|
|
3311
3400
|
if (includeScale) {
|
|
3312
3401
|
if (offsetParent) {
|
|
3313
3402
|
if (isElement(offsetParent)) {
|
|
@@ -3317,29 +3406,30 @@
|
|
|
3317
3406
|
scale = getScale(element);
|
|
3318
3407
|
}
|
|
3319
3408
|
}
|
|
3320
|
-
const
|
|
3321
|
-
|
|
3322
|
-
let
|
|
3323
|
-
let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
|
|
3409
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
3410
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
3411
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
3324
3412
|
let width = clientRect.width / scale.x;
|
|
3325
3413
|
let height = clientRect.height / scale.y;
|
|
3326
3414
|
if (domElement) {
|
|
3327
3415
|
const win = getWindow(domElement);
|
|
3328
3416
|
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
3329
|
-
let
|
|
3330
|
-
|
|
3417
|
+
let currentWin = win;
|
|
3418
|
+
let currentIFrame = currentWin.frameElement;
|
|
3419
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
3331
3420
|
const iframeScale = getScale(currentIFrame);
|
|
3332
3421
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
3333
|
-
const css = getComputedStyle(currentIFrame);
|
|
3334
|
-
iframeRect.
|
|
3335
|
-
iframeRect.
|
|
3422
|
+
const css = getComputedStyle$1(currentIFrame);
|
|
3423
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
3424
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
3336
3425
|
x *= iframeScale.x;
|
|
3337
3426
|
y *= iframeScale.y;
|
|
3338
3427
|
width *= iframeScale.x;
|
|
3339
3428
|
height *= iframeScale.y;
|
|
3340
|
-
x +=
|
|
3341
|
-
y +=
|
|
3342
|
-
|
|
3429
|
+
x += left;
|
|
3430
|
+
y += top;
|
|
3431
|
+
currentWin = getWindow(currentIFrame);
|
|
3432
|
+
currentIFrame = currentWin.frameElement;
|
|
3343
3433
|
}
|
|
3344
3434
|
}
|
|
3345
3435
|
return rectToClientRect({
|
|
@@ -3349,45 +3439,27 @@
|
|
|
3349
3439
|
y
|
|
3350
3440
|
});
|
|
3351
3441
|
}
|
|
3352
|
-
function getDocumentElement(node) {
|
|
3353
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
3354
|
-
}
|
|
3355
|
-
function getNodeScroll(element) {
|
|
3356
|
-
if (isElement(element)) {
|
|
3357
|
-
return {
|
|
3358
|
-
scrollLeft: element.scrollLeft,
|
|
3359
|
-
scrollTop: element.scrollTop
|
|
3360
|
-
};
|
|
3361
|
-
}
|
|
3362
|
-
return {
|
|
3363
|
-
scrollLeft: element.pageXOffset,
|
|
3364
|
-
scrollTop: element.pageYOffset
|
|
3365
|
-
};
|
|
3366
|
-
}
|
|
3367
3442
|
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
3368
3443
|
let {
|
|
3444
|
+
elements,
|
|
3369
3445
|
rect,
|
|
3370
3446
|
offsetParent,
|
|
3371
3447
|
strategy
|
|
3372
3448
|
} = _ref;
|
|
3373
|
-
const
|
|
3449
|
+
const isFixed = strategy === 'fixed';
|
|
3374
3450
|
const documentElement = getDocumentElement(offsetParent);
|
|
3375
|
-
|
|
3451
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
3452
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
3376
3453
|
return rect;
|
|
3377
3454
|
}
|
|
3378
3455
|
let scroll = {
|
|
3379
3456
|
scrollLeft: 0,
|
|
3380
3457
|
scrollTop: 0
|
|
3381
3458
|
};
|
|
3382
|
-
let scale =
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
const offsets = {
|
|
3387
|
-
x: 0,
|
|
3388
|
-
y: 0
|
|
3389
|
-
};
|
|
3390
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
3459
|
+
let scale = createCoords(1);
|
|
3460
|
+
const offsets = createCoords(0);
|
|
3461
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
3462
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
3391
3463
|
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
3392
3464
|
scroll = getNodeScroll(offsetParent);
|
|
3393
3465
|
}
|
|
@@ -3405,6 +3477,9 @@
|
|
|
3405
3477
|
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
|
|
3406
3478
|
};
|
|
3407
3479
|
}
|
|
3480
|
+
function getClientRects(element) {
|
|
3481
|
+
return Array.from(element.getClientRects());
|
|
3482
|
+
}
|
|
3408
3483
|
function getWindowScrollBarX(element) {
|
|
3409
3484
|
// If <html> has a CSS width greater than the viewport, then this will be
|
|
3410
3485
|
// incorrect for RTL.
|
|
@@ -3431,46 +3506,6 @@
|
|
|
3431
3506
|
y
|
|
3432
3507
|
};
|
|
3433
3508
|
}
|
|
3434
|
-
function getParentNode(node) {
|
|
3435
|
-
if (getNodeName(node) === 'html') {
|
|
3436
|
-
return node;
|
|
3437
|
-
}
|
|
3438
|
-
const result =
|
|
3439
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
3440
|
-
node.assignedSlot ||
|
|
3441
|
-
// DOM Element detected.
|
|
3442
|
-
node.parentNode ||
|
|
3443
|
-
// ShadowRoot detected.
|
|
3444
|
-
isShadowRoot(node) && node.host ||
|
|
3445
|
-
// Fallback.
|
|
3446
|
-
getDocumentElement(node);
|
|
3447
|
-
return isShadowRoot(result) ? result.host : result;
|
|
3448
|
-
}
|
|
3449
|
-
function getNearestOverflowAncestor(node) {
|
|
3450
|
-
const parentNode = getParentNode(node);
|
|
3451
|
-
if (isLastTraversableNode(parentNode)) {
|
|
3452
|
-
// `getParentNode` will never return a `Document` due to the fallback
|
|
3453
|
-
// check, so it's either the <html> or <body> element.
|
|
3454
|
-
return parentNode.ownerDocument.body;
|
|
3455
|
-
}
|
|
3456
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
3457
|
-
return parentNode;
|
|
3458
|
-
}
|
|
3459
|
-
return getNearestOverflowAncestor(parentNode);
|
|
3460
|
-
}
|
|
3461
|
-
function getOverflowAncestors(node, list) {
|
|
3462
|
-
var _node$ownerDocument;
|
|
3463
|
-
if (list === void 0) {
|
|
3464
|
-
list = [];
|
|
3465
|
-
}
|
|
3466
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
3467
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
3468
|
-
const win = getWindow(scrollableAncestor);
|
|
3469
|
-
if (isBody) {
|
|
3470
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
3471
|
-
}
|
|
3472
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
3473
|
-
}
|
|
3474
3509
|
function getViewportRect(element, strategy) {
|
|
3475
3510
|
const win = getWindow(element);
|
|
3476
3511
|
const html = getDocumentElement(element);
|
|
@@ -3482,7 +3517,7 @@
|
|
|
3482
3517
|
if (visualViewport) {
|
|
3483
3518
|
width = visualViewport.width;
|
|
3484
3519
|
height = visualViewport.height;
|
|
3485
|
-
const visualViewportBased =
|
|
3520
|
+
const visualViewportBased = isWebKit();
|
|
3486
3521
|
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
3487
3522
|
x = visualViewport.offsetLeft;
|
|
3488
3523
|
y = visualViewport.offsetTop;
|
|
@@ -3501,10 +3536,7 @@
|
|
|
3501
3536
|
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
3502
3537
|
const top = clientRect.top + element.clientTop;
|
|
3503
3538
|
const left = clientRect.left + element.clientLeft;
|
|
3504
|
-
const scale = isHTMLElement(element) ? getScale(element) :
|
|
3505
|
-
x: 1,
|
|
3506
|
-
y: 1
|
|
3507
|
-
};
|
|
3539
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
3508
3540
|
const width = element.clientWidth * scale.x;
|
|
3509
3541
|
const height = element.clientHeight * scale.y;
|
|
3510
3542
|
const x = left * scale.x;
|
|
@@ -3525,16 +3557,12 @@
|
|
|
3525
3557
|
} else if (isElement(clippingAncestor)) {
|
|
3526
3558
|
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
3527
3559
|
} else {
|
|
3528
|
-
const
|
|
3529
|
-
|
|
3560
|
+
const visualOffsets = getVisualOffsets(element);
|
|
3561
|
+
rect = {
|
|
3562
|
+
...clippingAncestor,
|
|
3563
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
3564
|
+
y: clippingAncestor.y - visualOffsets.y
|
|
3530
3565
|
};
|
|
3531
|
-
if (isClientRectVisualViewportBased()) {
|
|
3532
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
3533
|
-
const win = getWindow(element);
|
|
3534
|
-
mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
|
|
3535
|
-
mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
|
|
3536
|
-
}
|
|
3537
|
-
rect = mutableRect;
|
|
3538
3566
|
}
|
|
3539
3567
|
return rectToClientRect(rect);
|
|
3540
3568
|
}
|
|
@@ -3554,7 +3582,7 @@
|
|
|
3554
3582
|
if (cachedResult) {
|
|
3555
3583
|
return cachedResult;
|
|
3556
3584
|
}
|
|
3557
|
-
let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
3585
|
+
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
3558
3586
|
let currentContainingBlockComputedStyle = null;
|
|
3559
3587
|
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
3560
3588
|
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
@@ -3589,7 +3617,7 @@
|
|
|
3589
3617
|
rootBoundary,
|
|
3590
3618
|
strategy
|
|
3591
3619
|
} = _ref;
|
|
3592
|
-
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
3620
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
3593
3621
|
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
3594
3622
|
const firstClippingAncestor = clippingAncestors[0];
|
|
3595
3623
|
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
@@ -3608,7 +3636,48 @@
|
|
|
3608
3636
|
};
|
|
3609
3637
|
}
|
|
3610
3638
|
function getDimensions(element) {
|
|
3611
|
-
|
|
3639
|
+
const {
|
|
3640
|
+
width,
|
|
3641
|
+
height
|
|
3642
|
+
} = getCssDimensions(element);
|
|
3643
|
+
return {
|
|
3644
|
+
width,
|
|
3645
|
+
height
|
|
3646
|
+
};
|
|
3647
|
+
}
|
|
3648
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
3649
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
3650
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
3651
|
+
const isFixed = strategy === 'fixed';
|
|
3652
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
3653
|
+
let scroll = {
|
|
3654
|
+
scrollLeft: 0,
|
|
3655
|
+
scrollTop: 0
|
|
3656
|
+
};
|
|
3657
|
+
const offsets = createCoords(0);
|
|
3658
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
3659
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
3660
|
+
scroll = getNodeScroll(offsetParent);
|
|
3661
|
+
}
|
|
3662
|
+
if (isOffsetParentAnElement) {
|
|
3663
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
3664
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
3665
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
3666
|
+
} else if (documentElement) {
|
|
3667
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
3668
|
+
}
|
|
3669
|
+
}
|
|
3670
|
+
const x = rect.left + scroll.scrollLeft - offsets.x;
|
|
3671
|
+
const y = rect.top + scroll.scrollTop - offsets.y;
|
|
3672
|
+
return {
|
|
3673
|
+
x,
|
|
3674
|
+
y,
|
|
3675
|
+
width: rect.width,
|
|
3676
|
+
height: rect.height
|
|
3677
|
+
};
|
|
3678
|
+
}
|
|
3679
|
+
function isStaticPositioned(element) {
|
|
3680
|
+
return getComputedStyle$1(element).position === 'static';
|
|
3612
3681
|
}
|
|
3613
3682
|
function getTrueOffsetParent(element, polyfill) {
|
|
3614
3683
|
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
@@ -3619,98 +3688,102 @@
|
|
|
3619
3688
|
}
|
|
3620
3689
|
return element.offsetParent;
|
|
3621
3690
|
}
|
|
3622
|
-
function getContainingBlock(element) {
|
|
3623
|
-
let currentNode = getParentNode(element);
|
|
3624
|
-
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
3625
|
-
if (isContainingBlock(currentNode)) {
|
|
3626
|
-
return currentNode;
|
|
3627
|
-
} else {
|
|
3628
|
-
currentNode = getParentNode(currentNode);
|
|
3629
|
-
}
|
|
3630
|
-
}
|
|
3631
|
-
return null;
|
|
3632
|
-
}
|
|
3633
3691
|
|
|
3634
3692
|
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
3635
3693
|
// such as table ancestors and cross browser bugs.
|
|
3636
3694
|
function getOffsetParent(element, polyfill) {
|
|
3637
|
-
const
|
|
3695
|
+
const win = getWindow(element);
|
|
3696
|
+
if (isTopLayer(element)) {
|
|
3697
|
+
return win;
|
|
3698
|
+
}
|
|
3638
3699
|
if (!isHTMLElement(element)) {
|
|
3639
|
-
|
|
3700
|
+
let svgOffsetParent = getParentNode(element);
|
|
3701
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
3702
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
3703
|
+
return svgOffsetParent;
|
|
3704
|
+
}
|
|
3705
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
3706
|
+
}
|
|
3707
|
+
return win;
|
|
3640
3708
|
}
|
|
3641
3709
|
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
3642
|
-
while (offsetParent && isTableElement(offsetParent) &&
|
|
3710
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
3643
3711
|
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
3644
3712
|
}
|
|
3645
|
-
if (offsetParent && (
|
|
3646
|
-
return
|
|
3713
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
3714
|
+
return win;
|
|
3647
3715
|
}
|
|
3648
|
-
return offsetParent || getContainingBlock(element) ||
|
|
3716
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
3649
3717
|
}
|
|
3650
|
-
function
|
|
3651
|
-
const
|
|
3652
|
-
const
|
|
3653
|
-
const
|
|
3654
|
-
let scroll = {
|
|
3655
|
-
scrollLeft: 0,
|
|
3656
|
-
scrollTop: 0
|
|
3657
|
-
};
|
|
3658
|
-
const offsets = {
|
|
3659
|
-
x: 0,
|
|
3660
|
-
y: 0
|
|
3661
|
-
};
|
|
3662
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
3663
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
3664
|
-
scroll = getNodeScroll(offsetParent);
|
|
3665
|
-
}
|
|
3666
|
-
if (isHTMLElement(offsetParent)) {
|
|
3667
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
3668
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
3669
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
3670
|
-
} else if (documentElement) {
|
|
3671
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
3672
|
-
}
|
|
3673
|
-
}
|
|
3718
|
+
const getElementRects = async function (data) {
|
|
3719
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
3720
|
+
const getDimensionsFn = this.getDimensions;
|
|
3721
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
3674
3722
|
return {
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3723
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
3724
|
+
floating: {
|
|
3725
|
+
x: 0,
|
|
3726
|
+
y: 0,
|
|
3727
|
+
width: floatingDimensions.width,
|
|
3728
|
+
height: floatingDimensions.height
|
|
3729
|
+
}
|
|
3679
3730
|
};
|
|
3731
|
+
};
|
|
3732
|
+
function isRTL(element) {
|
|
3733
|
+
return getComputedStyle$1(element).direction === 'rtl';
|
|
3680
3734
|
}
|
|
3681
3735
|
const platform = {
|
|
3682
|
-
getClippingRect,
|
|
3683
3736
|
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
3684
|
-
isElement,
|
|
3685
|
-
getDimensions,
|
|
3686
|
-
getOffsetParent,
|
|
3687
3737
|
getDocumentElement,
|
|
3738
|
+
getClippingRect,
|
|
3739
|
+
getOffsetParent,
|
|
3740
|
+
getElementRects,
|
|
3741
|
+
getClientRects,
|
|
3742
|
+
getDimensions,
|
|
3688
3743
|
getScale,
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
reference,
|
|
3692
|
-
floating,
|
|
3693
|
-
strategy
|
|
3694
|
-
} = _ref;
|
|
3695
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
3696
|
-
const getDimensionsFn = this.getDimensions;
|
|
3697
|
-
return {
|
|
3698
|
-
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
3699
|
-
floating: {
|
|
3700
|
-
x: 0,
|
|
3701
|
-
y: 0,
|
|
3702
|
-
...(await getDimensionsFn(floating))
|
|
3703
|
-
}
|
|
3704
|
-
};
|
|
3705
|
-
},
|
|
3706
|
-
getClientRects: element => Array.from(element.getClientRects()),
|
|
3707
|
-
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
3744
|
+
isElement,
|
|
3745
|
+
isRTL
|
|
3708
3746
|
};
|
|
3709
3747
|
|
|
3748
|
+
/**
|
|
3749
|
+
* Modifies the placement by translating the floating element along the
|
|
3750
|
+
* specified axes.
|
|
3751
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
3752
|
+
* object may be passed.
|
|
3753
|
+
* @see https://floating-ui.com/docs/offset
|
|
3754
|
+
*/
|
|
3755
|
+
const offset = offset$1;
|
|
3756
|
+
|
|
3757
|
+
/**
|
|
3758
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
3759
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
3760
|
+
* @see https://floating-ui.com/docs/shift
|
|
3761
|
+
*/
|
|
3762
|
+
const shift = shift$1;
|
|
3763
|
+
|
|
3764
|
+
/**
|
|
3765
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
3766
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
3767
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
3768
|
+
* @see https://floating-ui.com/docs/flip
|
|
3769
|
+
*/
|
|
3770
|
+
const flip = flip$1;
|
|
3771
|
+
|
|
3772
|
+
/**
|
|
3773
|
+
* Provides data to position an inner element of the floating element so that it
|
|
3774
|
+
* appears centered to the reference element.
|
|
3775
|
+
* @see https://floating-ui.com/docs/arrow
|
|
3776
|
+
*/
|
|
3777
|
+
const arrow = arrow$1;
|
|
3778
|
+
|
|
3779
|
+
/**
|
|
3780
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
3781
|
+
*/
|
|
3782
|
+
const limitShift = limitShift$1;
|
|
3783
|
+
|
|
3710
3784
|
/**
|
|
3711
3785
|
* Computes the `x` and `y` coordinates that will place the floating element
|
|
3712
|
-
* next to a reference element
|
|
3713
|
-
* strategy.
|
|
3786
|
+
* next to a given reference element.
|
|
3714
3787
|
*/
|
|
3715
3788
|
const computePosition = (reference, floating, options) => {
|
|
3716
3789
|
// This caches the expensive `getClippingElementAncestors` function so that
|