@haiilo/catalyst 10.12.0 → 10.13.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/catalyst/catalyst.css +1 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.esm.js +1 -1
- package/dist/catalyst/index.esm.js.map +1 -1
- package/dist/catalyst/p-751d92ed.js +3 -0
- package/dist/catalyst/p-751d92ed.js.map +1 -0
- package/dist/catalyst/p-8f350146.entry.js +10 -0
- package/dist/catalyst/p-8f350146.entry.js.map +1 -0
- package/dist/catalyst/p-e1255160.js.map +1 -1
- package/dist/catalyst/p-f4873629.js +2 -0
- package/dist/catalyst/{p-2c8ac8cf.js.map → p-f4873629.js.map} +1 -1
- package/dist/catalyst/scss/core/_dialog.scss +1 -1
- package/dist/cjs/cat-alert_29.cjs.entry.js +582 -121
- package/dist/cjs/cat-alert_29.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +9 -9
- package/dist/cjs/catalyst.cjs.js.map +1 -1
- package/dist/cjs/index-a45dd7c9.js +1383 -0
- package/dist/cjs/index-a45dd7c9.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{of-f2844da8.js → of-5cd84f84.js} +22 -22
- package/dist/cjs/{of-f2844da8.js.map → of-5cd84f84.js.map} +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/cat-alert/cat-alert.js +1 -1
- package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
- package/dist/collection/components/cat-avatar/cat-avatar.js +0 -4
- package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -1
- package/dist/collection/components/cat-badge/cat-badge.js +1 -1
- package/dist/collection/components/cat-button/cat-button.js +0 -4
- package/dist/collection/components/cat-button/cat-button.js.map +1 -1
- package/dist/collection/components/cat-button-group/cat-button-group.js +1 -1
- package/dist/collection/components/cat-card/cat-card.js +1 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +1 -9
- package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
- package/dist/collection/components/cat-date/cat-date.js +3 -3
- package/dist/collection/components/cat-date-inline/cat-date-inline.js +4 -12
- package/dist/collection/components/cat-date-inline/cat-date-inline.js.map +1 -1
- package/dist/collection/components/cat-datepicker/cat-datepicker.js +4 -4
- package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -1
- package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.js +2 -2
- package/dist/collection/components/cat-dropdown/cat-dropdown.js +2 -2
- package/dist/collection/components/cat-form-group/cat-form-group.js +1 -1
- package/dist/collection/components/cat-icon/cat-icon.js +1 -1
- package/dist/collection/components/cat-input/cat-input.js +4 -10
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-pagination/cat-pagination.js +2 -2
- package/dist/collection/components/cat-radio/cat-radio.js +1 -9
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
- package/dist/collection/components/cat-radio-group/cat-radio-group.js +1 -1
- package/dist/collection/components/cat-scrollable/cat-scrollable.js +3 -3
- package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
- package/dist/collection/components/cat-select/cat-select.js +6 -12
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/components/cat-select-demo/cat-select-demo.js +1 -1
- package/dist/collection/components/cat-skeleton/cat-skeleton.js +1 -1
- package/dist/collection/components/cat-spinner/cat-spinner.js +2 -2
- package/dist/collection/components/cat-tab/cat-tab.js +1 -1
- package/dist/collection/components/cat-tabs/cat-tabs.js +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.js +3 -9
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-time/cat-time.js +3 -3
- package/dist/collection/components/cat-time/cat-time.js.map +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.js +1 -9
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +3 -3
- package/dist/collection/scss/core/_dialog.scss +1 -1
- package/dist/components/cat-alert.js +1 -1
- package/dist/components/cat-alert.js.map +1 -1
- package/dist/components/cat-avatar2.js +0 -4
- package/dist/components/cat-avatar2.js.map +1 -1
- package/dist/components/cat-badge.js +1 -1
- package/dist/components/cat-button-group.js +1 -1
- package/dist/components/cat-button2.js +0 -4
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-card.js +1 -1
- package/dist/components/cat-checkbox2.js +1 -9
- package/dist/components/cat-checkbox2.js.map +1 -1
- package/dist/components/cat-date-inline2.js +4 -12
- package/dist/components/cat-date-inline2.js.map +1 -1
- package/dist/components/cat-date.js +2 -2
- package/dist/components/cat-datepicker-inline.js +2 -2
- package/dist/components/cat-datepicker.js +3 -3
- package/dist/components/cat-datepicker.js.map +1 -1
- package/dist/components/cat-dropdown2.js +1 -1
- package/dist/components/cat-form-group.js +1 -1
- package/dist/components/cat-icon-registry.js +21 -21
- package/dist/components/cat-icon2.js +1 -1
- package/dist/components/cat-input2.js +4 -10
- package/dist/components/cat-input2.js.map +1 -1
- package/dist/components/cat-pagination.js +2 -2
- package/dist/components/cat-radio-group.js +1 -1
- package/dist/components/cat-radio.js +1 -9
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-scrollable2.js +3 -3
- package/dist/components/cat-scrollable2.js.map +1 -1
- package/dist/components/cat-select-demo.js +1 -1
- package/dist/components/cat-select2.js +5 -11
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-skeleton2.js +1 -1
- package/dist/components/cat-spinner2.js +2 -2
- package/dist/components/cat-tab.js +1 -1
- package/dist/components/cat-tabs.js +1 -1
- package/dist/components/cat-textarea.js +3 -9
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-time.js +2 -2
- package/dist/components/cat-time.js.map +1 -1
- package/dist/components/cat-toggle.js +1 -9
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/cat-tooltip.js +2 -2
- package/dist/components/floating-ui.dom.esm.js +531 -13
- package/dist/components/floating-ui.dom.esm.js.map +1 -1
- package/dist/esm/cat-alert_29.entry.js +582 -121
- package/dist/esm/cat-alert_29.entry.js.map +1 -1
- package/dist/esm/catalyst.js +10 -10
- package/dist/esm/catalyst.js.map +1 -1
- package/dist/esm/index-3059296e.js +1354 -0
- package/dist/esm/index-3059296e.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +2 -2
- package/dist/esm/{of-53334b95.js → of-625babef.js} +22 -22
- package/dist/esm/{of-53334b95.js.map → of-625babef.js.map} +1 -1
- package/dist/types/components/cat-avatar/cat-avatar.d.ts +0 -1
- package/dist/types/components/cat-button/cat-button.d.ts +0 -1
- package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +0 -1
- package/dist/types/components/cat-date-inline/cat-date-inline.d.ts +0 -1
- package/dist/types/components/cat-radio/cat-radio.d.ts +0 -1
- package/dist/types/components/cat-toggle/cat-toggle.d.ts +0 -1
- package/dist/types/stencil-public-runtime.d.ts +3 -8
- package/loader/cdn.js +1 -3
- package/loader/index.cjs.js +1 -3
- package/loader/index.es2017.js +1 -3
- package/loader/index.js +1 -3
- package/package.json +16 -16
- package/dist/catalyst/p-22f0435a.js +0 -3
- package/dist/catalyst/p-22f0435a.js.map +0 -1
- package/dist/catalyst/p-2c8ac8cf.js +0 -2
- package/dist/catalyst/p-3e87007e.entry.js +0 -10
- package/dist/catalyst/p-3e87007e.entry.js.map +0 -1
- package/dist/cjs/index-66a60071.js +0 -2081
- package/dist/cjs/index-66a60071.js.map +0 -1
- package/dist/collection/utils/assert.js +0 -9
- package/dist/collection/utils/assert.js.map +0 -1
- package/dist/components/assert.js +0 -13
- package/dist/components/assert.js.map +0 -1
- package/dist/esm/index-b7832dfc.js +0 -2052
- package/dist/esm/index-b7832dfc.js.map +0 -1
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/types/utils/assert.d.ts +0 -1
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Custom positioning reference element.
|
|
3
3
|
* @see https://floating-ui.com/docs/virtual-elements
|
|
4
4
|
*/
|
|
5
|
+
|
|
6
|
+
const sides = ['top', 'right', 'bottom', 'left'];
|
|
7
|
+
const alignments = ['start', 'end'];
|
|
8
|
+
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
|
5
9
|
const min = Math.min;
|
|
6
10
|
const max = Math.max;
|
|
7
11
|
const round = Math.round;
|
|
@@ -333,6 +337,191 @@ async function detectOverflow(state, options) {
|
|
|
333
337
|
};
|
|
334
338
|
}
|
|
335
339
|
|
|
340
|
+
/**
|
|
341
|
+
* Provides data to position an inner element of the floating element so that it
|
|
342
|
+
* appears centered to the reference element.
|
|
343
|
+
* @see https://floating-ui.com/docs/arrow
|
|
344
|
+
*/
|
|
345
|
+
const arrow = options => ({
|
|
346
|
+
name: 'arrow',
|
|
347
|
+
options,
|
|
348
|
+
async fn(state) {
|
|
349
|
+
const {
|
|
350
|
+
x,
|
|
351
|
+
y,
|
|
352
|
+
placement,
|
|
353
|
+
rects,
|
|
354
|
+
platform,
|
|
355
|
+
elements,
|
|
356
|
+
middlewareData
|
|
357
|
+
} = state;
|
|
358
|
+
// Since `element` is required, we don't Partial<> the type.
|
|
359
|
+
const {
|
|
360
|
+
element,
|
|
361
|
+
padding = 0
|
|
362
|
+
} = evaluate(options, state) || {};
|
|
363
|
+
if (element == null) {
|
|
364
|
+
return {};
|
|
365
|
+
}
|
|
366
|
+
const paddingObject = getPaddingObject(padding);
|
|
367
|
+
const coords = {
|
|
368
|
+
x,
|
|
369
|
+
y
|
|
370
|
+
};
|
|
371
|
+
const axis = getAlignmentAxis(placement);
|
|
372
|
+
const length = getAxisLength(axis);
|
|
373
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
374
|
+
const isYAxis = axis === 'y';
|
|
375
|
+
const minProp = isYAxis ? 'top' : 'left';
|
|
376
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
377
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
378
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
379
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
380
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
381
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
382
|
+
|
|
383
|
+
// DOM platform can return `window` as the `offsetParent`.
|
|
384
|
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
|
385
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
386
|
+
}
|
|
387
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
388
|
+
|
|
389
|
+
// If the padding is large enough that it causes the arrow to no longer be
|
|
390
|
+
// centered, modify the padding so that it is centered.
|
|
391
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
392
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
393
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
394
|
+
|
|
395
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
|
396
|
+
// point is outside the floating element's bounds.
|
|
397
|
+
const min$1 = minPadding;
|
|
398
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
399
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
400
|
+
const offset = clamp(min$1, center, max);
|
|
401
|
+
|
|
402
|
+
// If the reference is small enough that the arrow's padding causes it to
|
|
403
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
|
404
|
+
// floating element itself. To ensure `shift()` continues to take action,
|
|
405
|
+
// a single reset is performed when this is true.
|
|
406
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
407
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
408
|
+
return {
|
|
409
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
410
|
+
data: {
|
|
411
|
+
[axis]: offset,
|
|
412
|
+
centerOffset: center - offset - alignmentOffset,
|
|
413
|
+
...(shouldAddOffset && {
|
|
414
|
+
alignmentOffset
|
|
415
|
+
})
|
|
416
|
+
},
|
|
417
|
+
reset: shouldAddOffset
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
423
|
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
|
424
|
+
return allowedPlacementsSortedByAlignment.filter(placement => {
|
|
425
|
+
if (alignment) {
|
|
426
|
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
427
|
+
}
|
|
428
|
+
return true;
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Optimizes the visibility of the floating element by choosing the placement
|
|
433
|
+
* that has the most space available automatically, without needing to specify a
|
|
434
|
+
* preferred placement. Alternative to `flip`.
|
|
435
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
436
|
+
*/
|
|
437
|
+
const autoPlacement = function (options) {
|
|
438
|
+
if (options === void 0) {
|
|
439
|
+
options = {};
|
|
440
|
+
}
|
|
441
|
+
return {
|
|
442
|
+
name: 'autoPlacement',
|
|
443
|
+
options,
|
|
444
|
+
async fn(state) {
|
|
445
|
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
|
446
|
+
const {
|
|
447
|
+
rects,
|
|
448
|
+
middlewareData,
|
|
449
|
+
placement,
|
|
450
|
+
platform,
|
|
451
|
+
elements
|
|
452
|
+
} = state;
|
|
453
|
+
const {
|
|
454
|
+
crossAxis = false,
|
|
455
|
+
alignment,
|
|
456
|
+
allowedPlacements = placements,
|
|
457
|
+
autoAlignment = true,
|
|
458
|
+
...detectOverflowOptions
|
|
459
|
+
} = evaluate(options, state);
|
|
460
|
+
const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
|
461
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
462
|
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
|
463
|
+
const currentPlacement = placements$1[currentIndex];
|
|
464
|
+
if (currentPlacement == null) {
|
|
465
|
+
return {};
|
|
466
|
+
}
|
|
467
|
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
468
|
+
|
|
469
|
+
// Make `computeCoords` start from the right place.
|
|
470
|
+
if (placement !== currentPlacement) {
|
|
471
|
+
return {
|
|
472
|
+
reset: {
|
|
473
|
+
placement: placements$1[0]
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
|
478
|
+
const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
|
|
479
|
+
placement: currentPlacement,
|
|
480
|
+
overflows: currentOverflows
|
|
481
|
+
}];
|
|
482
|
+
const nextPlacement = placements$1[currentIndex + 1];
|
|
483
|
+
|
|
484
|
+
// There are more placements to check.
|
|
485
|
+
if (nextPlacement) {
|
|
486
|
+
return {
|
|
487
|
+
data: {
|
|
488
|
+
index: currentIndex + 1,
|
|
489
|
+
overflows: allOverflows
|
|
490
|
+
},
|
|
491
|
+
reset: {
|
|
492
|
+
placement: nextPlacement
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
const placementsSortedByMostSpace = allOverflows.map(d => {
|
|
497
|
+
const alignment = getAlignment(d.placement);
|
|
498
|
+
return [d.placement, alignment && crossAxis ?
|
|
499
|
+
// Check along the mainAxis and main crossAxis side.
|
|
500
|
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
|
|
501
|
+
// Check only the mainAxis.
|
|
502
|
+
d.overflows[0], d.overflows];
|
|
503
|
+
}).sort((a, b) => a[1] - b[1]);
|
|
504
|
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
|
|
505
|
+
// Aligned placements should not check their opposite crossAxis
|
|
506
|
+
// side.
|
|
507
|
+
getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
|
|
508
|
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
|
509
|
+
if (resetPlacement !== placement) {
|
|
510
|
+
return {
|
|
511
|
+
data: {
|
|
512
|
+
index: currentIndex + 1,
|
|
513
|
+
overflows: allOverflows
|
|
514
|
+
},
|
|
515
|
+
reset: {
|
|
516
|
+
placement: resetPlacement
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
return {};
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
};
|
|
524
|
+
|
|
336
525
|
/**
|
|
337
526
|
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
338
527
|
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
@@ -448,6 +637,206 @@ const flip$1 = function (options) {
|
|
|
448
637
|
};
|
|
449
638
|
};
|
|
450
639
|
|
|
640
|
+
function getSideOffsets(overflow, rect) {
|
|
641
|
+
return {
|
|
642
|
+
top: overflow.top - rect.height,
|
|
643
|
+
right: overflow.right - rect.width,
|
|
644
|
+
bottom: overflow.bottom - rect.height,
|
|
645
|
+
left: overflow.left - rect.width
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function isAnySideFullyClipped(overflow) {
|
|
649
|
+
return sides.some(side => overflow[side] >= 0);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
653
|
+
* when it is not in the same clipping context as the reference element.
|
|
654
|
+
* @see https://floating-ui.com/docs/hide
|
|
655
|
+
*/
|
|
656
|
+
const hide = function (options) {
|
|
657
|
+
if (options === void 0) {
|
|
658
|
+
options = {};
|
|
659
|
+
}
|
|
660
|
+
return {
|
|
661
|
+
name: 'hide',
|
|
662
|
+
options,
|
|
663
|
+
async fn(state) {
|
|
664
|
+
const {
|
|
665
|
+
rects
|
|
666
|
+
} = state;
|
|
667
|
+
const {
|
|
668
|
+
strategy = 'referenceHidden',
|
|
669
|
+
...detectOverflowOptions
|
|
670
|
+
} = evaluate(options, state);
|
|
671
|
+
switch (strategy) {
|
|
672
|
+
case 'referenceHidden':
|
|
673
|
+
{
|
|
674
|
+
const overflow = await detectOverflow(state, {
|
|
675
|
+
...detectOverflowOptions,
|
|
676
|
+
elementContext: 'reference'
|
|
677
|
+
});
|
|
678
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
|
679
|
+
return {
|
|
680
|
+
data: {
|
|
681
|
+
referenceHiddenOffsets: offsets,
|
|
682
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
case 'escaped':
|
|
687
|
+
{
|
|
688
|
+
const overflow = await detectOverflow(state, {
|
|
689
|
+
...detectOverflowOptions,
|
|
690
|
+
altBoundary: true
|
|
691
|
+
});
|
|
692
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
|
693
|
+
return {
|
|
694
|
+
data: {
|
|
695
|
+
escapedOffsets: offsets,
|
|
696
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
default:
|
|
701
|
+
{
|
|
702
|
+
return {};
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
function getBoundingRect(rects) {
|
|
710
|
+
const minX = min(...rects.map(rect => rect.left));
|
|
711
|
+
const minY = min(...rects.map(rect => rect.top));
|
|
712
|
+
const maxX = max(...rects.map(rect => rect.right));
|
|
713
|
+
const maxY = max(...rects.map(rect => rect.bottom));
|
|
714
|
+
return {
|
|
715
|
+
x: minX,
|
|
716
|
+
y: minY,
|
|
717
|
+
width: maxX - minX,
|
|
718
|
+
height: maxY - minY
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
function getRectsByLine(rects) {
|
|
722
|
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
|
723
|
+
const groups = [];
|
|
724
|
+
let prevRect = null;
|
|
725
|
+
for (let i = 0; i < sortedRects.length; i++) {
|
|
726
|
+
const rect = sortedRects[i];
|
|
727
|
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
|
728
|
+
groups.push([rect]);
|
|
729
|
+
} else {
|
|
730
|
+
groups[groups.length - 1].push(rect);
|
|
731
|
+
}
|
|
732
|
+
prevRect = rect;
|
|
733
|
+
}
|
|
734
|
+
return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Provides improved positioning for inline reference elements that can span
|
|
738
|
+
* over multiple lines, such as hyperlinks or range selections.
|
|
739
|
+
* @see https://floating-ui.com/docs/inline
|
|
740
|
+
*/
|
|
741
|
+
const inline = function (options) {
|
|
742
|
+
if (options === void 0) {
|
|
743
|
+
options = {};
|
|
744
|
+
}
|
|
745
|
+
return {
|
|
746
|
+
name: 'inline',
|
|
747
|
+
options,
|
|
748
|
+
async fn(state) {
|
|
749
|
+
const {
|
|
750
|
+
placement,
|
|
751
|
+
elements,
|
|
752
|
+
rects,
|
|
753
|
+
platform,
|
|
754
|
+
strategy
|
|
755
|
+
} = state;
|
|
756
|
+
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
|
757
|
+
// ClientRect's bounds, despite the event listener being triggered. A
|
|
758
|
+
// padding of 2 seems to handle this issue.
|
|
759
|
+
const {
|
|
760
|
+
padding = 2,
|
|
761
|
+
x,
|
|
762
|
+
y
|
|
763
|
+
} = evaluate(options, state);
|
|
764
|
+
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
|
|
765
|
+
const clientRects = getRectsByLine(nativeClientRects);
|
|
766
|
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
|
767
|
+
const paddingObject = getPaddingObject(padding);
|
|
768
|
+
function getBoundingClientRect() {
|
|
769
|
+
// There are two rects and they are disjoined.
|
|
770
|
+
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
|
|
771
|
+
// Find the first rect in which the point is fully inside.
|
|
772
|
+
return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// There are 2 or more connected rects.
|
|
776
|
+
if (clientRects.length >= 2) {
|
|
777
|
+
if (getSideAxis(placement) === 'y') {
|
|
778
|
+
const firstRect = clientRects[0];
|
|
779
|
+
const lastRect = clientRects[clientRects.length - 1];
|
|
780
|
+
const isTop = getSide(placement) === 'top';
|
|
781
|
+
const top = firstRect.top;
|
|
782
|
+
const bottom = lastRect.bottom;
|
|
783
|
+
const left = isTop ? firstRect.left : lastRect.left;
|
|
784
|
+
const right = isTop ? firstRect.right : lastRect.right;
|
|
785
|
+
const width = right - left;
|
|
786
|
+
const height = bottom - top;
|
|
787
|
+
return {
|
|
788
|
+
top,
|
|
789
|
+
bottom,
|
|
790
|
+
left,
|
|
791
|
+
right,
|
|
792
|
+
width,
|
|
793
|
+
height,
|
|
794
|
+
x: left,
|
|
795
|
+
y: top
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
const isLeftSide = getSide(placement) === 'left';
|
|
799
|
+
const maxRight = max(...clientRects.map(rect => rect.right));
|
|
800
|
+
const minLeft = min(...clientRects.map(rect => rect.left));
|
|
801
|
+
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
802
|
+
const top = measureRects[0].top;
|
|
803
|
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
804
|
+
const left = minLeft;
|
|
805
|
+
const right = maxRight;
|
|
806
|
+
const width = right - left;
|
|
807
|
+
const height = bottom - top;
|
|
808
|
+
return {
|
|
809
|
+
top,
|
|
810
|
+
bottom,
|
|
811
|
+
left,
|
|
812
|
+
right,
|
|
813
|
+
width,
|
|
814
|
+
height,
|
|
815
|
+
x: left,
|
|
816
|
+
y: top
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
return fallback;
|
|
820
|
+
}
|
|
821
|
+
const resetRects = await platform.getElementRects({
|
|
822
|
+
reference: {
|
|
823
|
+
getBoundingClientRect
|
|
824
|
+
},
|
|
825
|
+
floating: elements.floating,
|
|
826
|
+
strategy
|
|
827
|
+
});
|
|
828
|
+
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
|
|
829
|
+
return {
|
|
830
|
+
reset: {
|
|
831
|
+
rects: resetRects
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
return {};
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
};
|
|
839
|
+
|
|
451
840
|
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
452
841
|
// Derivable.
|
|
453
842
|
|
|
@@ -497,7 +886,7 @@ async function convertValueToCoords(state, options) {
|
|
|
497
886
|
* object may be passed.
|
|
498
887
|
* @see https://floating-ui.com/docs/offset
|
|
499
888
|
*/
|
|
500
|
-
const offset = function (options) {
|
|
889
|
+
const offset$1 = function (options) {
|
|
501
890
|
if (options === void 0) {
|
|
502
891
|
options = 0;
|
|
503
892
|
}
|
|
@@ -604,6 +993,74 @@ const shift$1 = function (options) {
|
|
|
604
993
|
}
|
|
605
994
|
};
|
|
606
995
|
};
|
|
996
|
+
/**
|
|
997
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
998
|
+
*/
|
|
999
|
+
const limitShift = function (options) {
|
|
1000
|
+
if (options === void 0) {
|
|
1001
|
+
options = {};
|
|
1002
|
+
}
|
|
1003
|
+
return {
|
|
1004
|
+
options,
|
|
1005
|
+
fn(state) {
|
|
1006
|
+
const {
|
|
1007
|
+
x,
|
|
1008
|
+
y,
|
|
1009
|
+
placement,
|
|
1010
|
+
rects,
|
|
1011
|
+
middlewareData
|
|
1012
|
+
} = state;
|
|
1013
|
+
const {
|
|
1014
|
+
offset = 0,
|
|
1015
|
+
mainAxis: checkMainAxis = true,
|
|
1016
|
+
crossAxis: checkCrossAxis = true
|
|
1017
|
+
} = evaluate(options, state);
|
|
1018
|
+
const coords = {
|
|
1019
|
+
x,
|
|
1020
|
+
y
|
|
1021
|
+
};
|
|
1022
|
+
const crossAxis = getSideAxis(placement);
|
|
1023
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
1024
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1025
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1026
|
+
const rawOffset = evaluate(offset, state);
|
|
1027
|
+
const computedOffset = typeof rawOffset === 'number' ? {
|
|
1028
|
+
mainAxis: rawOffset,
|
|
1029
|
+
crossAxis: 0
|
|
1030
|
+
} : {
|
|
1031
|
+
mainAxis: 0,
|
|
1032
|
+
crossAxis: 0,
|
|
1033
|
+
...rawOffset
|
|
1034
|
+
};
|
|
1035
|
+
if (checkMainAxis) {
|
|
1036
|
+
const len = mainAxis === 'y' ? 'height' : 'width';
|
|
1037
|
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
|
|
1038
|
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
|
|
1039
|
+
if (mainAxisCoord < limitMin) {
|
|
1040
|
+
mainAxisCoord = limitMin;
|
|
1041
|
+
} else if (mainAxisCoord > limitMax) {
|
|
1042
|
+
mainAxisCoord = limitMax;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
if (checkCrossAxis) {
|
|
1046
|
+
var _middlewareData$offse, _middlewareData$offse2;
|
|
1047
|
+
const len = mainAxis === 'y' ? 'width' : 'height';
|
|
1048
|
+
const isOriginSide = ['top', 'left'].includes(getSide(placement));
|
|
1049
|
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
|
|
1050
|
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
|
|
1051
|
+
if (crossAxisCoord < limitMin) {
|
|
1052
|
+
crossAxisCoord = limitMin;
|
|
1053
|
+
} else if (crossAxisCoord > limitMax) {
|
|
1054
|
+
crossAxisCoord = limitMax;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
return {
|
|
1058
|
+
[mainAxis]: mainAxisCoord,
|
|
1059
|
+
[crossAxis]: crossAxisCoord
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
};
|
|
607
1064
|
|
|
608
1065
|
/**
|
|
609
1066
|
* Provides data that allows you to change the size of the floating element —
|
|
@@ -942,10 +1399,10 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
942
1399
|
}
|
|
943
1400
|
|
|
944
1401
|
const topLayerSelectors = [':popover-open', ':modal'];
|
|
945
|
-
function isTopLayer(
|
|
1402
|
+
function isTopLayer(element) {
|
|
946
1403
|
return topLayerSelectors.some(selector => {
|
|
947
1404
|
try {
|
|
948
|
-
return
|
|
1405
|
+
return element.matches(selector);
|
|
949
1406
|
} catch (e) {
|
|
950
1407
|
return false;
|
|
951
1408
|
}
|
|
@@ -1133,7 +1590,7 @@ function getClippingRect(_ref) {
|
|
|
1133
1590
|
rootBoundary,
|
|
1134
1591
|
strategy
|
|
1135
1592
|
} = _ref;
|
|
1136
|
-
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1593
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1137
1594
|
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1138
1595
|
const firstClippingAncestor = clippingAncestors[0];
|
|
1139
1596
|
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
@@ -1195,6 +1652,10 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
|
1195
1652
|
};
|
|
1196
1653
|
}
|
|
1197
1654
|
|
|
1655
|
+
function isStaticPositioned(element) {
|
|
1656
|
+
return getComputedStyle(element).position === 'static';
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1198
1659
|
function getTrueOffsetParent(element, polyfill) {
|
|
1199
1660
|
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
1200
1661
|
return null;
|
|
@@ -1208,29 +1669,41 @@ function getTrueOffsetParent(element, polyfill) {
|
|
|
1208
1669
|
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
1209
1670
|
// such as table ancestors and cross browser bugs.
|
|
1210
1671
|
function getOffsetParent(element, polyfill) {
|
|
1211
|
-
const
|
|
1212
|
-
if (
|
|
1213
|
-
return
|
|
1672
|
+
const win = getWindow(element);
|
|
1673
|
+
if (isTopLayer(element)) {
|
|
1674
|
+
return win;
|
|
1675
|
+
}
|
|
1676
|
+
if (!isHTMLElement(element)) {
|
|
1677
|
+
let svgOffsetParent = getParentNode(element);
|
|
1678
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1679
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
1680
|
+
return svgOffsetParent;
|
|
1681
|
+
}
|
|
1682
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1683
|
+
}
|
|
1684
|
+
return win;
|
|
1214
1685
|
}
|
|
1215
1686
|
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1216
|
-
while (offsetParent && isTableElement(offsetParent) &&
|
|
1687
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
1217
1688
|
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1218
1689
|
}
|
|
1219
|
-
if (offsetParent && (
|
|
1220
|
-
return
|
|
1690
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
1691
|
+
return win;
|
|
1221
1692
|
}
|
|
1222
|
-
return offsetParent || getContainingBlock(element) ||
|
|
1693
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
1223
1694
|
}
|
|
1224
1695
|
|
|
1225
1696
|
const getElementRects = async function (data) {
|
|
1226
1697
|
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1227
1698
|
const getDimensionsFn = this.getDimensions;
|
|
1699
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1228
1700
|
return {
|
|
1229
1701
|
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1230
1702
|
floating: {
|
|
1231
1703
|
x: 0,
|
|
1232
1704
|
y: 0,
|
|
1233
|
-
|
|
1705
|
+
width: floatingDimensions.width,
|
|
1706
|
+
height: floatingDimensions.height
|
|
1234
1707
|
}
|
|
1235
1708
|
};
|
|
1236
1709
|
};
|
|
@@ -1300,9 +1773,11 @@ function observeMove(element, onMove) {
|
|
|
1300
1773
|
return refresh();
|
|
1301
1774
|
}
|
|
1302
1775
|
if (!ratio) {
|
|
1776
|
+
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
|
1777
|
+
// to prevent an infinite loop of updates.
|
|
1303
1778
|
timeoutId = setTimeout(() => {
|
|
1304
1779
|
refresh(false, 1e-7);
|
|
1305
|
-
},
|
|
1780
|
+
}, 1000);
|
|
1306
1781
|
} else {
|
|
1307
1782
|
refresh(false, ratio);
|
|
1308
1783
|
}
|
|
@@ -1406,6 +1881,23 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1406
1881
|
};
|
|
1407
1882
|
}
|
|
1408
1883
|
|
|
1884
|
+
/**
|
|
1885
|
+
* Modifies the placement by translating the floating element along the
|
|
1886
|
+
* specified axes.
|
|
1887
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1888
|
+
* object may be passed.
|
|
1889
|
+
* @see https://floating-ui.com/docs/offset
|
|
1890
|
+
*/
|
|
1891
|
+
const offset = offset$1;
|
|
1892
|
+
|
|
1893
|
+
/**
|
|
1894
|
+
* Optimizes the visibility of the floating element by choosing the placement
|
|
1895
|
+
* that has the most space available automatically, without needing to specify a
|
|
1896
|
+
* preferred placement. Alternative to `flip`.
|
|
1897
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
1898
|
+
*/
|
|
1899
|
+
autoPlacement;
|
|
1900
|
+
|
|
1409
1901
|
/**
|
|
1410
1902
|
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1411
1903
|
* keep it in view when it will overflow the clipping boundary.
|
|
@@ -1429,6 +1921,32 @@ const flip = flip$1;
|
|
|
1429
1921
|
*/
|
|
1430
1922
|
const size = size$1;
|
|
1431
1923
|
|
|
1924
|
+
/**
|
|
1925
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
1926
|
+
* when it is not in the same clipping context as the reference element.
|
|
1927
|
+
* @see https://floating-ui.com/docs/hide
|
|
1928
|
+
*/
|
|
1929
|
+
hide;
|
|
1930
|
+
|
|
1931
|
+
/**
|
|
1932
|
+
* Provides data to position an inner element of the floating element so that it
|
|
1933
|
+
* appears centered to the reference element.
|
|
1934
|
+
* @see https://floating-ui.com/docs/arrow
|
|
1935
|
+
*/
|
|
1936
|
+
arrow;
|
|
1937
|
+
|
|
1938
|
+
/**
|
|
1939
|
+
* Provides improved positioning for inline reference elements that can span
|
|
1940
|
+
* over multiple lines, such as hyperlinks or range selections.
|
|
1941
|
+
* @see https://floating-ui.com/docs/inline
|
|
1942
|
+
*/
|
|
1943
|
+
inline;
|
|
1944
|
+
|
|
1945
|
+
/**
|
|
1946
|
+
* Built-in `limiter` that will stop `shift()` at a certain point.
|
|
1947
|
+
*/
|
|
1948
|
+
limitShift;
|
|
1949
|
+
|
|
1432
1950
|
/**
|
|
1433
1951
|
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1434
1952
|
* next to a given reference element.
|