@aurodesignsystem-dev/auro-formkit 0.0.0-pr1422.0 → 0.0.0-pr1422.2
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/components/bibtemplate/dist/auro-bibtemplate.d.ts +66 -0
- package/components/bibtemplate/dist/buttonVersion.d.ts +2 -0
- package/components/bibtemplate/dist/headerVersion.d.ts +2 -0
- package/components/bibtemplate/dist/iconVersion.d.ts +2 -0
- package/components/bibtemplate/dist/index.d.ts +2 -0
- package/components/bibtemplate/dist/index.js +395 -0
- package/components/bibtemplate/dist/registered.js +395 -0
- package/components/bibtemplate/dist/styles/color-css.d.ts +2 -0
- package/components/bibtemplate/dist/styles/style-css.d.ts +2 -0
- package/components/bibtemplate/dist/styles/tokens-css.d.ts +2 -0
- package/components/checkbox/demo/api.md +489 -0
- package/components/checkbox/demo/api.min.js +2133 -0
- package/components/checkbox/demo/index.md +55 -0
- package/components/checkbox/demo/index.min.js +2108 -0
- package/components/checkbox/demo/keyboardBehavior.md +0 -0
- package/components/checkbox/demo/readme.md +142 -0
- package/components/checkbox/dist/auro-checkbox-group.d.ts +176 -0
- package/components/checkbox/dist/auro-checkbox.d.ts +209 -0
- package/components/checkbox/dist/index.d.ts +3 -0
- package/components/checkbox/dist/index.js +2057 -0
- package/components/checkbox/dist/registered.js +2058 -0
- package/components/checkbox/dist/styles/auro-checkbox-css.d.ts +2 -0
- package/components/checkbox/dist/styles/auro-checkbox-group-css.d.ts +2 -0
- package/components/checkbox/dist/styles/color-css.d.ts +2 -0
- package/components/checkbox/dist/styles/colorGroup-css.d.ts +2 -0
- package/components/checkbox/dist/styles/tokens-css.d.ts +2 -0
- package/components/combobox/demo/api.md +2287 -0
- package/components/combobox/demo/api.min.js +18025 -0
- package/components/combobox/demo/index.md +196 -0
- package/components/combobox/demo/index.min.js +17930 -0
- package/components/combobox/demo/keyboardBehavior.md +281 -0
- package/components/combobox/demo/readme.md +158 -0
- package/components/combobox/dist/auro-combobox.d.ts +578 -0
- package/components/combobox/dist/comboboxKeyboardStrategy.d.ts +9 -0
- package/components/combobox/dist/index.d.ts +2 -0
- package/components/combobox/dist/index.js +15845 -0
- package/components/combobox/dist/registered.js +15847 -0
- package/components/combobox/dist/styles/emphasized/style-css.d.ts +2 -0
- package/components/combobox/dist/styles/snowflake/style-css.d.ts +2 -0
- package/components/combobox/dist/styles/style-css.d.ts +2 -0
- package/components/counter/demo/api.md +1285 -0
- package/components/counter/demo/api.min.js +8237 -0
- package/components/counter/demo/index.md +92 -0
- package/components/counter/demo/index.min.js +8218 -0
- package/components/counter/demo/keyboardBehavior.md +127 -0
- package/components/counter/demo/readme.md +161 -0
- package/components/counter/dist/auro-counter-button.d.ts +14 -0
- package/components/counter/dist/auro-counter-group.d.ts +390 -0
- package/components/counter/dist/auro-counter-wrapper.d.ts +17 -0
- package/components/counter/dist/auro-counter.d.ts +136 -0
- package/components/counter/dist/buttonVersion.d.ts +2 -0
- package/components/counter/dist/iconVersion.d.ts +2 -0
- package/components/counter/dist/index.d.ts +3 -0
- package/components/counter/dist/index.js +8140 -0
- package/components/counter/dist/keyboardStrategy.d.ts +4 -0
- package/components/counter/dist/registered.js +8141 -0
- package/components/counter/dist/styles/color-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-button-color-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-button-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-group-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-wrapper-color-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-wrapper-css.d.ts +2 -0
- package/components/counter/dist/styles/shapeSize-css.d.ts +2 -0
- package/components/counter/dist/styles/style-css.d.ts +2 -0
- package/components/counter/dist/styles/tokens-css.d.ts +2 -0
- package/components/datepicker/demo/api.md +1824 -0
- package/components/datepicker/demo/api.min.js +24654 -0
- package/components/datepicker/demo/index.md +158 -0
- package/components/datepicker/demo/index.min.js +24375 -0
- package/components/datepicker/demo/keyboardBehavior.md +19 -0
- package/components/datepicker/demo/readme.md +137 -0
- package/components/datepicker/dist/auro-calendar-cell.d.ts +169 -0
- package/components/datepicker/dist/auro-calendar-month.d.ts +20 -0
- package/components/datepicker/dist/auro-calendar.d.ts +173 -0
- package/components/datepicker/dist/auro-datepicker.d.ts +716 -0
- package/components/datepicker/dist/buttonVersion.d.ts +2 -0
- package/components/datepicker/dist/datepickerKeyboardStrategy.d.ts +1 -0
- package/components/datepicker/dist/iconVersion.d.ts +2 -0
- package/components/datepicker/dist/index.d.ts +2 -0
- package/components/datepicker/dist/index.js +24290 -0
- package/components/datepicker/dist/popoverVersion.d.ts +2 -0
- package/components/datepicker/dist/registered.js +24290 -0
- package/components/datepicker/dist/styles/classic/color-css.d.ts +2 -0
- package/components/datepicker/dist/styles/classic/style-css.d.ts +2 -0
- package/components/datepicker/dist/styles/color-calendar-css.d.ts +2 -0
- package/components/datepicker/dist/styles/color-cell-css.d.ts +2 -0
- package/components/datepicker/dist/styles/color-css.d.ts +2 -0
- package/components/datepicker/dist/styles/color-month-css.d.ts +2 -0
- package/components/datepicker/dist/styles/shapeSize-css.d.ts +2 -0
- package/components/datepicker/dist/styles/snowflake/color-css.d.ts +2 -0
- package/components/datepicker/dist/styles/snowflake/style-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-auro-calendar-cell-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-auro-calendar-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-auro-calendar-month-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-css.d.ts +2 -0
- package/components/datepicker/dist/styles/tokens-css.d.ts +2 -0
- package/components/datepicker/dist/utilities.d.ts +78 -0
- package/components/datepicker/dist/utilitiesCalendar.d.ts +38 -0
- package/components/datepicker/dist/utilitiesCalendarRender.d.ts +50 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/day.d.ts +5 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker-calendar.d.ts +60 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker-cell.d.ts +1 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker.d.ts +57 -0
- package/components/dropdown/demo/api.md +1358 -0
- package/components/dropdown/demo/api.min.js +5019 -0
- package/components/dropdown/demo/index.md +283 -0
- package/components/dropdown/demo/index.min.js +4954 -0
- package/components/dropdown/demo/keyboardBehavior.md +77 -0
- package/components/dropdown/demo/readme.md +160 -0
- package/components/dropdown/dist/auro-dropdown.d.ts +482 -0
- package/components/dropdown/dist/auro-dropdownBib.d.ts +128 -0
- package/components/dropdown/dist/dropdownBibKeyboardStrategy.d.ts +7 -0
- package/components/dropdown/dist/iconVersion.d.ts +2 -0
- package/components/dropdown/dist/index.d.ts +2 -0
- package/components/dropdown/dist/index.js +4847 -0
- package/components/dropdown/dist/registered.js +4847 -0
- package/components/dropdown/dist/styles/classic/bibColors-css.d.ts +2 -0
- package/components/dropdown/dist/styles/classic/bibStyles-css.d.ts +2 -0
- package/components/dropdown/dist/styles/classic/color-css.d.ts +2 -0
- package/components/dropdown/dist/styles/classic/style-css.d.ts +2 -0
- package/components/dropdown/dist/styles/color-css.d.ts +2 -0
- package/components/dropdown/dist/styles/emphasized/style-css.d.ts +2 -0
- package/components/dropdown/dist/styles/shapeSize-css.d.ts +2 -0
- package/components/dropdown/dist/styles/snowflake/style-css.d.ts +2 -0
- package/components/dropdown/dist/styles/style-css.d.ts +2 -0
- package/components/dropdown/dist/styles/tokens-css.d.ts +2 -0
- package/components/form/demo/api.md +319 -0
- package/components/form/demo/api.min.js +71170 -0
- package/components/form/demo/index.md +128 -0
- package/components/form/demo/index.min.js +71170 -0
- package/components/form/demo/keyboardBehavior.md +0 -0
- package/components/form/demo/readme.md +145 -0
- package/components/form/dist/auro-form.d.ts +280 -0
- package/components/form/dist/index.d.ts +2 -0
- package/components/form/dist/index.js +718 -0
- package/components/form/dist/registered.d.ts +1 -0
- package/components/form/dist/registered.js +718 -0
- package/components/form/dist/styles/style-css.d.ts +2 -0
- package/components/helptext/dist/auro-helptext.d.ts +69 -0
- package/components/helptext/dist/index.d.ts +2 -0
- package/components/helptext/dist/index.js +231 -0
- package/components/helptext/dist/registered.js +231 -0
- package/components/helptext/dist/styles/color-css.d.ts +2 -0
- package/components/helptext/dist/styles/style-css.d.ts +2 -0
- package/components/helptext/dist/styles/tokens-css.d.ts +2 -0
- package/components/input/demo/api.md +1397 -0
- package/components/input/demo/api.min.js +7473 -0
- package/components/input/demo/index.md +161 -0
- package/components/input/demo/index.min.js +7393 -0
- package/components/input/demo/keyboardBehavior.md +0 -0
- package/components/input/demo/readme.md +134 -0
- package/components/input/dist/auro-input.d.ts +207 -0
- package/components/input/dist/base-input.d.ts +628 -0
- package/components/input/dist/buttonVersion.d.ts +2 -0
- package/components/input/dist/i18n.d.ts +18 -0
- package/components/input/dist/iconVersion.d.ts +2 -0
- package/components/input/dist/index.d.ts +2 -0
- package/components/input/dist/index.js +7305 -0
- package/components/input/dist/registered.js +7305 -0
- package/components/input/dist/styles/classic/color-css.d.ts +2 -0
- package/components/input/dist/styles/classic/style-css.d.ts +2 -0
- package/components/input/dist/styles/color-css.d.ts +2 -0
- package/components/input/dist/styles/default/borders-css.d.ts +2 -0
- package/components/input/dist/styles/default/color-css.d.ts +2 -0
- package/components/input/dist/styles/default/mixins-css.d.ts +2 -0
- package/components/input/dist/styles/default/notificationIcons-css.d.ts +2 -0
- package/components/input/dist/styles/default/style-css.d.ts +2 -0
- package/components/input/dist/styles/emphasized/color-css.d.ts +2 -0
- package/components/input/dist/styles/emphasized/style-css.d.ts +2 -0
- package/components/input/dist/styles/mixins-css.d.ts +2 -0
- package/components/input/dist/styles/shapeSize-css.d.ts +2 -0
- package/components/input/dist/styles/snowflake/style-css.d.ts +2 -0
- package/components/input/dist/styles/style-css.d.ts +2 -0
- package/components/input/dist/styles/tokens-css.d.ts +2 -0
- package/components/input/dist/utilities.d.ts +25 -0
- package/components/layoutElement/dist/auroElement.d.ts +40 -0
- package/components/layoutElement/dist/index.d.ts +2 -0
- package/components/layoutElement/dist/index.js +107 -0
- package/components/layoutElement/dist/registered.js +107 -0
- package/components/menu/demo/api.md +1201 -0
- package/components/menu/demo/api.min.js +2397 -0
- package/components/menu/demo/index.md +72 -0
- package/components/menu/demo/index.min.js +2290 -0
- package/components/menu/demo/keyboardBehavior.md +0 -0
- package/components/menu/demo/readme.md +145 -0
- package/components/menu/dist/auro-menu-utils.d.ts +34 -0
- package/components/menu/dist/auro-menu.context.d.ts +239 -0
- package/components/menu/dist/auro-menu.d.ts +317 -0
- package/components/menu/dist/auro-menuoption.d.ts +210 -0
- package/components/menu/dist/iconVersion.d.ts +2 -0
- package/components/menu/dist/index.d.ts +4 -0
- package/components/menu/dist/index.js +2253 -0
- package/components/menu/dist/registered.js +2201 -0
- package/components/menu/dist/styles/default/color-menu-css.d.ts +2 -0
- package/components/menu/dist/styles/default/color-menuoption-css.d.ts +2 -0
- package/components/menu/dist/styles/default/style-menu-css.d.ts +2 -0
- package/components/menu/dist/styles/default/style-menuoption-css.d.ts +2 -0
- package/components/menu/dist/styles/default/tokens-css.d.ts +2 -0
- package/components/radio/demo/api.md +675 -0
- package/components/radio/demo/api.min.js +2210 -0
- package/components/radio/demo/index.md +73 -0
- package/components/radio/demo/index.min.js +2167 -0
- package/components/radio/demo/keyboardBehavior.md +0 -0
- package/components/radio/demo/readme.md +141 -0
- package/components/radio/dist/auro-radio-group.d.ts +250 -0
- package/components/radio/dist/auro-radio.d.ts +180 -0
- package/components/radio/dist/index.d.ts +3 -0
- package/components/radio/dist/index.js +2116 -0
- package/components/radio/dist/registered.js +2117 -0
- package/components/radio/dist/styles/auro-radio-group-css.d.ts +2 -0
- package/components/radio/dist/styles/color-css.d.ts +2 -0
- package/components/radio/dist/styles/groupColor-css.d.ts +2 -0
- package/components/radio/dist/styles/style-css.d.ts +2 -0
- package/components/radio/dist/styles/tokens-css.d.ts +2 -0
- package/components/select/demo/api.md +2378 -0
- package/components/select/demo/api.min.js +10542 -0
- package/components/select/demo/index.md +355 -0
- package/components/select/demo/index.min.js +10449 -0
- package/components/select/demo/keyboardBehavior.md +245 -0
- package/components/select/demo/readme.md +148 -0
- package/components/select/dist/auro-select.d.ts +553 -0
- package/components/select/dist/index.d.ts +2 -0
- package/components/select/dist/index.js +8376 -0
- package/components/select/dist/registered.js +8376 -0
- package/components/select/dist/selectKeyboardStrategy.d.ts +11 -0
- package/components/select/dist/styles/emphasized/color-css.d.ts +2 -0
- package/components/select/dist/styles/shapeSize-css.d.ts +2 -0
- package/components/select/dist/styles/style-css.d.ts +2 -0
- package/components/select/dist/styles/tokens-css.d.ts +2 -0
- package/custom-elements.json +18806 -0
- package/package.json +2 -2
|
@@ -0,0 +1,4847 @@
|
|
|
1
|
+
import { unsafeStatic, literal, html as html$1 } from 'lit/static-html.js';
|
|
2
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
3
|
+
import { createRef, ref } from 'lit/directives/ref.js';
|
|
4
|
+
import { css, html, LitElement } from 'lit';
|
|
5
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
|
+
import 'lit-html';
|
|
7
|
+
import 'lit-html/directives/unsafe-html.js';
|
|
8
|
+
|
|
9
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
10
|
+
// See LICENSE in the project root for license information.
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
/* eslint-disable line-comment-position, no-inline-comments, no-confusing-arrow, no-nested-ternary, implicit-arrow-linebreak */
|
|
15
|
+
|
|
16
|
+
let AuroLibraryRuntimeUtils$1 = class AuroLibraryRuntimeUtils {
|
|
17
|
+
|
|
18
|
+
/* eslint-disable jsdoc/require-param */
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This will register a new custom element with the browser.
|
|
22
|
+
* @param {String} name - The name of the custom element.
|
|
23
|
+
* @param {Object} componentClass - The class to register as a custom element.
|
|
24
|
+
* @returns {void}
|
|
25
|
+
*/
|
|
26
|
+
registerComponent(name, componentClass) {
|
|
27
|
+
if (!customElements.get(name)) {
|
|
28
|
+
customElements.define(name, class extends componentClass {});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Finds and returns the closest HTML Element based on a selector.
|
|
34
|
+
* @returns {void}
|
|
35
|
+
*/
|
|
36
|
+
closestElement(
|
|
37
|
+
selector, // selector like in .closest()
|
|
38
|
+
base = this, // extra functionality to skip a parent
|
|
39
|
+
__Closest = (el, found = el && el.closest(selector)) =>
|
|
40
|
+
!el || el === document || el === window
|
|
41
|
+
? null // standard .closest() returns null for non-found selectors also
|
|
42
|
+
: found
|
|
43
|
+
? found // found a selector INside this element
|
|
44
|
+
: __Closest(el.getRootNode().host) // recursion!! break out to parent DOM
|
|
45
|
+
) {
|
|
46
|
+
return __Closest(base);
|
|
47
|
+
}
|
|
48
|
+
/* eslint-enable jsdoc/require-param */
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* If the element passed is registered with a different tag name than what is passed in, the tag name is added as an attribute to the element.
|
|
52
|
+
* @param {Object} elem - The element to check.
|
|
53
|
+
* @param {String} tagName - The name of the Auro component to check for or add as an attribute.
|
|
54
|
+
* @returns {void}
|
|
55
|
+
*/
|
|
56
|
+
handleComponentTagRename(elem, tagName) {
|
|
57
|
+
const tag = tagName.toLowerCase();
|
|
58
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
59
|
+
|
|
60
|
+
if (elemTag !== tag) {
|
|
61
|
+
elem.setAttribute(tag, true);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Validates if an element is a specific Auro component.
|
|
67
|
+
* @param {Object} elem - The element to validate.
|
|
68
|
+
* @param {String} tagName - The name of the Auro component to check against.
|
|
69
|
+
* @returns {Boolean} - Returns true if the element is the specified Auro component.
|
|
70
|
+
*/
|
|
71
|
+
elementMatch(elem, tagName) {
|
|
72
|
+
const tag = tagName.toLowerCase();
|
|
73
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
74
|
+
|
|
75
|
+
return elemTag === tag || elem.hasAttribute(tag);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Gets the text content of a named slot.
|
|
80
|
+
* @returns {String}
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
getSlotText(elem, name) {
|
|
84
|
+
const slot = elem.shadowRoot?.querySelector(`slot[name="${name}"]`);
|
|
85
|
+
const nodes = slot?.assignedNodes({ flatten: true }) || [];
|
|
86
|
+
const text = nodes.map(n => n.textContent?.trim()).join(' ').trim();
|
|
87
|
+
|
|
88
|
+
return text || null;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Custom positioning reference element.
|
|
94
|
+
* @see https://floating-ui.com/docs/virtual-elements
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
const sides = ['top', 'right', 'bottom', 'left'];
|
|
98
|
+
const alignments = ['start', 'end'];
|
|
99
|
+
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
|
100
|
+
const min = Math.min;
|
|
101
|
+
const max = Math.max;
|
|
102
|
+
const round = Math.round;
|
|
103
|
+
const floor = Math.floor;
|
|
104
|
+
const createCoords = v => ({
|
|
105
|
+
x: v,
|
|
106
|
+
y: v
|
|
107
|
+
});
|
|
108
|
+
const oppositeSideMap = {
|
|
109
|
+
left: 'right',
|
|
110
|
+
right: 'left',
|
|
111
|
+
bottom: 'top',
|
|
112
|
+
top: 'bottom'
|
|
113
|
+
};
|
|
114
|
+
function clamp(start, value, end) {
|
|
115
|
+
return max(start, min(value, end));
|
|
116
|
+
}
|
|
117
|
+
function evaluate(value, param) {
|
|
118
|
+
return typeof value === 'function' ? value(param) : value;
|
|
119
|
+
}
|
|
120
|
+
function getSide(placement) {
|
|
121
|
+
return placement.split('-')[0];
|
|
122
|
+
}
|
|
123
|
+
function getAlignment(placement) {
|
|
124
|
+
return placement.split('-')[1];
|
|
125
|
+
}
|
|
126
|
+
function getOppositeAxis(axis) {
|
|
127
|
+
return axis === 'x' ? 'y' : 'x';
|
|
128
|
+
}
|
|
129
|
+
function getAxisLength(axis) {
|
|
130
|
+
return axis === 'y' ? 'height' : 'width';
|
|
131
|
+
}
|
|
132
|
+
function getSideAxis(placement) {
|
|
133
|
+
const firstChar = placement[0];
|
|
134
|
+
return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';
|
|
135
|
+
}
|
|
136
|
+
function getAlignmentAxis(placement) {
|
|
137
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
138
|
+
}
|
|
139
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
140
|
+
if (rtl === void 0) {
|
|
141
|
+
rtl = false;
|
|
142
|
+
}
|
|
143
|
+
const alignment = getAlignment(placement);
|
|
144
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
145
|
+
const length = getAxisLength(alignmentAxis);
|
|
146
|
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
147
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
148
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
149
|
+
}
|
|
150
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
151
|
+
}
|
|
152
|
+
function getExpandedPlacements(placement) {
|
|
153
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
154
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
155
|
+
}
|
|
156
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
157
|
+
return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
|
|
158
|
+
}
|
|
159
|
+
const lrPlacement = ['left', 'right'];
|
|
160
|
+
const rlPlacement = ['right', 'left'];
|
|
161
|
+
const tbPlacement = ['top', 'bottom'];
|
|
162
|
+
const btPlacement = ['bottom', 'top'];
|
|
163
|
+
function getSideList(side, isStart, rtl) {
|
|
164
|
+
switch (side) {
|
|
165
|
+
case 'top':
|
|
166
|
+
case 'bottom':
|
|
167
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
168
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
169
|
+
case 'left':
|
|
170
|
+
case 'right':
|
|
171
|
+
return isStart ? tbPlacement : btPlacement;
|
|
172
|
+
default:
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
177
|
+
const alignment = getAlignment(placement);
|
|
178
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
179
|
+
if (alignment) {
|
|
180
|
+
list = list.map(side => side + "-" + alignment);
|
|
181
|
+
if (flipAlignment) {
|
|
182
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return list;
|
|
186
|
+
}
|
|
187
|
+
function getOppositePlacement(placement) {
|
|
188
|
+
const side = getSide(placement);
|
|
189
|
+
return oppositeSideMap[side] + placement.slice(side.length);
|
|
190
|
+
}
|
|
191
|
+
function expandPaddingObject(padding) {
|
|
192
|
+
return {
|
|
193
|
+
top: 0,
|
|
194
|
+
right: 0,
|
|
195
|
+
bottom: 0,
|
|
196
|
+
left: 0,
|
|
197
|
+
...padding
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function getPaddingObject(padding) {
|
|
201
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
202
|
+
top: padding,
|
|
203
|
+
right: padding,
|
|
204
|
+
bottom: padding,
|
|
205
|
+
left: padding
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function rectToClientRect(rect) {
|
|
209
|
+
const {
|
|
210
|
+
x,
|
|
211
|
+
y,
|
|
212
|
+
width,
|
|
213
|
+
height
|
|
214
|
+
} = rect;
|
|
215
|
+
return {
|
|
216
|
+
width,
|
|
217
|
+
height,
|
|
218
|
+
top: y,
|
|
219
|
+
left: x,
|
|
220
|
+
right: x + width,
|
|
221
|
+
bottom: y + height,
|
|
222
|
+
x,
|
|
223
|
+
y
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
228
|
+
let {
|
|
229
|
+
reference,
|
|
230
|
+
floating
|
|
231
|
+
} = _ref;
|
|
232
|
+
const sideAxis = getSideAxis(placement);
|
|
233
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
234
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
235
|
+
const side = getSide(placement);
|
|
236
|
+
const isVertical = sideAxis === 'y';
|
|
237
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
238
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
239
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
240
|
+
let coords;
|
|
241
|
+
switch (side) {
|
|
242
|
+
case 'top':
|
|
243
|
+
coords = {
|
|
244
|
+
x: commonX,
|
|
245
|
+
y: reference.y - floating.height
|
|
246
|
+
};
|
|
247
|
+
break;
|
|
248
|
+
case 'bottom':
|
|
249
|
+
coords = {
|
|
250
|
+
x: commonX,
|
|
251
|
+
y: reference.y + reference.height
|
|
252
|
+
};
|
|
253
|
+
break;
|
|
254
|
+
case 'right':
|
|
255
|
+
coords = {
|
|
256
|
+
x: reference.x + reference.width,
|
|
257
|
+
y: commonY
|
|
258
|
+
};
|
|
259
|
+
break;
|
|
260
|
+
case 'left':
|
|
261
|
+
coords = {
|
|
262
|
+
x: reference.x - floating.width,
|
|
263
|
+
y: commonY
|
|
264
|
+
};
|
|
265
|
+
break;
|
|
266
|
+
default:
|
|
267
|
+
coords = {
|
|
268
|
+
x: reference.x,
|
|
269
|
+
y: reference.y
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
switch (getAlignment(placement)) {
|
|
273
|
+
case 'start':
|
|
274
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
275
|
+
break;
|
|
276
|
+
case 'end':
|
|
277
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
return coords;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
285
|
+
* element is overflowing a given clipping boundary on each side.
|
|
286
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
287
|
+
* - negative = how many pixels left before it will overflow
|
|
288
|
+
* - 0 = lies flush with the boundary
|
|
289
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
290
|
+
*/
|
|
291
|
+
async function detectOverflow(state, options) {
|
|
292
|
+
var _await$platform$isEle;
|
|
293
|
+
if (options === void 0) {
|
|
294
|
+
options = {};
|
|
295
|
+
}
|
|
296
|
+
const {
|
|
297
|
+
x,
|
|
298
|
+
y,
|
|
299
|
+
platform,
|
|
300
|
+
rects,
|
|
301
|
+
elements,
|
|
302
|
+
strategy
|
|
303
|
+
} = state;
|
|
304
|
+
const {
|
|
305
|
+
boundary = 'clippingAncestors',
|
|
306
|
+
rootBoundary = 'viewport',
|
|
307
|
+
elementContext = 'floating',
|
|
308
|
+
altBoundary = false,
|
|
309
|
+
padding = 0
|
|
310
|
+
} = evaluate(options, state);
|
|
311
|
+
const paddingObject = getPaddingObject(padding);
|
|
312
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
313
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
314
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
315
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
316
|
+
boundary,
|
|
317
|
+
rootBoundary,
|
|
318
|
+
strategy
|
|
319
|
+
}));
|
|
320
|
+
const rect = elementContext === 'floating' ? {
|
|
321
|
+
x,
|
|
322
|
+
y,
|
|
323
|
+
width: rects.floating.width,
|
|
324
|
+
height: rects.floating.height
|
|
325
|
+
} : rects.reference;
|
|
326
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
327
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
328
|
+
x: 1,
|
|
329
|
+
y: 1
|
|
330
|
+
} : {
|
|
331
|
+
x: 1,
|
|
332
|
+
y: 1
|
|
333
|
+
};
|
|
334
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
335
|
+
elements,
|
|
336
|
+
rect,
|
|
337
|
+
offsetParent,
|
|
338
|
+
strategy
|
|
339
|
+
}) : rect);
|
|
340
|
+
return {
|
|
341
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
342
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
343
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
344
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Maximum number of resets that can occur before bailing to avoid infinite reset loops.
|
|
349
|
+
const MAX_RESET_COUNT = 50;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
353
|
+
* next to a given reference element.
|
|
354
|
+
*
|
|
355
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
356
|
+
* write one for the platform you are using Floating UI with.
|
|
357
|
+
*/
|
|
358
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
359
|
+
const {
|
|
360
|
+
placement = 'bottom',
|
|
361
|
+
strategy = 'absolute',
|
|
362
|
+
middleware = [],
|
|
363
|
+
platform
|
|
364
|
+
} = config;
|
|
365
|
+
const platformWithDetectOverflow = platform.detectOverflow ? platform : {
|
|
366
|
+
...platform,
|
|
367
|
+
detectOverflow
|
|
368
|
+
};
|
|
369
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
370
|
+
let rects = await platform.getElementRects({
|
|
371
|
+
reference,
|
|
372
|
+
floating,
|
|
373
|
+
strategy
|
|
374
|
+
});
|
|
375
|
+
let {
|
|
376
|
+
x,
|
|
377
|
+
y
|
|
378
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
379
|
+
let statefulPlacement = placement;
|
|
380
|
+
let resetCount = 0;
|
|
381
|
+
const middlewareData = {};
|
|
382
|
+
for (let i = 0; i < middleware.length; i++) {
|
|
383
|
+
const currentMiddleware = middleware[i];
|
|
384
|
+
if (!currentMiddleware) {
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
const {
|
|
388
|
+
name,
|
|
389
|
+
fn
|
|
390
|
+
} = currentMiddleware;
|
|
391
|
+
const {
|
|
392
|
+
x: nextX,
|
|
393
|
+
y: nextY,
|
|
394
|
+
data,
|
|
395
|
+
reset
|
|
396
|
+
} = await fn({
|
|
397
|
+
x,
|
|
398
|
+
y,
|
|
399
|
+
initialPlacement: placement,
|
|
400
|
+
placement: statefulPlacement,
|
|
401
|
+
strategy,
|
|
402
|
+
middlewareData,
|
|
403
|
+
rects,
|
|
404
|
+
platform: platformWithDetectOverflow,
|
|
405
|
+
elements: {
|
|
406
|
+
reference,
|
|
407
|
+
floating
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
x = nextX != null ? nextX : x;
|
|
411
|
+
y = nextY != null ? nextY : y;
|
|
412
|
+
middlewareData[name] = {
|
|
413
|
+
...middlewareData[name],
|
|
414
|
+
...data
|
|
415
|
+
};
|
|
416
|
+
if (reset && resetCount < MAX_RESET_COUNT) {
|
|
417
|
+
resetCount++;
|
|
418
|
+
if (typeof reset === 'object') {
|
|
419
|
+
if (reset.placement) {
|
|
420
|
+
statefulPlacement = reset.placement;
|
|
421
|
+
}
|
|
422
|
+
if (reset.rects) {
|
|
423
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
424
|
+
reference,
|
|
425
|
+
floating,
|
|
426
|
+
strategy
|
|
427
|
+
}) : reset.rects;
|
|
428
|
+
}
|
|
429
|
+
({
|
|
430
|
+
x,
|
|
431
|
+
y
|
|
432
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
433
|
+
}
|
|
434
|
+
i = -1;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return {
|
|
438
|
+
x,
|
|
439
|
+
y,
|
|
440
|
+
placement: statefulPlacement,
|
|
441
|
+
strategy,
|
|
442
|
+
middlewareData
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
447
|
+
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
|
|
448
|
+
return allowedPlacementsSortedByAlignment.filter(placement => {
|
|
449
|
+
if (alignment) {
|
|
450
|
+
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
451
|
+
}
|
|
452
|
+
return true;
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Optimizes the visibility of the floating element by choosing the placement
|
|
457
|
+
* that has the most space available automatically, without needing to specify a
|
|
458
|
+
* preferred placement. Alternative to `flip`.
|
|
459
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
460
|
+
*/
|
|
461
|
+
const autoPlacement$1 = function (options) {
|
|
462
|
+
if (options === void 0) {
|
|
463
|
+
options = {};
|
|
464
|
+
}
|
|
465
|
+
return {
|
|
466
|
+
name: 'autoPlacement',
|
|
467
|
+
options,
|
|
468
|
+
async fn(state) {
|
|
469
|
+
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
|
470
|
+
const {
|
|
471
|
+
rects,
|
|
472
|
+
middlewareData,
|
|
473
|
+
placement,
|
|
474
|
+
platform,
|
|
475
|
+
elements
|
|
476
|
+
} = state;
|
|
477
|
+
const {
|
|
478
|
+
crossAxis = false,
|
|
479
|
+
alignment,
|
|
480
|
+
allowedPlacements = placements,
|
|
481
|
+
autoAlignment = true,
|
|
482
|
+
...detectOverflowOptions
|
|
483
|
+
} = evaluate(options, state);
|
|
484
|
+
const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
|
485
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
486
|
+
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
|
487
|
+
const currentPlacement = placements$1[currentIndex];
|
|
488
|
+
if (currentPlacement == null) {
|
|
489
|
+
return {};
|
|
490
|
+
}
|
|
491
|
+
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
492
|
+
|
|
493
|
+
// Make `computeCoords` start from the right place.
|
|
494
|
+
if (placement !== currentPlacement) {
|
|
495
|
+
return {
|
|
496
|
+
reset: {
|
|
497
|
+
placement: placements$1[0]
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
|
502
|
+
const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
|
|
503
|
+
placement: currentPlacement,
|
|
504
|
+
overflows: currentOverflows
|
|
505
|
+
}];
|
|
506
|
+
const nextPlacement = placements$1[currentIndex + 1];
|
|
507
|
+
|
|
508
|
+
// There are more placements to check.
|
|
509
|
+
if (nextPlacement) {
|
|
510
|
+
return {
|
|
511
|
+
data: {
|
|
512
|
+
index: currentIndex + 1,
|
|
513
|
+
overflows: allOverflows
|
|
514
|
+
},
|
|
515
|
+
reset: {
|
|
516
|
+
placement: nextPlacement
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
const placementsSortedByMostSpace = allOverflows.map(d => {
|
|
521
|
+
const alignment = getAlignment(d.placement);
|
|
522
|
+
return [d.placement, alignment && crossAxis ?
|
|
523
|
+
// Check along the mainAxis and main crossAxis side.
|
|
524
|
+
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
|
|
525
|
+
// Check only the mainAxis.
|
|
526
|
+
d.overflows[0], d.overflows];
|
|
527
|
+
}).sort((a, b) => a[1] - b[1]);
|
|
528
|
+
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
|
|
529
|
+
// Aligned placements should not check their opposite crossAxis
|
|
530
|
+
// side.
|
|
531
|
+
getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
|
|
532
|
+
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
|
533
|
+
if (resetPlacement !== placement) {
|
|
534
|
+
return {
|
|
535
|
+
data: {
|
|
536
|
+
index: currentIndex + 1,
|
|
537
|
+
overflows: allOverflows
|
|
538
|
+
},
|
|
539
|
+
reset: {
|
|
540
|
+
placement: resetPlacement
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
return {};
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
551
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
552
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
553
|
+
* @see https://floating-ui.com/docs/flip
|
|
554
|
+
*/
|
|
555
|
+
const flip$1 = function (options) {
|
|
556
|
+
if (options === void 0) {
|
|
557
|
+
options = {};
|
|
558
|
+
}
|
|
559
|
+
return {
|
|
560
|
+
name: 'flip',
|
|
561
|
+
options,
|
|
562
|
+
async fn(state) {
|
|
563
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
564
|
+
const {
|
|
565
|
+
placement,
|
|
566
|
+
middlewareData,
|
|
567
|
+
rects,
|
|
568
|
+
initialPlacement,
|
|
569
|
+
platform,
|
|
570
|
+
elements
|
|
571
|
+
} = state;
|
|
572
|
+
const {
|
|
573
|
+
mainAxis: checkMainAxis = true,
|
|
574
|
+
crossAxis: checkCrossAxis = true,
|
|
575
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
576
|
+
fallbackStrategy = 'bestFit',
|
|
577
|
+
fallbackAxisSideDirection = 'none',
|
|
578
|
+
flipAlignment = true,
|
|
579
|
+
...detectOverflowOptions
|
|
580
|
+
} = evaluate(options, state);
|
|
581
|
+
|
|
582
|
+
// If a reset by the arrow was caused due to an alignment offset being
|
|
583
|
+
// added, we should skip any logic now since `flip()` has already done its
|
|
584
|
+
// work.
|
|
585
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
|
586
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
587
|
+
return {};
|
|
588
|
+
}
|
|
589
|
+
const side = getSide(placement);
|
|
590
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
591
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
592
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
593
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
594
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
|
595
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
596
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
597
|
+
}
|
|
598
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
599
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
600
|
+
const overflows = [];
|
|
601
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
602
|
+
if (checkMainAxis) {
|
|
603
|
+
overflows.push(overflow[side]);
|
|
604
|
+
}
|
|
605
|
+
if (checkCrossAxis) {
|
|
606
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
607
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
608
|
+
}
|
|
609
|
+
overflowsData = [...overflowsData, {
|
|
610
|
+
placement,
|
|
611
|
+
overflows
|
|
612
|
+
}];
|
|
613
|
+
|
|
614
|
+
// One or more sides is overflowing.
|
|
615
|
+
if (!overflows.every(side => side <= 0)) {
|
|
616
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
617
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
618
|
+
const nextPlacement = placements[nextIndex];
|
|
619
|
+
if (nextPlacement) {
|
|
620
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
621
|
+
if (!ignoreCrossAxisOverflow ||
|
|
622
|
+
// We leave the current main axis only if every placement on that axis
|
|
623
|
+
// overflows the main axis.
|
|
624
|
+
overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
625
|
+
// Try next placement and re-run the lifecycle.
|
|
626
|
+
return {
|
|
627
|
+
data: {
|
|
628
|
+
index: nextIndex,
|
|
629
|
+
overflows: overflowsData
|
|
630
|
+
},
|
|
631
|
+
reset: {
|
|
632
|
+
placement: nextPlacement
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
639
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
640
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
641
|
+
|
|
642
|
+
// Otherwise fallback.
|
|
643
|
+
if (!resetPlacement) {
|
|
644
|
+
switch (fallbackStrategy) {
|
|
645
|
+
case 'bestFit':
|
|
646
|
+
{
|
|
647
|
+
var _overflowsData$filter2;
|
|
648
|
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
|
649
|
+
if (hasFallbackAxisSideDirection) {
|
|
650
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
651
|
+
return currentSideAxis === initialSideAxis ||
|
|
652
|
+
// Create a bias to the `y` side axis due to horizontal
|
|
653
|
+
// reading directions favoring greater width.
|
|
654
|
+
currentSideAxis === 'y';
|
|
655
|
+
}
|
|
656
|
+
return true;
|
|
657
|
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
658
|
+
if (placement) {
|
|
659
|
+
resetPlacement = placement;
|
|
660
|
+
}
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
case 'initialPlacement':
|
|
664
|
+
resetPlacement = initialPlacement;
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
if (placement !== resetPlacement) {
|
|
669
|
+
return {
|
|
670
|
+
reset: {
|
|
671
|
+
placement: resetPlacement
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
return {};
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
const originSides = /*#__PURE__*/new Set(['left', 'top']);
|
|
682
|
+
|
|
683
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
684
|
+
// Derivable.
|
|
685
|
+
|
|
686
|
+
async function convertValueToCoords(state, options) {
|
|
687
|
+
const {
|
|
688
|
+
placement,
|
|
689
|
+
platform,
|
|
690
|
+
elements
|
|
691
|
+
} = state;
|
|
692
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
693
|
+
const side = getSide(placement);
|
|
694
|
+
const alignment = getAlignment(placement);
|
|
695
|
+
const isVertical = getSideAxis(placement) === 'y';
|
|
696
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
697
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
698
|
+
const rawValue = evaluate(options, state);
|
|
699
|
+
|
|
700
|
+
// eslint-disable-next-line prefer-const
|
|
701
|
+
let {
|
|
702
|
+
mainAxis,
|
|
703
|
+
crossAxis,
|
|
704
|
+
alignmentAxis
|
|
705
|
+
} = typeof rawValue === 'number' ? {
|
|
706
|
+
mainAxis: rawValue,
|
|
707
|
+
crossAxis: 0,
|
|
708
|
+
alignmentAxis: null
|
|
709
|
+
} : {
|
|
710
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
711
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
712
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
713
|
+
};
|
|
714
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
|
715
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
716
|
+
}
|
|
717
|
+
return isVertical ? {
|
|
718
|
+
x: crossAxis * crossAxisMulti,
|
|
719
|
+
y: mainAxis * mainAxisMulti
|
|
720
|
+
} : {
|
|
721
|
+
x: mainAxis * mainAxisMulti,
|
|
722
|
+
y: crossAxis * crossAxisMulti
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Modifies the placement by translating the floating element along the
|
|
728
|
+
* specified axes.
|
|
729
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
730
|
+
* object may be passed.
|
|
731
|
+
* @see https://floating-ui.com/docs/offset
|
|
732
|
+
*/
|
|
733
|
+
const offset$1 = function (options) {
|
|
734
|
+
if (options === void 0) {
|
|
735
|
+
options = 0;
|
|
736
|
+
}
|
|
737
|
+
return {
|
|
738
|
+
name: 'offset',
|
|
739
|
+
options,
|
|
740
|
+
async fn(state) {
|
|
741
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
742
|
+
const {
|
|
743
|
+
x,
|
|
744
|
+
y,
|
|
745
|
+
placement,
|
|
746
|
+
middlewareData
|
|
747
|
+
} = state;
|
|
748
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
749
|
+
|
|
750
|
+
// If the placement is the same and the arrow caused an alignment offset
|
|
751
|
+
// then we don't need to change the positioning coordinates.
|
|
752
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
753
|
+
return {};
|
|
754
|
+
}
|
|
755
|
+
return {
|
|
756
|
+
x: x + diffCoords.x,
|
|
757
|
+
y: y + diffCoords.y,
|
|
758
|
+
data: {
|
|
759
|
+
...diffCoords,
|
|
760
|
+
placement
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
769
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
770
|
+
* @see https://floating-ui.com/docs/shift
|
|
771
|
+
*/
|
|
772
|
+
const shift$1 = function (options) {
|
|
773
|
+
if (options === void 0) {
|
|
774
|
+
options = {};
|
|
775
|
+
}
|
|
776
|
+
return {
|
|
777
|
+
name: 'shift',
|
|
778
|
+
options,
|
|
779
|
+
async fn(state) {
|
|
780
|
+
const {
|
|
781
|
+
x,
|
|
782
|
+
y,
|
|
783
|
+
placement,
|
|
784
|
+
platform
|
|
785
|
+
} = state;
|
|
786
|
+
const {
|
|
787
|
+
mainAxis: checkMainAxis = true,
|
|
788
|
+
crossAxis: checkCrossAxis = false,
|
|
789
|
+
limiter = {
|
|
790
|
+
fn: _ref => {
|
|
791
|
+
let {
|
|
792
|
+
x,
|
|
793
|
+
y
|
|
794
|
+
} = _ref;
|
|
795
|
+
return {
|
|
796
|
+
x,
|
|
797
|
+
y
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
...detectOverflowOptions
|
|
802
|
+
} = evaluate(options, state);
|
|
803
|
+
const coords = {
|
|
804
|
+
x,
|
|
805
|
+
y
|
|
806
|
+
};
|
|
807
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
808
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
809
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
810
|
+
let mainAxisCoord = coords[mainAxis];
|
|
811
|
+
let crossAxisCoord = coords[crossAxis];
|
|
812
|
+
if (checkMainAxis) {
|
|
813
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
814
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
815
|
+
const min = mainAxisCoord + overflow[minSide];
|
|
816
|
+
const max = mainAxisCoord - overflow[maxSide];
|
|
817
|
+
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
818
|
+
}
|
|
819
|
+
if (checkCrossAxis) {
|
|
820
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
821
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
822
|
+
const min = crossAxisCoord + overflow[minSide];
|
|
823
|
+
const max = crossAxisCoord - overflow[maxSide];
|
|
824
|
+
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
825
|
+
}
|
|
826
|
+
const limitedCoords = limiter.fn({
|
|
827
|
+
...state,
|
|
828
|
+
[mainAxis]: mainAxisCoord,
|
|
829
|
+
[crossAxis]: crossAxisCoord
|
|
830
|
+
});
|
|
831
|
+
return {
|
|
832
|
+
...limitedCoords,
|
|
833
|
+
data: {
|
|
834
|
+
x: limitedCoords.x - x,
|
|
835
|
+
y: limitedCoords.y - y,
|
|
836
|
+
enabled: {
|
|
837
|
+
[mainAxis]: checkMainAxis,
|
|
838
|
+
[crossAxis]: checkCrossAxis
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
function hasWindow() {
|
|
847
|
+
return typeof window !== 'undefined';
|
|
848
|
+
}
|
|
849
|
+
function getNodeName(node) {
|
|
850
|
+
if (isNode(node)) {
|
|
851
|
+
return (node.nodeName || '').toLowerCase();
|
|
852
|
+
}
|
|
853
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
854
|
+
// returning `#document` an infinite loop won't occur.
|
|
855
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
856
|
+
return '#document';
|
|
857
|
+
}
|
|
858
|
+
function getWindow(node) {
|
|
859
|
+
var _node$ownerDocument;
|
|
860
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
861
|
+
}
|
|
862
|
+
function getDocumentElement(node) {
|
|
863
|
+
var _ref;
|
|
864
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
865
|
+
}
|
|
866
|
+
function isNode(value) {
|
|
867
|
+
if (!hasWindow()) {
|
|
868
|
+
return false;
|
|
869
|
+
}
|
|
870
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
871
|
+
}
|
|
872
|
+
function isElement(value) {
|
|
873
|
+
if (!hasWindow()) {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
877
|
+
}
|
|
878
|
+
function isHTMLElement(value) {
|
|
879
|
+
if (!hasWindow()) {
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
883
|
+
}
|
|
884
|
+
function isShadowRoot(value) {
|
|
885
|
+
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
889
|
+
}
|
|
890
|
+
function isOverflowElement(element) {
|
|
891
|
+
const {
|
|
892
|
+
overflow,
|
|
893
|
+
overflowX,
|
|
894
|
+
overflowY,
|
|
895
|
+
display
|
|
896
|
+
} = getComputedStyle$1(element);
|
|
897
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';
|
|
898
|
+
}
|
|
899
|
+
function isTableElement(element) {
|
|
900
|
+
return /^(table|td|th)$/.test(getNodeName(element));
|
|
901
|
+
}
|
|
902
|
+
function isTopLayer(element) {
|
|
903
|
+
try {
|
|
904
|
+
if (element.matches(':popover-open')) {
|
|
905
|
+
return true;
|
|
906
|
+
}
|
|
907
|
+
} catch (_e) {
|
|
908
|
+
// no-op
|
|
909
|
+
}
|
|
910
|
+
try {
|
|
911
|
+
return element.matches(':modal');
|
|
912
|
+
} catch (_e) {
|
|
913
|
+
return false;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
|
|
917
|
+
const containRe = /paint|layout|strict|content/;
|
|
918
|
+
const isNotNone = value => !!value && value !== 'none';
|
|
919
|
+
let isWebKitValue;
|
|
920
|
+
function isContainingBlock(elementOrCss) {
|
|
921
|
+
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
922
|
+
|
|
923
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
924
|
+
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
|
925
|
+
return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');
|
|
926
|
+
}
|
|
927
|
+
function getContainingBlock(element) {
|
|
928
|
+
let currentNode = getParentNode(element);
|
|
929
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
930
|
+
if (isContainingBlock(currentNode)) {
|
|
931
|
+
return currentNode;
|
|
932
|
+
} else if (isTopLayer(currentNode)) {
|
|
933
|
+
return null;
|
|
934
|
+
}
|
|
935
|
+
currentNode = getParentNode(currentNode);
|
|
936
|
+
}
|
|
937
|
+
return null;
|
|
938
|
+
}
|
|
939
|
+
function isWebKit() {
|
|
940
|
+
if (isWebKitValue == null) {
|
|
941
|
+
isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');
|
|
942
|
+
}
|
|
943
|
+
return isWebKitValue;
|
|
944
|
+
}
|
|
945
|
+
function isLastTraversableNode(node) {
|
|
946
|
+
return /^(html|body|#document)$/.test(getNodeName(node));
|
|
947
|
+
}
|
|
948
|
+
function getComputedStyle$1(element) {
|
|
949
|
+
return getWindow(element).getComputedStyle(element);
|
|
950
|
+
}
|
|
951
|
+
function getNodeScroll(element) {
|
|
952
|
+
if (isElement(element)) {
|
|
953
|
+
return {
|
|
954
|
+
scrollLeft: element.scrollLeft,
|
|
955
|
+
scrollTop: element.scrollTop
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
return {
|
|
959
|
+
scrollLeft: element.scrollX,
|
|
960
|
+
scrollTop: element.scrollY
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
function getParentNode(node) {
|
|
964
|
+
if (getNodeName(node) === 'html') {
|
|
965
|
+
return node;
|
|
966
|
+
}
|
|
967
|
+
const result =
|
|
968
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
969
|
+
node.assignedSlot ||
|
|
970
|
+
// DOM Element detected.
|
|
971
|
+
node.parentNode ||
|
|
972
|
+
// ShadowRoot detected.
|
|
973
|
+
isShadowRoot(node) && node.host ||
|
|
974
|
+
// Fallback.
|
|
975
|
+
getDocumentElement(node);
|
|
976
|
+
return isShadowRoot(result) ? result.host : result;
|
|
977
|
+
}
|
|
978
|
+
function getNearestOverflowAncestor(node) {
|
|
979
|
+
const parentNode = getParentNode(node);
|
|
980
|
+
if (isLastTraversableNode(parentNode)) {
|
|
981
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
982
|
+
}
|
|
983
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
984
|
+
return parentNode;
|
|
985
|
+
}
|
|
986
|
+
return getNearestOverflowAncestor(parentNode);
|
|
987
|
+
}
|
|
988
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
989
|
+
var _node$ownerDocument2;
|
|
990
|
+
if (list === void 0) {
|
|
991
|
+
list = [];
|
|
992
|
+
}
|
|
993
|
+
if (traverseIframes === void 0) {
|
|
994
|
+
traverseIframes = true;
|
|
995
|
+
}
|
|
996
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
997
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
998
|
+
const win = getWindow(scrollableAncestor);
|
|
999
|
+
if (isBody) {
|
|
1000
|
+
const frameElement = getFrameElement(win);
|
|
1001
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
1002
|
+
} else {
|
|
1003
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
function getFrameElement(win) {
|
|
1007
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
function getCssDimensions(element) {
|
|
1011
|
+
const css = getComputedStyle$1(element);
|
|
1012
|
+
// In testing environments, the `width` and `height` properties are empty
|
|
1013
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
1014
|
+
let width = parseFloat(css.width) || 0;
|
|
1015
|
+
let height = parseFloat(css.height) || 0;
|
|
1016
|
+
const hasOffset = isHTMLElement(element);
|
|
1017
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1018
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1019
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1020
|
+
if (shouldFallback) {
|
|
1021
|
+
width = offsetWidth;
|
|
1022
|
+
height = offsetHeight;
|
|
1023
|
+
}
|
|
1024
|
+
return {
|
|
1025
|
+
width,
|
|
1026
|
+
height,
|
|
1027
|
+
$: shouldFallback
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
function unwrapElement(element) {
|
|
1032
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
function getScale(element) {
|
|
1036
|
+
const domElement = unwrapElement(element);
|
|
1037
|
+
if (!isHTMLElement(domElement)) {
|
|
1038
|
+
return createCoords(1);
|
|
1039
|
+
}
|
|
1040
|
+
const rect = domElement.getBoundingClientRect();
|
|
1041
|
+
const {
|
|
1042
|
+
width,
|
|
1043
|
+
height,
|
|
1044
|
+
$
|
|
1045
|
+
} = getCssDimensions(domElement);
|
|
1046
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
1047
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
1048
|
+
|
|
1049
|
+
// 0, NaN, or Infinity should always fallback to 1.
|
|
1050
|
+
|
|
1051
|
+
if (!x || !Number.isFinite(x)) {
|
|
1052
|
+
x = 1;
|
|
1053
|
+
}
|
|
1054
|
+
if (!y || !Number.isFinite(y)) {
|
|
1055
|
+
y = 1;
|
|
1056
|
+
}
|
|
1057
|
+
return {
|
|
1058
|
+
x,
|
|
1059
|
+
y
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
1064
|
+
function getVisualOffsets(element) {
|
|
1065
|
+
const win = getWindow(element);
|
|
1066
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
1067
|
+
return noOffsets;
|
|
1068
|
+
}
|
|
1069
|
+
return {
|
|
1070
|
+
x: win.visualViewport.offsetLeft,
|
|
1071
|
+
y: win.visualViewport.offsetTop
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1075
|
+
if (isFixed === void 0) {
|
|
1076
|
+
isFixed = false;
|
|
1077
|
+
}
|
|
1078
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
1079
|
+
return false;
|
|
1080
|
+
}
|
|
1081
|
+
return isFixed;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1085
|
+
if (includeScale === void 0) {
|
|
1086
|
+
includeScale = false;
|
|
1087
|
+
}
|
|
1088
|
+
if (isFixedStrategy === void 0) {
|
|
1089
|
+
isFixedStrategy = false;
|
|
1090
|
+
}
|
|
1091
|
+
const clientRect = element.getBoundingClientRect();
|
|
1092
|
+
const domElement = unwrapElement(element);
|
|
1093
|
+
let scale = createCoords(1);
|
|
1094
|
+
if (includeScale) {
|
|
1095
|
+
if (offsetParent) {
|
|
1096
|
+
if (isElement(offsetParent)) {
|
|
1097
|
+
scale = getScale(offsetParent);
|
|
1098
|
+
}
|
|
1099
|
+
} else {
|
|
1100
|
+
scale = getScale(element);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1104
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1105
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1106
|
+
let width = clientRect.width / scale.x;
|
|
1107
|
+
let height = clientRect.height / scale.y;
|
|
1108
|
+
if (domElement) {
|
|
1109
|
+
const win = getWindow(domElement);
|
|
1110
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1111
|
+
let currentWin = win;
|
|
1112
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
1113
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1114
|
+
const iframeScale = getScale(currentIFrame);
|
|
1115
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1116
|
+
const css = getComputedStyle$1(currentIFrame);
|
|
1117
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1118
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1119
|
+
x *= iframeScale.x;
|
|
1120
|
+
y *= iframeScale.y;
|
|
1121
|
+
width *= iframeScale.x;
|
|
1122
|
+
height *= iframeScale.y;
|
|
1123
|
+
x += left;
|
|
1124
|
+
y += top;
|
|
1125
|
+
currentWin = getWindow(currentIFrame);
|
|
1126
|
+
currentIFrame = getFrameElement(currentWin);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
return rectToClientRect({
|
|
1130
|
+
width,
|
|
1131
|
+
height,
|
|
1132
|
+
x,
|
|
1133
|
+
y
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
1138
|
+
// incorrect for RTL.
|
|
1139
|
+
function getWindowScrollBarX(element, rect) {
|
|
1140
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
1141
|
+
if (!rect) {
|
|
1142
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
1143
|
+
}
|
|
1144
|
+
return rect.left + leftScroll;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
1148
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
1149
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
1150
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
1151
|
+
return {
|
|
1152
|
+
x,
|
|
1153
|
+
y
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1158
|
+
let {
|
|
1159
|
+
elements,
|
|
1160
|
+
rect,
|
|
1161
|
+
offsetParent,
|
|
1162
|
+
strategy
|
|
1163
|
+
} = _ref;
|
|
1164
|
+
const isFixed = strategy === 'fixed';
|
|
1165
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1166
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
1167
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1168
|
+
return rect;
|
|
1169
|
+
}
|
|
1170
|
+
let scroll = {
|
|
1171
|
+
scrollLeft: 0,
|
|
1172
|
+
scrollTop: 0
|
|
1173
|
+
};
|
|
1174
|
+
let scale = createCoords(1);
|
|
1175
|
+
const offsets = createCoords(0);
|
|
1176
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1177
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1178
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1179
|
+
scroll = getNodeScroll(offsetParent);
|
|
1180
|
+
}
|
|
1181
|
+
if (isOffsetParentAnElement) {
|
|
1182
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1183
|
+
scale = getScale(offsetParent);
|
|
1184
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1185
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1189
|
+
return {
|
|
1190
|
+
width: rect.width * scale.x,
|
|
1191
|
+
height: rect.height * scale.y,
|
|
1192
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
1193
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
function getClientRects(element) {
|
|
1198
|
+
return Array.from(element.getClientRects());
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
|
1202
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
1203
|
+
function getDocumentRect(element) {
|
|
1204
|
+
const html = getDocumentElement(element);
|
|
1205
|
+
const scroll = getNodeScroll(element);
|
|
1206
|
+
const body = element.ownerDocument.body;
|
|
1207
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1208
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1209
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1210
|
+
const y = -scroll.scrollTop;
|
|
1211
|
+
if (getComputedStyle$1(body).direction === 'rtl') {
|
|
1212
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1213
|
+
}
|
|
1214
|
+
return {
|
|
1215
|
+
width,
|
|
1216
|
+
height,
|
|
1217
|
+
x,
|
|
1218
|
+
y
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// Safety check: ensure the scrollbar space is reasonable in case this
|
|
1223
|
+
// calculation is affected by unusual styles.
|
|
1224
|
+
// Most scrollbars leave 15-18px of space.
|
|
1225
|
+
const SCROLLBAR_MAX = 25;
|
|
1226
|
+
function getViewportRect(element, strategy) {
|
|
1227
|
+
const win = getWindow(element);
|
|
1228
|
+
const html = getDocumentElement(element);
|
|
1229
|
+
const visualViewport = win.visualViewport;
|
|
1230
|
+
let width = html.clientWidth;
|
|
1231
|
+
let height = html.clientHeight;
|
|
1232
|
+
let x = 0;
|
|
1233
|
+
let y = 0;
|
|
1234
|
+
if (visualViewport) {
|
|
1235
|
+
width = visualViewport.width;
|
|
1236
|
+
height = visualViewport.height;
|
|
1237
|
+
const visualViewportBased = isWebKit();
|
|
1238
|
+
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
1239
|
+
x = visualViewport.offsetLeft;
|
|
1240
|
+
y = visualViewport.offsetTop;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
const windowScrollbarX = getWindowScrollBarX(html);
|
|
1244
|
+
// <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
|
|
1245
|
+
// visual width of the <html> but this is not considered in the size
|
|
1246
|
+
// of `html.clientWidth`.
|
|
1247
|
+
if (windowScrollbarX <= 0) {
|
|
1248
|
+
const doc = html.ownerDocument;
|
|
1249
|
+
const body = doc.body;
|
|
1250
|
+
const bodyStyles = getComputedStyle(body);
|
|
1251
|
+
const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
1252
|
+
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
1253
|
+
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
|
1254
|
+
width -= clippingStableScrollbarWidth;
|
|
1255
|
+
}
|
|
1256
|
+
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
|
1257
|
+
// If the <body> scrollbar is on the left, the width needs to be extended
|
|
1258
|
+
// by the scrollbar amount so there isn't extra space on the right.
|
|
1259
|
+
width += windowScrollbarX;
|
|
1260
|
+
}
|
|
1261
|
+
return {
|
|
1262
|
+
width,
|
|
1263
|
+
height,
|
|
1264
|
+
x,
|
|
1265
|
+
y
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
// Returns the inner client rect, subtracting scrollbars if present.
|
|
1270
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
1271
|
+
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
1272
|
+
const top = clientRect.top + element.clientTop;
|
|
1273
|
+
const left = clientRect.left + element.clientLeft;
|
|
1274
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1275
|
+
const width = element.clientWidth * scale.x;
|
|
1276
|
+
const height = element.clientHeight * scale.y;
|
|
1277
|
+
const x = left * scale.x;
|
|
1278
|
+
const y = top * scale.y;
|
|
1279
|
+
return {
|
|
1280
|
+
width,
|
|
1281
|
+
height,
|
|
1282
|
+
x,
|
|
1283
|
+
y
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1287
|
+
let rect;
|
|
1288
|
+
if (clippingAncestor === 'viewport') {
|
|
1289
|
+
rect = getViewportRect(element, strategy);
|
|
1290
|
+
} else if (clippingAncestor === 'document') {
|
|
1291
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
1292
|
+
} else if (isElement(clippingAncestor)) {
|
|
1293
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1294
|
+
} else {
|
|
1295
|
+
const visualOffsets = getVisualOffsets(element);
|
|
1296
|
+
rect = {
|
|
1297
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
1298
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
1299
|
+
width: clippingAncestor.width,
|
|
1300
|
+
height: clippingAncestor.height
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
return rectToClientRect(rect);
|
|
1304
|
+
}
|
|
1305
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
1306
|
+
const parentNode = getParentNode(element);
|
|
1307
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1308
|
+
return false;
|
|
1309
|
+
}
|
|
1310
|
+
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
1314
|
+
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
1315
|
+
// of the given element up the tree.
|
|
1316
|
+
function getClippingElementAncestors(element, cache) {
|
|
1317
|
+
const cachedResult = cache.get(element);
|
|
1318
|
+
if (cachedResult) {
|
|
1319
|
+
return cachedResult;
|
|
1320
|
+
}
|
|
1321
|
+
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
1322
|
+
let currentContainingBlockComputedStyle = null;
|
|
1323
|
+
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
1324
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1325
|
+
|
|
1326
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1327
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1328
|
+
const computedStyle = getComputedStyle$1(currentNode);
|
|
1329
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1330
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
1331
|
+
currentContainingBlockComputedStyle = null;
|
|
1332
|
+
}
|
|
1333
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === 'absolute' || currentContainingBlockComputedStyle.position === 'fixed') || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1334
|
+
if (shouldDropCurrentNode) {
|
|
1335
|
+
// Drop non-containing blocks.
|
|
1336
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
1337
|
+
} else {
|
|
1338
|
+
// Record last containing block for next iteration.
|
|
1339
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
1340
|
+
}
|
|
1341
|
+
currentNode = getParentNode(currentNode);
|
|
1342
|
+
}
|
|
1343
|
+
cache.set(element, result);
|
|
1344
|
+
return result;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
// Gets the maximum area that the element is visible in due to any number of
|
|
1348
|
+
// clipping ancestors.
|
|
1349
|
+
function getClippingRect(_ref) {
|
|
1350
|
+
let {
|
|
1351
|
+
element,
|
|
1352
|
+
boundary,
|
|
1353
|
+
rootBoundary,
|
|
1354
|
+
strategy
|
|
1355
|
+
} = _ref;
|
|
1356
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1357
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1358
|
+
const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
|
|
1359
|
+
let top = firstRect.top;
|
|
1360
|
+
let right = firstRect.right;
|
|
1361
|
+
let bottom = firstRect.bottom;
|
|
1362
|
+
let left = firstRect.left;
|
|
1363
|
+
for (let i = 1; i < clippingAncestors.length; i++) {
|
|
1364
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
|
|
1365
|
+
top = max(rect.top, top);
|
|
1366
|
+
right = min(rect.right, right);
|
|
1367
|
+
bottom = min(rect.bottom, bottom);
|
|
1368
|
+
left = max(rect.left, left);
|
|
1369
|
+
}
|
|
1370
|
+
return {
|
|
1371
|
+
width: right - left,
|
|
1372
|
+
height: bottom - top,
|
|
1373
|
+
x: left,
|
|
1374
|
+
y: top
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
function getDimensions(element) {
|
|
1379
|
+
const {
|
|
1380
|
+
width,
|
|
1381
|
+
height
|
|
1382
|
+
} = getCssDimensions(element);
|
|
1383
|
+
return {
|
|
1384
|
+
width,
|
|
1385
|
+
height
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1390
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1391
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1392
|
+
const isFixed = strategy === 'fixed';
|
|
1393
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1394
|
+
let scroll = {
|
|
1395
|
+
scrollLeft: 0,
|
|
1396
|
+
scrollTop: 0
|
|
1397
|
+
};
|
|
1398
|
+
const offsets = createCoords(0);
|
|
1399
|
+
|
|
1400
|
+
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
|
1401
|
+
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
|
1402
|
+
function setLeftRTLScrollbarOffset() {
|
|
1403
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1404
|
+
}
|
|
1405
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1406
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1407
|
+
scroll = getNodeScroll(offsetParent);
|
|
1408
|
+
}
|
|
1409
|
+
if (isOffsetParentAnElement) {
|
|
1410
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1411
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1412
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1413
|
+
} else if (documentElement) {
|
|
1414
|
+
setLeftRTLScrollbarOffset();
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
1418
|
+
setLeftRTLScrollbarOffset();
|
|
1419
|
+
}
|
|
1420
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1421
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
1422
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
1423
|
+
return {
|
|
1424
|
+
x,
|
|
1425
|
+
y,
|
|
1426
|
+
width: rect.width,
|
|
1427
|
+
height: rect.height
|
|
1428
|
+
};
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
function isStaticPositioned(element) {
|
|
1432
|
+
return getComputedStyle$1(element).position === 'static';
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
1436
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
1437
|
+
return null;
|
|
1438
|
+
}
|
|
1439
|
+
if (polyfill) {
|
|
1440
|
+
return polyfill(element);
|
|
1441
|
+
}
|
|
1442
|
+
let rawOffsetParent = element.offsetParent;
|
|
1443
|
+
|
|
1444
|
+
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
|
1445
|
+
// while Chrome and Safari return the <body> element. The <body> element must
|
|
1446
|
+
// be used to perform the correct calculations even if the <html> element is
|
|
1447
|
+
// non-static.
|
|
1448
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
1449
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
1450
|
+
}
|
|
1451
|
+
return rawOffsetParent;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
1455
|
+
// such as table ancestors and cross browser bugs.
|
|
1456
|
+
function getOffsetParent(element, polyfill) {
|
|
1457
|
+
const win = getWindow(element);
|
|
1458
|
+
if (isTopLayer(element)) {
|
|
1459
|
+
return win;
|
|
1460
|
+
}
|
|
1461
|
+
if (!isHTMLElement(element)) {
|
|
1462
|
+
let svgOffsetParent = getParentNode(element);
|
|
1463
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1464
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
1465
|
+
return svgOffsetParent;
|
|
1466
|
+
}
|
|
1467
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1468
|
+
}
|
|
1469
|
+
return win;
|
|
1470
|
+
}
|
|
1471
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1472
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
1473
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1474
|
+
}
|
|
1475
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
1476
|
+
return win;
|
|
1477
|
+
}
|
|
1478
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
const getElementRects = async function (data) {
|
|
1482
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1483
|
+
const getDimensionsFn = this.getDimensions;
|
|
1484
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1485
|
+
return {
|
|
1486
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1487
|
+
floating: {
|
|
1488
|
+
x: 0,
|
|
1489
|
+
y: 0,
|
|
1490
|
+
width: floatingDimensions.width,
|
|
1491
|
+
height: floatingDimensions.height
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1494
|
+
};
|
|
1495
|
+
|
|
1496
|
+
function isRTL(element) {
|
|
1497
|
+
return getComputedStyle$1(element).direction === 'rtl';
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
const platform = {
|
|
1501
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1502
|
+
getDocumentElement,
|
|
1503
|
+
getClippingRect,
|
|
1504
|
+
getOffsetParent,
|
|
1505
|
+
getElementRects,
|
|
1506
|
+
getClientRects,
|
|
1507
|
+
getDimensions,
|
|
1508
|
+
getScale,
|
|
1509
|
+
isElement,
|
|
1510
|
+
isRTL
|
|
1511
|
+
};
|
|
1512
|
+
|
|
1513
|
+
function rectsAreEqual(a, b) {
|
|
1514
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
// https://samthor.au/2021/observing-dom/
|
|
1518
|
+
function observeMove(element, onMove) {
|
|
1519
|
+
let io = null;
|
|
1520
|
+
let timeoutId;
|
|
1521
|
+
const root = getDocumentElement(element);
|
|
1522
|
+
function cleanup() {
|
|
1523
|
+
var _io;
|
|
1524
|
+
clearTimeout(timeoutId);
|
|
1525
|
+
(_io = io) == null || _io.disconnect();
|
|
1526
|
+
io = null;
|
|
1527
|
+
}
|
|
1528
|
+
function refresh(skip, threshold) {
|
|
1529
|
+
if (skip === void 0) {
|
|
1530
|
+
skip = false;
|
|
1531
|
+
}
|
|
1532
|
+
if (threshold === void 0) {
|
|
1533
|
+
threshold = 1;
|
|
1534
|
+
}
|
|
1535
|
+
cleanup();
|
|
1536
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
1537
|
+
const {
|
|
1538
|
+
left,
|
|
1539
|
+
top,
|
|
1540
|
+
width,
|
|
1541
|
+
height
|
|
1542
|
+
} = elementRectForRootMargin;
|
|
1543
|
+
if (!skip) {
|
|
1544
|
+
onMove();
|
|
1545
|
+
}
|
|
1546
|
+
if (!width || !height) {
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
const insetTop = floor(top);
|
|
1550
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
1551
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1552
|
+
const insetLeft = floor(left);
|
|
1553
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
1554
|
+
const options = {
|
|
1555
|
+
rootMargin,
|
|
1556
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
1557
|
+
};
|
|
1558
|
+
let isFirstUpdate = true;
|
|
1559
|
+
function handleObserve(entries) {
|
|
1560
|
+
const ratio = entries[0].intersectionRatio;
|
|
1561
|
+
if (ratio !== threshold) {
|
|
1562
|
+
if (!isFirstUpdate) {
|
|
1563
|
+
return refresh();
|
|
1564
|
+
}
|
|
1565
|
+
if (!ratio) {
|
|
1566
|
+
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
|
1567
|
+
// to prevent an infinite loop of updates.
|
|
1568
|
+
timeoutId = setTimeout(() => {
|
|
1569
|
+
refresh(false, 1e-7);
|
|
1570
|
+
}, 1000);
|
|
1571
|
+
} else {
|
|
1572
|
+
refresh(false, ratio);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
|
1576
|
+
// It's possible that even though the ratio is reported as 1, the
|
|
1577
|
+
// element is not actually fully within the IntersectionObserver's root
|
|
1578
|
+
// area anymore. This can happen under performance constraints. This may
|
|
1579
|
+
// be a bug in the browser's IntersectionObserver implementation. To
|
|
1580
|
+
// work around this, we compare the element's bounding rect now with
|
|
1581
|
+
// what it was at the time we created the IntersectionObserver. If they
|
|
1582
|
+
// are not equal then the element moved, so we refresh.
|
|
1583
|
+
refresh();
|
|
1584
|
+
}
|
|
1585
|
+
isFirstUpdate = false;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
// Older browsers don't support a `document` as the root and will throw an
|
|
1589
|
+
// error.
|
|
1590
|
+
try {
|
|
1591
|
+
io = new IntersectionObserver(handleObserve, {
|
|
1592
|
+
...options,
|
|
1593
|
+
// Handle <iframe>s
|
|
1594
|
+
root: root.ownerDocument
|
|
1595
|
+
});
|
|
1596
|
+
} catch (_e) {
|
|
1597
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
1598
|
+
}
|
|
1599
|
+
io.observe(element);
|
|
1600
|
+
}
|
|
1601
|
+
refresh(true);
|
|
1602
|
+
return cleanup;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Automatically updates the position of the floating element when necessary.
|
|
1607
|
+
* Should only be called when the floating element is mounted on the DOM or
|
|
1608
|
+
* visible on the screen.
|
|
1609
|
+
* @returns cleanup function that should be invoked when the floating element is
|
|
1610
|
+
* removed from the DOM or hidden from the screen.
|
|
1611
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
|
1612
|
+
*/
|
|
1613
|
+
function autoUpdate(reference, floating, update, options) {
|
|
1614
|
+
if (options === void 0) {
|
|
1615
|
+
options = {};
|
|
1616
|
+
}
|
|
1617
|
+
const {
|
|
1618
|
+
ancestorScroll = true,
|
|
1619
|
+
ancestorResize = true,
|
|
1620
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
1621
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
1622
|
+
animationFrame = false
|
|
1623
|
+
} = options;
|
|
1624
|
+
const referenceEl = unwrapElement(reference);
|
|
1625
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...(floating ? getOverflowAncestors(floating) : [])] : [];
|
|
1626
|
+
ancestors.forEach(ancestor => {
|
|
1627
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1628
|
+
passive: true
|
|
1629
|
+
});
|
|
1630
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1631
|
+
});
|
|
1632
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
1633
|
+
let reobserveFrame = -1;
|
|
1634
|
+
let resizeObserver = null;
|
|
1635
|
+
if (elementResize) {
|
|
1636
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
1637
|
+
let [firstEntry] = _ref;
|
|
1638
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
|
|
1639
|
+
// Prevent update loops when using the `size` middleware.
|
|
1640
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
1641
|
+
resizeObserver.unobserve(floating);
|
|
1642
|
+
cancelAnimationFrame(reobserveFrame);
|
|
1643
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
1644
|
+
var _resizeObserver;
|
|
1645
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
1646
|
+
});
|
|
1647
|
+
}
|
|
1648
|
+
update();
|
|
1649
|
+
});
|
|
1650
|
+
if (referenceEl && !animationFrame) {
|
|
1651
|
+
resizeObserver.observe(referenceEl);
|
|
1652
|
+
}
|
|
1653
|
+
if (floating) {
|
|
1654
|
+
resizeObserver.observe(floating);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
let frameId;
|
|
1658
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1659
|
+
if (animationFrame) {
|
|
1660
|
+
frameLoop();
|
|
1661
|
+
}
|
|
1662
|
+
function frameLoop() {
|
|
1663
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
1664
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
|
1665
|
+
update();
|
|
1666
|
+
}
|
|
1667
|
+
prevRefRect = nextRefRect;
|
|
1668
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
1669
|
+
}
|
|
1670
|
+
update();
|
|
1671
|
+
return () => {
|
|
1672
|
+
var _resizeObserver2;
|
|
1673
|
+
ancestors.forEach(ancestor => {
|
|
1674
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1675
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1676
|
+
});
|
|
1677
|
+
cleanupIo == null || cleanupIo();
|
|
1678
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
1679
|
+
resizeObserver = null;
|
|
1680
|
+
if (animationFrame) {
|
|
1681
|
+
cancelAnimationFrame(frameId);
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* Modifies the placement by translating the floating element along the
|
|
1688
|
+
* specified axes.
|
|
1689
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1690
|
+
* object may be passed.
|
|
1691
|
+
* @see https://floating-ui.com/docs/offset
|
|
1692
|
+
*/
|
|
1693
|
+
const offset = offset$1;
|
|
1694
|
+
|
|
1695
|
+
/**
|
|
1696
|
+
* Optimizes the visibility of the floating element by choosing the placement
|
|
1697
|
+
* that has the most space available automatically, without needing to specify a
|
|
1698
|
+
* preferred placement. Alternative to `flip`.
|
|
1699
|
+
* @see https://floating-ui.com/docs/autoPlacement
|
|
1700
|
+
*/
|
|
1701
|
+
const autoPlacement = autoPlacement$1;
|
|
1702
|
+
|
|
1703
|
+
/**
|
|
1704
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1705
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
1706
|
+
* @see https://floating-ui.com/docs/shift
|
|
1707
|
+
*/
|
|
1708
|
+
const shift = shift$1;
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1712
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1713
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
1714
|
+
* @see https://floating-ui.com/docs/flip
|
|
1715
|
+
*/
|
|
1716
|
+
const flip = flip$1;
|
|
1717
|
+
|
|
1718
|
+
/**
|
|
1719
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1720
|
+
* next to a given reference element.
|
|
1721
|
+
*/
|
|
1722
|
+
const computePosition = (reference, floating, options) => {
|
|
1723
|
+
// This caches the expensive `getClippingElementAncestors` function so that
|
|
1724
|
+
// multiple lifecycle resets re-use the same result. It only lives for a
|
|
1725
|
+
// single call. If other functions become expensive, we can add them as well.
|
|
1726
|
+
const cache = new Map();
|
|
1727
|
+
const mergedOptions = {
|
|
1728
|
+
platform,
|
|
1729
|
+
...options
|
|
1730
|
+
};
|
|
1731
|
+
const platformWithCache = {
|
|
1732
|
+
...mergedOptions.platform,
|
|
1733
|
+
_c: cache
|
|
1734
|
+
};
|
|
1735
|
+
return computePosition$1(reference, floating, {
|
|
1736
|
+
...mergedOptions,
|
|
1737
|
+
platform: platformWithCache
|
|
1738
|
+
});
|
|
1739
|
+
};
|
|
1740
|
+
|
|
1741
|
+
/* eslint-disable line-comment-position, no-inline-comments */
|
|
1742
|
+
|
|
1743
|
+
|
|
1744
|
+
const MAX_CONFIGURATION_COUNT = 10;
|
|
1745
|
+
|
|
1746
|
+
class AuroFloatingUI {
|
|
1747
|
+
/**
|
|
1748
|
+
* @private
|
|
1749
|
+
*/
|
|
1750
|
+
static isMousePressed = false;
|
|
1751
|
+
|
|
1752
|
+
/**
|
|
1753
|
+
* @private
|
|
1754
|
+
*/
|
|
1755
|
+
static isMousePressHandlerInitialized = false;
|
|
1756
|
+
|
|
1757
|
+
/**
|
|
1758
|
+
* @private
|
|
1759
|
+
*/
|
|
1760
|
+
static setupMousePressChecker() {
|
|
1761
|
+
if (
|
|
1762
|
+
!AuroFloatingUI.isMousePressHandlerInitialized &&
|
|
1763
|
+
window &&
|
|
1764
|
+
window.addEventListener
|
|
1765
|
+
) {
|
|
1766
|
+
AuroFloatingUI.isMousePressHandlerInitialized = true;
|
|
1767
|
+
|
|
1768
|
+
// Track timeout for isMousePressed reset to avoid race conditions
|
|
1769
|
+
if (!AuroFloatingUI._mousePressedTimeout) {
|
|
1770
|
+
AuroFloatingUI._mousePressedTimeout = null;
|
|
1771
|
+
}
|
|
1772
|
+
const mouseEventGlobalHandler = (event) => {
|
|
1773
|
+
const isPressed = event.type === "mousedown";
|
|
1774
|
+
if (isPressed) {
|
|
1775
|
+
// Clear any pending timeout to prevent race condition
|
|
1776
|
+
if (AuroFloatingUI._mousePressedTimeout !== null) {
|
|
1777
|
+
clearTimeout(AuroFloatingUI._mousePressedTimeout);
|
|
1778
|
+
AuroFloatingUI._mousePressedTimeout = null;
|
|
1779
|
+
}
|
|
1780
|
+
if (!AuroFloatingUI.isMousePressed) {
|
|
1781
|
+
AuroFloatingUI.isMousePressed = true;
|
|
1782
|
+
}
|
|
1783
|
+
} else if (AuroFloatingUI.isMousePressed && !isPressed) {
|
|
1784
|
+
// Schedule reset and track timeout ID
|
|
1785
|
+
AuroFloatingUI._mousePressedTimeout = setTimeout(() => {
|
|
1786
|
+
AuroFloatingUI.isMousePressed = false;
|
|
1787
|
+
AuroFloatingUI._mousePressedTimeout = null;
|
|
1788
|
+
}, 0);
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
|
|
1792
|
+
window.addEventListener("mousedown", mouseEventGlobalHandler);
|
|
1793
|
+
window.addEventListener("mouseup", mouseEventGlobalHandler);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
constructor(element, behavior) {
|
|
1798
|
+
this.element = element;
|
|
1799
|
+
this.behavior = behavior;
|
|
1800
|
+
|
|
1801
|
+
// Store event listener references for cleanup
|
|
1802
|
+
this.focusHandler = null;
|
|
1803
|
+
this.clickHandler = null;
|
|
1804
|
+
this.keyDownHandler = null;
|
|
1805
|
+
|
|
1806
|
+
/**
|
|
1807
|
+
* @private
|
|
1808
|
+
*/
|
|
1809
|
+
this.enableKeyboardHandling = true;
|
|
1810
|
+
|
|
1811
|
+
/**
|
|
1812
|
+
* @private
|
|
1813
|
+
*/
|
|
1814
|
+
this.configureTrial = 0;
|
|
1815
|
+
|
|
1816
|
+
/**
|
|
1817
|
+
* @private
|
|
1818
|
+
*/
|
|
1819
|
+
this.eventPrefix = undefined;
|
|
1820
|
+
|
|
1821
|
+
/**
|
|
1822
|
+
* @private
|
|
1823
|
+
*/
|
|
1824
|
+
this.id = undefined;
|
|
1825
|
+
|
|
1826
|
+
/**
|
|
1827
|
+
* @private
|
|
1828
|
+
*/
|
|
1829
|
+
this.showing = false;
|
|
1830
|
+
|
|
1831
|
+
/**
|
|
1832
|
+
* @private
|
|
1833
|
+
*/
|
|
1834
|
+
this.strategy = undefined;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
/**
|
|
1838
|
+
* Mirrors the size of the bibSizer element to the bib content.
|
|
1839
|
+
* Copies the width, height, max-width, and max-height styles from the bibSizer element to the bib content container.
|
|
1840
|
+
* This ensures that the bib content has the same dimensions as the sizer element.
|
|
1841
|
+
*/
|
|
1842
|
+
mirrorSize() {
|
|
1843
|
+
const element = this.element;
|
|
1844
|
+
if (!element) {
|
|
1845
|
+
return;
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
// mirror the boxsize from bibSizer
|
|
1849
|
+
if (element.bibSizer && element.matchWidth && element.bib?.shadowRoot) {
|
|
1850
|
+
const sizerStyle = window.getComputedStyle(element.bibSizer);
|
|
1851
|
+
const bibContent = element.bib.shadowRoot.querySelector(".container");
|
|
1852
|
+
if (!bibContent) {
|
|
1853
|
+
return;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
if (sizerStyle.width !== "0px") {
|
|
1857
|
+
bibContent.style.width = sizerStyle.width;
|
|
1858
|
+
}
|
|
1859
|
+
if (sizerStyle.height !== "0px") {
|
|
1860
|
+
bibContent.style.height = sizerStyle.height;
|
|
1861
|
+
}
|
|
1862
|
+
bibContent.style.maxWidth = sizerStyle.maxWidth;
|
|
1863
|
+
bibContent.style.maxHeight = sizerStyle.maxHeight;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* @private
|
|
1869
|
+
* Determines the positioning strategy based on the current viewport size and mobile breakpoint.
|
|
1870
|
+
*
|
|
1871
|
+
* This method checks if the current viewport width is less than or equal to the specified mobile fullscreen breakpoint
|
|
1872
|
+
* defined in the bib element. If it is, the strategy is set to 'fullscreen'; otherwise, it defaults to 'floating'.
|
|
1873
|
+
*
|
|
1874
|
+
* @returns {String} The positioning strategy, one of 'fullscreen', 'floating', 'cover'.
|
|
1875
|
+
*/
|
|
1876
|
+
getPositioningStrategy() {
|
|
1877
|
+
const element = this.element;
|
|
1878
|
+
if (!element) {
|
|
1879
|
+
return "floating";
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
const breakpoint =
|
|
1883
|
+
element.bib?.mobileFullscreenBreakpoint ||
|
|
1884
|
+
element.floaterConfig?.fullscreenBreakpoint;
|
|
1885
|
+
switch (this.behavior) {
|
|
1886
|
+
case "tooltip":
|
|
1887
|
+
return "floating";
|
|
1888
|
+
case "dialog":
|
|
1889
|
+
case "drawer":
|
|
1890
|
+
if (breakpoint) {
|
|
1891
|
+
const smallerThanBreakpoint = window.matchMedia(
|
|
1892
|
+
`(max-width: ${breakpoint})`,
|
|
1893
|
+
).matches;
|
|
1894
|
+
|
|
1895
|
+
element.expanded = smallerThanBreakpoint;
|
|
1896
|
+
}
|
|
1897
|
+
if (element.nested) {
|
|
1898
|
+
return "cover";
|
|
1899
|
+
}
|
|
1900
|
+
return "fullscreen";
|
|
1901
|
+
case "dropdown":
|
|
1902
|
+
case undefined:
|
|
1903
|
+
case null:
|
|
1904
|
+
if (breakpoint) {
|
|
1905
|
+
const smallerThanBreakpoint = window.matchMedia(
|
|
1906
|
+
`(max-width: ${breakpoint})`,
|
|
1907
|
+
).matches;
|
|
1908
|
+
if (smallerThanBreakpoint) {
|
|
1909
|
+
return "fullscreen";
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
return "floating";
|
|
1913
|
+
default:
|
|
1914
|
+
return this.behavior;
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
/**
|
|
1919
|
+
* @private
|
|
1920
|
+
* Positions the bib element based on the current configuration and positioning strategy.
|
|
1921
|
+
*
|
|
1922
|
+
* This method determines the appropriate positioning strategy (fullscreen or not) and configures the bib accordingly.
|
|
1923
|
+
* It also sets up middleware for the floater configuration, computes the position of the bib relative to the trigger element,
|
|
1924
|
+
* and applies the calculated position to the bib's style.
|
|
1925
|
+
*/
|
|
1926
|
+
position() {
|
|
1927
|
+
const element = this.element;
|
|
1928
|
+
if (!element) {
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
const strategy = this.getPositioningStrategy();
|
|
1933
|
+
this.configureBibStrategy(strategy);
|
|
1934
|
+
|
|
1935
|
+
if (strategy === "floating") {
|
|
1936
|
+
if (!element.trigger || !element.bib) {
|
|
1937
|
+
return;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
this.mirrorSize();
|
|
1941
|
+
// Define the middlware for the floater configuration
|
|
1942
|
+
const middleware = [
|
|
1943
|
+
offset(element.floaterConfig?.offset || 0),
|
|
1944
|
+
...(element.floaterConfig?.shift ? [shift()] : []), // Add shift middleware if shift is enabled.
|
|
1945
|
+
...(element.floaterConfig?.flip ? [flip()] : []), // Add flip middleware if flip is enabled.
|
|
1946
|
+
...(element.floaterConfig?.autoPlacement ? [autoPlacement()] : []), // Add autoPlacement middleware if autoPlacement is enabled.
|
|
1947
|
+
];
|
|
1948
|
+
|
|
1949
|
+
// Compute the position of the bib
|
|
1950
|
+
computePosition(element.trigger, element.bib, {
|
|
1951
|
+
strategy: element.floaterConfig?.strategy || "fixed",
|
|
1952
|
+
placement: element.floaterConfig?.placement,
|
|
1953
|
+
middleware: middleware || [],
|
|
1954
|
+
}).then(({ x, y }) => {
|
|
1955
|
+
// eslint-disable-line id-length
|
|
1956
|
+
const currentElement = this.element;
|
|
1957
|
+
if (!currentElement?.bib) {
|
|
1958
|
+
return;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
Object.assign(currentElement.bib.style, {
|
|
1962
|
+
left: `${x}px`,
|
|
1963
|
+
top: `${y}px`,
|
|
1964
|
+
});
|
|
1965
|
+
});
|
|
1966
|
+
} else if (strategy === "cover") {
|
|
1967
|
+
if (!element.parentNode || !element.bib) {
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
// Compute the position of the bib
|
|
1972
|
+
computePosition(element.parentNode, element.bib, {
|
|
1973
|
+
placement: "bottom-start",
|
|
1974
|
+
}).then(({ x, y }) => {
|
|
1975
|
+
// eslint-disable-line id-length
|
|
1976
|
+
const currentElement = this.element;
|
|
1977
|
+
if (!currentElement?.bib || !currentElement.parentNode) {
|
|
1978
|
+
return;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
Object.assign(currentElement.bib.style, {
|
|
1982
|
+
left: `${x}px`,
|
|
1983
|
+
top: `${y - currentElement.parentNode.offsetHeight}px`,
|
|
1984
|
+
width: `${currentElement.parentNode.offsetWidth}px`,
|
|
1985
|
+
height: `${currentElement.parentNode.offsetHeight}px`,
|
|
1986
|
+
});
|
|
1987
|
+
});
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
/**
|
|
1992
|
+
* @private
|
|
1993
|
+
* Controls whether to lock the scrolling for the document's body.
|
|
1994
|
+
* @param {Boolean} lock - If true, locks the body's scrolling functionlity; otherwise, unlock.
|
|
1995
|
+
*/
|
|
1996
|
+
lockScroll(lock = true) {
|
|
1997
|
+
const element = this.element;
|
|
1998
|
+
|
|
1999
|
+
if (lock) {
|
|
2000
|
+
if (!element?.bib) {
|
|
2001
|
+
return;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
document.body.style.overflow = "hidden"; // hide body's scrollbar
|
|
2005
|
+
|
|
2006
|
+
// Move `bib` by the amount the viewport is shifted to stay aligned in fullscreen.
|
|
2007
|
+
element.bib.style.transform = `translateY(${window?.visualViewport?.offsetTop}px)`;
|
|
2008
|
+
} else {
|
|
2009
|
+
document.body.style.overflow = "";
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
/**
|
|
2014
|
+
* @private
|
|
2015
|
+
* Configures the bib element's display strategy.
|
|
2016
|
+
*
|
|
2017
|
+
* Sets the bib to fullscreen or floating mode based on the provided strategy.
|
|
2018
|
+
* Dispatches a 'strategy-change' event if the strategy changes.
|
|
2019
|
+
*
|
|
2020
|
+
* @param {string} strategy - The positioning strategy ('fullscreen' or 'floating').
|
|
2021
|
+
*/
|
|
2022
|
+
configureBibStrategy(value) {
|
|
2023
|
+
const element = this.element;
|
|
2024
|
+
if (!element?.bib) {
|
|
2025
|
+
return;
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
if (value === "fullscreen") {
|
|
2029
|
+
element.isBibFullscreen = true;
|
|
2030
|
+
// reset the prev position
|
|
2031
|
+
element.bib.setAttribute("isfullscreen", "");
|
|
2032
|
+
element.bib.style.position = "fixed";
|
|
2033
|
+
element.bib.style.top = "0px";
|
|
2034
|
+
element.bib.style.left = "0px";
|
|
2035
|
+
element.bib.style.width = "";
|
|
2036
|
+
element.bib.style.height = "";
|
|
2037
|
+
element.style.contain = "";
|
|
2038
|
+
|
|
2039
|
+
// reset the size that was mirroring `size` css-part
|
|
2040
|
+
const bibContent = element.bib.shadowRoot?.querySelector(".container");
|
|
2041
|
+
if (bibContent) {
|
|
2042
|
+
bibContent.style.width = "";
|
|
2043
|
+
bibContent.style.height = "";
|
|
2044
|
+
bibContent.style.maxWidth = "";
|
|
2045
|
+
bibContent.style.maxHeight = `${window?.visualViewport?.height}px`;
|
|
2046
|
+
this.configureTrial = 0;
|
|
2047
|
+
} else if (this.configureTrial < MAX_CONFIGURATION_COUNT) {
|
|
2048
|
+
this.configureTrial += 1;
|
|
2049
|
+
|
|
2050
|
+
setTimeout(() => {
|
|
2051
|
+
this.configureBibStrategy(value);
|
|
2052
|
+
}, 0);
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
if (element.isPopoverVisible) {
|
|
2056
|
+
this.lockScroll(true);
|
|
2057
|
+
}
|
|
2058
|
+
} else {
|
|
2059
|
+
element.bib.style.position = "";
|
|
2060
|
+
element.bib.removeAttribute("isfullscreen");
|
|
2061
|
+
element.isBibFullscreen = false;
|
|
2062
|
+
element.style.contain = "layout";
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
const isChanged = this.strategy && this.strategy !== value;
|
|
2066
|
+
this.strategy = value;
|
|
2067
|
+
if (isChanged) {
|
|
2068
|
+
const event = new CustomEvent(
|
|
2069
|
+
this.eventPrefix
|
|
2070
|
+
? `${this.eventPrefix}-strategy-change`
|
|
2071
|
+
: "strategy-change",
|
|
2072
|
+
{
|
|
2073
|
+
detail: {
|
|
2074
|
+
value,
|
|
2075
|
+
},
|
|
2076
|
+
composed: true,
|
|
2077
|
+
},
|
|
2078
|
+
);
|
|
2079
|
+
|
|
2080
|
+
element.dispatchEvent(event);
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
updateState() {
|
|
2085
|
+
const element = this.element;
|
|
2086
|
+
if (!element) {
|
|
2087
|
+
return;
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
const isVisible = element.isPopoverVisible;
|
|
2091
|
+
if (!isVisible) {
|
|
2092
|
+
this.cleanupHideHandlers();
|
|
2093
|
+
try {
|
|
2094
|
+
element.cleanup?.();
|
|
2095
|
+
} catch (error) {
|
|
2096
|
+
// Do nothing
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
/**
|
|
2102
|
+
* @private
|
|
2103
|
+
* getting called on 'blur' in trigger or `focusin` in document
|
|
2104
|
+
*
|
|
2105
|
+
* Hides the bib if focus moves outside of the trigger or bib, unless a 'noHideOnThisFocusLoss' flag is set.
|
|
2106
|
+
* This method checks if the currently active element is still within the trigger or bib.
|
|
2107
|
+
* If not, and if the bib isn't in fullscreen mode with focus lost, it hides the bib.
|
|
2108
|
+
*/
|
|
2109
|
+
handleFocusLoss() {
|
|
2110
|
+
const element = this.element;
|
|
2111
|
+
if (!element?.bib) {
|
|
2112
|
+
return;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
// if mouse is being pressed, skip and let click event to handle the action
|
|
2116
|
+
if (AuroFloatingUI.isMousePressed) {
|
|
2117
|
+
return;
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
if (
|
|
2121
|
+
element.noHideOnThisFocusLoss ||
|
|
2122
|
+
element.hasAttribute("noHideOnThisFocusLoss")
|
|
2123
|
+
) {
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
// if focus is still inside of trigger or bib, do not close
|
|
2128
|
+
if (element.matches(":focus") || element.matches(":focus-within")) {
|
|
2129
|
+
return;
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
// if fullscreen bib is in fullscreen mode, do not close
|
|
2133
|
+
if (element.bib.hasAttribute("isfullscreen")) {
|
|
2134
|
+
return;
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
this.hideBib("keydown");
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
setupHideHandlers() {
|
|
2141
|
+
const element = this.element;
|
|
2142
|
+
if (!element) {
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
// Define handlers & store references
|
|
2147
|
+
this.focusHandler = () => this.handleFocusLoss();
|
|
2148
|
+
|
|
2149
|
+
this.clickHandler = (evt) => {
|
|
2150
|
+
const element = this.element;
|
|
2151
|
+
if (!element?.bib) {
|
|
2152
|
+
return;
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
// When the bib is fullscreen (modal dialog), don't close on outside
|
|
2156
|
+
// clicks. VoiceOver's synthetic click events inside a top-layer modal
|
|
2157
|
+
// <dialog> may not include the bib in composedPath(), causing false
|
|
2158
|
+
// positives. This mirrors the fullscreen guard in handleFocusLoss().
|
|
2159
|
+
if (element.bib.hasAttribute("isfullscreen")) {
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
if (
|
|
2164
|
+
(!evt.composedPath().includes(element.trigger) &&
|
|
2165
|
+
!evt.composedPath().includes(element.bib)) ||
|
|
2166
|
+
(element.bib.backdrop &&
|
|
2167
|
+
evt.composedPath().includes(element.bib.backdrop))
|
|
2168
|
+
) {
|
|
2169
|
+
const existedVisibleFloatingUI =
|
|
2170
|
+
document.expandedAuroFormkitDropdown || document.expandedAuroFloater;
|
|
2171
|
+
|
|
2172
|
+
if (
|
|
2173
|
+
existedVisibleFloatingUI &&
|
|
2174
|
+
existedVisibleFloatingUI.element.isPopoverVisible
|
|
2175
|
+
) {
|
|
2176
|
+
// if something else is open, close that
|
|
2177
|
+
existedVisibleFloatingUI.hideBib();
|
|
2178
|
+
document.expandedAuroFormkitDropdown = null;
|
|
2179
|
+
document.expandedAuroFloater = this;
|
|
2180
|
+
} else {
|
|
2181
|
+
this.hideBib("click");
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
};
|
|
2185
|
+
|
|
2186
|
+
// ESC key handler
|
|
2187
|
+
this.keyDownHandler = (evt) => {
|
|
2188
|
+
const element = this.element;
|
|
2189
|
+
if (!element) {
|
|
2190
|
+
return;
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
if (evt.key === "Escape" && element.isPopoverVisible) {
|
|
2194
|
+
const existedVisibleFloatingUI =
|
|
2195
|
+
document.expandedAuroFormkitDropdown || document.expandedAuroFloater;
|
|
2196
|
+
if (
|
|
2197
|
+
existedVisibleFloatingUI &&
|
|
2198
|
+
existedVisibleFloatingUI !== this &&
|
|
2199
|
+
existedVisibleFloatingUI.element.isPopoverVisible
|
|
2200
|
+
) {
|
|
2201
|
+
// if something else is open, let it handle itself
|
|
2202
|
+
return;
|
|
2203
|
+
}
|
|
2204
|
+
this.hideBib("keydown");
|
|
2205
|
+
}
|
|
2206
|
+
};
|
|
2207
|
+
|
|
2208
|
+
if (this.behavior !== "drawer" && this.behavior !== "dialog") {
|
|
2209
|
+
// Add event listeners using the stored references
|
|
2210
|
+
document.addEventListener("focusin", this.focusHandler);
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
if (this.enableKeyboardHandling) {
|
|
2214
|
+
document.addEventListener("keydown", this.keyDownHandler);
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
// send this task to the end of queue to prevent conflicting
|
|
2218
|
+
// it conflicts if showBib gets call from a button that's not this.element.trigger
|
|
2219
|
+
setTimeout(() => {
|
|
2220
|
+
window.addEventListener("click", this.clickHandler);
|
|
2221
|
+
}, 0);
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
cleanupHideHandlers() {
|
|
2225
|
+
// Remove event listeners if they exist
|
|
2226
|
+
|
|
2227
|
+
if (this.focusHandler) {
|
|
2228
|
+
document.removeEventListener("focusin", this.focusHandler);
|
|
2229
|
+
this.focusHandler = null;
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
if (this.clickHandler) {
|
|
2233
|
+
window.removeEventListener("click", this.clickHandler);
|
|
2234
|
+
this.clickHandler = null;
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
if (this.keyDownHandler) {
|
|
2238
|
+
document.removeEventListener("keydown", this.keyDownHandler);
|
|
2239
|
+
this.keyDownHandler = null;
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
handleUpdate(changedProperties) {
|
|
2244
|
+
if (changedProperties.has("isPopoverVisible")) {
|
|
2245
|
+
this.updateState();
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
updateCurrentExpandedDropdown() {
|
|
2250
|
+
if (!this.element) {
|
|
2251
|
+
return;
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
// Close any other dropdown that is already open
|
|
2255
|
+
const existedVisibleFloatingUI =
|
|
2256
|
+
document.expandedAuroFormkitDropdown || document.expandedAuroFloater;
|
|
2257
|
+
if (
|
|
2258
|
+
existedVisibleFloatingUI &&
|
|
2259
|
+
existedVisibleFloatingUI !== this &&
|
|
2260
|
+
existedVisibleFloatingUI.element.isPopoverVisible &&
|
|
2261
|
+
existedVisibleFloatingUI.eventPrefix === this.eventPrefix
|
|
2262
|
+
) {
|
|
2263
|
+
existedVisibleFloatingUI.hideBib();
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
document.expandedAuroFloater = this;
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
showBib() {
|
|
2270
|
+
const element = this.element;
|
|
2271
|
+
if (!element) {
|
|
2272
|
+
return;
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
if (!element.bib || (!element.trigger && !element.parentNode)) {
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2279
|
+
if (!element.disabled && !this.showing) {
|
|
2280
|
+
this.updateCurrentExpandedDropdown();
|
|
2281
|
+
element.triggerChevron?.setAttribute("data-expanded", true);
|
|
2282
|
+
|
|
2283
|
+
// prevent double showing: isPopovervisible gets first and showBib gets called later
|
|
2284
|
+
if (!this.showing) {
|
|
2285
|
+
if (!element.modal) {
|
|
2286
|
+
this.setupHideHandlers();
|
|
2287
|
+
}
|
|
2288
|
+
this.showing = true;
|
|
2289
|
+
element.isPopoverVisible = true;
|
|
2290
|
+
this.position();
|
|
2291
|
+
this.dispatchEventDropdownToggle();
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
// Setup auto update to handle resize and scroll
|
|
2295
|
+
element.cleanup = autoUpdate(
|
|
2296
|
+
element.trigger || element.parentNode,
|
|
2297
|
+
element.bib,
|
|
2298
|
+
() => {
|
|
2299
|
+
this.position();
|
|
2300
|
+
},
|
|
2301
|
+
);
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
/**
|
|
2306
|
+
* Hides the floating UI element.
|
|
2307
|
+
* @param {String} eventType - The event type that triggered the hiding action.
|
|
2308
|
+
*/
|
|
2309
|
+
hideBib(eventType = "unknown") {
|
|
2310
|
+
const element = this.element;
|
|
2311
|
+
if (!element) {
|
|
2312
|
+
return;
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
if (element.disabled) {
|
|
2316
|
+
return;
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
// noToggle dropdowns should not close when the trigger is clicked (the
|
|
2320
|
+
// "toggle" behavior), but they CAN still close via other interactions like
|
|
2321
|
+
// Escape key or focus loss.
|
|
2322
|
+
if (element.noToggle && eventType === "click") {
|
|
2323
|
+
return;
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
this.lockScroll(false);
|
|
2327
|
+
element.triggerChevron?.removeAttribute("data-expanded");
|
|
2328
|
+
|
|
2329
|
+
if (element.isPopoverVisible) {
|
|
2330
|
+
element.isPopoverVisible = false;
|
|
2331
|
+
}
|
|
2332
|
+
if (this.showing) {
|
|
2333
|
+
this.cleanupHideHandlers();
|
|
2334
|
+
this.showing = false;
|
|
2335
|
+
this.dispatchEventDropdownToggle(eventType);
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
// Only clear the global reference if the bib was actually hidden.
|
|
2339
|
+
// Clearing it when hideBib is blocked (e.g. noToggle + click) corrupts
|
|
2340
|
+
// the singleton state so other dropdowns can't detect this one is still open.
|
|
2341
|
+
document.expandedAuroFloater = null;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
/**
|
|
2345
|
+
* @private
|
|
2346
|
+
* @returns {void} Dispatches event with an object showing the state of the dropdown.
|
|
2347
|
+
* @param {String} eventType - The event type that triggered the toggle action.
|
|
2348
|
+
*/
|
|
2349
|
+
dispatchEventDropdownToggle(eventType) {
|
|
2350
|
+
const element = this.element;
|
|
2351
|
+
if (!element) {
|
|
2352
|
+
return;
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
const event = new CustomEvent(
|
|
2356
|
+
this.eventPrefix ? `${this.eventPrefix}-toggled` : "toggled",
|
|
2357
|
+
{
|
|
2358
|
+
detail: {
|
|
2359
|
+
expanded: this.showing,
|
|
2360
|
+
eventType: eventType || "unknown",
|
|
2361
|
+
},
|
|
2362
|
+
composed: true,
|
|
2363
|
+
},
|
|
2364
|
+
);
|
|
2365
|
+
|
|
2366
|
+
element.dispatchEvent(event);
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
handleClick() {
|
|
2370
|
+
const element = this.element;
|
|
2371
|
+
if (!element) {
|
|
2372
|
+
return;
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
if (element.isPopoverVisible) {
|
|
2376
|
+
this.hideBib("click");
|
|
2377
|
+
} else {
|
|
2378
|
+
this.showBib();
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
const event = new CustomEvent(
|
|
2382
|
+
this.eventPrefix ? `${this.eventPrefix}-triggerClick` : "triggerClick",
|
|
2383
|
+
{
|
|
2384
|
+
composed: true,
|
|
2385
|
+
detail: {
|
|
2386
|
+
expanded: element.isPopoverVisible,
|
|
2387
|
+
},
|
|
2388
|
+
},
|
|
2389
|
+
);
|
|
2390
|
+
|
|
2391
|
+
element.dispatchEvent(event);
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
handleEvent(event) {
|
|
2395
|
+
const element = this.element;
|
|
2396
|
+
if (!element || element.disableEventShow) {
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
switch (event.type) {
|
|
2401
|
+
case "keydown": {
|
|
2402
|
+
// Support both Enter and Space keys for accessibility
|
|
2403
|
+
// Space is included as it's expected behavior for interactive elements
|
|
2404
|
+
|
|
2405
|
+
const origin = event.composedPath()[0];
|
|
2406
|
+
if (
|
|
2407
|
+
event.key === "Enter" ||
|
|
2408
|
+
(event.key === " " && (!origin || origin.tagName !== "INPUT"))
|
|
2409
|
+
) {
|
|
2410
|
+
event.preventDefault();
|
|
2411
|
+
this.handleClick();
|
|
2412
|
+
}
|
|
2413
|
+
break;
|
|
2414
|
+
}
|
|
2415
|
+
case "mouseenter":
|
|
2416
|
+
if (element.hoverToggle) {
|
|
2417
|
+
this.showBib();
|
|
2418
|
+
}
|
|
2419
|
+
break;
|
|
2420
|
+
case "mouseleave":
|
|
2421
|
+
if (element.hoverToggle) {
|
|
2422
|
+
this.hideBib("mouseleave");
|
|
2423
|
+
}
|
|
2424
|
+
break;
|
|
2425
|
+
case "focus":
|
|
2426
|
+
if (element.focusShow) {
|
|
2427
|
+
/*
|
|
2428
|
+
This needs to better handle clicking that gives focus -
|
|
2429
|
+
currently it shows and then immediately hides the bib
|
|
2430
|
+
*/
|
|
2431
|
+
this.showBib();
|
|
2432
|
+
}
|
|
2433
|
+
break;
|
|
2434
|
+
case "blur":
|
|
2435
|
+
// send this task 100ms later queue to
|
|
2436
|
+
// wait a frame in case focus moves within the floating element/bib
|
|
2437
|
+
setTimeout(() => this.handleFocusLoss(), 0);
|
|
2438
|
+
break;
|
|
2439
|
+
case "click":
|
|
2440
|
+
if (document.activeElement === document.body) {
|
|
2441
|
+
event.currentTarget.focus();
|
|
2442
|
+
}
|
|
2443
|
+
this.handleClick();
|
|
2444
|
+
break;
|
|
2445
|
+
// Do nothing
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
/**
|
|
2450
|
+
* Manages the tabIndex of the trigger element based on its focusability.
|
|
2451
|
+
*
|
|
2452
|
+
* If the trigger element or any of its children are inherently focusable, the tabIndex of the component is set to -1.
|
|
2453
|
+
* This prevents the component itself from being focusable when the trigger element already handles focus.
|
|
2454
|
+
*/
|
|
2455
|
+
handleTriggerTabIndex() {
|
|
2456
|
+
const element = this.element;
|
|
2457
|
+
if (!element) {
|
|
2458
|
+
return;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
const focusableElementSelectors = [
|
|
2462
|
+
"a",
|
|
2463
|
+
"button",
|
|
2464
|
+
'input:not([type="hidden"])',
|
|
2465
|
+
"select",
|
|
2466
|
+
"textarea",
|
|
2467
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
2468
|
+
"auro-button",
|
|
2469
|
+
"auro-input",
|
|
2470
|
+
"auro-hyperlink",
|
|
2471
|
+
];
|
|
2472
|
+
|
|
2473
|
+
const triggerNode = element.querySelectorAll('[slot="trigger"]')[0];
|
|
2474
|
+
if (!triggerNode) {
|
|
2475
|
+
return;
|
|
2476
|
+
}
|
|
2477
|
+
const triggerNodeTagName = triggerNode.tagName.toLowerCase();
|
|
2478
|
+
|
|
2479
|
+
focusableElementSelectors.forEach((selector) => {
|
|
2480
|
+
// Check if the trigger node element is focusable
|
|
2481
|
+
if (triggerNodeTagName === selector) {
|
|
2482
|
+
element.tabIndex = -1;
|
|
2483
|
+
return;
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
// Check if any child is focusable
|
|
2487
|
+
if (triggerNode.querySelector(selector)) {
|
|
2488
|
+
element.tabIndex = -1;
|
|
2489
|
+
}
|
|
2490
|
+
});
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
/**
|
|
2494
|
+
*
|
|
2495
|
+
* @param {*} eventPrefix
|
|
2496
|
+
*/
|
|
2497
|
+
regenerateBibId() {
|
|
2498
|
+
const element = this.element;
|
|
2499
|
+
if (!element) {
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
this.id = element.getAttribute("id");
|
|
2504
|
+
if (!this.id) {
|
|
2505
|
+
this.id = window.crypto.randomUUID();
|
|
2506
|
+
element.setAttribute("id", this.id);
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
element.bib?.setAttribute("id", `${this.id}-floater-bib`);
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
configure(elem, eventPrefix, enableKeyboardHandling = true) {
|
|
2513
|
+
AuroFloatingUI.setupMousePressChecker();
|
|
2514
|
+
this.enableKeyboardHandling = enableKeyboardHandling;
|
|
2515
|
+
|
|
2516
|
+
this.eventPrefix = eventPrefix;
|
|
2517
|
+
if (this.element !== elem) {
|
|
2518
|
+
this.element = elem;
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
const element = this.element;
|
|
2522
|
+
if (!element) {
|
|
2523
|
+
return;
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
if (this.behavior !== element.behavior) {
|
|
2527
|
+
this.behavior = element.behavior;
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
if (element.trigger) {
|
|
2531
|
+
this.disconnect();
|
|
2532
|
+
}
|
|
2533
|
+
element.trigger =
|
|
2534
|
+
element.triggerElement ||
|
|
2535
|
+
element.shadowRoot?.querySelector("#trigger") ||
|
|
2536
|
+
element.trigger;
|
|
2537
|
+
element.bib = element.shadowRoot?.querySelector("#bib") || element.bib;
|
|
2538
|
+
element.bibSizer = element.shadowRoot?.querySelector("#bibSizer");
|
|
2539
|
+
element.triggerChevron =
|
|
2540
|
+
element.shadowRoot?.querySelector("#showStateIcon");
|
|
2541
|
+
|
|
2542
|
+
if (element.floaterConfig) {
|
|
2543
|
+
element.hoverToggle = element.floaterConfig.hoverToggle;
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
this.regenerateBibId();
|
|
2547
|
+
this.handleTriggerTabIndex();
|
|
2548
|
+
|
|
2549
|
+
this.handleEvent = this.handleEvent.bind(this);
|
|
2550
|
+
if (element.trigger) {
|
|
2551
|
+
if (this.enableKeyboardHandling) {
|
|
2552
|
+
element.trigger.addEventListener("keydown", this.handleEvent);
|
|
2553
|
+
}
|
|
2554
|
+
element.trigger.addEventListener("click", this.handleEvent);
|
|
2555
|
+
element.trigger.addEventListener("mouseenter", this.handleEvent);
|
|
2556
|
+
element.trigger.addEventListener("mouseleave", this.handleEvent);
|
|
2557
|
+
element.trigger.addEventListener("focus", this.handleEvent);
|
|
2558
|
+
element.trigger.addEventListener("blur", this.handleEvent);
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
disconnect() {
|
|
2563
|
+
this.cleanupHideHandlers();
|
|
2564
|
+
|
|
2565
|
+
const element = this.element;
|
|
2566
|
+
if (!element) {
|
|
2567
|
+
return;
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
element.cleanup?.();
|
|
2571
|
+
|
|
2572
|
+
if (element.bib && element.shadowRoot) {
|
|
2573
|
+
element.shadowRoot.append(element.bib);
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
// Remove event & keyboard listeners
|
|
2577
|
+
if (element.trigger) {
|
|
2578
|
+
element.trigger.removeEventListener("keydown", this.handleEvent);
|
|
2579
|
+
element.trigger.removeEventListener("click", this.handleEvent);
|
|
2580
|
+
element.trigger.removeEventListener("mouseenter", this.handleEvent);
|
|
2581
|
+
element.trigger.removeEventListener("mouseleave", this.handleEvent);
|
|
2582
|
+
element.trigger.removeEventListener("focus", this.handleEvent);
|
|
2583
|
+
element.trigger.removeEventListener("blur", this.handleEvent);
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
// Selectors for focusable elements
|
|
2589
|
+
const FOCUSABLE_SELECTORS = [
|
|
2590
|
+
"a[href]",
|
|
2591
|
+
"button:not([disabled])",
|
|
2592
|
+
"textarea:not([disabled])",
|
|
2593
|
+
"input:not([disabled])",
|
|
2594
|
+
"select:not([disabled])",
|
|
2595
|
+
'[role="tab"]:not([disabled])',
|
|
2596
|
+
'[role="link"]:not([disabled])',
|
|
2597
|
+
'[role="button"]:not([disabled])',
|
|
2598
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
2599
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
2600
|
+
];
|
|
2601
|
+
|
|
2602
|
+
// List of custom components that are known to be focusable
|
|
2603
|
+
const FOCUSABLE_COMPONENTS = [
|
|
2604
|
+
"auro-checkbox",
|
|
2605
|
+
"auro-radio",
|
|
2606
|
+
"auro-dropdown",
|
|
2607
|
+
"auro-button",
|
|
2608
|
+
"auro-combobox",
|
|
2609
|
+
"auro-input",
|
|
2610
|
+
"auro-counter",
|
|
2611
|
+
// 'auro-menu', // Auro menu is not focusable by default, it uses a different interaction model
|
|
2612
|
+
"auro-select",
|
|
2613
|
+
"auro-datepicker",
|
|
2614
|
+
"auro-hyperlink",
|
|
2615
|
+
"auro-accordion",
|
|
2616
|
+
];
|
|
2617
|
+
|
|
2618
|
+
/**
|
|
2619
|
+
* Determines if a given element is a custom focusable component.
|
|
2620
|
+
* Returns true if the element matches a known focusable component and is not disabled.
|
|
2621
|
+
*
|
|
2622
|
+
* @param {HTMLElement} element The element to check for focusability.
|
|
2623
|
+
* @returns {boolean} True if the element is a focusable custom component, false otherwise.
|
|
2624
|
+
*/
|
|
2625
|
+
function isFocusableComponent(element) {
|
|
2626
|
+
const componentName = element.tagName.toLowerCase();
|
|
2627
|
+
|
|
2628
|
+
// Guard Clause: Element is a focusable component
|
|
2629
|
+
if (
|
|
2630
|
+
!FOCUSABLE_COMPONENTS.some(
|
|
2631
|
+
(name) => element.hasAttribute(name) || componentName === name,
|
|
2632
|
+
)
|
|
2633
|
+
)
|
|
2634
|
+
return false;
|
|
2635
|
+
|
|
2636
|
+
// Guard Clause: Element is not disabled
|
|
2637
|
+
if (element.hasAttribute("disabled")) return false;
|
|
2638
|
+
|
|
2639
|
+
// Guard Clause: The element is a hyperlink and has no href attribute
|
|
2640
|
+
if (componentName.match("hyperlink") && !element.hasAttribute("href"))
|
|
2641
|
+
return false;
|
|
2642
|
+
|
|
2643
|
+
// If all guard clauses pass, the element is a focusable component
|
|
2644
|
+
return true;
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
/**
|
|
2648
|
+
* Safely get a numeric tabindex for an element.
|
|
2649
|
+
* Returns a number if the tabindex is a valid integer, otherwise null.
|
|
2650
|
+
*
|
|
2651
|
+
* @param {HTMLElement} element The element whose tabindex to read.
|
|
2652
|
+
* @returns {?number} The numeric tabindex or null if missing/invalid.
|
|
2653
|
+
*/
|
|
2654
|
+
function getNumericTabIndex(element) {
|
|
2655
|
+
const raw = element.getAttribute("tabindex");
|
|
2656
|
+
if (raw == null) return null;
|
|
2657
|
+
|
|
2658
|
+
const value = Number.parseInt(raw, 10);
|
|
2659
|
+
return Number.isNaN(value) ? null : value;
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
/**
|
|
2663
|
+
* Retrieves all focusable elements within the container in DOM order, including those in shadow DOM and slots.
|
|
2664
|
+
* Returns a unique, ordered array of elements that can receive focus.
|
|
2665
|
+
* Also sorts elements with tabindex first, preserving their order.
|
|
2666
|
+
*
|
|
2667
|
+
* @param {HTMLElement} container The container to search within
|
|
2668
|
+
* @returns {Array<HTMLElement>} An array of focusable elements within the container.
|
|
2669
|
+
*/
|
|
2670
|
+
function getFocusableElements(container) {
|
|
2671
|
+
// Get elements in DOM order by walking the tree
|
|
2672
|
+
const orderedFocusableElements = [];
|
|
2673
|
+
|
|
2674
|
+
// Define a recursive function to collect focusable elements in DOM order
|
|
2675
|
+
const collectFocusableElements = (root) => {
|
|
2676
|
+
// Check if current element is focusable
|
|
2677
|
+
if (root.nodeType === Node.ELEMENT_NODE) {
|
|
2678
|
+
// Check if this is a custom component that is focusable
|
|
2679
|
+
const isComponentFocusable = isFocusableComponent(root);
|
|
2680
|
+
|
|
2681
|
+
if (isComponentFocusable) {
|
|
2682
|
+
// Add the component itself as a focusable element and don't traverse its shadow DOM
|
|
2683
|
+
orderedFocusableElements.push(root);
|
|
2684
|
+
return; // Skip traversing inside this component
|
|
2685
|
+
}
|
|
2686
|
+
|
|
2687
|
+
// Check if the element itself matches any selector
|
|
2688
|
+
for (const selector of FOCUSABLE_SELECTORS) {
|
|
2689
|
+
if (root.matches?.(selector)) {
|
|
2690
|
+
orderedFocusableElements.push(root);
|
|
2691
|
+
break; // Once we know it's focusable, no need to check other selectors
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
// Process shadow DOM only for non-Auro components
|
|
2696
|
+
if (root.shadowRoot) {
|
|
2697
|
+
// Process shadow DOM children in order
|
|
2698
|
+
if (root.shadowRoot.children) {
|
|
2699
|
+
Array.from(root.shadowRoot.children).forEach((child) => {
|
|
2700
|
+
collectFocusableElements(child);
|
|
2701
|
+
});
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
// Process slots and their assigned nodes in order
|
|
2706
|
+
if (root.tagName === "SLOT") {
|
|
2707
|
+
const assignedNodes = root.assignedNodes({ flatten: true });
|
|
2708
|
+
for (const node of assignedNodes) {
|
|
2709
|
+
collectFocusableElements(node);
|
|
2710
|
+
}
|
|
2711
|
+
} else {
|
|
2712
|
+
// Process light DOM children in order
|
|
2713
|
+
if (root.children) {
|
|
2714
|
+
Array.from(root.children).forEach((child) => {
|
|
2715
|
+
collectFocusableElements(child);
|
|
2716
|
+
});
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
};
|
|
2721
|
+
|
|
2722
|
+
// Start the traversal from the container
|
|
2723
|
+
collectFocusableElements(container);
|
|
2724
|
+
|
|
2725
|
+
// Remove duplicates that might have been collected through different paths
|
|
2726
|
+
// while preserving order
|
|
2727
|
+
const uniqueElements = [];
|
|
2728
|
+
const seen = new Set();
|
|
2729
|
+
|
|
2730
|
+
for (const element of orderedFocusableElements) {
|
|
2731
|
+
if (!seen.has(element)) {
|
|
2732
|
+
seen.add(element);
|
|
2733
|
+
uniqueElements.push(element);
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
// Move tab-indexed elements to the front while preserving their order
|
|
2738
|
+
// This ensures that elements with tabindex are prioritized in the focus order
|
|
2739
|
+
|
|
2740
|
+
// First extract elements with valid positive tabindex
|
|
2741
|
+
const elementsWithTabindex = uniqueElements.filter((el) => {
|
|
2742
|
+
const tabindex = getNumericTabIndex(el);
|
|
2743
|
+
return tabindex !== null && tabindex > 0;
|
|
2744
|
+
});
|
|
2745
|
+
|
|
2746
|
+
// Sort these elements by their tabindex value
|
|
2747
|
+
elementsWithTabindex.sort((a, b) => {
|
|
2748
|
+
const aIndex = getNumericTabIndex(a) ?? 0;
|
|
2749
|
+
const bIndex = getNumericTabIndex(b) ?? 0;
|
|
2750
|
+
return aIndex - bIndex;
|
|
2751
|
+
});
|
|
2752
|
+
|
|
2753
|
+
// Elements without tabindex (preserving their original order)
|
|
2754
|
+
const elementsWithoutTabindex = uniqueElements.filter((el) => {
|
|
2755
|
+
const tabindex = getNumericTabIndex(el);
|
|
2756
|
+
|
|
2757
|
+
// Elements without tabindex or with tabindex of 0 stay in DOM order
|
|
2758
|
+
return tabindex === null || tabindex === 0;
|
|
2759
|
+
});
|
|
2760
|
+
|
|
2761
|
+
// Combine both arrays with tabindex elements first
|
|
2762
|
+
const tabIndexedUniqueElements = [
|
|
2763
|
+
...elementsWithTabindex,
|
|
2764
|
+
...elementsWithoutTabindex,
|
|
2765
|
+
];
|
|
2766
|
+
|
|
2767
|
+
return tabIndexedUniqueElements;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
/**
|
|
2771
|
+
* FocusTrap manages keyboard focus within a specified container element, ensuring that focus does not leave the container when tabbing.
|
|
2772
|
+
* It is commonly used for modal dialogs or overlays to improve accessibility by trapping focus within interactive UI components.
|
|
2773
|
+
*/
|
|
2774
|
+
class FocusTrap {
|
|
2775
|
+
/**
|
|
2776
|
+
* Creates a new FocusTrap instance for the given container element.
|
|
2777
|
+
* Initializes event listeners and prepares the container for focus management.
|
|
2778
|
+
*
|
|
2779
|
+
* @param {HTMLElement} container The DOM element to trap focus within.
|
|
2780
|
+
* @param {boolean} [controlTabOrder=false] If true enables manual control of the tab order by the FocusTrap.
|
|
2781
|
+
* @throws {Error} If the provided container is not a valid HTMLElement.
|
|
2782
|
+
*/
|
|
2783
|
+
constructor(container, controlTabOrder = false) {
|
|
2784
|
+
if (!container || !(container instanceof HTMLElement)) {
|
|
2785
|
+
throw new Error("FocusTrap requires a valid HTMLElement.");
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
this.container = container;
|
|
2789
|
+
this.tabDirection = "forward"; // or 'backward';
|
|
2790
|
+
this.controlTabOrder = controlTabOrder;
|
|
2791
|
+
|
|
2792
|
+
this._init();
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
/**
|
|
2796
|
+
* Initializes the focus trap by setting up event listeners and attributes on the container.
|
|
2797
|
+
* Prepares the container for focus management, including support for shadow DOM and inert attributes.
|
|
2798
|
+
*
|
|
2799
|
+
* @private
|
|
2800
|
+
*/
|
|
2801
|
+
_init() {
|
|
2802
|
+
// Add inert attribute to prevent focusing programmatically as well (if supported)
|
|
2803
|
+
if ("inert" in HTMLElement.prototype) {
|
|
2804
|
+
this.container.inert = false; // Ensure the container isn't inert
|
|
2805
|
+
this.container.setAttribute("data-focus-trap-container", true); // Mark for identification
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
// Track tab direction
|
|
2809
|
+
this.container.addEventListener("keydown", this._onKeydown);
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
/**
|
|
2813
|
+
* Gets an array of currently active (focused) elements in the document and shadow DOM.
|
|
2814
|
+
* @returns {Array<HTMLElement>} An array of focusable elements within the container.
|
|
2815
|
+
* @private
|
|
2816
|
+
*/
|
|
2817
|
+
_getActiveElements() {
|
|
2818
|
+
// Get the active element(s) in the document and shadow root
|
|
2819
|
+
// This will include the active element in the shadow DOM if it exists
|
|
2820
|
+
// Active element may be inside the shadow DOM depending on delegatesFocus, so we need to check both
|
|
2821
|
+
let { activeElement } = document;
|
|
2822
|
+
const actives = [activeElement];
|
|
2823
|
+
while (activeElement?.shadowRoot?.activeElement) {
|
|
2824
|
+
actives.push(activeElement.shadowRoot.activeElement);
|
|
2825
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
|
2826
|
+
}
|
|
2827
|
+
return actives;
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2830
|
+
/**
|
|
2831
|
+
* Gets the next focus index based on the current index and focusable elements.
|
|
2832
|
+
* @param {number} currentIndex The current index of the focused element.
|
|
2833
|
+
* @param {Array<HTMLElement>} focusables The array of focusable elements.
|
|
2834
|
+
* @returns {number|null} The next focus index or null if not determined.
|
|
2835
|
+
*/
|
|
2836
|
+
_getNextFocusIndex(currentIndex, focusables, actives) {
|
|
2837
|
+
if (this.controlTabOrder) {
|
|
2838
|
+
// Calculate the new index based on the current index and tab direction
|
|
2839
|
+
let newFocusIndex =
|
|
2840
|
+
currentIndex + (this.tabDirection === "forward" ? 1 : -1);
|
|
2841
|
+
|
|
2842
|
+
// Wrap-around logic
|
|
2843
|
+
if (newFocusIndex < 0) newFocusIndex = focusables.length - 1;
|
|
2844
|
+
if (newFocusIndex >= focusables.length) newFocusIndex = 0;
|
|
2845
|
+
|
|
2846
|
+
// Early return with the new index
|
|
2847
|
+
return newFocusIndex;
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
// Determine if we need to wrap
|
|
2851
|
+
const atFirst =
|
|
2852
|
+
actives.includes(focusables[0]) || actives.includes(this.container);
|
|
2853
|
+
const atLast = actives.includes(focusables[focusables.length - 1]);
|
|
2854
|
+
|
|
2855
|
+
// Only wrap if at the ends
|
|
2856
|
+
if (this.tabDirection === "backward" && atFirst) {
|
|
2857
|
+
return focusables.length - 1;
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
if (this.tabDirection === "forward" && atLast) {
|
|
2861
|
+
return 0;
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
// No wrap, so don't change focus, return early
|
|
2865
|
+
return null;
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2868
|
+
/**
|
|
2869
|
+
* Handles the Tab key press event to manage focus within the container.
|
|
2870
|
+
* @param {KeyboardEvent} e The keyboard event triggered by the user.
|
|
2871
|
+
* @returns {void}
|
|
2872
|
+
*/
|
|
2873
|
+
_handleTabKey(e) {
|
|
2874
|
+
// Update the focusable elements
|
|
2875
|
+
const focusables = this._getFocusableElements();
|
|
2876
|
+
|
|
2877
|
+
// If there are no focusable elements, exit
|
|
2878
|
+
if (!focusables.length) return;
|
|
2879
|
+
|
|
2880
|
+
// Set the tab direction based on the key pressed
|
|
2881
|
+
this.tabDirection = e.shiftKey ? "backward" : "forward";
|
|
2882
|
+
|
|
2883
|
+
// Get the active elements that are currently focused
|
|
2884
|
+
const actives = this._getActiveElements();
|
|
2885
|
+
|
|
2886
|
+
// If we're at either end of the focusable elements, wrap around to the other end
|
|
2887
|
+
let focusIndex = focusables.findIndex((el) => actives.includes(el));
|
|
2888
|
+
|
|
2889
|
+
// Fallback if we have no focused element
|
|
2890
|
+
if (focusIndex === -1) focusIndex = 0;
|
|
2891
|
+
|
|
2892
|
+
// Get the next focus index based on the current focus index, tab direction, and controlTabOrder setting
|
|
2893
|
+
// Is null if no new focus index is determined
|
|
2894
|
+
const newFocusIndex = this._getNextFocusIndex(
|
|
2895
|
+
focusIndex,
|
|
2896
|
+
focusables,
|
|
2897
|
+
actives,
|
|
2898
|
+
);
|
|
2899
|
+
|
|
2900
|
+
// If we have a new focus index, set focus to that element
|
|
2901
|
+
if (newFocusIndex !== null) {
|
|
2902
|
+
e.preventDefault();
|
|
2903
|
+
focusables[newFocusIndex].focus();
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
/**
|
|
2908
|
+
* Catches the keydown event
|
|
2909
|
+
* @param {KeyboardEvent} e The keyboard event triggered by user interaction.
|
|
2910
|
+
* @private
|
|
2911
|
+
*/
|
|
2912
|
+
_onKeydown = (e) => {
|
|
2913
|
+
// Handle tab
|
|
2914
|
+
if (e.key === "Tab") this._handleTabKey(e);
|
|
2915
|
+
};
|
|
2916
|
+
|
|
2917
|
+
/**
|
|
2918
|
+
* Retrieves all focusable elements within the container in DOM order, including those in shadow DOM and slots.
|
|
2919
|
+
* Returns a unique, ordered array of elements that can receive focus.
|
|
2920
|
+
*
|
|
2921
|
+
* @returns {Array<HTMLElement>} An array of focusable elements within the container.
|
|
2922
|
+
* @private
|
|
2923
|
+
*/
|
|
2924
|
+
_getFocusableElements() {
|
|
2925
|
+
// Use the imported utility function to get focusable elements
|
|
2926
|
+
const elements = getFocusableElements(this.container);
|
|
2927
|
+
|
|
2928
|
+
// Return the elements found
|
|
2929
|
+
return elements;
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
/**
|
|
2933
|
+
* Moves focus to the first focusable element within the container.
|
|
2934
|
+
* Useful for setting initial focus when activating the focus trap.
|
|
2935
|
+
*/
|
|
2936
|
+
focusFirstElement() {
|
|
2937
|
+
const focusables = this._getFocusableElements();
|
|
2938
|
+
if (focusables.length) focusables[0].focus();
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2941
|
+
/**
|
|
2942
|
+
* Moves focus to the last focusable element within the container.
|
|
2943
|
+
* Useful for setting focus when deactivating or cycling focus in reverse.
|
|
2944
|
+
*/
|
|
2945
|
+
focusLastElement() {
|
|
2946
|
+
const focusables = this._getFocusableElements();
|
|
2947
|
+
if (focusables.length) focusables[focusables.length - 1].focus();
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
/**
|
|
2951
|
+
* Removes event listeners and attributes added by the focus trap.
|
|
2952
|
+
* Call this method to clean up when the focus trap is no longer needed.
|
|
2953
|
+
*/
|
|
2954
|
+
disconnect() {
|
|
2955
|
+
if (this.container.hasAttribute("data-focus-trap-container")) {
|
|
2956
|
+
this.container.removeAttribute("data-focus-trap-container");
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
this.container.removeEventListener("keydown", this._onKeydown);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
2964
|
+
// See LICENSE in the project root for license information.
|
|
2965
|
+
|
|
2966
|
+
|
|
2967
|
+
class AuroDependencyVersioning {
|
|
2968
|
+
|
|
2969
|
+
/**
|
|
2970
|
+
* Generates a unique string to be used for child auro element naming.
|
|
2971
|
+
* @private
|
|
2972
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
2973
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
2974
|
+
* @returns {string} - Unique string to be used for naming.
|
|
2975
|
+
*/
|
|
2976
|
+
generateElementName(baseName, version) {
|
|
2977
|
+
let result = baseName;
|
|
2978
|
+
|
|
2979
|
+
result += '-';
|
|
2980
|
+
result += version.replace(/[.]/g, '_');
|
|
2981
|
+
|
|
2982
|
+
return result;
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
/**
|
|
2986
|
+
* Generates a unique string to be used for child auro element naming.
|
|
2987
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
2988
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
2989
|
+
* @returns {string} - Unique string to be used for naming.
|
|
2990
|
+
*/
|
|
2991
|
+
generateTag(baseName, version, tagClass) {
|
|
2992
|
+
const elementName = this.generateElementName(baseName, version);
|
|
2993
|
+
const tag = literal`${unsafeStatic(elementName)}`;
|
|
2994
|
+
|
|
2995
|
+
if (!customElements.get(elementName)) {
|
|
2996
|
+
customElements.define(elementName, class extends tagClass {});
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
return tag;
|
|
3000
|
+
}
|
|
3001
|
+
}
|
|
3002
|
+
|
|
3003
|
+
class p{registerComponent(t,a){customElements.get(t)||customElements.define(t,class extends a{});}closestElement(t,a=this,e=(a,s=a&&a.closest(t))=>a&&a!==document&&a!==window?s||e(a.getRootNode().host):null){return e(a)}handleComponentTagRename(t,a){const e=a.toLowerCase();t.tagName.toLowerCase()!==e&&t.setAttribute(e,true);}elementMatch(t,a){const e=a.toLowerCase();return t.tagName.toLowerCase()===e||t.hasAttribute(e)}getSlotText(t,a){const e=t.shadowRoot?.querySelector(`slot[name="${a}"]`);return (e?.assignedNodes({flatten:true})||[]).map(t=>t.textContent?.trim()).join(" ").trim()||null}}var u='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-labelledby="error__desc" class="ico_squareLarge" data-deprecated="true" role="img" style="min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor" viewBox="0 0 24 24" part="svg"><title/><desc id="error__desc">Error alert indicator.</desc><path d="m13.047 5.599 6.786 11.586A1.207 1.207 0 0 1 18.786 19H5.214a1.207 1.207 0 0 1-1.047-1.815l6.786-11.586a1.214 1.214 0 0 1 2.094 0m-1.165.87a.23.23 0 0 0-.085.085L5.419 17.442a.232.232 0 0 0 .203.35h12.756a.234.234 0 0 0 .203-.35L12.203 6.554a.236.236 0 0 0-.321-.084M12 15.5a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m-.024-6.22c.325 0 .589.261.589.583v4.434a.586.586 0 0 1-.589.583.586.586 0 0 1-.588-.583V9.863c0-.322.264-.583.588-.583"/></svg>';class m extends LitElement{static get properties(){return {hidden:{type:Boolean,reflect:true},hiddenVisually:{type:Boolean,reflect:true},hiddenAudible:{type:Boolean,reflect:true}}}hideAudible(t){return t?"true":"false"}}const g=new Map,f=(t,a={})=>{const e=a.responseParser||(t=>t.text());return g.has(t)||g.set(t,fetch(t).then(e)),g.get(t)};var w=css`:focus:not(:focus-visible){outline:3px solid transparent}.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);width:1px;height:1px;padding:0;border:0}.ico_squareLarge{fill:currentColor;height:var(--auro-size-lg, var(--ds-size-300, 1.5rem))}.ico_squareSmall{fill:currentColor;height:.6rem}.ico_squareMed{fill:currentColor;height:var(--auro-size-md, var(--ds-size-200, 1rem))}.ico_squareSml{fill:currentColor;height:var(--auro-size-sm, var(--ds-size-150, .75rem))}:host{color:currentColor;vertical-align:middle;display:inline-block}svg{min-width:var(--ds-auro-icon-size, 1.5rem)!important;width:var(--ds-auro-icon-size, 1.5rem)!important;height:var(--ds-auro-icon-size, 1.5rem)!important}.componentWrapper{display:flex;line-height:var(--ds-auro-icon-size)}.svgWrapper{height:var(--ds-auro-icon-size);width:var(--ds-auro-icon-size)}.svgWrapper [part=svg]{display:flex}.labelWrapper{margin-left:var(--ds-size-50, .25rem)}.labelWrapper ::slotted(*){line-height:inherit!important}
|
|
3004
|
+
`;class z extends m{constructor(){super(),this._initializeDefaults();}_initializeDefaults(){this.onDark=false,this.appearance="default";}static get properties(){return {...m.properties,onDark:{type:Boolean,reflect:true},appearance:{type:String,reflect:true},svg:{attribute:false,reflect:true}}}static get styles(){return w}async fetchIcon(t,a){let e="";e="logos"===t?await f(`${this.uri}/${t}/${a}.svg`):await f(`${this.uri}/icons/${t}/${a}.svg`);return (new DOMParser).parseFromString(e,"text/html").body.querySelector("svg")}async firstUpdated(){try{if(!this.customSvg){const t=await this.fetchIcon(this.category,this.name);if(t)this.svg=t;else if(!t){const t=(new DOMParser).parseFromString(u,"text/html");this.svg=t.body.firstChild;}}}catch(t){this.svg=void 0;}}}css`.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);width:1px;height:1px;padding:0;border:0}:host{display:inline-block;--ds-auro-icon-size: 100%;width:100%;height:100%}:host .logo{color:var(--ds-auro-alaska-color)}:host([onDark]),:host([appearance=inverse]){--ds-auro-alaska-color: #FFF}
|
|
3005
|
+
`;var y=css`:host{--ds-auro-icon-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-alaska-color: #02426D;--ds-auro-icon-size: var(--ds-size-300, 1.5rem)}
|
|
3006
|
+
`;var x=css`:host{color:var(--ds-auro-icon-color)}:host([customColor]){color:inherit}:host(:not([onDark])[variant=accent1]),:host(:not([appearance=inverse])[variant=accent1]){--ds-auro-icon-color: var(--ds-basic-color-texticon-accent1, #265688)}:host(:not([onDark])[variant=disabled]),:host(:not([appearance=inverse])[variant=disabled]){--ds-auro-icon-color: var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host(:not([onDark])[variant=muted]),:host(:not([appearance=inverse])[variant=muted]){--ds-auro-icon-color: var(--ds-basic-color-texticon-muted, #676767)}:host(:not([onDark])[variant=statusDefault]),:host(:not([appearance=inverse])[variant=statusDefault]){--ds-auro-icon-color: var(--ds-basic-color-status-default, #afb9c6)}:host(:not([onDark])[variant=statusInfo]),:host(:not([appearance=inverse])[variant=statusInfo]){--ds-auro-icon-color: var(--ds-basic-color-status-info, #01426a)}:host(:not([onDark])[variant=statusSuccess]),:host(:not([appearance=inverse])[variant=statusSuccess]){--ds-auro-icon-color: var(--ds-basic-color-status-success, #447a1f)}:host(:not([onDark])[variant=statusWarning]),:host(:not([appearance=inverse])[variant=statusWarning]){--ds-auro-icon-color: var(--ds-basic-color-status-warning, #fac200)}:host(:not([onDark])[variant=statusError]),:host(:not([appearance=inverse])[variant=statusError]){--ds-auro-icon-color: var(--ds-basic-color-status-error, #e31f26)}:host(:not([onDark])[variant=statusInfoSubtle]),:host(:not([appearance=inverse])[variant=statusInfoSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-info-subtle, #ebf3f9)}:host(:not([onDark])[variant=statusSuccessSubtle]),:host(:not([appearance=inverse])[variant=statusSuccessSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-success-subtle, #d6eac7)}:host(:not([onDark])[variant=statusWarningSubtle]),:host(:not([appearance=inverse])[variant=statusWarningSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-warning-subtle, #fff0b2)}:host(:not([onDark])[variant=statusErrorSubtle]),:host(:not([appearance=inverse])[variant=statusErrorSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-error-subtle, #fbc6c6)}:host(:not([onDark])[variant=fareBasicEconomy]),:host(:not([appearance=inverse])[variant=fareBasicEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-basiceconomy, #97eaf8)}:host(:not([onDark])[variant=fareBusiness]),:host(:not([appearance=inverse])[variant=fareBusiness]){--ds-auro-icon-color: var(--ds-basic-color-fare-business, #01426a)}:host(:not([onDark])[variant=fareEconomy]),:host(:not([appearance=inverse])[variant=fareEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-economy, #0074ca)}:host(:not([onDark])[variant=fareFirst]),:host(:not([appearance=inverse])[variant=fareFirst]){--ds-auro-icon-color: var(--ds-basic-color-fare-first, #00274a)}:host(:not([onDark])[variant=farePremiumEconomy]),:host(:not([appearance=inverse])[variant=farePremiumEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-premiumeconomy, #005154)}:host(:not([onDark])[variant=tierOneWorldEmerald]),:host(:not([appearance=inverse])[variant=tierOneWorldEmerald]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-emerald, #139142)}:host(:not([onDark])[variant=tierOneWorldSapphire]),:host(:not([appearance=inverse])[variant=tierOneWorldSapphire]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-sapphire, #015daa)}:host(:not([onDark])[variant=tierOneWorldRuby]),:host(:not([appearance=inverse])[variant=tierOneWorldRuby]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-ruby, #a41d4a)}:host([onDark]),:host([appearance=inverse]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse, #ffffff)}:host([onDark][variant=disabled]),:host([appearance=inverse][variant=disabled]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}:host([onDark][variant=muted]),:host([appearance=inverse][variant=muted]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse-muted, #ccd2db)}:host([onDark][variant=statusError]),:host([appearance=inverse][variant=statusError]){--ds-auro-icon-color: var(--ds-advanced-color-state-error-inverse, #f9a4a8)}
|
|
3007
|
+
`;class _ extends z{constructor(){super(),this._initializeDefaults();}_initializeDefaults(){this.variant=void 0,this.uri="https://cdn.jsdelivr.net/npm/@alaskaairux/icons@latest/dist",this.runtimeUtils=new p;}static get properties(){return {...z.properties,ariaHidden:{type:String,reflect:true},category:{type:String,reflect:true},customColor:{type:Boolean,reflect:true},customSvg:{type:Boolean},label:{type:Boolean,reflect:true},name:{type:String,reflect:true},variant:{type:String,reflect:true}}}static get styles(){return [z.styles,y,w,x]}static register(t="auro-icon"){p.prototype.registerComponent(t,_);}connectedCallback(){super.connectedCallback(),this.runtimeUtils.handleComponentTagRename(this,"auro-icon");}exposeCssParts(){this.setAttribute("exportparts","svg:iconSvg");}async firstUpdated(){if(await super.firstUpdated(),this.hasAttribute("ariaHidden")&&this.svg){const t=this.svg.querySelector("desc");t&&(t.remove(),this.svg.removeAttribute("aria-labelledby"));}}render(){const t={labelWrapper:true,util_displayHiddenVisually:!this.label};return html`
|
|
3008
|
+
<div class="componentWrapper">
|
|
3009
|
+
<div
|
|
3010
|
+
class="${classMap({svgWrapper:true})}"
|
|
3011
|
+
title="${ifDefined(this.title||void 0)}">
|
|
3012
|
+
<span aria-hidden="${ifDefined(this.ariaHidden||true)}" part="svg">
|
|
3013
|
+
${this.customSvg?html`
|
|
3014
|
+
<slot name="svg"></slot>
|
|
3015
|
+
`:html`
|
|
3016
|
+
${this.svg}
|
|
3017
|
+
`}
|
|
3018
|
+
</span>
|
|
3019
|
+
</div>
|
|
3020
|
+
|
|
3021
|
+
<div class="${classMap(t)}" part="label">
|
|
3022
|
+
<slot></slot>
|
|
3023
|
+
</div>
|
|
3024
|
+
</div>
|
|
3025
|
+
`}}
|
|
3026
|
+
|
|
3027
|
+
var iconVersion = '9.1.2';
|
|
3028
|
+
|
|
3029
|
+
/**
|
|
3030
|
+
* Computes display state once per keydown event.
|
|
3031
|
+
* Centralizes null-safety checks and makes the shared/modal/popover branching explicit.
|
|
3032
|
+
*
|
|
3033
|
+
* @param {HTMLElement} component - The component with a dropdown reference.
|
|
3034
|
+
* @param {Object} [options] - Optional config.
|
|
3035
|
+
* @param {HTMLElement} [options.dropdown] - Explicit dropdown reference. Falls back to component.dropdown.
|
|
3036
|
+
* @param {Function} [options.inputResolver] - Called with (component, ctx) to resolve the active input element.
|
|
3037
|
+
* @returns {{isExpanded: boolean, isModal: boolean, isPopover: boolean, activeInput: HTMLElement|null}}
|
|
3038
|
+
* isModal and isPopover reflect the display mode (fullscreen vs not) regardless of expanded state.
|
|
3039
|
+
*/
|
|
3040
|
+
function createDisplayContext(component, options = {}) {
|
|
3041
|
+
const dd = options.dropdown || component.dropdown;
|
|
3042
|
+
// isPopoverVisible reflects as the `open` attribute.
|
|
3043
|
+
// It reports whether the bib is open in any mode (popover or modal).
|
|
3044
|
+
const isExpanded = Boolean(dd && dd.isPopoverVisible);
|
|
3045
|
+
const isFullscreen = Boolean(dd && dd.isBibFullscreen);
|
|
3046
|
+
|
|
3047
|
+
const ctx = {
|
|
3048
|
+
isExpanded,
|
|
3049
|
+
isModal: isFullscreen,
|
|
3050
|
+
isPopover: !isFullscreen,
|
|
3051
|
+
activeInput: null,
|
|
3052
|
+
};
|
|
3053
|
+
|
|
3054
|
+
if (options.inputResolver) {
|
|
3055
|
+
const resolvedInput = options.inputResolver(component, ctx);
|
|
3056
|
+
// Guard against resolvers returning undefined or non-HTMLElement values.
|
|
3057
|
+
ctx.activeInput = resolvedInput instanceof HTMLElement ? resolvedInput : null;
|
|
3058
|
+
}
|
|
3059
|
+
|
|
3060
|
+
return ctx;
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
/**
|
|
3064
|
+
* Wires up a keydown listener that dispatches to strategy[evt.key] or strategy.default.
|
|
3065
|
+
* Handles both sync and async handlers.
|
|
3066
|
+
* @param {HTMLElement} component - The component to attach the listener to.
|
|
3067
|
+
* @param {Object} strategy - Map of key names to handler functions.
|
|
3068
|
+
* @param {Object} [options] - Optional config passed to createDisplayContext.
|
|
3069
|
+
*/
|
|
3070
|
+
function applyKeyboardStrategy(component, strategy, options = {}) {
|
|
3071
|
+
component.addEventListener('keydown', async (evt) => {
|
|
3072
|
+
const handler = strategy[evt.key] || strategy.default;
|
|
3073
|
+
if (typeof handler === 'function') {
|
|
3074
|
+
const ctx = createDisplayContext(component, options);
|
|
3075
|
+
await handler(component, evt, ctx);
|
|
3076
|
+
}
|
|
3077
|
+
});
|
|
3078
|
+
}
|
|
3079
|
+
|
|
3080
|
+
var styleCss$2 = css`:host{position:fixed;z-index:var(--depth-tooltip, 400);display:none;isolation:isolate}:host dialog{width:auto;max-width:none;height:auto;max-height:none;padding:0;border:none;margin:0;outline:none;transform:translateZ(0)}:host dialog::backdrop{background:transparent}:host(:not([isfullscreen])) dialog{position:relative;inset:unset}:host(:not([isfullscreen])) .container.shape-box{border-radius:unset}:host(:not([isfullscreen])) .container[class*=shape-pill],:host(:not([isfullscreen])) .container[class*=shape-snowflake]{border-radius:30px}:host(:not([isfullscreen])) .container[class*=shape-rounded]{border-radius:16px}:host(:not([matchWidth])) .container{min-width:fit-content}:host([isfullscreen]){position:fixed;top:0;left:0}:host([isfullscreen]) .container{width:100dvw;max-width:none;height:100dvh;max-height:none;border-radius:unset;margin-top:0;box-shadow:unset;overscroll-behavior:contain}:host([isfullscreen]) .container::backdrop{background:var(--ds-color-background-primary, #fff)}:host(:popover-open){position:fixed;overflow:visible;padding:0;border:none;margin:0;background:transparent;inset:unset;outline:none}:host([data-show]){display:flex}:host([common]:not([isfullscreen])) .container,:host([rounded]:not([isfullscreen])) .container{border-radius:var(--ds-border-radius, 0.375rem)}:host([common][isfullscreen]) .container,:host([rounded][isfullscreen]) .container{border-radius:unset;box-shadow:unset}.container{display:inline-block;overflow:auto;box-sizing:border-box;border-radius:var(--ds-border-radius, 0.375rem);margin:var(--ds-size-50, 0.25rem) 0}.util_displayHiddenVisually{position:absolute;overflow:hidden;width:1px;height:1px;padding:0;border:0;margin:-1px;clip-path:inset(50%);white-space:nowrap}`;
|
|
3081
|
+
|
|
3082
|
+
var colorCss$2 = css`.container{background-color:var(--ds-auro-dropdownbib-container-color);box-shadow:var(--ds-auro-dropdownbib-boxshadow-color);color:var(--ds-auro-dropdownbib-text-color)}`;
|
|
3083
|
+
|
|
3084
|
+
var tokensCss$1 = css`:host(:not([ondark])),:host(:not([appearance=inverse])){--ds-auro-dropdown-label-text-color: var(--ds-basic-color-texticon-muted, #676767);--ds-auro-dropdown-trigger-background-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-dropdown-trigger-hover-background-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-dropdown-trigger-container-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-dropdown-trigger-border-color: var(--ds-basic-color-border-bold, #585e67);--ds-auro-dropdown-trigger-outline-color: transparent;--ds-auro-dropdown-trigger-text-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-dropdownbib-boxshadow-color: var(--ds-elevation-200, 0px 0px 10px rgba(0, 0, 0, 0.15));--ds-auro-dropdownbib-background-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-dropdownbib-container-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-dropdownbib-text-color: var(--ds-basic-color-texticon-default, #2a2a2a)}:host([ondark]),:host([appearance=inverse]){--ds-auro-dropdown-label-text-color: var(--ds-basic-color-texticon-inverse-muted, #ccd2db);--ds-auro-dropdown-trigger-background-color: var(--ds-advanced-color-shared-background-inverse, rgba(255, 255, 255, 0.15));--ds-auro-dropdown-trigger-hover-background-color: var(--ds-advanced-color-shared-background-inverse, rgba(255, 255, 255, 0.15));--ds-auro-dropdown-trigger-container-color: var(--ds-advanced-color-shared-background-inverse, rgba(255, 255, 255, 0.15));--ds-auro-dropdown-trigger-border-color: var(--ds-basic-color-border-inverse, #ffffff);--ds-auro-dropdown-trigger-outline-color: transparent;--ds-auro-dropdown-trigger-text-color: var(--ds-basic-color-texticon-inverse, #ffffff);--ds-auro-dropdownbib-boxshadow-color: var(--ds-elevation-200, 0px 0px 10px rgba(0, 0, 0, 0.15));--ds-auro-dropdownbib-background-color: var(--ds-advanced-color-shared-background-inverse, rgba(255, 255, 255, 0.15));--ds-auro-dropdownbib-container-color: var(--ds-advanced-color-shared-background-inverse, rgba(255, 255, 255, 0.15));--ds-auro-dropdownbib-text-color: var(--ds-basic-color-texticon-inverse, #ffffff)}`;
|
|
3085
|
+
|
|
3086
|
+
/**
|
|
3087
|
+
* Creates a keyboard strategy for dialog-specific key handling.
|
|
3088
|
+
* All other keydown behavior is left to the browser's native bubbling path.
|
|
3089
|
+
* @param {HTMLElement} bib - The dropdown bib element.
|
|
3090
|
+
* @returns {Object} Keyboard handlers keyed by `event.key`.
|
|
3091
|
+
*/
|
|
3092
|
+
// eslint-disable-next-line no-unused-vars
|
|
3093
|
+
function createDropdownBibKeyboardStrategy(bib) {
|
|
3094
|
+
return {
|
|
3095
|
+
// eslint-disable-next-line no-unused-vars
|
|
3096
|
+
Enter(_dialog, event) {
|
|
3097
|
+
// Floating UI handles Enter key to open the dropdown
|
|
3098
|
+
},
|
|
3099
|
+
// eslint-disable-next-line no-unused-vars
|
|
3100
|
+
Escape(_dialog, event) {
|
|
3101
|
+
// Floating UI handles Escape key to close the dropdown
|
|
3102
|
+
}
|
|
3103
|
+
};
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
// Copyright (c) 2020 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
3107
|
+
// See LICENSE in the project root for license information.
|
|
3108
|
+
/* eslint-disable max-lines */
|
|
3109
|
+
// ---------------------------------------------------------------------
|
|
3110
|
+
|
|
3111
|
+
|
|
3112
|
+
const DESIGN_TOKEN_BREAKPOINT_PREFIX = '--ds-grid-breakpoint-';
|
|
3113
|
+
const DESIGN_TOKEN_BREAKPOINT_OPTIONS = [
|
|
3114
|
+
'xl',
|
|
3115
|
+
'lg',
|
|
3116
|
+
'md',
|
|
3117
|
+
'sm',
|
|
3118
|
+
'xs',
|
|
3119
|
+
];
|
|
3120
|
+
|
|
3121
|
+
/**
|
|
3122
|
+
* @prop { String } fullscreenBreakpoint - Defines the screen size breakpoint (`lg`, `md`, `sm`, or `xs`) at which the dropdown switches to fullscreen mode on mobile. When expanded, the dropdown will automatically display in fullscreen mode if the screen size is equal to or smaller than the selected breakpoint.
|
|
3123
|
+
* @csspart bibContainer - Apply css to the bib container.
|
|
3124
|
+
*/
|
|
3125
|
+
|
|
3126
|
+
class AuroDropdownBib extends LitElement {
|
|
3127
|
+
// not extending AuroElement because Bib needs only `shape` prop
|
|
3128
|
+
constructor() {
|
|
3129
|
+
super();
|
|
3130
|
+
|
|
3131
|
+
/**
|
|
3132
|
+
* @private
|
|
3133
|
+
*/
|
|
3134
|
+
this._mobileBreakpointName = undefined;
|
|
3135
|
+
|
|
3136
|
+
AuroLibraryRuntimeUtils$1.prototype.handleComponentTagRename(this, 'auro-dropdownbib');
|
|
3137
|
+
|
|
3138
|
+
this.shape = "rounded";
|
|
3139
|
+
this.matchWidth = false;
|
|
3140
|
+
this.hasActiveDescendant = false;
|
|
3141
|
+
}
|
|
3142
|
+
|
|
3143
|
+
static get styles() {
|
|
3144
|
+
return [
|
|
3145
|
+
styleCss$2,
|
|
3146
|
+
colorCss$2,
|
|
3147
|
+
tokensCss$1
|
|
3148
|
+
];
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3151
|
+
static get properties() {
|
|
3152
|
+
return {
|
|
3153
|
+
|
|
3154
|
+
/**
|
|
3155
|
+
* If declared, will take the fullscreen when the bib is displayed.
|
|
3156
|
+
*/
|
|
3157
|
+
isFullscreen: {
|
|
3158
|
+
type: Boolean,
|
|
3159
|
+
reflect: true
|
|
3160
|
+
},
|
|
3161
|
+
|
|
3162
|
+
/**
|
|
3163
|
+
* If declared, will apply all styles for the common theme.
|
|
3164
|
+
*/
|
|
3165
|
+
common: {
|
|
3166
|
+
type: Boolean,
|
|
3167
|
+
reflect: true
|
|
3168
|
+
},
|
|
3169
|
+
|
|
3170
|
+
/**
|
|
3171
|
+
* If declared, will apply extra padding to bib content.
|
|
3172
|
+
*/
|
|
3173
|
+
inset: {
|
|
3174
|
+
type: Boolean,
|
|
3175
|
+
reflect: true
|
|
3176
|
+
},
|
|
3177
|
+
|
|
3178
|
+
/**
|
|
3179
|
+
* If declared, the bib width will match the trigger width.
|
|
3180
|
+
* @private
|
|
3181
|
+
*/
|
|
3182
|
+
matchWidth: {
|
|
3183
|
+
type: Boolean,
|
|
3184
|
+
reflect: true
|
|
3185
|
+
},
|
|
3186
|
+
|
|
3187
|
+
/**
|
|
3188
|
+
* If declared, will apply border-radius to the bib.
|
|
3189
|
+
*/
|
|
3190
|
+
rounded: {
|
|
3191
|
+
type: Boolean,
|
|
3192
|
+
reflect: true
|
|
3193
|
+
},
|
|
3194
|
+
|
|
3195
|
+
/**
|
|
3196
|
+
* A reference to the associated bib template element.
|
|
3197
|
+
*/
|
|
3198
|
+
bibTemplate: {
|
|
3199
|
+
type: Object
|
|
3200
|
+
},
|
|
3201
|
+
|
|
3202
|
+
shape: {
|
|
3203
|
+
type: String,
|
|
3204
|
+
reflect: true
|
|
3205
|
+
},
|
|
3206
|
+
|
|
3207
|
+
/**
|
|
3208
|
+
* Accessible label for the dialog element, used when displayed as a modal.
|
|
3209
|
+
* Applied via aria-labelledby on a visually hidden element rather than
|
|
3210
|
+
* aria-label because iOS VoiceOver does not reliably read aria-label
|
|
3211
|
+
* on <dialog> elements.
|
|
3212
|
+
* @private
|
|
3213
|
+
*/
|
|
3214
|
+
dialogLabel: {
|
|
3215
|
+
type: String
|
|
3216
|
+
},
|
|
3217
|
+
|
|
3218
|
+
/**
|
|
3219
|
+
* Overrides the native role of the dialog element.
|
|
3220
|
+
* For example, set to `"presentation"` on desktop combobox to prevent
|
|
3221
|
+
* VoiceOver from announcing "listbox inside of a dialog".
|
|
3222
|
+
* When `undefined`, the dialog keeps its native role.
|
|
3223
|
+
* @private
|
|
3224
|
+
*/
|
|
3225
|
+
dialogRole: {
|
|
3226
|
+
type: String
|
|
3227
|
+
},
|
|
3228
|
+
|
|
3229
|
+
/**
|
|
3230
|
+
* Tracks whether a menu option is currently highlighted.
|
|
3231
|
+
* @private
|
|
3232
|
+
*/
|
|
3233
|
+
hasActiveDescendant: {
|
|
3234
|
+
type: Boolean
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
}
|
|
3238
|
+
|
|
3239
|
+
set mobileFullscreenBreakpoint(value) {
|
|
3240
|
+
// verify the defined breakpoint is valid and exit out if not
|
|
3241
|
+
// 'disabled' is a design token breakpoint so it acts as our "undefined" value
|
|
3242
|
+
const validatedValue = DESIGN_TOKEN_BREAKPOINT_OPTIONS.includes(value) ? value : undefined;
|
|
3243
|
+
// Store the breakpoint NAME only. The CSS token pixel value is read lazily
|
|
3244
|
+
// in the getter so it is always resolved against the current document styles.
|
|
3245
|
+
// Caching the pixel value here races against stylesheet load in WebKit —
|
|
3246
|
+
// external CDN stylesheets may not yet be applied when the component upgrades,
|
|
3247
|
+
// causing getPropertyValue() to return "" and fullscreen mode to never activate.
|
|
3248
|
+
this._mobileBreakpointName = validatedValue;
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3251
|
+
get mobileFullscreenBreakpoint() {
|
|
3252
|
+
if (!this._mobileBreakpointName) {
|
|
3253
|
+
return undefined;
|
|
3254
|
+
}
|
|
3255
|
+
const value = getComputedStyle(document.documentElement).
|
|
3256
|
+
getPropertyValue(DESIGN_TOKEN_BREAKPOINT_PREFIX + this._mobileBreakpointName).
|
|
3257
|
+
trim();
|
|
3258
|
+
return value || undefined;
|
|
3259
|
+
}
|
|
3260
|
+
|
|
3261
|
+
updated(changedProperties) {
|
|
3262
|
+
if (changedProperties.has('isFullscreen')) {
|
|
3263
|
+
this.childNodes.forEach((child) => {
|
|
3264
|
+
// skip any text that is not in an HTMLElement on setting `isFullscreen` attr.
|
|
3265
|
+
if (child.nodeName !== '#text') {
|
|
3266
|
+
if (this.isFullscreen) {
|
|
3267
|
+
child.setAttribute('isFullscreen', 'true');
|
|
3268
|
+
} else {
|
|
3269
|
+
child.removeAttribute('isFullscreen');
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
});
|
|
3273
|
+
|
|
3274
|
+
if (this.bibTemplate) {
|
|
3275
|
+
// If the bib template is found, set the fullscreen attribute
|
|
3276
|
+
if (this.isFullscreen) {
|
|
3277
|
+
this.bibTemplate.setAttribute('isFullscreen', 'true');
|
|
3278
|
+
} else {
|
|
3279
|
+
this.bibTemplate.removeAttribute('isFullscreen');
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
connectedCallback() {
|
|
3286
|
+
super.connectedCallback();
|
|
3287
|
+
|
|
3288
|
+
// Listen for the auro-bibtemplate-connected event to set the fullscreen attribute
|
|
3289
|
+
this.addEventListener('auro-bibtemplate-connected', (event) => {
|
|
3290
|
+
const bibTemplate = event.detail.element;
|
|
3291
|
+
this.bibTemplate = bibTemplate;
|
|
3292
|
+
|
|
3293
|
+
if (bibTemplate) {
|
|
3294
|
+
// If the bib template is found, set the fullscreen attribute
|
|
3295
|
+
if (this.isFullscreen) {
|
|
3296
|
+
bibTemplate.setAttribute('isFullscreen', 'true');
|
|
3297
|
+
} else {
|
|
3298
|
+
bibTemplate.removeAttribute('isFullscreen');
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
});
|
|
3302
|
+
}
|
|
3303
|
+
|
|
3304
|
+
firstUpdated(changedProperties) {
|
|
3305
|
+
super.firstUpdated(changedProperties);
|
|
3306
|
+
|
|
3307
|
+
const dialog = this.shadowRoot.querySelector('dialog');
|
|
3308
|
+
this._setupCancelHandler(dialog);
|
|
3309
|
+
applyKeyboardStrategy(dialog, createDropdownBibKeyboardStrategy());
|
|
3310
|
+
|
|
3311
|
+
this.dispatchEvent(new CustomEvent('auro-dropdownbib-connected', {
|
|
3312
|
+
bubbles: true,
|
|
3313
|
+
composed: true,
|
|
3314
|
+
detail: {
|
|
3315
|
+
element: this
|
|
3316
|
+
}
|
|
3317
|
+
}));
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
/**
|
|
3321
|
+
* Forwards the dialog's native `cancel` event (fired on ESC) as
|
|
3322
|
+
* an `auro-bib-cancel` custom event so parent components can close.
|
|
3323
|
+
* @param {HTMLDialogElement} dialog - The dialog element to attach the cancel listener to.
|
|
3324
|
+
* @private
|
|
3325
|
+
*/
|
|
3326
|
+
_setupCancelHandler(dialog) {
|
|
3327
|
+
dialog.addEventListener('cancel', (event) => {
|
|
3328
|
+
event.preventDefault();
|
|
3329
|
+
this.dispatchEvent(new CustomEvent('auro-bib-cancel', {
|
|
3330
|
+
bubbles: true,
|
|
3331
|
+
composed: true
|
|
3332
|
+
}));
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
|
|
3336
|
+
|
|
3337
|
+
/**
|
|
3338
|
+
* Blocks touch-driven page scroll while a fullscreen modal dialog is open.
|
|
3339
|
+
*
|
|
3340
|
+
* The showModal() function places the dialog in the browser's **top layer**,
|
|
3341
|
+
* which is a separate rendering layer above the normal DOM. On mobile, the
|
|
3342
|
+
* compositor processes visual-viewport panning before top-layer touch
|
|
3343
|
+
* handling. This means the entire viewport — including the top-layer dialog
|
|
3344
|
+
* — can be panned by a touch gesture, causing the page behind the dialog to
|
|
3345
|
+
* scroll into view. To prevent this, we add a touchmove listener that cancels
|
|
3346
|
+
* the event if the touch started outside the dialog or any scrollable child within it.
|
|
3347
|
+
*
|
|
3348
|
+
* @private
|
|
3349
|
+
*/
|
|
3350
|
+
_lockTouchScroll() {
|
|
3351
|
+
const dialog = this.shadowRoot.querySelector('dialog');
|
|
3352
|
+
|
|
3353
|
+
this._touchMoveHandler = (event) => {
|
|
3354
|
+
// Walk the composed path (which crosses shadow DOM boundaries) to
|
|
3355
|
+
// check whether the touch started inside a scrollable element that
|
|
3356
|
+
// lives within the dialog. If so, allow the scroll.
|
|
3357
|
+
for (const el of event.composedPath()) {
|
|
3358
|
+
if (el === dialog) {
|
|
3359
|
+
// Reached the dialog boundary without finding a scrollable child.
|
|
3360
|
+
break;
|
|
3361
|
+
}
|
|
3362
|
+
if (el instanceof HTMLElement && el.scrollHeight > el.clientHeight) {
|
|
3363
|
+
const { overflowY } = getComputedStyle(el);
|
|
3364
|
+
if (overflowY === 'auto' || overflowY === 'scroll') {
|
|
3365
|
+
return;
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
|
|
3370
|
+
event.preventDefault();
|
|
3371
|
+
};
|
|
3372
|
+
|
|
3373
|
+
document.addEventListener('touchmove', this._touchMoveHandler, { passive: false });
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3376
|
+
/**
|
|
3377
|
+
* Removes the touchmove listener added by _lockTouchScroll().
|
|
3378
|
+
* @private
|
|
3379
|
+
*/
|
|
3380
|
+
_unlockTouchScroll() {
|
|
3381
|
+
if (this._touchMoveHandler) {
|
|
3382
|
+
document.removeEventListener('touchmove', this._touchMoveHandler);
|
|
3383
|
+
this._touchMoveHandler = undefined;
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3387
|
+
open(modal = true) {
|
|
3388
|
+
const dialog = this.shadowRoot.querySelector('dialog');
|
|
3389
|
+
|
|
3390
|
+
if (dialog && !dialog.open) {
|
|
3391
|
+
if (modal) {
|
|
3392
|
+
// Prevent showModal() from scrolling the page to bring the dialog
|
|
3393
|
+
// into view. Locking overflow on <html> blocks the viewport scroll
|
|
3394
|
+
// that browsers perform natively; we release it immediately after
|
|
3395
|
+
// so it doesn't interfere with the modal's focus management.
|
|
3396
|
+
const { documentElement } = document;
|
|
3397
|
+
const prevOverflow = documentElement.style.overflow;
|
|
3398
|
+
documentElement.style.overflow = 'hidden';
|
|
3399
|
+
|
|
3400
|
+
try {
|
|
3401
|
+
dialog.showModal();
|
|
3402
|
+
} finally {
|
|
3403
|
+
// Restore overflow immediately — the lock was only needed to
|
|
3404
|
+
// suppress the browser's native scroll-into-view behavior
|
|
3405
|
+
// triggered by showModal(). Keeping it locked would block
|
|
3406
|
+
// scrolling inside the modal.
|
|
3407
|
+
documentElement.style.overflow = prevOverflow;
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3410
|
+
this._lockTouchScroll();
|
|
3411
|
+
|
|
3412
|
+
} else {
|
|
3413
|
+
// Open the inner dialog so slotted content renders.
|
|
3414
|
+
dialog.setAttribute('open', '');
|
|
3415
|
+
|
|
3416
|
+
// Use popover on the host for top-layer placement without focus
|
|
3417
|
+
// management or inertness. This escapes ancestor container-type
|
|
3418
|
+
// containment that would trap position:fixed relative to the container.
|
|
3419
|
+
// Set popover dynamically to avoid UA [popover]:not(:popover-open) { display: none }
|
|
3420
|
+
// interfering with Floating UI measurement before showPopover().
|
|
3421
|
+
this.setAttribute('popover', 'manual');
|
|
3422
|
+
this.showPopover();
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
|
|
3427
|
+
/**
|
|
3428
|
+
* Closes the dialog.
|
|
3429
|
+
*/
|
|
3430
|
+
close() {
|
|
3431
|
+
this.hasActiveDescendant = false;
|
|
3432
|
+
|
|
3433
|
+
const dialog = this.shadowRoot.querySelector('dialog');
|
|
3434
|
+
|
|
3435
|
+
if (dialog && dialog.open) {
|
|
3436
|
+
this._unlockTouchScroll();
|
|
3437
|
+
dialog.close();
|
|
3438
|
+
}
|
|
3439
|
+
// Clean up the popover used for desktop top-layer placement.
|
|
3440
|
+
// Remove the attribute entirely so the UA rule
|
|
3441
|
+
// [popover]:not(:popover-open) { display: none } doesn't hide
|
|
3442
|
+
// the host while Floating UI measures it for the next open.
|
|
3443
|
+
if (this.matches(':popover-open')) {
|
|
3444
|
+
this.hidePopover();
|
|
3445
|
+
this.removeAttribute('popover');
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
|
|
3449
|
+
// function that renders the HTML and CSS into the scope of the component
|
|
3450
|
+
render() {
|
|
3451
|
+
const classes = {
|
|
3452
|
+
container: true
|
|
3453
|
+
};
|
|
3454
|
+
|
|
3455
|
+
// Since this class does not inherit from AuroElement, we apply the shape-related class within the `render` function,
|
|
3456
|
+
// mimicking the class naming convention used in AuroElement.resetShapeClasses.
|
|
3457
|
+
classes[`shape-${this.shape}`] = true;
|
|
3458
|
+
|
|
3459
|
+
return html$1`
|
|
3460
|
+
<dialog class="${classMap(classes)}" part="bibContainer" role="${ifDefined(this.dialogRole)}" aria-labelledby="${ifDefined(this.dialogLabel ? 'dialogLabel' : undefined)}">
|
|
3461
|
+
${this.dialogLabel ? html$1`<span id="dialogLabel" class="util_displayHiddenVisually">${this.dialogLabel}</span>` : ''}
|
|
3462
|
+
<slot></slot>
|
|
3463
|
+
<span id="srAnnouncement" class="util_displayHiddenVisually" aria-live="polite" role="status"></span>
|
|
3464
|
+
</dialog>
|
|
3465
|
+
`;
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
|
|
3469
|
+
var shapeSizeCss = css`.shape-classic-xl,.shape-classic-lg,.shape-classic-md,.shape-classic-sm,.shape-classic-xs{min-height:56px;max-height:56px;border-style:solid;border-width:1px;border-radius:var(--ds-border-radius, 0.375rem)}.shape-classic-xl.simple,.shape-classic-lg.simple,.shape-classic-md.simple,.shape-classic-sm.simple,.shape-classic-xs.simple{border-width:0px;min-height:58px;max-height:58px;background-color:unset;box-shadow:none}.shape-classic-xl.thin,.shape-classic-lg.thin,.shape-classic-md.thin,.shape-classic-sm.thin,.shape-classic-xs.thin{border-width:1px;min-height:56px;max-height:56px;background-color:unset}.shape-classic-xl.parentBorder,.shape-classic-lg.parentBorder,.shape-classic-md.parentBorder,.shape-classic-sm.parentBorder,.shape-classic-xs.parentBorder{border:0;box-shadow:unset;min-height:54px;max-height:54px}.shape-snowflake-xl,.shape-snowflake-lg,.shape-snowflake-md,.shape-snowflake-sm,.shape-snowflake-xs{min-height:56px;max-height:56px;border-style:solid;border-width:2px;border-color:transparent;border-radius:30px}.shape-snowflake-xl.simple,.shape-snowflake-lg.simple,.shape-snowflake-md.simple,.shape-snowflake-sm.simple,.shape-snowflake-xs.simple{border-width:0px;min-height:60px;max-height:60px;background-color:unset;box-shadow:none}.shape-snowflake-xl.thin,.shape-snowflake-lg.thin,.shape-snowflake-md.thin,.shape-snowflake-sm.thin,.shape-snowflake-xs.thin{border-width:1px;min-height:58px;max-height:58px;background-color:unset}.shape-snowflake-xl.parentBorder,.shape-snowflake-lg.parentBorder,.shape-snowflake-md.parentBorder,.shape-snowflake-sm.parentBorder,.shape-snowflake-xs.parentBorder{border:0;box-shadow:unset;min-height:56px;max-height:56px}.shape-box-xl{min-height:68px;max-height:68px;border-style:solid;border-width:2px;border-color:transparent}.shape-box-xl.simple{border-width:0px;min-height:72px;max-height:72px;background-color:unset;box-shadow:none}.shape-box-xl.thin{border-width:1px;min-height:70px;max-height:70px;background-color:unset}.shape-box-xl.parentBorder{border:0;box-shadow:unset;min-height:68px;max-height:68px}.shape-box-lg{min-height:52px;max-height:52px;border-style:solid;border-width:2px;border-color:transparent}.shape-box-lg.simple{border-width:0px;min-height:56px;max-height:56px;background-color:unset;box-shadow:none}.shape-box-lg.thin{border-width:1px;min-height:54px;max-height:54px;background-color:unset}.shape-box-lg.parentBorder{border:0;box-shadow:unset;min-height:52px;max-height:52px}.shape-box-md{min-height:44px;max-height:44px;border-style:solid;border-width:2px;border-color:transparent}.shape-box-md.simple{border-width:0px;min-height:48px;max-height:48px;background-color:unset;box-shadow:none}.shape-box-md.thin{border-width:1px;min-height:46px;max-height:46px;background-color:unset}.shape-box-md.parentBorder{border:0;box-shadow:unset;min-height:44px;max-height:44px}.shape-box-sm{min-height:32px;max-height:32px;border-style:solid;border-width:2px;border-color:transparent}.shape-box-sm.simple{border-width:0px;min-height:36px;max-height:36px;background-color:unset;box-shadow:none}.shape-box-sm.thin{border-width:1px;min-height:34px;max-height:34px;background-color:unset}.shape-box-sm.parentBorder{border:0;box-shadow:unset;min-height:32px;max-height:32px}.shape-box-xs{min-height:20px;max-height:20px;border-style:solid;border-width:2px;border-color:transparent}.shape-box-xs.simple{border-width:0px;min-height:24px;max-height:24px;background-color:unset;box-shadow:none}.shape-box-xs.thin{border-width:1px;min-height:22px;max-height:22px;background-color:unset}.shape-box-xs.parentBorder{border:0;box-shadow:unset;min-height:20px;max-height:20px}.shape-rounded-lg{min-height:56px;max-height:56px;border-style:solid;border-width:2px;border-color:transparent;border-radius:6px}.shape-rounded-lg.simple{border-width:0px;min-height:56px;max-height:56px;background-color:unset;box-shadow:none}.shape-rounded-lg.thin{border-width:1px;min-height:54px;max-height:54px;background-color:unset}.shape-rounded-lg.parentBorder{border:0;box-shadow:unset;min-height:52px;max-height:52px}.shape-pill-xl{min-height:68px;max-height:68px;border-style:solid;border-width:2px;border-color:transparent;border-radius:36px}.shape-pill-xl.simple{border-width:0px;min-height:72px;max-height:72px;background-color:unset;box-shadow:none}.shape-pill-xl.thin{border-width:1px;min-height:70px;max-height:70px;background-color:unset}.shape-pill-xl.parentBorder{border:0;box-shadow:unset;min-height:68px;max-height:68px}.shape-pill-left-xl{min-height:68px;max-height:68px;border-style:solid;border-width:2px;border-color:transparent;border-radius:36px 0 0 36px}.shape-pill-left-xl.simple{border-width:0px;min-height:72px;max-height:72px;background-color:unset;box-shadow:none}.shape-pill-left-xl.thin{border-width:1px;min-height:70px;max-height:70px;background-color:unset}.shape-pill-left-xl.parentBorder{border:0;box-shadow:unset;min-height:68px;max-height:68px}.shape-pill-right-xl{min-height:68px;max-height:68px;border-style:solid;border-width:2px;border-color:transparent;border-radius:0 36px 36px 0}.shape-pill-right-xl.simple{border-width:0px;min-height:72px;max-height:72px;background-color:unset;box-shadow:none}.shape-pill-right-xl.thin{border-width:1px;min-height:70px;max-height:70px;background-color:unset}.shape-pill-right-xl.parentBorder{border:0;box-shadow:unset;min-height:68px;max-height:68px}.shape-pill-md{min-height:44px;max-height:44px;border-style:solid;border-width:2px;border-color:transparent;border-radius:36px}.shape-pill-md.simple{border-width:0px;min-height:48px;max-height:48px;background-color:unset;box-shadow:none}.shape-pill-md.thin{border-width:1px;min-height:46px;max-height:46px;background-color:unset}.shape-pill-md.parentBorder{border:0;box-shadow:unset;min-height:44px;max-height:44px}.shape-pill-left-md{min-height:44px;max-height:44px;border-style:solid;border-width:2px;border-color:transparent;border-radius:36px 0 0 36px}.shape-pill-left-md.simple{border-width:0px;min-height:48px;max-height:48px;background-color:unset;box-shadow:none}.shape-pill-left-md.thin{border-width:1px;min-height:46px;max-height:46px;background-color:unset}.shape-pill-left-md.parentBorder{border:0;box-shadow:unset;min-height:44px;max-height:44px}.shape-pill-right-md{min-height:44px;max-height:44px;border-style:solid;border-width:2px;border-color:transparent;border-radius:0 36px 36px 0}.shape-pill-right-md.simple{border-width:0px;min-height:48px;max-height:48px;background-color:unset;box-shadow:none}.shape-pill-right-md.thin{border-width:1px;min-height:46px;max-height:46px;background-color:unset}.shape-pill-right-md.parentBorder{border:0;box-shadow:unset;min-height:44px;max-height:44px}`;
|
|
3470
|
+
|
|
3471
|
+
var colorCss$1 = css`:host(:not([layout*=classic])){--ds-auro-dropdown-trigger-border-color: transparent}:host(:not([disabled],[onDark])) .wrapper:focus-within,:host(:not([disabled],[onDark])) .wrapper:active,:host(:not([disabled],[appearance=inverse])) .wrapper:focus-within,:host(:not([disabled],[appearance=inverse])) .wrapper:active{--ds-auro-dropdown-trigger-border-color: var(--ds-advanced-color-state-focused, #01426a);--ds-auro-dropdown-trigger-outline-color: var(--ds-advanced-color-state-focused, #01426a)}:host(:not([disabled],[onDark])) .wrapper:hover,:host(:not([disabled],[appearance=inverse])) .wrapper:hover{--ds-auro-dropdown-trigger-background-color: var(--ds-auro-dropdown-trigger-hover-background-color)}:host(:not([ondark])) .wrapper,:host(:not([appearance=inverse])) .wrapper{border-color:var(--ds-auro-dropdown-trigger-border-color);background-color:var(--ds-auro-dropdown-trigger-background-color);color:var(--ds-auro-dropdown-trigger-text-color)}:host(:not([onDark])[disabled]),:host(:not([appearance=inverse])[disabled]){--ds-auro-dropdown-trigger-text-color: var(--ds-basic-color-texticon-disabled, #d0d0d0);--ds-auro-dropdown-label-text-color: var(--ds-basic-color-texticon-disabled, #d0d0d0);--ds-auro-dropdown-trigger-border-color: var(--ds-basic-color-border-subtle, #dddddd)}:host(:not([onDark])[disabled]) #triggerLabel,:host(:not([appearance=inverse])[disabled]) #triggerLabel{cursor:default}:host(:not([ondark])[error]),:host(:not([appearance=inverse])[error]){--ds-auro-dropdown-trigger-border-color: var(--ds-basic-color-status-error, #e31f26)}:host(:not([disabled])[onDark]) .wrapper:focus-within,:host(:not([disabled])[onDark]) .wrapper:active,:host(:not([disabled])[appearance=inverse]) .wrapper:focus-within,:host(:not([disabled])[appearance=inverse]) .wrapper:active{--ds-auro-dropdown-trigger-border-color: var(--ds-advanced-color-state-focused-inverse, #ffffff);--ds-auro-dropdown-trigger-outline-color: var(--ds-advanced-color-state-focused-inverse, #ffffff)}:host(:not([disabled])[onDark]) .wrapper:hover,:host(:not([disabled])[appearance=inverse]) .wrapper:hover{--ds-auro-dropdown-trigger-background-color: var(--ds-auro-dropdown-trigger-hover-background-color)}:host([onDark]) .label,:host([onDark]) .helpText,:host([appearance=inverse]) .label,:host([appearance=inverse]) .helpText{color:var(--ds-auro-dropdown-label-text-color)}:host([onDark]) .wrapper,:host([appearance=inverse]) .wrapper{border-color:var(--ds-auro-dropdown-trigger-border-color);background-color:var(--ds-auro-dropdown-trigger-background-color);color:var(--ds-auro-dropdown-trigger-text-color)}:host([onDark][disabled]),:host([appearance=inverse][disabled]){--ds-auro-dropdown-trigger-text-color: var(--ds-basic-color-texticon-inverse-disabled, #7e8894);--ds-auro-dropdown-label-text-color: var(--ds-basic-color-texticon-inverse-disabled, #7e8894);--ds-auro-dropdown-trigger-container-color: var(--ds-advanced-color-shared-background-inverse-disabled, rgba(255, 255, 255, 0.1))}:host([onDark][disabled]) #triggerLabel,:host([appearance=inverse][disabled]) #triggerLabel{cursor:default}:host([ondark][error]),:host([appearance=inverse][error]){--ds-auro-dropdown-trigger-border-color: var(--ds-advanced-color-state-error-inverse, #f9a4a8)}`;
|
|
3472
|
+
|
|
3473
|
+
var styleCss$1 = css`:host{position:relative;display:block;text-align:left}:host([open]){z-index:var(--depth-tooltip, 400)}.wrapper{display:flex;flex:1;flex-direction:row;align-items:center;justify-content:center;outline:none}.triggerContentWrapper{display:flex;overflow:hidden;width:100%;flex:1;align-items:center;justify-content:center;text-overflow:ellipsis;white-space:nowrap}:host([matchwidth]) #bibSizer{width:100%}`;
|
|
3474
|
+
|
|
3475
|
+
var classicColorCss = css``;
|
|
3476
|
+
|
|
3477
|
+
var classicLayoutCss = css`@media(hover: hover){:host(:not([disabled])) .wrapper:hover{cursor:pointer}}:host([layout*=classic]){position:relative;max-width:100%}:host([layout*=classic]) #bibSizer{position:absolute;z-index:-1;opacity:0;pointer-events:none}:host([layout*=classic]) label{transition:font-size .3s cubic-bezier(0.215, 0.61, 0.355, 1);white-space:normal}:host([layout*=classic]) .wrapper{display:flex;flex-direction:row;box-shadow:inset 0 0 0 1px var(--ds-auro-dropdown-trigger-outline-color)}:host([layout*=classic]) .triggerContentWrapper{overflow:hidden;flex:1;justify-content:start;text-overflow:ellipsis;white-space:nowrap}:host([layout*=classic]) #showStateIcon{display:flex;overflow:hidden;height:100%;align-items:center;padding-right:var(--ds-size-150, 0.75rem)}:host([layout*=classic]) #showStateIcon [auro-icon]{height:var(--ds-size-300, 1.5rem)}:host([layout*=classic]) #showStateIcon[data-expanded=true] [auro-icon]{transform:rotate(-180deg)}`;
|
|
3478
|
+
|
|
3479
|
+
var styleEmphasizedCss = css`.layout-emphasized .chevron,.layout-emphasized-left .chevron,.layout-emphasized-right .chevron{margin-right:var(--ds-size-300, 1.5rem)}:host([layout*=emphasized][shape*=pill]:not([layout*=right])) .leftIndent{width:calc(100% - var(--ds-size-300, 1.5rem));margin-left:var(--ds-size-300, 1.5rem)}:host([layout*=emphasized][shape*=pill]:not([layout*=left])) .rightIndent{width:calc(100% - var(--ds-size-300, 1.5rem));margin-right:var(--ds-size-300, 1.5rem)}:host([layout*=emphasized][shape*=pill]:not([layout*=left]):not([layout*=right])) .rightIndent{width:calc(100% - var(--ds-size-600, 3rem));margin-right:var(--ds-size-300, 1.5rem)}`;
|
|
3480
|
+
|
|
3481
|
+
var styleSnowflakeCss = css`:host([layout*=snowflake]) .leftIndent{width:calc(100% - var(--ds-size-400, 2rem));margin-left:var(--ds-size-200, 1rem)}:host([layout*=snowflake]) .rightIndent{width:calc(100% - var(--ds-size-400, 2rem));margin-right:var(--ds-size-200, 1rem)}:host([layout*=snowflake]) .trigger,:host([layout*=snowflake]) .helpText{text-align:center}.layout-snowflake .chevron,.layout-snowflake-left .chevron,.layout-snowflake-right .chevron{margin-right:var(--ds-size-200, 1rem)}`;
|
|
3482
|
+
|
|
3483
|
+
var colorCss = css`:host([error]){--ds-auro-helptext-color: var(--ds-basic-color-status-error, #e31f26)}:host([onDark]),:host([appearance=inverse]){--ds-auro-helptext-color: var(--ds-basic-color-texticon-inverse-muted, #ccd2db)}:host([onDark][error]),:host([appearance=inverse][error]){--ds-auro-helptext-color: var(--ds-advanced-color-state-error-inverse, #f9a4a8)}.helptext-wrapper{color:var(--ds-auro-helptext-color)}`;
|
|
3484
|
+
|
|
3485
|
+
var styleCss = css`.body-default{font-size:var(--wcss-body-default-font-size, 1rem);line-height:var(--wcss-body-default-line-height, 1.5rem)}.body-default,.body-lg{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-lg{font-size:var(--wcss-body-lg-font-size, 1.125rem);line-height:var(--wcss-body-lg-line-height, 1.625rem)}.body-sm{font-size:var(--wcss-body-sm-font-size, 0.875rem);line-height:var(--wcss-body-sm-line-height, 1.25rem)}.body-sm,.body-xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-xs{font-size:var(--wcss-body-xs-font-size, 0.75rem);line-height:var(--wcss-body-xs-line-height, 1rem)}.body-2xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-2xs-font-size, 0.625rem);font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);line-height:var(--wcss-body-2xs-line-height, 0.875rem)}.display-2xl{font-family:var(--wcss-display-2xl-family, "AS Circular"),var(--wcss-display-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-2xl-font-size, clamp(3.5rem, 6vw, 5.375rem));font-weight:var(--wcss-display-2xl-weight, 300);letter-spacing:var(--wcss-display-2xl-letter-spacing, 0);line-height:var(--wcss-display-2xl-line-height, 1.3)}.display-xl{font-family:var(--wcss-display-xl-family, "AS Circular"),var(--wcss-display-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-xl-font-size, clamp(3rem, 5.3333333333vw, 4.5rem));font-weight:var(--wcss-display-xl-weight, 300);letter-spacing:var(--wcss-display-xl-letter-spacing, 0);line-height:var(--wcss-display-xl-line-height, 1.3)}.display-lg{font-family:var(--wcss-display-lg-family, "AS Circular"),var(--wcss-display-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-lg-font-size, clamp(2.75rem, 4.6666666667vw, 4rem));font-weight:var(--wcss-display-lg-weight, 300);letter-spacing:var(--wcss-display-lg-letter-spacing, 0);line-height:var(--wcss-display-lg-line-height, 1.3)}.display-md{font-family:var(--wcss-display-md-family, "AS Circular"),var(--wcss-display-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-md-font-size, clamp(2.5rem, 4vw, 3.5rem));font-weight:var(--wcss-display-md-weight, 300);letter-spacing:var(--wcss-display-md-letter-spacing, 0);line-height:var(--wcss-display-md-line-height, 1.3)}.display-sm{font-family:var(--wcss-display-sm-family, "AS Circular"),var(--wcss-display-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-sm-font-size, clamp(2rem, 3.6666666667vw, 3rem));font-weight:var(--wcss-display-sm-weight, 300);letter-spacing:var(--wcss-display-sm-letter-spacing, 0);line-height:var(--wcss-display-sm-line-height, 1.3)}.display-xs{font-family:var(--wcss-display-xs-family, "AS Circular"),var(--wcss-display-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-xs-font-size, clamp(1.75rem, 3vw, 2.375rem));font-weight:var(--wcss-display-xs-weight, 300);letter-spacing:var(--wcss-display-xs-letter-spacing, 0);line-height:var(--wcss-display-xs-line-height, 1.3)}.heading-xl{font-family:var(--wcss-heading-xl-family, "AS Circular"),var(--wcss-heading-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-xl-font-size, clamp(2rem, 3vw, 2.5rem));font-weight:var(--wcss-heading-xl-weight, 300);letter-spacing:var(--wcss-heading-xl-letter-spacing, 0);line-height:var(--wcss-heading-xl-line-height, 1.3)}.heading-lg{font-family:var(--wcss-heading-lg-family, "AS Circular"),var(--wcss-heading-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-lg-font-size, clamp(1.75rem, 2.6666666667vw, 2.25rem));font-weight:var(--wcss-heading-lg-weight, 300);letter-spacing:var(--wcss-heading-lg-letter-spacing, 0);line-height:var(--wcss-heading-lg-line-height, 1.3)}.heading-md{font-family:var(--wcss-heading-md-family, "AS Circular"),var(--wcss-heading-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-md-font-size, clamp(1.625rem, 2.3333333333vw, 1.75rem));font-weight:var(--wcss-heading-md-weight, 300);letter-spacing:var(--wcss-heading-md-letter-spacing, 0);line-height:var(--wcss-heading-md-line-height, 1.3)}.heading-sm{font-family:var(--wcss-heading-sm-family, "AS Circular"),var(--wcss-heading-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-sm-font-size, clamp(1.375rem, 2vw, 1.5rem));font-weight:var(--wcss-heading-sm-weight, 300);letter-spacing:var(--wcss-heading-sm-letter-spacing, 0);line-height:var(--wcss-heading-sm-line-height, 1.3)}.heading-xs{font-family:var(--wcss-heading-xs-family, "AS Circular"),var(--wcss-heading-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-xs-font-size, clamp(1.25rem, 1.6666666667vw, 1.25rem));font-weight:var(--wcss-heading-xs-weight, 450);letter-spacing:var(--wcss-heading-xs-letter-spacing, 0);line-height:var(--wcss-heading-xs-line-height, 1.3)}.heading-2xs{font-family:var(--wcss-heading-2xs-family, "AS Circular"),var(--wcss-heading-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-2xs-font-size, clamp(1.125rem, 1.5vw, 1.125rem));font-weight:var(--wcss-heading-2xs-weight, 450);letter-spacing:var(--wcss-heading-2xs-letter-spacing, 0);line-height:var(--wcss-heading-2xs-line-height, 1.3)}.accent-2xl{font-family:var(--wcss-accent-2xl-family, "Good OT"),var(--wcss-accent-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-2xl-font-size, clamp(2rem, 3.1666666667vw, 2.375rem));font-weight:var(--wcss-accent-2xl-weight, 450);letter-spacing:var(--wcss-accent-2xl-letter-spacing, 0.05em);line-height:var(--wcss-accent-2xl-line-height, 1)}.accent-2xl,.accent-xl{text-transform:uppercase}.accent-xl{font-family:var(--wcss-accent-xl-family, "Good OT"),var(--wcss-accent-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-xl-font-size, clamp(1.625rem, 2.3333333333vw, 2rem));font-weight:var(--wcss-accent-xl-weight, 450);letter-spacing:var(--wcss-accent-xl-letter-spacing, 0.05em);line-height:var(--wcss-accent-xl-line-height, 1.3)}.accent-lg{font-family:var(--wcss-accent-lg-family, "Good OT"),var(--wcss-accent-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-lg-font-size, clamp(1.5rem, 2.1666666667vw, 1.75rem));font-weight:var(--wcss-accent-lg-weight, 450);letter-spacing:var(--wcss-accent-lg-letter-spacing, 0.05em);line-height:var(--wcss-accent-lg-line-height, 1.3)}.accent-lg,.accent-md{text-transform:uppercase}.accent-md{font-family:var(--wcss-accent-md-family, "Good OT"),var(--wcss-accent-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-md-font-size, clamp(1.375rem, 1.8333333333vw, 1.5rem));font-weight:var(--wcss-accent-md-weight, 500);letter-spacing:var(--wcss-accent-md-letter-spacing, 0.05em);line-height:var(--wcss-accent-md-line-height, 1.3)}.accent-sm{font-family:var(--wcss-accent-sm-family, "Good OT"),var(--wcss-accent-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-sm-font-size, clamp(1.125rem, 1.5vw, 1.25rem));font-weight:var(--wcss-accent-sm-weight, 500);letter-spacing:var(--wcss-accent-sm-letter-spacing, 0.05em);line-height:var(--wcss-accent-sm-line-height, 1.3)}.accent-sm,.accent-xs{text-transform:uppercase}.accent-xs{font-family:var(--wcss-accent-xs-family, "Good OT"),var(--wcss-accent-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-xs-font-size, clamp(1rem, 1.3333333333vw, 1rem));font-weight:var(--wcss-accent-xs-weight, 500);letter-spacing:var(--wcss-accent-xs-letter-spacing, 0.1em);line-height:var(--wcss-accent-xs-line-height, 1.3)}.accent-2xs{font-family:var(--wcss-accent-2xs-family, "Good OT"),var(--wcss-accent-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-2xs-font-size, clamp(0.875rem, 1.1666666667vw, 0.875rem));font-weight:var(--wcss-accent-2xs-weight, 450);letter-spacing:var(--wcss-accent-2xs-letter-spacing, 0.1em);line-height:var(--wcss-accent-2xs-line-height, 1.3);text-transform:uppercase}:host{position:relative;display:block}.helptext-wrapper{display:none}.helptext-wrapper[visible]{display:block}::slotted(*:not(:empty)){margin-top:var(--ds-size-50, 0.25rem);margin-bottom:0}::slotted(p){margin-block:0}`;
|
|
3486
|
+
|
|
3487
|
+
var tokensCss = css`:host{--ds-auro-helptext-color: var(--ds-basic-color-texticon-muted, #676767)}`;
|
|
3488
|
+
|
|
3489
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
3490
|
+
// See LICENSE in the project root for license information.
|
|
3491
|
+
|
|
3492
|
+
// ---------------------------------------------------------------------
|
|
3493
|
+
|
|
3494
|
+
/* eslint-disable line-comment-position, no-inline-comments, no-confusing-arrow, no-nested-ternary, implicit-arrow-linebreak */
|
|
3495
|
+
|
|
3496
|
+
class AuroLibraryRuntimeUtils {
|
|
3497
|
+
|
|
3498
|
+
/* eslint-disable jsdoc/require-param */
|
|
3499
|
+
|
|
3500
|
+
/**
|
|
3501
|
+
* This will register a new custom element with the browser.
|
|
3502
|
+
* @param {String} name - The name of the custom element.
|
|
3503
|
+
* @param {Object} componentClass - The class to register as a custom element.
|
|
3504
|
+
* @returns {void}
|
|
3505
|
+
*/
|
|
3506
|
+
registerComponent(name, componentClass) {
|
|
3507
|
+
if (!customElements.get(name)) {
|
|
3508
|
+
customElements.define(name, class extends componentClass {});
|
|
3509
|
+
}
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3512
|
+
/**
|
|
3513
|
+
* Finds and returns the closest HTML Element based on a selector.
|
|
3514
|
+
* @returns {void}
|
|
3515
|
+
*/
|
|
3516
|
+
closestElement(
|
|
3517
|
+
selector, // selector like in .closest()
|
|
3518
|
+
base = this, // extra functionality to skip a parent
|
|
3519
|
+
__Closest = (el, found = el && el.closest(selector)) =>
|
|
3520
|
+
!el || el === document || el === window
|
|
3521
|
+
? null // standard .closest() returns null for non-found selectors also
|
|
3522
|
+
: found
|
|
3523
|
+
? found // found a selector INside this element
|
|
3524
|
+
: __Closest(el.getRootNode().host) // recursion!! break out to parent DOM
|
|
3525
|
+
) {
|
|
3526
|
+
return __Closest(base);
|
|
3527
|
+
}
|
|
3528
|
+
/* eslint-enable jsdoc/require-param */
|
|
3529
|
+
|
|
3530
|
+
/**
|
|
3531
|
+
* If the element passed is registered with a different tag name than what is passed in, the tag name is added as an attribute to the element.
|
|
3532
|
+
* @param {Object} elem - The element to check.
|
|
3533
|
+
* @param {String} tagName - The name of the Auro component to check for or add as an attribute.
|
|
3534
|
+
* @returns {void}
|
|
3535
|
+
*/
|
|
3536
|
+
handleComponentTagRename(elem, tagName) {
|
|
3537
|
+
const tag = tagName.toLowerCase();
|
|
3538
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
3539
|
+
|
|
3540
|
+
if (elemTag !== tag) {
|
|
3541
|
+
elem.setAttribute(tag, true);
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
|
|
3545
|
+
/**
|
|
3546
|
+
* Validates if an element is a specific Auro component.
|
|
3547
|
+
* @param {Object} elem - The element to validate.
|
|
3548
|
+
* @param {String} tagName - The name of the Auro component to check against.
|
|
3549
|
+
* @returns {Boolean} - Returns true if the element is the specified Auro component.
|
|
3550
|
+
*/
|
|
3551
|
+
elementMatch(elem, tagName) {
|
|
3552
|
+
const tag = tagName.toLowerCase();
|
|
3553
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
3554
|
+
|
|
3555
|
+
return elemTag === tag || elem.hasAttribute(tag);
|
|
3556
|
+
}
|
|
3557
|
+
|
|
3558
|
+
/**
|
|
3559
|
+
* Gets the text content of a named slot.
|
|
3560
|
+
* @returns {String}
|
|
3561
|
+
* @private
|
|
3562
|
+
*/
|
|
3563
|
+
getSlotText(elem, name) {
|
|
3564
|
+
const slot = elem.shadowRoot?.querySelector(`slot[name="${name}"]`);
|
|
3565
|
+
const nodes = slot?.assignedNodes({ flatten: true }) || [];
|
|
3566
|
+
const text = nodes.map(n => n.textContent?.trim()).join(' ').trim();
|
|
3567
|
+
|
|
3568
|
+
return text || null;
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
|
|
3572
|
+
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
3573
|
+
// See LICENSE in the project root for license information.
|
|
3574
|
+
|
|
3575
|
+
|
|
3576
|
+
/**
|
|
3577
|
+
* Displays help text or error messages within form elements - Internal Use Only.
|
|
3578
|
+
*/
|
|
3579
|
+
class AuroHelpText extends LitElement {
|
|
3580
|
+
|
|
3581
|
+
constructor() {
|
|
3582
|
+
super();
|
|
3583
|
+
|
|
3584
|
+
this.error = false;
|
|
3585
|
+
this.appearance = "default";
|
|
3586
|
+
this.onDark = false;
|
|
3587
|
+
this.hasTextContent = false;
|
|
3588
|
+
|
|
3589
|
+
AuroLibraryRuntimeUtils.prototype.handleComponentTagRename(this, 'auro-helptext');
|
|
3590
|
+
}
|
|
3591
|
+
|
|
3592
|
+
static get styles() {
|
|
3593
|
+
return [
|
|
3594
|
+
colorCss,
|
|
3595
|
+
styleCss,
|
|
3596
|
+
tokensCss
|
|
3597
|
+
];
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3600
|
+
// function to define props used within the scope of this component
|
|
3601
|
+
static get properties() {
|
|
3602
|
+
return {
|
|
3603
|
+
|
|
3604
|
+
/**
|
|
3605
|
+
* Defines whether the component will be on lighter or darker backgrounds.
|
|
3606
|
+
* @property {'default', 'inverse'} - The appearance of the help text, either default (for light backgrounds) or inverse (for dark backgrounds).
|
|
3607
|
+
* @default 'default'
|
|
3608
|
+
*/
|
|
3609
|
+
appearance: {
|
|
3610
|
+
type: String,
|
|
3611
|
+
reflect: true
|
|
3612
|
+
},
|
|
3613
|
+
|
|
3614
|
+
/**
|
|
3615
|
+
* @private
|
|
3616
|
+
*/
|
|
3617
|
+
slotNodes: {
|
|
3618
|
+
type: Boolean,
|
|
3619
|
+
},
|
|
3620
|
+
|
|
3621
|
+
/**
|
|
3622
|
+
* @private
|
|
3623
|
+
*/
|
|
3624
|
+
hasTextContent: {
|
|
3625
|
+
type: Boolean,
|
|
3626
|
+
},
|
|
3627
|
+
|
|
3628
|
+
/**
|
|
3629
|
+
* If declared, make font color red.
|
|
3630
|
+
*/
|
|
3631
|
+
error: {
|
|
3632
|
+
type: Boolean,
|
|
3633
|
+
reflect: true,
|
|
3634
|
+
},
|
|
3635
|
+
|
|
3636
|
+
/**
|
|
3637
|
+
* DEPRECATED - use `appearance` instead.
|
|
3638
|
+
*/
|
|
3639
|
+
onDark: {
|
|
3640
|
+
type: Boolean,
|
|
3641
|
+
reflect: true
|
|
3642
|
+
}
|
|
3643
|
+
};
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
/**
|
|
3647
|
+
* This will register this element with the browser.
|
|
3648
|
+
* @param {string} [name="auro-helptext"] - The name of element that you want to register to.
|
|
3649
|
+
*
|
|
3650
|
+
* @example
|
|
3651
|
+
* AuroCheckbox.register("custom-helptext") // this will register this element to <custom-helptext/>
|
|
3652
|
+
*
|
|
3653
|
+
*/
|
|
3654
|
+
static register(name = "auro-helptext") {
|
|
3655
|
+
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroHelpText);
|
|
3656
|
+
}
|
|
3657
|
+
|
|
3658
|
+
updated() {
|
|
3659
|
+
this.handleSlotChange();
|
|
3660
|
+
}
|
|
3661
|
+
|
|
3662
|
+
handleSlotChange(event) {
|
|
3663
|
+
if (event) {
|
|
3664
|
+
this.slotNodes = event.target.assignedNodes();
|
|
3665
|
+
}
|
|
3666
|
+
|
|
3667
|
+
this.hasTextContent = this.checkSlotsForContent(this.slotNodes);
|
|
3668
|
+
}
|
|
3669
|
+
|
|
3670
|
+
/**
|
|
3671
|
+
* Checks if any of the provided nodes or their nested slot nodes contain non-empty text content.
|
|
3672
|
+
*
|
|
3673
|
+
* @param {NodeList|Array} nodes - The list of nodes to check for content.
|
|
3674
|
+
* @returns {boolean} - Returns true if any node or nested slot node contains non-empty text content, otherwise false.
|
|
3675
|
+
* @private
|
|
3676
|
+
*/
|
|
3677
|
+
checkSlotsForContent(nodes) {
|
|
3678
|
+
if (!nodes) {
|
|
3679
|
+
return false;
|
|
3680
|
+
}
|
|
3681
|
+
|
|
3682
|
+
return nodes.some((node) => {
|
|
3683
|
+
if (node.textContent.trim()) {
|
|
3684
|
+
return true;
|
|
3685
|
+
}
|
|
3686
|
+
|
|
3687
|
+
if (!node.querySelector) {
|
|
3688
|
+
return false;
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3691
|
+
const nestedSlot = node.tagName === 'SLOT' ? node : node.querySelector('slot');
|
|
3692
|
+
if (!nestedSlot) {
|
|
3693
|
+
return false;
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
const nestedSlotNodes = nestedSlot.assignedNodes();
|
|
3697
|
+
return this.checkSlotsForContent(nestedSlotNodes);
|
|
3698
|
+
});
|
|
3699
|
+
}
|
|
3700
|
+
|
|
3701
|
+
// function that renders the HTML and CSS into the scope of the component
|
|
3702
|
+
render() {
|
|
3703
|
+
return html`
|
|
3704
|
+
<div class="helptext-wrapper body-xs" ?visible="${this.hasTextContent}">
|
|
3705
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
3706
|
+
</div>
|
|
3707
|
+
`;
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3711
|
+
var formkitVersion = '202604071818';
|
|
3712
|
+
|
|
3713
|
+
class AuroElement extends LitElement {
|
|
3714
|
+
static get properties() {
|
|
3715
|
+
return {
|
|
3716
|
+
|
|
3717
|
+
/**
|
|
3718
|
+
* Defines the language of an element.
|
|
3719
|
+
* @default {'default'}
|
|
3720
|
+
*/
|
|
3721
|
+
layout: {
|
|
3722
|
+
type: String,
|
|
3723
|
+
attribute: "layout",
|
|
3724
|
+
reflect: true
|
|
3725
|
+
},
|
|
3726
|
+
|
|
3727
|
+
shape: {
|
|
3728
|
+
type: String,
|
|
3729
|
+
attribute: "shape",
|
|
3730
|
+
reflect: true
|
|
3731
|
+
},
|
|
3732
|
+
|
|
3733
|
+
size: {
|
|
3734
|
+
type: String,
|
|
3735
|
+
attribute: "size",
|
|
3736
|
+
reflect: true
|
|
3737
|
+
},
|
|
3738
|
+
|
|
3739
|
+
onDark: {
|
|
3740
|
+
type: Boolean,
|
|
3741
|
+
attribute: "ondark",
|
|
3742
|
+
reflect: true
|
|
3743
|
+
}
|
|
3744
|
+
};
|
|
3745
|
+
}
|
|
3746
|
+
|
|
3747
|
+
/**
|
|
3748
|
+
* Returns true if the element has focus.
|
|
3749
|
+
* @private
|
|
3750
|
+
* @returns {boolean} - Returns true if the element has focus.
|
|
3751
|
+
*/
|
|
3752
|
+
get componentHasFocus() {
|
|
3753
|
+
return this.matches(':focus') || this.matches(':focus-within');
|
|
3754
|
+
}
|
|
3755
|
+
|
|
3756
|
+
resetShapeClasses() {
|
|
3757
|
+
const wrapper = this.shadowRoot.querySelector('.wrapper');
|
|
3758
|
+
|
|
3759
|
+
if (wrapper) {
|
|
3760
|
+
wrapper.classList.forEach((className) => {
|
|
3761
|
+
if (className.startsWith('shape-')) {
|
|
3762
|
+
wrapper.classList.remove(className);
|
|
3763
|
+
}
|
|
3764
|
+
});
|
|
3765
|
+
|
|
3766
|
+
if (this.shape && this.size) {
|
|
3767
|
+
wrapper.classList.add(`shape-${this.shape.toLowerCase()}-${this.size.toLowerCase()}`);
|
|
3768
|
+
} else {
|
|
3769
|
+
wrapper.classList.add('shape-none');
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3773
|
+
}
|
|
3774
|
+
|
|
3775
|
+
resetLayoutClasses() {
|
|
3776
|
+
if (this.layout) {
|
|
3777
|
+
const wrapper = this.shadowRoot.querySelector('.wrapper');
|
|
3778
|
+
|
|
3779
|
+
if (wrapper) {
|
|
3780
|
+
wrapper.classList.forEach((className) => {
|
|
3781
|
+
if (className.startsWith('layout-')) {
|
|
3782
|
+
wrapper.classList.remove(className);
|
|
3783
|
+
}
|
|
3784
|
+
});
|
|
3785
|
+
|
|
3786
|
+
wrapper.classList.add(`layout-${this.layout.toLowerCase()}`);
|
|
3787
|
+
}
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3790
|
+
|
|
3791
|
+
updateComponentArchitecture() {
|
|
3792
|
+
this.resetLayoutClasses();
|
|
3793
|
+
this.resetShapeClasses();
|
|
3794
|
+
}
|
|
3795
|
+
|
|
3796
|
+
updated(changedProperties) {
|
|
3797
|
+
if (changedProperties.has('layout') || changedProperties.has('shape') || changedProperties.has('size')) {
|
|
3798
|
+
this.updateComponentArchitecture();
|
|
3799
|
+
}
|
|
3800
|
+
}
|
|
3801
|
+
|
|
3802
|
+
// Try to render the defined `this.layout` layout. If that fails, fall back to the default layout.
|
|
3803
|
+
// This will catch if an invalid layout value is passed in and render the default layout if so.
|
|
3804
|
+
render() {
|
|
3805
|
+
try {
|
|
3806
|
+
return this.renderLayout();
|
|
3807
|
+
} catch (error) {
|
|
3808
|
+
// failed to get the defined layout
|
|
3809
|
+
console.error('Failed to get the defined layout - using the default layout', error); // eslint-disable-line no-console
|
|
3810
|
+
|
|
3811
|
+
// fallback to the default layout
|
|
3812
|
+
return this.getLayout('default');
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3817
|
+
// Copyright (c) 2026 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
3818
|
+
// See LICENSE in the project root for license information.
|
|
3819
|
+
|
|
3820
|
+
|
|
3821
|
+
/**
|
|
3822
|
+
* The `auro-dropdown` element provides a way to place content in a bib that can be toggled.
|
|
3823
|
+
* @customElement auro-dropdown
|
|
3824
|
+
*
|
|
3825
|
+
* @slot - Default slot for the dropdown bib content.
|
|
3826
|
+
* @slot helpText - Defines the content of the helpText.
|
|
3827
|
+
* @slot trigger - Defines the content of the trigger.
|
|
3828
|
+
* @csspart trigger - The trigger content container.
|
|
3829
|
+
* @csspart chevron - The collapsed/expanded state icon container.
|
|
3830
|
+
* @csspart size - The size of the dropdown bib. (height, width, maxHeight, maxWidth only)
|
|
3831
|
+
* @csspart helpText - The helpText content container.
|
|
3832
|
+
* @event auroDropdown-triggerClick - Notifies that the trigger has been clicked.
|
|
3833
|
+
* @event auroDropdown-toggled - Notifies that the visibility of the dropdown bib has changed.
|
|
3834
|
+
* @event auroDropdown-idAdded - Notifies consumers that the unique ID for the dropdown bib has been generated.
|
|
3835
|
+
*/
|
|
3836
|
+
class AuroDropdown extends AuroElement {
|
|
3837
|
+
static get shadowRootOptions() {
|
|
3838
|
+
return {
|
|
3839
|
+
...AuroElement.shadowRootOptions,
|
|
3840
|
+
delegatesFocus: true,
|
|
3841
|
+
};
|
|
3842
|
+
}
|
|
3843
|
+
|
|
3844
|
+
constructor() {
|
|
3845
|
+
super();
|
|
3846
|
+
|
|
3847
|
+
this.isPopoverVisible = false;
|
|
3848
|
+
this.isBibFullscreen = false;
|
|
3849
|
+
this.matchWidth = false;
|
|
3850
|
+
this.noHideOnThisFocusLoss = false;
|
|
3851
|
+
|
|
3852
|
+
this.errorMessage = undefined; // TODO - check with Doug if there is still more to do here
|
|
3853
|
+
|
|
3854
|
+
// Layout Config
|
|
3855
|
+
this.layout = undefined;
|
|
3856
|
+
this.shape = undefined;
|
|
3857
|
+
this.size = undefined;
|
|
3858
|
+
|
|
3859
|
+
this.parentBorder = false;
|
|
3860
|
+
|
|
3861
|
+
/** @private */
|
|
3862
|
+
this.handleDropdownToggle = this.handleDropdownToggle.bind(this);
|
|
3863
|
+
|
|
3864
|
+
/** @private */
|
|
3865
|
+
this.bibElement = createRef();
|
|
3866
|
+
|
|
3867
|
+
this._intializeDefaults();
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3870
|
+
/**
|
|
3871
|
+
* @private
|
|
3872
|
+
* @returns {object} Class definition for the wrapper element.
|
|
3873
|
+
*/
|
|
3874
|
+
get commonWrapperClasses() {
|
|
3875
|
+
return {
|
|
3876
|
+
'trigger': true,
|
|
3877
|
+
'wrapper': true,
|
|
3878
|
+
'hasFocus': this.hasFocus,
|
|
3879
|
+
'simple': this.simple,
|
|
3880
|
+
'parentBorder': this.parentBorder
|
|
3881
|
+
};
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3884
|
+
/**
|
|
3885
|
+
* @private
|
|
3886
|
+
* @returns {void} Internal defaults.
|
|
3887
|
+
*/
|
|
3888
|
+
_intializeDefaults() {
|
|
3889
|
+
this.appearance = 'default';
|
|
3890
|
+
this.chevron = false;
|
|
3891
|
+
this.disabled = false;
|
|
3892
|
+
this.disableKeyboardHandling = false;
|
|
3893
|
+
this.error = false;
|
|
3894
|
+
this.tabIndex = 0;
|
|
3895
|
+
this.noToggle = false;
|
|
3896
|
+
this.a11yRole = 'button';
|
|
3897
|
+
this.onDark = false;
|
|
3898
|
+
this.showTriggerBorders = true;
|
|
3899
|
+
this.triggerContentFocusable = false;
|
|
3900
|
+
this.simple = false;
|
|
3901
|
+
|
|
3902
|
+
// floaterConfig
|
|
3903
|
+
this.placement = 'bottom-start';
|
|
3904
|
+
this.offset = 0;
|
|
3905
|
+
this.noFlip = false;
|
|
3906
|
+
this.shift = false;
|
|
3907
|
+
this.autoPlacement = false;
|
|
3908
|
+
|
|
3909
|
+
/**
|
|
3910
|
+
* @private
|
|
3911
|
+
*/
|
|
3912
|
+
this.hasTriggerContent = false;
|
|
3913
|
+
|
|
3914
|
+
/**
|
|
3915
|
+
* @private
|
|
3916
|
+
*/
|
|
3917
|
+
this.triggerContentSlot = undefined;
|
|
3918
|
+
|
|
3919
|
+
/**
|
|
3920
|
+
* @private
|
|
3921
|
+
*/
|
|
3922
|
+
this.runtimeUtils = new AuroLibraryRuntimeUtils$1();
|
|
3923
|
+
|
|
3924
|
+
/**
|
|
3925
|
+
* @private
|
|
3926
|
+
*/
|
|
3927
|
+
this.floater = new AuroFloatingUI();
|
|
3928
|
+
|
|
3929
|
+
/**
|
|
3930
|
+
* Generate unique names for dependency components.
|
|
3931
|
+
*/
|
|
3932
|
+
const versioning = new AuroDependencyVersioning();
|
|
3933
|
+
|
|
3934
|
+
/**
|
|
3935
|
+
* @private
|
|
3936
|
+
*/
|
|
3937
|
+
this.iconTag = versioning.generateTag('auro-formkit-dropdown-icon', iconVersion, _);
|
|
3938
|
+
|
|
3939
|
+
/**
|
|
3940
|
+
* @private
|
|
3941
|
+
*/
|
|
3942
|
+
this.dropdownBibTag = versioning.generateTag('auro-formkit-dropdown-dropdownbib', formkitVersion, AuroDropdownBib);
|
|
3943
|
+
|
|
3944
|
+
/**
|
|
3945
|
+
* @private
|
|
3946
|
+
*/
|
|
3947
|
+
this.helpTextTag = versioning.generateTag('auro-formkit-dropdown-helptext', formkitVersion, AuroHelpText);
|
|
3948
|
+
|
|
3949
|
+
/**
|
|
3950
|
+
* @private
|
|
3951
|
+
*/
|
|
3952
|
+
this.bindFocusEventToTrigger = this.bindFocusEventToTrigger.bind(this);
|
|
3953
|
+
}
|
|
3954
|
+
|
|
3955
|
+
/**
|
|
3956
|
+
* @ignore
|
|
3957
|
+
*/
|
|
3958
|
+
get floaterConfig() {
|
|
3959
|
+
return {
|
|
3960
|
+
placement: this.placement,
|
|
3961
|
+
flip: !this.noFlip,
|
|
3962
|
+
shift: this.shift,
|
|
3963
|
+
autoPlacement: this.autoPlacement,
|
|
3964
|
+
offset: this.offset,
|
|
3965
|
+
};
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
/**
|
|
3969
|
+
* Public method to hide the dropdown.
|
|
3970
|
+
* @returns {void}
|
|
3971
|
+
*/
|
|
3972
|
+
hide() {
|
|
3973
|
+
this.floater.hideBib();
|
|
3974
|
+
}
|
|
3975
|
+
|
|
3976
|
+
/**
|
|
3977
|
+
* Public method to show the dropdown.
|
|
3978
|
+
* @returns {void}
|
|
3979
|
+
*/
|
|
3980
|
+
show() {
|
|
3981
|
+
this.floater.showBib();
|
|
3982
|
+
|
|
3983
|
+
// Open dialog synchronously so callers remain in the user gesture
|
|
3984
|
+
// chain. This is critical for mobile browsers (iOS Safari) to keep
|
|
3985
|
+
// the virtual keyboard open when transitioning from the trigger
|
|
3986
|
+
// input to an input inside the fullscreen dialog. Without this,
|
|
3987
|
+
// showModal() fires asynchronously via Lit's update cycle, which
|
|
3988
|
+
// falls outside the user activation window and causes iOS to
|
|
3989
|
+
// dismiss the keyboard.
|
|
3990
|
+
if (this.bibElement && this.bibElement.value) {
|
|
3991
|
+
this.bibElement.value.open(this.isBibFullscreen);
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
|
|
3995
|
+
/**
|
|
3996
|
+
* When bib is open, focus on the first element inside of bib.
|
|
3997
|
+
* If not, trigger element will get focus.
|
|
3998
|
+
*/
|
|
3999
|
+
focus() {
|
|
4000
|
+
if (this.isPopoverVisible && this.bibContent) {
|
|
4001
|
+
const focusables = getFocusableElements(this.bibContent);
|
|
4002
|
+
if (focusables.length > 0) {
|
|
4003
|
+
focusables[0].focus();
|
|
4004
|
+
}
|
|
4005
|
+
} else {
|
|
4006
|
+
this.trigger.focus();
|
|
4007
|
+
}
|
|
4008
|
+
}
|
|
4009
|
+
|
|
4010
|
+
/**
|
|
4011
|
+
* Sets the active descendant element for accessibility.
|
|
4012
|
+
* Uses ariaActiveDescendantElement to cross shadow DOM boundaries.
|
|
4013
|
+
* This function is used in components that contain `auro-dropdown` to set the active descendant.
|
|
4014
|
+
* @private
|
|
4015
|
+
* @param {HTMLElement|null} element - The element to set as the active descendant, or null to clear.
|
|
4016
|
+
* @returns {void}
|
|
4017
|
+
*/
|
|
4018
|
+
setActiveDescendant(element) {
|
|
4019
|
+
if (!this.trigger) {
|
|
4020
|
+
return;
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
if (element) {
|
|
4024
|
+
this.trigger.ariaActiveDescendantElement = element;
|
|
4025
|
+
} else {
|
|
4026
|
+
this.trigger.ariaActiveDescendantElement = null;
|
|
4027
|
+
this.trigger.removeAttribute('aria-activedescendant');
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
// In fullscreen, focus stays on the close button while arrow keys
|
|
4031
|
+
// highlight options via active-descendant. Without this flag the
|
|
4032
|
+
// keyboard bridge clicks the close button on Enter (closing the
|
|
4033
|
+
// bib without selecting). When true, the bridge skips the button
|
|
4034
|
+
// click and forwards Enter to the parent to make the selection.
|
|
4035
|
+
if (this.bibContent) {
|
|
4036
|
+
this.bibContent.hasActiveDescendant = this.isBibFullscreen && Boolean(element);
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
// function to define props used within the scope of this component
|
|
4041
|
+
static get properties() {
|
|
4042
|
+
return {
|
|
4043
|
+
|
|
4044
|
+
/**
|
|
4045
|
+
* The value for the role attribute of the trigger element.
|
|
4046
|
+
*/
|
|
4047
|
+
a11yRole: {
|
|
4048
|
+
type: String,
|
|
4049
|
+
attribute: false,
|
|
4050
|
+
reflect: false
|
|
4051
|
+
},
|
|
4052
|
+
|
|
4053
|
+
/**
|
|
4054
|
+
* Defines whether the component will be on lighter or darker backgrounds.
|
|
4055
|
+
* @type {'default' | 'inverse'}
|
|
4056
|
+
* @default 'default'
|
|
4057
|
+
*/
|
|
4058
|
+
appearance: {
|
|
4059
|
+
type: String,
|
|
4060
|
+
reflect: true
|
|
4061
|
+
},
|
|
4062
|
+
|
|
4063
|
+
/**
|
|
4064
|
+
* If declared, bib's position will be automatically calculated where to appear.
|
|
4065
|
+
*/
|
|
4066
|
+
autoPlacement: {
|
|
4067
|
+
type: Boolean,
|
|
4068
|
+
reflect: true
|
|
4069
|
+
},
|
|
4070
|
+
|
|
4071
|
+
/**
|
|
4072
|
+
* If declared, the dropdown will only show by calling the API .show() public method.
|
|
4073
|
+
*/
|
|
4074
|
+
disableEventShow: {
|
|
4075
|
+
type: Boolean,
|
|
4076
|
+
reflect: true
|
|
4077
|
+
},
|
|
4078
|
+
|
|
4079
|
+
/**
|
|
4080
|
+
* If declared, applies a border around the trigger slot.
|
|
4081
|
+
*/
|
|
4082
|
+
simple: {
|
|
4083
|
+
type: Boolean,
|
|
4084
|
+
reflect: true
|
|
4085
|
+
},
|
|
4086
|
+
|
|
4087
|
+
/**
|
|
4088
|
+
* If declared, the dropdown displays a chevron on the right.
|
|
4089
|
+
*/
|
|
4090
|
+
chevron: {
|
|
4091
|
+
type: Boolean,
|
|
4092
|
+
reflect: true,
|
|
4093
|
+
attribute: 'chevron'
|
|
4094
|
+
},
|
|
4095
|
+
|
|
4096
|
+
/**
|
|
4097
|
+
* If declared, the dropdown is not interactive.
|
|
4098
|
+
*/
|
|
4099
|
+
disabled: {
|
|
4100
|
+
type: Boolean,
|
|
4101
|
+
reflect: true
|
|
4102
|
+
},
|
|
4103
|
+
|
|
4104
|
+
/**
|
|
4105
|
+
* If declared, the dropdown will not handle keyboard events and will require the consumer to manage this behavior.
|
|
4106
|
+
*/
|
|
4107
|
+
disableKeyboardHandling: {
|
|
4108
|
+
type: Boolean,
|
|
4109
|
+
reflect: true
|
|
4110
|
+
},
|
|
4111
|
+
|
|
4112
|
+
/**
|
|
4113
|
+
* @private
|
|
4114
|
+
*/
|
|
4115
|
+
dropdownWidth: {
|
|
4116
|
+
type: Number
|
|
4117
|
+
},
|
|
4118
|
+
|
|
4119
|
+
/**
|
|
4120
|
+
* The unique ID for the dropdown bib element.
|
|
4121
|
+
* @private
|
|
4122
|
+
*/
|
|
4123
|
+
dropdownId: {
|
|
4124
|
+
type: String,
|
|
4125
|
+
reflect: false,
|
|
4126
|
+
attribute: false
|
|
4127
|
+
},
|
|
4128
|
+
|
|
4129
|
+
/**
|
|
4130
|
+
* If declared, will apply error UI to the dropdown.
|
|
4131
|
+
*/
|
|
4132
|
+
error: {
|
|
4133
|
+
type: Boolean,
|
|
4134
|
+
reflect: true
|
|
4135
|
+
},
|
|
4136
|
+
|
|
4137
|
+
/**
|
|
4138
|
+
* Contains the help text message for the current validity error.
|
|
4139
|
+
*/
|
|
4140
|
+
errorMessage: {
|
|
4141
|
+
type: String
|
|
4142
|
+
},
|
|
4143
|
+
|
|
4144
|
+
/**
|
|
4145
|
+
* If declared, the bib will display when focus is applied to the trigger.
|
|
4146
|
+
*/
|
|
4147
|
+
focusShow: {
|
|
4148
|
+
type: Boolean,
|
|
4149
|
+
reflect: true
|
|
4150
|
+
},
|
|
4151
|
+
|
|
4152
|
+
/**
|
|
4153
|
+
* If true, the dropdown bib is displayed.
|
|
4154
|
+
*/
|
|
4155
|
+
isPopoverVisible: {
|
|
4156
|
+
type: Boolean,
|
|
4157
|
+
reflect: true,
|
|
4158
|
+
attribute: 'open'
|
|
4159
|
+
},
|
|
4160
|
+
|
|
4161
|
+
/**
|
|
4162
|
+
* If true, the dropdown bib is taking the fullscreen when it's open.
|
|
4163
|
+
*/
|
|
4164
|
+
isBibFullscreen: {
|
|
4165
|
+
type: Boolean,
|
|
4166
|
+
reflect: true
|
|
4167
|
+
},
|
|
4168
|
+
|
|
4169
|
+
/**
|
|
4170
|
+
* If declared, the trigger will toggle the dropdown on mouseover/mouseout.
|
|
4171
|
+
*/
|
|
4172
|
+
hoverToggle: {
|
|
4173
|
+
type: Boolean,
|
|
4174
|
+
reflect: true
|
|
4175
|
+
},
|
|
4176
|
+
|
|
4177
|
+
/**
|
|
4178
|
+
* @private
|
|
4179
|
+
*/
|
|
4180
|
+
hasTriggerContent: {
|
|
4181
|
+
type: Boolean
|
|
4182
|
+
},
|
|
4183
|
+
|
|
4184
|
+
/**
|
|
4185
|
+
* Defines the screen size breakpoint at which the dropdown switches to fullscreen mode on mobile. `disabled` indicates a dropdown should _never_ enter fullscreen.
|
|
4186
|
+
*
|
|
4187
|
+
* When expanded, the dropdown will automatically display in fullscreen mode
|
|
4188
|
+
* if the screen size is equal to or smaller than the selected breakpoint.
|
|
4189
|
+
* @type {'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'disabled'}
|
|
4190
|
+
* @default 'sm'
|
|
4191
|
+
*/
|
|
4192
|
+
fullscreenBreakpoint: {
|
|
4193
|
+
type: String,
|
|
4194
|
+
reflect: true
|
|
4195
|
+
},
|
|
4196
|
+
|
|
4197
|
+
/**
|
|
4198
|
+
* Sets the layout of the dropdown.
|
|
4199
|
+
* @type {'classic' | 'emphasized' | 'snowflake'}
|
|
4200
|
+
* @default 'classic'
|
|
4201
|
+
*/
|
|
4202
|
+
layout: {
|
|
4203
|
+
type: String,
|
|
4204
|
+
reflect: true
|
|
4205
|
+
},
|
|
4206
|
+
|
|
4207
|
+
/**
|
|
4208
|
+
* Defines if the trigger should size based on the parent element providing the border UI.
|
|
4209
|
+
* @private
|
|
4210
|
+
*/
|
|
4211
|
+
parentBorder: {
|
|
4212
|
+
type: Boolean,
|
|
4213
|
+
reflect: true
|
|
4214
|
+
},
|
|
4215
|
+
|
|
4216
|
+
/**
|
|
4217
|
+
* If declared, the popover and trigger will be set to the same width.
|
|
4218
|
+
*/
|
|
4219
|
+
matchWidth: {
|
|
4220
|
+
type: Boolean,
|
|
4221
|
+
reflect: true
|
|
4222
|
+
},
|
|
4223
|
+
|
|
4224
|
+
/**
|
|
4225
|
+
* If declared, the bib will NOT flip to an alternate position
|
|
4226
|
+
* when there isn't enough space in the specified `placement`.
|
|
4227
|
+
*/
|
|
4228
|
+
noFlip: {
|
|
4229
|
+
type: Boolean,
|
|
4230
|
+
reflect: true
|
|
4231
|
+
},
|
|
4232
|
+
|
|
4233
|
+
/**
|
|
4234
|
+
* If declared, the dropdown will shift its position to avoid being cut off by the viewport.
|
|
4235
|
+
*/
|
|
4236
|
+
shift: {
|
|
4237
|
+
type: Boolean,
|
|
4238
|
+
reflect: true
|
|
4239
|
+
},
|
|
4240
|
+
|
|
4241
|
+
/**
|
|
4242
|
+
* If declared, the dropdown will not hide when moving focus outside the element.
|
|
4243
|
+
*/
|
|
4244
|
+
noHideOnThisFocusLoss: {
|
|
4245
|
+
type: Boolean,
|
|
4246
|
+
reflect: true
|
|
4247
|
+
},
|
|
4248
|
+
|
|
4249
|
+
/**
|
|
4250
|
+
* If declared, the trigger will only show the dropdown bib.
|
|
4251
|
+
*/
|
|
4252
|
+
noToggle: {
|
|
4253
|
+
type: Boolean,
|
|
4254
|
+
reflect: true
|
|
4255
|
+
},
|
|
4256
|
+
|
|
4257
|
+
/**
|
|
4258
|
+
* Gap between the trigger element and bib.
|
|
4259
|
+
* @default 0
|
|
4260
|
+
*/
|
|
4261
|
+
offset: {
|
|
4262
|
+
type: Number,
|
|
4263
|
+
reflect: true
|
|
4264
|
+
},
|
|
4265
|
+
|
|
4266
|
+
/**
|
|
4267
|
+
* DEPRECATED - use `appearance="inverse"` instead.
|
|
4268
|
+
*/
|
|
4269
|
+
onDark: {
|
|
4270
|
+
type: Boolean,
|
|
4271
|
+
reflect: true
|
|
4272
|
+
},
|
|
4273
|
+
|
|
4274
|
+
/**
|
|
4275
|
+
* If declared, and a function is set, that function will execute when the slot content is updated.
|
|
4276
|
+
*/
|
|
4277
|
+
onSlotChange: {
|
|
4278
|
+
type: Function,
|
|
4279
|
+
reflect: false
|
|
4280
|
+
},
|
|
4281
|
+
|
|
4282
|
+
/**
|
|
4283
|
+
* Position where the bib should appear relative to the trigger.
|
|
4284
|
+
* @type {'top' | 'right' | 'bottom' | 'left' | 'bottom-start' | 'top-start' | 'top-end' | 'right-start' | 'right-end' | 'bottom-end' | 'left-start' | 'left-end'}
|
|
4285
|
+
* @default 'bottom-start'
|
|
4286
|
+
*/
|
|
4287
|
+
placement: {
|
|
4288
|
+
type: String,
|
|
4289
|
+
reflect: true
|
|
4290
|
+
},
|
|
4291
|
+
|
|
4292
|
+
/**
|
|
4293
|
+
* @private
|
|
4294
|
+
*/
|
|
4295
|
+
tabIndex: {
|
|
4296
|
+
type: Number
|
|
4297
|
+
},
|
|
4298
|
+
|
|
4299
|
+
/**
|
|
4300
|
+
* Accessible label for the dropdown bib dialog element.
|
|
4301
|
+
* @private
|
|
4302
|
+
*/
|
|
4303
|
+
bibDialogLabel: {
|
|
4304
|
+
type: String,
|
|
4305
|
+
attribute: false,
|
|
4306
|
+
reflect: false
|
|
4307
|
+
}
|
|
4308
|
+
};
|
|
4309
|
+
}
|
|
4310
|
+
|
|
4311
|
+
static get styles() {
|
|
4312
|
+
return [
|
|
4313
|
+
styleCss$1,
|
|
4314
|
+
tokensCss$1,
|
|
4315
|
+
colorCss$1,
|
|
4316
|
+
|
|
4317
|
+
// default layout
|
|
4318
|
+
classicColorCss,
|
|
4319
|
+
classicLayoutCss,
|
|
4320
|
+
|
|
4321
|
+
// emphasized layout
|
|
4322
|
+
styleEmphasizedCss,
|
|
4323
|
+
|
|
4324
|
+
// snowflake layout
|
|
4325
|
+
styleSnowflakeCss,
|
|
4326
|
+
|
|
4327
|
+
shapeSizeCss
|
|
4328
|
+
];
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4331
|
+
/**
|
|
4332
|
+
* This will register this element with the browser.
|
|
4333
|
+
* @param {string} [name="auro-dropdown"] - The name of the element that you want to register.
|
|
4334
|
+
*
|
|
4335
|
+
* @example
|
|
4336
|
+
* AuroDropdown.register("custom-dropdown") // this will register this element to <custom-dropdown/>
|
|
4337
|
+
*
|
|
4338
|
+
*/
|
|
4339
|
+
static register(name = "auro-dropdown") {
|
|
4340
|
+
AuroLibraryRuntimeUtils$1.prototype.registerComponent(name, AuroDropdown);
|
|
4341
|
+
}
|
|
4342
|
+
|
|
4343
|
+
/**
|
|
4344
|
+
* Accessor for reusing the focusable entity query string.
|
|
4345
|
+
* @private
|
|
4346
|
+
* @returns {string}
|
|
4347
|
+
*/
|
|
4348
|
+
get focusableEntityQuery () {
|
|
4349
|
+
return 'auro-input, [auro-input], auro-button, [auro-button], button, input';
|
|
4350
|
+
}
|
|
4351
|
+
|
|
4352
|
+
connectedCallback() {
|
|
4353
|
+
super.connectedCallback();
|
|
4354
|
+
}
|
|
4355
|
+
|
|
4356
|
+
disconnectedCallback() {
|
|
4357
|
+
super.disconnectedCallback();
|
|
4358
|
+
if (this.floater) {
|
|
4359
|
+
this.floater.hideBib('disconnect');
|
|
4360
|
+
this.floater.disconnect();
|
|
4361
|
+
}
|
|
4362
|
+
this.clearTriggerFocusEventBinding();
|
|
4363
|
+
}
|
|
4364
|
+
|
|
4365
|
+
updated(changedProperties) {
|
|
4366
|
+
super.updated(changedProperties);
|
|
4367
|
+
this.floater.handleUpdate(changedProperties);
|
|
4368
|
+
|
|
4369
|
+
// Note: `disabled` is not a breakpoint (it is not a screen size),
|
|
4370
|
+
// so it looks like we never consume this - however, dropdownBib handles this in the setter as "undefined"
|
|
4371
|
+
if (changedProperties.has('fullscreenBreakpoint')) {
|
|
4372
|
+
this.bibContent.mobileFullscreenBreakpoint = this.fullscreenBreakpoint;
|
|
4373
|
+
}
|
|
4374
|
+
|
|
4375
|
+
// when trigger's content is changed without any attribute or node change,
|
|
4376
|
+
// `requestUpdate` needs to be called to update hasTriggerContent
|
|
4377
|
+
if (changedProperties.size === 0 || changedProperties.has('isPopoverVisible')) {
|
|
4378
|
+
this.handleTriggerContentSlotChange();
|
|
4379
|
+
}
|
|
4380
|
+
|
|
4381
|
+
if (changedProperties.has('isPopoverVisible') && this.bibElement.value) {
|
|
4382
|
+
if (this.isPopoverVisible) {
|
|
4383
|
+
// Fullscreen: use showModal() for native accessibility (inert outside, focus trap)
|
|
4384
|
+
// Desktop: use show() for Floating UI positioning + FocusTrap for focus management
|
|
4385
|
+
const useModal = this.isBibFullscreen;
|
|
4386
|
+
this.bibElement.value.open(useModal);
|
|
4387
|
+
} else {
|
|
4388
|
+
this.bibElement.value.close();
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4391
|
+
|
|
4392
|
+
// When fullscreen strategy changes while open, re-open dialog with correct mode
|
|
4393
|
+
// (e.g. resizing from desktop → mobile while dropdown is open)
|
|
4394
|
+
if (changedProperties.has('isBibFullscreen') && this.isPopoverVisible && this.bibElement.value) {
|
|
4395
|
+
const useModal = this.isBibFullscreen;
|
|
4396
|
+
this.bibElement.value.close();
|
|
4397
|
+
this.bibElement.value.open(useModal);
|
|
4398
|
+
}
|
|
4399
|
+
}
|
|
4400
|
+
|
|
4401
|
+
/**
|
|
4402
|
+
* Handles the custom event `auroDropdown-toggled` to update the visibility of the dropdown bib.
|
|
4403
|
+
* @private
|
|
4404
|
+
* @param {CustomEvent} event - The custom event that contains the dropdown toggle information.
|
|
4405
|
+
*/
|
|
4406
|
+
handleDropdownToggle(event) {
|
|
4407
|
+
this.updateFocusTrap();
|
|
4408
|
+
this.isPopoverVisible = event.detail.expanded;
|
|
4409
|
+
const eventType = event.detail.eventType || "unknown";
|
|
4410
|
+
if (!this.isPopoverVisible && this.hasFocus && eventType === "keydown") {
|
|
4411
|
+
this.trigger.focus();
|
|
4412
|
+
}
|
|
4413
|
+
}
|
|
4414
|
+
|
|
4415
|
+
firstUpdated() {
|
|
4416
|
+
// Configure the floater to, this will generate the ID for the bib
|
|
4417
|
+
this.floater.configure(this, 'auroDropdown', !this.disableKeyboardHandling);
|
|
4418
|
+
|
|
4419
|
+
// Prevent `contain: layout` on the dropdown host. Layout containment
|
|
4420
|
+
// creates a containing block for position:fixed descendants (the bib),
|
|
4421
|
+
// which clips the bib inside ancestor overflow contexts such as a
|
|
4422
|
+
// <dialog> element. Without it, the bib's position:fixed is relative
|
|
4423
|
+
// to the viewport, letting Floating UI's flip middleware detect
|
|
4424
|
+
// viewport boundaries and the bib escape overflow clipping.
|
|
4425
|
+
const origConfigureBibStrategy = this.floater.configureBibStrategy.bind(this.floater);
|
|
4426
|
+
this.floater.configureBibStrategy = (value) => {
|
|
4427
|
+
origConfigureBibStrategy(value);
|
|
4428
|
+
this.style.contain = '';
|
|
4429
|
+
};
|
|
4430
|
+
|
|
4431
|
+
this.addEventListener('auroDropdown-toggled', this.handleDropdownToggle);
|
|
4432
|
+
|
|
4433
|
+
// Handle ESC key from dialog's cancel event
|
|
4434
|
+
this.addEventListener('auro-bib-cancel', () => {
|
|
4435
|
+
this.floater.hideBib('keydown');
|
|
4436
|
+
});
|
|
4437
|
+
|
|
4438
|
+
/**
|
|
4439
|
+
* @description Let subscribers know that the dropdown ID ha been generated and added.
|
|
4440
|
+
* @event auroDropdown-idAdded
|
|
4441
|
+
* @type {Object<key: 'id', value: string>} - The ID of the dropdown bib element.
|
|
4442
|
+
*/
|
|
4443
|
+
this.dispatchEvent(new CustomEvent('auroDropdown-idAdded', {detail: {id: this.floater.element.id}}));
|
|
4444
|
+
|
|
4445
|
+
// Set the bib ID locally for aria-controls (must be in the same shadow root as the trigger)
|
|
4446
|
+
if (!this.triggerContentFocusable) {
|
|
4447
|
+
this.dropdownId = this.floater.element.bib.id;
|
|
4448
|
+
}
|
|
4449
|
+
|
|
4450
|
+
this.bibContent = this.floater.element.bib;
|
|
4451
|
+
|
|
4452
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
4453
|
+
this.runtimeUtils.handleComponentTagRename(this, 'auro-dropdown');
|
|
4454
|
+
|
|
4455
|
+
this.trigger.addEventListener('click', () => {
|
|
4456
|
+
this.dispatchEvent(new CustomEvent('auroDropdown-triggerClick', {
|
|
4457
|
+
bubbles: true,
|
|
4458
|
+
composed: true
|
|
4459
|
+
}));
|
|
4460
|
+
});
|
|
4461
|
+
}
|
|
4462
|
+
|
|
4463
|
+
/**
|
|
4464
|
+
* Exposes CSS parts for styling from parent components.
|
|
4465
|
+
* @returns {void}
|
|
4466
|
+
*/
|
|
4467
|
+
exposeCssParts() {
|
|
4468
|
+
this.setAttribute('exportparts', 'trigger:dropdownTrigger, chevron:dropdownChevron, helpText:dropdownHelpText, size:dropdownSize');
|
|
4469
|
+
}
|
|
4470
|
+
|
|
4471
|
+
/**
|
|
4472
|
+
* Determines if content is within a custom slot.
|
|
4473
|
+
* @private
|
|
4474
|
+
* @param {HTMLElement} element - The element to check.
|
|
4475
|
+
* @returns {Boolean}
|
|
4476
|
+
*/
|
|
4477
|
+
isCustomSlotContent(element) {
|
|
4478
|
+
let currentElement = element;
|
|
4479
|
+
|
|
4480
|
+
let inCustomSlot = false;
|
|
4481
|
+
|
|
4482
|
+
while (currentElement) {
|
|
4483
|
+
currentElement = currentElement.parentElement;
|
|
4484
|
+
|
|
4485
|
+
if (currentElement && currentElement.hasAttribute('slot')) {
|
|
4486
|
+
inCustomSlot = true;
|
|
4487
|
+
break;
|
|
4488
|
+
}
|
|
4489
|
+
}
|
|
4490
|
+
|
|
4491
|
+
return inCustomSlot;
|
|
4492
|
+
}
|
|
4493
|
+
|
|
4494
|
+
/**
|
|
4495
|
+
* Function to support @focusin event.
|
|
4496
|
+
* @private
|
|
4497
|
+
* @return {void}
|
|
4498
|
+
*/
|
|
4499
|
+
handleFocusin() {
|
|
4500
|
+
this.hasFocus = true;
|
|
4501
|
+
}
|
|
4502
|
+
|
|
4503
|
+
/**
|
|
4504
|
+
* @private
|
|
4505
|
+
*/
|
|
4506
|
+
updateFocusTrap() {
|
|
4507
|
+
if (this.isPopoverVisible) {
|
|
4508
|
+
if (!this.isBibFullscreen) {
|
|
4509
|
+
// Desktop: show() doesn't trap focus, so use FocusTrap
|
|
4510
|
+
this.focusTrap = new FocusTrap(this.bibContent);
|
|
4511
|
+
this.focusTrap.focusFirstElement();
|
|
4512
|
+
}
|
|
4513
|
+
// Fullscreen: showModal() provides native focus trapping
|
|
4514
|
+
return;
|
|
4515
|
+
}
|
|
4516
|
+
|
|
4517
|
+
if (this.focusTrap) {
|
|
4518
|
+
this.focusTrap.disconnect();
|
|
4519
|
+
this.focusTrap = undefined;
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4522
|
+
|
|
4523
|
+
/**
|
|
4524
|
+
* Function to support @focusout event.
|
|
4525
|
+
* @private
|
|
4526
|
+
* @return {void}
|
|
4527
|
+
*/
|
|
4528
|
+
handleFocusout() {
|
|
4529
|
+
this.hasFocus = false;
|
|
4530
|
+
}
|
|
4531
|
+
|
|
4532
|
+
/**
|
|
4533
|
+
* Creates and dispatches a duplicate focus event on the trigger element.
|
|
4534
|
+
* @private
|
|
4535
|
+
* @param {Event} event - The original focus event.
|
|
4536
|
+
*/
|
|
4537
|
+
bindFocusEventToTrigger(event) {
|
|
4538
|
+
const dupEvent = new FocusEvent(event.type, {
|
|
4539
|
+
bubbles: false,
|
|
4540
|
+
cancelable: false,
|
|
4541
|
+
composed: true,
|
|
4542
|
+
});
|
|
4543
|
+
this.trigger.dispatchEvent(dupEvent);
|
|
4544
|
+
}
|
|
4545
|
+
|
|
4546
|
+
/**
|
|
4547
|
+
* Sets up event listeners to deliver focus and blur events from nested Auro components within the trigger slot to trigger.
|
|
4548
|
+
* This ensures that focus/blur events originating from within these components are propagated to the trigger element itself.
|
|
4549
|
+
* @private
|
|
4550
|
+
*/
|
|
4551
|
+
setupTriggerFocusEventBinding() {
|
|
4552
|
+
if (!this.triggerContentSlot || this.triggerContentSlot.length === 0) {
|
|
4553
|
+
return;
|
|
4554
|
+
}
|
|
4555
|
+
|
|
4556
|
+
this.triggerContentSlot.forEach((node) => {
|
|
4557
|
+
if (node.querySelectorAll) {
|
|
4558
|
+
const auroElements = node.querySelectorAll(this.focusableEntityQuery);
|
|
4559
|
+
auroElements.forEach((auroEl) => {
|
|
4560
|
+
auroEl.addEventListener('focus', this.bindFocusEventToTrigger);
|
|
4561
|
+
auroEl.addEventListener('blur', this.bindFocusEventToTrigger);
|
|
4562
|
+
});
|
|
4563
|
+
}
|
|
4564
|
+
});
|
|
4565
|
+
}
|
|
4566
|
+
|
|
4567
|
+
/**
|
|
4568
|
+
* Clears focus and blur event listeners from nested Auro components within the trigger slot.
|
|
4569
|
+
* @private
|
|
4570
|
+
* @returns {void}
|
|
4571
|
+
*/
|
|
4572
|
+
clearTriggerFocusEventBinding() {
|
|
4573
|
+
if (!this.triggerContentSlot || this.triggerContentSlot.length === 0) {
|
|
4574
|
+
return;
|
|
4575
|
+
}
|
|
4576
|
+
|
|
4577
|
+
this.triggerContentSlot.forEach((node) => {
|
|
4578
|
+
if (node.querySelectorAll) {
|
|
4579
|
+
const auroElements = node.querySelectorAll(this.focusableEntityQuery);
|
|
4580
|
+
auroElements.forEach((auroEl) => {
|
|
4581
|
+
auroEl.removeEventListener('focus', this.bindFocusEventToTrigger);
|
|
4582
|
+
auroEl.removeEventListener('blur', this.bindFocusEventToTrigger);
|
|
4583
|
+
});
|
|
4584
|
+
}
|
|
4585
|
+
});
|
|
4586
|
+
}
|
|
4587
|
+
|
|
4588
|
+
/*
|
|
4589
|
+
* Sets aria attributes for the trigger element if a custom one is passed in.
|
|
4590
|
+
* @private
|
|
4591
|
+
* @method setTriggerAriaAttributes
|
|
4592
|
+
* @param { HTMLElement } triggerElement - The custom trigger element.
|
|
4593
|
+
*/
|
|
4594
|
+
clearTriggerA11yAttributes(triggerElement) {
|
|
4595
|
+
|
|
4596
|
+
if (!triggerElement || !triggerElement.removeAttribute) {
|
|
4597
|
+
return;
|
|
4598
|
+
}
|
|
4599
|
+
|
|
4600
|
+
// Reset appropriate attributes for a11y
|
|
4601
|
+
triggerElement.removeAttribute('aria-labelledby');
|
|
4602
|
+
if (triggerElement.getAttribute('id') === `${this.id}-trigger-element`) {
|
|
4603
|
+
triggerElement.removeAttribute('id');
|
|
4604
|
+
}
|
|
4605
|
+
triggerElement.removeAttribute('role');
|
|
4606
|
+
triggerElement.removeAttribute('aria-expanded');
|
|
4607
|
+
|
|
4608
|
+
triggerElement.removeAttribute('aria-controls');
|
|
4609
|
+
triggerElement.removeAttribute('aria-autocomplete');
|
|
4610
|
+
}
|
|
4611
|
+
|
|
4612
|
+
/**
|
|
4613
|
+
* Handles changes to the trigger content slot and updates related properties.
|
|
4614
|
+
*
|
|
4615
|
+
* It first updates the floater settings
|
|
4616
|
+
* Then, it retrieves the assigned nodes from the event target and checks if any of
|
|
4617
|
+
* the nodes contain non-empty text content, updating the `hasTriggerContent` property accordingly.
|
|
4618
|
+
*
|
|
4619
|
+
* @private
|
|
4620
|
+
* @method handleTriggerContentSlotChange
|
|
4621
|
+
* @param {Event} event - Native slotchange event.
|
|
4622
|
+
* @returns {void}
|
|
4623
|
+
*/
|
|
4624
|
+
handleTriggerContentSlotChange(event) {
|
|
4625
|
+
this.floater.handleTriggerTabIndex();
|
|
4626
|
+
|
|
4627
|
+
// Get the trigger
|
|
4628
|
+
const trigger = this.shadowRoot.querySelector('#trigger');
|
|
4629
|
+
|
|
4630
|
+
// Get the trigger slot
|
|
4631
|
+
const triggerSlot = this.shadowRoot.querySelector('.triggerContentWrapper slot');
|
|
4632
|
+
|
|
4633
|
+
// If there's a trigger slot
|
|
4634
|
+
if (triggerSlot) {
|
|
4635
|
+
|
|
4636
|
+
// Get the content nodes to see if there are any children
|
|
4637
|
+
const triggerContentNodes = triggerSlot.assignedNodes();
|
|
4638
|
+
|
|
4639
|
+
// If there are children
|
|
4640
|
+
if (triggerContentNodes) {
|
|
4641
|
+
|
|
4642
|
+
// See if any of them are focusable elements
|
|
4643
|
+
this.triggerContentFocusable = triggerContentNodes.some((node) => getFocusableElements(node).length > 0);
|
|
4644
|
+
|
|
4645
|
+
// If any of them are focusable elements
|
|
4646
|
+
if (this.triggerContentFocusable) {
|
|
4647
|
+
|
|
4648
|
+
// Assume the consumer will be providing their own a11y in whatever they passed in
|
|
4649
|
+
this.clearTriggerA11yAttributes(trigger);
|
|
4650
|
+
|
|
4651
|
+
// Remove the tabindex from the trigger so it doesn't interrupt focus flow
|
|
4652
|
+
trigger.removeAttribute('tabindex');
|
|
4653
|
+
} else {
|
|
4654
|
+
|
|
4655
|
+
// Add the tabindex to the trigger so that it's in the focus flow
|
|
4656
|
+
trigger.setAttribute('tabindex', '0');
|
|
4657
|
+
}
|
|
4658
|
+
}
|
|
4659
|
+
}
|
|
4660
|
+
|
|
4661
|
+
if (event) {
|
|
4662
|
+
// Wrap in a try-catch block to handle errors when trying to use assignedNodes from the NodeJS test environment.
|
|
4663
|
+
try {
|
|
4664
|
+
this.triggerNode = event.target;
|
|
4665
|
+
this.triggerContentSlot = event.target.assignedNodes();
|
|
4666
|
+
} catch (error) {
|
|
4667
|
+
console.warn('auro-dropdown: Unable to access the trigger content slot.', error); // eslint-disable-line no-console
|
|
4668
|
+
}
|
|
4669
|
+
}
|
|
4670
|
+
|
|
4671
|
+
if (this.triggerContentSlot) {
|
|
4672
|
+
this.setupTriggerFocusEventBinding();
|
|
4673
|
+
|
|
4674
|
+
this.hasTriggerContent = this.triggerContentSlot.some((slot) => {
|
|
4675
|
+
if (slot.textContent.trim()) {
|
|
4676
|
+
return true;
|
|
4677
|
+
}
|
|
4678
|
+
const slotInSlot = slot.querySelector('slot');
|
|
4679
|
+
if (!slotInSlot) {
|
|
4680
|
+
return false;
|
|
4681
|
+
}
|
|
4682
|
+
const slotsInSlotNodes = slotInSlot.assignedNodes();
|
|
4683
|
+
return slotsInSlotNodes.some((ss) => Boolean(ss.textContent.trim()));
|
|
4684
|
+
});
|
|
4685
|
+
} else {
|
|
4686
|
+
this.hasTriggerContent = false;
|
|
4687
|
+
}
|
|
4688
|
+
}
|
|
4689
|
+
|
|
4690
|
+
/**
|
|
4691
|
+
* Handles the default slot change event and updates the content.
|
|
4692
|
+
*
|
|
4693
|
+
* This method retrieves all nodes assigned to the default slot of the event target and appends them
|
|
4694
|
+
* to the `bibContent` element. If a callback function `onSlotChange` is defined, it is invoked to
|
|
4695
|
+
* notify about the slot change.
|
|
4696
|
+
*
|
|
4697
|
+
* @private
|
|
4698
|
+
* @method handleDefaultSlot
|
|
4699
|
+
* @fires Function#onSlotChange - Optional callback invoked when the slot content changes.
|
|
4700
|
+
*/
|
|
4701
|
+
handleDefaultSlot() {
|
|
4702
|
+
|
|
4703
|
+
if (this.onSlotChange) {
|
|
4704
|
+
this.onSlotChange();
|
|
4705
|
+
}
|
|
4706
|
+
}
|
|
4707
|
+
|
|
4708
|
+
/**
|
|
4709
|
+
* Returns HTML for the common portion of the layouts.
|
|
4710
|
+
* @private
|
|
4711
|
+
* @param {Object} helpTextClasses - Classes to apply to the help text container.
|
|
4712
|
+
* @returns {html} - Returns HTML.
|
|
4713
|
+
*/
|
|
4714
|
+
renderBasicHtml(helpTextClasses) {
|
|
4715
|
+
return html$1`
|
|
4716
|
+
<div>
|
|
4717
|
+
<div
|
|
4718
|
+
id="trigger"
|
|
4719
|
+
class="${classMap(this.commonWrapperClasses)}" part="wrapper"
|
|
4720
|
+
tabindex="${ifDefined(this.triggerContentFocusable ? undefined : this.tabIndex)}"
|
|
4721
|
+
role="${ifDefined(this.triggerContentFocusable ? undefined : this.a11yRole)}"
|
|
4722
|
+
aria-expanded="${ifDefined(this.a11yRole === 'button' || this.triggerContentFocusable ? undefined : this.isPopoverVisible)}"
|
|
4723
|
+
aria-controls="${ifDefined(this.a11yRole === 'button' || this.triggerContentFocusable ? undefined : this.dropdownId)}"
|
|
4724
|
+
aria-labelledby="${ifDefined(this.triggerContentFocusable ? undefined : 'triggerLabel')}"
|
|
4725
|
+
aria-disabled="${ifDefined(this.disabled ? 'true' : undefined)}"
|
|
4726
|
+
@focusin="${this.handleFocusin}"
|
|
4727
|
+
@blur="${this.handleFocusOut}">
|
|
4728
|
+
<div class="triggerContentWrapper" id="triggerLabel">
|
|
4729
|
+
<slot
|
|
4730
|
+
name="trigger"
|
|
4731
|
+
@slotchange="${this.handleTriggerContentSlotChange}"></slot>
|
|
4732
|
+
</div>
|
|
4733
|
+
${this.chevron ? html$1`
|
|
4734
|
+
<div
|
|
4735
|
+
id="showStateIcon"
|
|
4736
|
+
class="chevron"
|
|
4737
|
+
part="chevron"
|
|
4738
|
+
aria-hidden="true">
|
|
4739
|
+
<${this.iconTag}
|
|
4740
|
+
category="interface"
|
|
4741
|
+
name="${this.isPopoverVisible ? 'chevron-up' : `chevron-down`}"
|
|
4742
|
+
appearance="${this.onDark ? 'inverse' : this.appearance}"
|
|
4743
|
+
variant="${this.disabled ? 'disabled' : 'muted'}"
|
|
4744
|
+
ariaHidden="true">
|
|
4745
|
+
</${this.iconTag}>
|
|
4746
|
+
</div>
|
|
4747
|
+
` : undefined }
|
|
4748
|
+
</div>
|
|
4749
|
+
<div class="${classMap(helpTextClasses)}">
|
|
4750
|
+
<slot name="helpText"></slot>
|
|
4751
|
+
</div>
|
|
4752
|
+
<div id="bibSizer" part="size"></div>
|
|
4753
|
+
<${this.dropdownBibTag}
|
|
4754
|
+
id="bib"
|
|
4755
|
+
shape="${this.shape}"
|
|
4756
|
+
?data-show="${this.isPopoverVisible}"
|
|
4757
|
+
?isfullscreen="${this.isBibFullscreen}"
|
|
4758
|
+
.dialogLabel="${this.bibDialogLabel}"
|
|
4759
|
+
${ref(this.bibElement)}
|
|
4760
|
+
>
|
|
4761
|
+
<div class="slotContent">
|
|
4762
|
+
<slot @slotchange="${this.handleDefaultSlot}"></slot>
|
|
4763
|
+
</div>
|
|
4764
|
+
</${this.dropdownBibTag}>
|
|
4765
|
+
</div>
|
|
4766
|
+
`;
|
|
4767
|
+
}
|
|
4768
|
+
|
|
4769
|
+
/**
|
|
4770
|
+
* Returns HTML for the classic layout. Does not support type="*".
|
|
4771
|
+
* @private
|
|
4772
|
+
* @returns {html} - Returns HTML for the classic layout.
|
|
4773
|
+
*/
|
|
4774
|
+
renderLayoutClassic() {
|
|
4775
|
+
// TODO: check with Doug why this was never used?
|
|
4776
|
+
const helpTextClasses = {
|
|
4777
|
+
'helpText': true
|
|
4778
|
+
};
|
|
4779
|
+
|
|
4780
|
+
return html$1`
|
|
4781
|
+
${this.renderBasicHtml(helpTextClasses)}
|
|
4782
|
+
`;
|
|
4783
|
+
}
|
|
4784
|
+
|
|
4785
|
+
/**
|
|
4786
|
+
* Returns HTML for the snowflake layout. Does not support type="*".
|
|
4787
|
+
* @private
|
|
4788
|
+
* @returns {html} - Returns HTML for the snowflake layout.
|
|
4789
|
+
*/
|
|
4790
|
+
renderLayoutSnowflake() {
|
|
4791
|
+
const helpTextClasses = {
|
|
4792
|
+
'helpText': true,
|
|
4793
|
+
'leftIndent': true,
|
|
4794
|
+
'rightIndent': true
|
|
4795
|
+
};
|
|
4796
|
+
|
|
4797
|
+
return html$1`
|
|
4798
|
+
${this.renderBasicHtml(helpTextClasses)}
|
|
4799
|
+
`;
|
|
4800
|
+
}
|
|
4801
|
+
|
|
4802
|
+
/**
|
|
4803
|
+
* Returns HTML for the emphasized layout. Does not support type="*".
|
|
4804
|
+
* @private
|
|
4805
|
+
* @returns {html} - Returns HTML for the emphasized layout.
|
|
4806
|
+
*/
|
|
4807
|
+
renderLayoutEmphasized() {
|
|
4808
|
+
const helpTextClasses = {
|
|
4809
|
+
'helpText': true,
|
|
4810
|
+
'leftIndent': this.shape.toLowerCase().includes('pill') && !this.shape.toLowerCase().includes('right'),
|
|
4811
|
+
'rightIndent': this.shape.toLowerCase().includes('pill') && !this.shape.toLowerCase().includes('left')
|
|
4812
|
+
};
|
|
4813
|
+
|
|
4814
|
+
return html$1`
|
|
4815
|
+
${this.renderBasicHtml(helpTextClasses)}
|
|
4816
|
+
`;
|
|
4817
|
+
}
|
|
4818
|
+
|
|
4819
|
+
/**
|
|
4820
|
+
* Logic to determine the layout of the component.
|
|
4821
|
+
* @private
|
|
4822
|
+
* @param {string} [ForcedLayout] - Used to force a specific layout, pass in the layout name to use.
|
|
4823
|
+
* @returns {HTMLCollection} - Returns the HTML for the layout.
|
|
4824
|
+
*/
|
|
4825
|
+
renderLayout(ForcedLayout) {
|
|
4826
|
+
const layout = ForcedLayout || this.layout;
|
|
4827
|
+
|
|
4828
|
+
switch (layout) {
|
|
4829
|
+
case 'emphasized':
|
|
4830
|
+
return this.renderLayoutEmphasized();
|
|
4831
|
+
case 'emphasized-left':
|
|
4832
|
+
return this.renderLayoutEmphasized();
|
|
4833
|
+
case 'emphasized-right':
|
|
4834
|
+
return this.renderLayoutEmphasized();
|
|
4835
|
+
case 'snowflake':
|
|
4836
|
+
return this.renderLayoutSnowflake();
|
|
4837
|
+
case 'snowflake-left':
|
|
4838
|
+
return this.renderLayoutSnowflake();
|
|
4839
|
+
case 'snowflake-right':
|
|
4840
|
+
return this.renderLayoutSnowflake();
|
|
4841
|
+
default:
|
|
4842
|
+
return this.renderLayoutClassic();
|
|
4843
|
+
}
|
|
4844
|
+
}
|
|
4845
|
+
}
|
|
4846
|
+
|
|
4847
|
+
AuroDropdown.register();
|