@aurodesignsystem-dev/auro-formkit 0.0.0-pr1551.0 → 0.0.0-pr1552.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/checkbox/demo/customize.min.js +1 -1
- package/components/checkbox/demo/getting-started.min.js +1 -1
- package/components/checkbox/demo/index.min.js +1 -1
- package/components/checkbox/dist/index.js +1 -1
- package/components/checkbox/dist/registered.js +1 -1
- package/components/combobox/demo/customize.min.js +207 -46
- package/components/combobox/demo/getting-started.min.js +207 -46
- package/components/combobox/demo/index.min.js +207 -46
- package/components/combobox/dist/index.js +207 -46
- package/components/combobox/dist/registered.js +207 -46
- package/components/counter/demo/customize.min.js +206 -45
- package/components/counter/demo/index.min.js +206 -45
- package/components/counter/dist/index.js +206 -45
- package/components/counter/dist/registered.js +206 -45
- package/components/datepicker/demo/customize.min.js +207 -46
- package/components/datepicker/demo/index.min.js +207 -46
- package/components/datepicker/dist/index.js +207 -46
- package/components/datepicker/dist/registered.js +207 -46
- package/components/dropdown/demo/customize.min.js +205 -44
- package/components/dropdown/demo/getting-started.min.js +205 -44
- package/components/dropdown/demo/index.min.js +205 -44
- package/components/dropdown/dist/index.js +205 -44
- package/components/dropdown/dist/registered.js +205 -44
- package/components/form/demo/customize.min.js +829 -185
- package/components/form/demo/getting-started.min.js +829 -185
- package/components/form/demo/index.min.js +829 -185
- package/components/form/demo/registerDemoDeps.min.js +829 -185
- package/components/input/demo/customize.min.js +1 -1
- package/components/input/demo/getting-started.min.js +1 -1
- package/components/input/demo/index.min.js +1 -1
- package/components/input/dist/index.js +1 -1
- package/components/input/dist/registered.js +1 -1
- package/components/radio/demo/customize.min.js +1 -1
- package/components/radio/demo/getting-started.min.js +1 -1
- package/components/radio/demo/index.min.js +1 -1
- package/components/radio/dist/index.js +1 -1
- package/components/radio/dist/registered.js +1 -1
- package/components/select/demo/customize.min.js +206 -45
- package/components/select/demo/getting-started.min.js +206 -45
- package/components/select/demo/index.min.js +206 -45
- package/components/select/dist/index.js +206 -45
- package/components/select/dist/registered.js +206 -45
- package/package.json +2 -2
|
@@ -2295,40 +2295,12 @@ class AuroFloatingUI {
|
|
|
2295
2295
|
return;
|
|
2296
2296
|
}
|
|
2297
2297
|
|
|
2298
|
-
// Chrome-specific: during popover top-layer promotion after a click on a
|
|
2299
|
-
// slotted focusable, :focus-within can briefly evaluate false while the
|
|
2300
|
-
// active element is still structurally inside the trigger/bib. Fall back
|
|
2301
|
-
// to a shadow-piercing ancestry walk from the deep active element before
|
|
2302
|
-
// treating this as a real focus loss.
|
|
2303
|
-
try {
|
|
2304
|
-
let active = document.activeElement;
|
|
2305
|
-
while (active && active.shadowRoot && active.shadowRoot.activeElement) {
|
|
2306
|
-
active = active.shadowRoot.activeElement;
|
|
2307
|
-
}
|
|
2308
|
-
const targets = [element, element.trigger, element.bib].filter(Boolean);
|
|
2309
|
-
let node = active;
|
|
2310
|
-
while (node) {
|
|
2311
|
-
if (targets.includes(node)) {
|
|
2312
|
-
return;
|
|
2313
|
-
}
|
|
2314
|
-
node =
|
|
2315
|
-
node.parentElement ||
|
|
2316
|
-
(node.getRootNode && node.getRootNode().host) ||
|
|
2317
|
-
null;
|
|
2318
|
-
}
|
|
2319
|
-
} catch (e) {
|
|
2320
|
-
// Defensive: fall through to the existing close path if traversal fails.
|
|
2321
|
-
}
|
|
2322
|
-
|
|
2323
2298
|
// if fullscreen bib is in fullscreen mode, do not close
|
|
2324
2299
|
if (element.bib.hasAttribute("isfullscreen")) {
|
|
2325
2300
|
return;
|
|
2326
2301
|
}
|
|
2327
2302
|
|
|
2328
|
-
|
|
2329
|
-
// Escape keydown close. Consumers use this to decide whether to restore
|
|
2330
|
-
// focus to the trigger (Escape) or let it advance naturally (Tab).
|
|
2331
|
-
this.hideBib("focusloss");
|
|
2303
|
+
this.hideBib("keydown");
|
|
2332
2304
|
}
|
|
2333
2305
|
|
|
2334
2306
|
setupHideHandlers() {
|
|
@@ -2998,6 +2970,199 @@ function getFocusableElements(container) {
|
|
|
2998
2970
|
return tabIndexedUniqueElements;
|
|
2999
2971
|
}
|
|
3000
2972
|
|
|
2973
|
+
/**
|
|
2974
|
+
* FocusTrap manages keyboard focus within a specified container element, ensuring that focus does not leave the container when tabbing.
|
|
2975
|
+
* It is commonly used for modal dialogs or overlays to improve accessibility by trapping focus within interactive UI components.
|
|
2976
|
+
*/
|
|
2977
|
+
class FocusTrap {
|
|
2978
|
+
/**
|
|
2979
|
+
* Creates a new FocusTrap instance for the given container element.
|
|
2980
|
+
* Initializes event listeners and prepares the container for focus management.
|
|
2981
|
+
*
|
|
2982
|
+
* @param {HTMLElement} container The DOM element to trap focus within.
|
|
2983
|
+
* @param {boolean} [controlTabOrder=false] If true enables manual control of the tab order by the FocusTrap.
|
|
2984
|
+
* @throws {Error} If the provided container is not a valid HTMLElement.
|
|
2985
|
+
*/
|
|
2986
|
+
constructor(container, controlTabOrder = false) {
|
|
2987
|
+
if (!container || !(container instanceof HTMLElement)) {
|
|
2988
|
+
throw new Error("FocusTrap requires a valid HTMLElement.");
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
this.container = container;
|
|
2992
|
+
this.tabDirection = "forward"; // or 'backward';
|
|
2993
|
+
this.controlTabOrder = controlTabOrder;
|
|
2994
|
+
|
|
2995
|
+
this._init();
|
|
2996
|
+
}
|
|
2997
|
+
|
|
2998
|
+
/**
|
|
2999
|
+
* Initializes the focus trap by setting up event listeners and attributes on the container.
|
|
3000
|
+
* Prepares the container for focus management, including support for shadow DOM and inert attributes.
|
|
3001
|
+
*
|
|
3002
|
+
* @private
|
|
3003
|
+
*/
|
|
3004
|
+
_init() {
|
|
3005
|
+
// Add inert attribute to prevent focusing programmatically as well (if supported)
|
|
3006
|
+
if ("inert" in HTMLElement.prototype) {
|
|
3007
|
+
this.container.inert = false; // Ensure the container isn't inert
|
|
3008
|
+
this.container.setAttribute("data-focus-trap-container", true); // Mark for identification
|
|
3009
|
+
}
|
|
3010
|
+
|
|
3011
|
+
// Track tab direction
|
|
3012
|
+
this.container.addEventListener("keydown", this._onKeydown);
|
|
3013
|
+
}
|
|
3014
|
+
|
|
3015
|
+
/**
|
|
3016
|
+
* Gets an array of currently active (focused) elements in the document and shadow DOM.
|
|
3017
|
+
* @returns {Array<HTMLElement>} An array of focusable elements within the container.
|
|
3018
|
+
* @private
|
|
3019
|
+
*/
|
|
3020
|
+
_getActiveElements() {
|
|
3021
|
+
// Get the active element(s) in the document and shadow root
|
|
3022
|
+
// This will include the active element in the shadow DOM if it exists
|
|
3023
|
+
// Active element may be inside the shadow DOM depending on delegatesFocus, so we need to check both
|
|
3024
|
+
let { activeElement } = document;
|
|
3025
|
+
const actives = [activeElement];
|
|
3026
|
+
while (activeElement?.shadowRoot?.activeElement) {
|
|
3027
|
+
actives.push(activeElement.shadowRoot.activeElement);
|
|
3028
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
|
3029
|
+
}
|
|
3030
|
+
return actives;
|
|
3031
|
+
}
|
|
3032
|
+
|
|
3033
|
+
/**
|
|
3034
|
+
* Gets the next focus index based on the current index and focusable elements.
|
|
3035
|
+
* @param {number} currentIndex The current index of the focused element.
|
|
3036
|
+
* @param {Array<HTMLElement>} focusables The array of focusable elements.
|
|
3037
|
+
* @returns {number|null} The next focus index or null if not determined.
|
|
3038
|
+
*/
|
|
3039
|
+
_getNextFocusIndex(currentIndex, focusables, actives) {
|
|
3040
|
+
if (this.controlTabOrder) {
|
|
3041
|
+
// Calculate the new index based on the current index and tab direction
|
|
3042
|
+
let newFocusIndex =
|
|
3043
|
+
currentIndex + (this.tabDirection === "forward" ? 1 : -1);
|
|
3044
|
+
|
|
3045
|
+
// Wrap-around logic
|
|
3046
|
+
if (newFocusIndex < 0) newFocusIndex = focusables.length - 1;
|
|
3047
|
+
if (newFocusIndex >= focusables.length) newFocusIndex = 0;
|
|
3048
|
+
|
|
3049
|
+
// Early return with the new index
|
|
3050
|
+
return newFocusIndex;
|
|
3051
|
+
}
|
|
3052
|
+
|
|
3053
|
+
// Determine if we need to wrap
|
|
3054
|
+
const atFirst =
|
|
3055
|
+
actives.includes(focusables[0]) || actives.includes(this.container);
|
|
3056
|
+
const atLast = actives.includes(focusables[focusables.length - 1]);
|
|
3057
|
+
|
|
3058
|
+
// Only wrap if at the ends
|
|
3059
|
+
if (this.tabDirection === "backward" && atFirst) {
|
|
3060
|
+
return focusables.length - 1;
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
if (this.tabDirection === "forward" && atLast) {
|
|
3064
|
+
return 0;
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
// No wrap, so don't change focus, return early
|
|
3068
|
+
return null;
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
/**
|
|
3072
|
+
* Handles the Tab key press event to manage focus within the container.
|
|
3073
|
+
* @param {KeyboardEvent} e The keyboard event triggered by the user.
|
|
3074
|
+
* @returns {void}
|
|
3075
|
+
*/
|
|
3076
|
+
_handleTabKey(e) {
|
|
3077
|
+
// Update the focusable elements
|
|
3078
|
+
const focusables = this._getFocusableElements();
|
|
3079
|
+
|
|
3080
|
+
// If there are no focusable elements, exit
|
|
3081
|
+
if (!focusables.length) return;
|
|
3082
|
+
|
|
3083
|
+
// Set the tab direction based on the key pressed
|
|
3084
|
+
this.tabDirection = e.shiftKey ? "backward" : "forward";
|
|
3085
|
+
|
|
3086
|
+
// Get the active elements that are currently focused
|
|
3087
|
+
const actives = this._getActiveElements();
|
|
3088
|
+
|
|
3089
|
+
// If we're at either end of the focusable elements, wrap around to the other end
|
|
3090
|
+
let focusIndex = focusables.findIndex((el) => actives.includes(el));
|
|
3091
|
+
|
|
3092
|
+
// Fallback if we have no focused element
|
|
3093
|
+
if (focusIndex === -1) focusIndex = 0;
|
|
3094
|
+
|
|
3095
|
+
// Get the next focus index based on the current focus index, tab direction, and controlTabOrder setting
|
|
3096
|
+
// Is null if no new focus index is determined
|
|
3097
|
+
const newFocusIndex = this._getNextFocusIndex(
|
|
3098
|
+
focusIndex,
|
|
3099
|
+
focusables,
|
|
3100
|
+
actives,
|
|
3101
|
+
);
|
|
3102
|
+
|
|
3103
|
+
// If we have a new focus index, set focus to that element
|
|
3104
|
+
if (newFocusIndex !== null) {
|
|
3105
|
+
e.preventDefault();
|
|
3106
|
+
focusables[newFocusIndex].focus();
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
/**
|
|
3111
|
+
* Catches the keydown event
|
|
3112
|
+
* @param {KeyboardEvent} e The keyboard event triggered by user interaction.
|
|
3113
|
+
* @private
|
|
3114
|
+
*/
|
|
3115
|
+
_onKeydown = (e) => {
|
|
3116
|
+
// Handle tab
|
|
3117
|
+
if (e.key === "Tab") this._handleTabKey(e);
|
|
3118
|
+
};
|
|
3119
|
+
|
|
3120
|
+
/**
|
|
3121
|
+
* Retrieves all focusable elements within the container in DOM order, including those in shadow DOM and slots.
|
|
3122
|
+
* Returns a unique, ordered array of elements that can receive focus.
|
|
3123
|
+
*
|
|
3124
|
+
* @returns {Array<HTMLElement>} An array of focusable elements within the container.
|
|
3125
|
+
* @private
|
|
3126
|
+
*/
|
|
3127
|
+
_getFocusableElements() {
|
|
3128
|
+
// Use the imported utility function to get focusable elements
|
|
3129
|
+
const elements = getFocusableElements(this.container);
|
|
3130
|
+
|
|
3131
|
+
// Return the elements found
|
|
3132
|
+
return elements;
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
/**
|
|
3136
|
+
* Moves focus to the first focusable element within the container.
|
|
3137
|
+
* Useful for setting initial focus when activating the focus trap.
|
|
3138
|
+
*/
|
|
3139
|
+
focusFirstElement() {
|
|
3140
|
+
const focusables = this._getFocusableElements();
|
|
3141
|
+
if (focusables.length) focusables[0].focus();
|
|
3142
|
+
}
|
|
3143
|
+
|
|
3144
|
+
/**
|
|
3145
|
+
* Moves focus to the last focusable element within the container.
|
|
3146
|
+
* Useful for setting focus when deactivating or cycling focus in reverse.
|
|
3147
|
+
*/
|
|
3148
|
+
focusLastElement() {
|
|
3149
|
+
const focusables = this._getFocusableElements();
|
|
3150
|
+
if (focusables.length) focusables[focusables.length - 1].focus();
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
/**
|
|
3154
|
+
* Removes event listeners and attributes added by the focus trap.
|
|
3155
|
+
* Call this method to clean up when the focus trap is no longer needed.
|
|
3156
|
+
*/
|
|
3157
|
+
disconnect() {
|
|
3158
|
+
if (this.container.hasAttribute("data-focus-trap-container")) {
|
|
3159
|
+
this.container.removeAttribute("data-focus-trap-container");
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3162
|
+
this.container.removeEventListener("keydown", this._onKeydown);
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3001
3166
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
3002
3167
|
// See LICENSE in the project root for license information.
|
|
3003
3168
|
|
|
@@ -3526,7 +3691,7 @@ class AuroDropdownBib extends i {
|
|
|
3526
3691
|
classes[`shape-${this.shape}`] = true;
|
|
3527
3692
|
|
|
3528
3693
|
return u$2`
|
|
3529
|
-
<dialog
|
|
3694
|
+
<dialog class="${e$4(classes)}" part="bibContainer" role="${o(this.dialogRole)}" aria-labelledby="${o(this.dialogLabel ? 'dialogLabel' : undefined)}">
|
|
3530
3695
|
${this.dialogLabel ? u$2`<span id="dialogLabel" class="util_displayHiddenVisually">${this.dialogLabel}</span>` : ''}
|
|
3531
3696
|
<slot></slot>
|
|
3532
3697
|
<span id="srAnnouncement" class="util_displayHiddenVisually" aria-live="polite" role="status"></span>
|
|
@@ -3777,7 +3942,7 @@ class AuroHelpText extends i {
|
|
|
3777
3942
|
}
|
|
3778
3943
|
}
|
|
3779
3944
|
|
|
3780
|
-
var formkitVersion = '
|
|
3945
|
+
var formkitVersion = '202607092329';
|
|
3781
3946
|
|
|
3782
3947
|
class AuroElement extends i {
|
|
3783
3948
|
static get properties() {
|
|
@@ -4531,10 +4696,7 @@ class AuroDropdown extends AuroElement {
|
|
|
4531
4696
|
}
|
|
4532
4697
|
|
|
4533
4698
|
|
|
4534
|
-
|
|
4535
|
-
// — restoring to the trigger would trap the user on this dropdown, forcing
|
|
4536
|
-
// an extra Tab to move on. Escape and outside-click still restore.
|
|
4537
|
-
if (!this.isPopoverVisible && eventType !== "focusloss") {
|
|
4699
|
+
if (!this.isPopoverVisible) {
|
|
4538
4700
|
// wait til the bib gets fully closed and rendered
|
|
4539
4701
|
setTimeout(() => {
|
|
4540
4702
|
// Skip if the bib re-opened, or if focus moved intentionally outside the dropdown (not to body).
|
|
@@ -4764,16 +4926,15 @@ class AuroDropdown extends AuroElement {
|
|
|
4764
4926
|
}
|
|
4765
4927
|
});
|
|
4766
4928
|
} else {
|
|
4767
|
-
// Normal desktop
|
|
4768
|
-
//
|
|
4769
|
-
//
|
|
4770
|
-
//
|
|
4771
|
-
//
|
|
4772
|
-
|
|
4929
|
+
// Normal desktop: use FocusTrap on the bib element.
|
|
4930
|
+
// Defer focusFirstElement to the next frame because the popover
|
|
4931
|
+
// is positioned asynchronously by Floating UI — calling focus()
|
|
4932
|
+
// synchronously here would target elements with zero dimensions
|
|
4933
|
+
// and the focus call would be silently ignored.
|
|
4934
|
+
this.focusTrap = new FocusTrap(this.bibContent);
|
|
4773
4935
|
requestAnimationFrame(() => {
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
focusables[0].focus();
|
|
4936
|
+
if (this.focusTrap) {
|
|
4937
|
+
this.focusTrap.focusFirstElement();
|
|
4777
4938
|
}
|
|
4778
4939
|
});
|
|
4779
4940
|
}
|
|
@@ -2322,40 +2322,12 @@ class AuroFloatingUI {
|
|
|
2322
2322
|
return;
|
|
2323
2323
|
}
|
|
2324
2324
|
|
|
2325
|
-
// Chrome-specific: during popover top-layer promotion after a click on a
|
|
2326
|
-
// slotted focusable, :focus-within can briefly evaluate false while the
|
|
2327
|
-
// active element is still structurally inside the trigger/bib. Fall back
|
|
2328
|
-
// to a shadow-piercing ancestry walk from the deep active element before
|
|
2329
|
-
// treating this as a real focus loss.
|
|
2330
|
-
try {
|
|
2331
|
-
let active = document.activeElement;
|
|
2332
|
-
while (active && active.shadowRoot && active.shadowRoot.activeElement) {
|
|
2333
|
-
active = active.shadowRoot.activeElement;
|
|
2334
|
-
}
|
|
2335
|
-
const targets = [element, element.trigger, element.bib].filter(Boolean);
|
|
2336
|
-
let node = active;
|
|
2337
|
-
while (node) {
|
|
2338
|
-
if (targets.includes(node)) {
|
|
2339
|
-
return;
|
|
2340
|
-
}
|
|
2341
|
-
node =
|
|
2342
|
-
node.parentElement ||
|
|
2343
|
-
(node.getRootNode && node.getRootNode().host) ||
|
|
2344
|
-
null;
|
|
2345
|
-
}
|
|
2346
|
-
} catch (e) {
|
|
2347
|
-
// Defensive: fall through to the existing close path if traversal fails.
|
|
2348
|
-
}
|
|
2349
|
-
|
|
2350
2325
|
// if fullscreen bib is in fullscreen mode, do not close
|
|
2351
2326
|
if (element.bib.hasAttribute("isfullscreen")) {
|
|
2352
2327
|
return;
|
|
2353
2328
|
}
|
|
2354
2329
|
|
|
2355
|
-
|
|
2356
|
-
// Escape keydown close. Consumers use this to decide whether to restore
|
|
2357
|
-
// focus to the trigger (Escape) or let it advance naturally (Tab).
|
|
2358
|
-
this.hideBib("focusloss");
|
|
2330
|
+
this.hideBib("keydown");
|
|
2359
2331
|
}
|
|
2360
2332
|
|
|
2361
2333
|
setupHideHandlers() {
|
|
@@ -3025,6 +2997,199 @@ function getFocusableElements(container) {
|
|
|
3025
2997
|
return tabIndexedUniqueElements;
|
|
3026
2998
|
}
|
|
3027
2999
|
|
|
3000
|
+
/**
|
|
3001
|
+
* FocusTrap manages keyboard focus within a specified container element, ensuring that focus does not leave the container when tabbing.
|
|
3002
|
+
* It is commonly used for modal dialogs or overlays to improve accessibility by trapping focus within interactive UI components.
|
|
3003
|
+
*/
|
|
3004
|
+
class FocusTrap {
|
|
3005
|
+
/**
|
|
3006
|
+
* Creates a new FocusTrap instance for the given container element.
|
|
3007
|
+
* Initializes event listeners and prepares the container for focus management.
|
|
3008
|
+
*
|
|
3009
|
+
* @param {HTMLElement} container The DOM element to trap focus within.
|
|
3010
|
+
* @param {boolean} [controlTabOrder=false] If true enables manual control of the tab order by the FocusTrap.
|
|
3011
|
+
* @throws {Error} If the provided container is not a valid HTMLElement.
|
|
3012
|
+
*/
|
|
3013
|
+
constructor(container, controlTabOrder = false) {
|
|
3014
|
+
if (!container || !(container instanceof HTMLElement)) {
|
|
3015
|
+
throw new Error("FocusTrap requires a valid HTMLElement.");
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
this.container = container;
|
|
3019
|
+
this.tabDirection = "forward"; // or 'backward';
|
|
3020
|
+
this.controlTabOrder = controlTabOrder;
|
|
3021
|
+
|
|
3022
|
+
this._init();
|
|
3023
|
+
}
|
|
3024
|
+
|
|
3025
|
+
/**
|
|
3026
|
+
* Initializes the focus trap by setting up event listeners and attributes on the container.
|
|
3027
|
+
* Prepares the container for focus management, including support for shadow DOM and inert attributes.
|
|
3028
|
+
*
|
|
3029
|
+
* @private
|
|
3030
|
+
*/
|
|
3031
|
+
_init() {
|
|
3032
|
+
// Add inert attribute to prevent focusing programmatically as well (if supported)
|
|
3033
|
+
if ("inert" in HTMLElement.prototype) {
|
|
3034
|
+
this.container.inert = false; // Ensure the container isn't inert
|
|
3035
|
+
this.container.setAttribute("data-focus-trap-container", true); // Mark for identification
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
// Track tab direction
|
|
3039
|
+
this.container.addEventListener("keydown", this._onKeydown);
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
/**
|
|
3043
|
+
* Gets an array of currently active (focused) elements in the document and shadow DOM.
|
|
3044
|
+
* @returns {Array<HTMLElement>} An array of focusable elements within the container.
|
|
3045
|
+
* @private
|
|
3046
|
+
*/
|
|
3047
|
+
_getActiveElements() {
|
|
3048
|
+
// Get the active element(s) in the document and shadow root
|
|
3049
|
+
// This will include the active element in the shadow DOM if it exists
|
|
3050
|
+
// Active element may be inside the shadow DOM depending on delegatesFocus, so we need to check both
|
|
3051
|
+
let { activeElement } = document;
|
|
3052
|
+
const actives = [activeElement];
|
|
3053
|
+
while (activeElement?.shadowRoot?.activeElement) {
|
|
3054
|
+
actives.push(activeElement.shadowRoot.activeElement);
|
|
3055
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
|
3056
|
+
}
|
|
3057
|
+
return actives;
|
|
3058
|
+
}
|
|
3059
|
+
|
|
3060
|
+
/**
|
|
3061
|
+
* Gets the next focus index based on the current index and focusable elements.
|
|
3062
|
+
* @param {number} currentIndex The current index of the focused element.
|
|
3063
|
+
* @param {Array<HTMLElement>} focusables The array of focusable elements.
|
|
3064
|
+
* @returns {number|null} The next focus index or null if not determined.
|
|
3065
|
+
*/
|
|
3066
|
+
_getNextFocusIndex(currentIndex, focusables, actives) {
|
|
3067
|
+
if (this.controlTabOrder) {
|
|
3068
|
+
// Calculate the new index based on the current index and tab direction
|
|
3069
|
+
let newFocusIndex =
|
|
3070
|
+
currentIndex + (this.tabDirection === "forward" ? 1 : -1);
|
|
3071
|
+
|
|
3072
|
+
// Wrap-around logic
|
|
3073
|
+
if (newFocusIndex < 0) newFocusIndex = focusables.length - 1;
|
|
3074
|
+
if (newFocusIndex >= focusables.length) newFocusIndex = 0;
|
|
3075
|
+
|
|
3076
|
+
// Early return with the new index
|
|
3077
|
+
return newFocusIndex;
|
|
3078
|
+
}
|
|
3079
|
+
|
|
3080
|
+
// Determine if we need to wrap
|
|
3081
|
+
const atFirst =
|
|
3082
|
+
actives.includes(focusables[0]) || actives.includes(this.container);
|
|
3083
|
+
const atLast = actives.includes(focusables[focusables.length - 1]);
|
|
3084
|
+
|
|
3085
|
+
// Only wrap if at the ends
|
|
3086
|
+
if (this.tabDirection === "backward" && atFirst) {
|
|
3087
|
+
return focusables.length - 1;
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3090
|
+
if (this.tabDirection === "forward" && atLast) {
|
|
3091
|
+
return 0;
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
// No wrap, so don't change focus, return early
|
|
3095
|
+
return null;
|
|
3096
|
+
}
|
|
3097
|
+
|
|
3098
|
+
/**
|
|
3099
|
+
* Handles the Tab key press event to manage focus within the container.
|
|
3100
|
+
* @param {KeyboardEvent} e The keyboard event triggered by the user.
|
|
3101
|
+
* @returns {void}
|
|
3102
|
+
*/
|
|
3103
|
+
_handleTabKey(e) {
|
|
3104
|
+
// Update the focusable elements
|
|
3105
|
+
const focusables = this._getFocusableElements();
|
|
3106
|
+
|
|
3107
|
+
// If there are no focusable elements, exit
|
|
3108
|
+
if (!focusables.length) return;
|
|
3109
|
+
|
|
3110
|
+
// Set the tab direction based on the key pressed
|
|
3111
|
+
this.tabDirection = e.shiftKey ? "backward" : "forward";
|
|
3112
|
+
|
|
3113
|
+
// Get the active elements that are currently focused
|
|
3114
|
+
const actives = this._getActiveElements();
|
|
3115
|
+
|
|
3116
|
+
// If we're at either end of the focusable elements, wrap around to the other end
|
|
3117
|
+
let focusIndex = focusables.findIndex((el) => actives.includes(el));
|
|
3118
|
+
|
|
3119
|
+
// Fallback if we have no focused element
|
|
3120
|
+
if (focusIndex === -1) focusIndex = 0;
|
|
3121
|
+
|
|
3122
|
+
// Get the next focus index based on the current focus index, tab direction, and controlTabOrder setting
|
|
3123
|
+
// Is null if no new focus index is determined
|
|
3124
|
+
const newFocusIndex = this._getNextFocusIndex(
|
|
3125
|
+
focusIndex,
|
|
3126
|
+
focusables,
|
|
3127
|
+
actives,
|
|
3128
|
+
);
|
|
3129
|
+
|
|
3130
|
+
// If we have a new focus index, set focus to that element
|
|
3131
|
+
if (newFocusIndex !== null) {
|
|
3132
|
+
e.preventDefault();
|
|
3133
|
+
focusables[newFocusIndex].focus();
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
|
|
3137
|
+
/**
|
|
3138
|
+
* Catches the keydown event
|
|
3139
|
+
* @param {KeyboardEvent} e The keyboard event triggered by user interaction.
|
|
3140
|
+
* @private
|
|
3141
|
+
*/
|
|
3142
|
+
_onKeydown = (e) => {
|
|
3143
|
+
// Handle tab
|
|
3144
|
+
if (e.key === "Tab") this._handleTabKey(e);
|
|
3145
|
+
};
|
|
3146
|
+
|
|
3147
|
+
/**
|
|
3148
|
+
* Retrieves all focusable elements within the container in DOM order, including those in shadow DOM and slots.
|
|
3149
|
+
* Returns a unique, ordered array of elements that can receive focus.
|
|
3150
|
+
*
|
|
3151
|
+
* @returns {Array<HTMLElement>} An array of focusable elements within the container.
|
|
3152
|
+
* @private
|
|
3153
|
+
*/
|
|
3154
|
+
_getFocusableElements() {
|
|
3155
|
+
// Use the imported utility function to get focusable elements
|
|
3156
|
+
const elements = getFocusableElements(this.container);
|
|
3157
|
+
|
|
3158
|
+
// Return the elements found
|
|
3159
|
+
return elements;
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3162
|
+
/**
|
|
3163
|
+
* Moves focus to the first focusable element within the container.
|
|
3164
|
+
* Useful for setting initial focus when activating the focus trap.
|
|
3165
|
+
*/
|
|
3166
|
+
focusFirstElement() {
|
|
3167
|
+
const focusables = this._getFocusableElements();
|
|
3168
|
+
if (focusables.length) focusables[0].focus();
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
/**
|
|
3172
|
+
* Moves focus to the last focusable element within the container.
|
|
3173
|
+
* Useful for setting focus when deactivating or cycling focus in reverse.
|
|
3174
|
+
*/
|
|
3175
|
+
focusLastElement() {
|
|
3176
|
+
const focusables = this._getFocusableElements();
|
|
3177
|
+
if (focusables.length) focusables[focusables.length - 1].focus();
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
/**
|
|
3181
|
+
* Removes event listeners and attributes added by the focus trap.
|
|
3182
|
+
* Call this method to clean up when the focus trap is no longer needed.
|
|
3183
|
+
*/
|
|
3184
|
+
disconnect() {
|
|
3185
|
+
if (this.container.hasAttribute("data-focus-trap-container")) {
|
|
3186
|
+
this.container.removeAttribute("data-focus-trap-container");
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
this.container.removeEventListener("keydown", this._onKeydown);
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3028
3193
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
3029
3194
|
// See LICENSE in the project root for license information.
|
|
3030
3195
|
|
|
@@ -3553,7 +3718,7 @@ class AuroDropdownBib extends i {
|
|
|
3553
3718
|
classes[`shape-${this.shape}`] = true;
|
|
3554
3719
|
|
|
3555
3720
|
return u$2`
|
|
3556
|
-
<dialog
|
|
3721
|
+
<dialog class="${e$4(classes)}" part="bibContainer" role="${o(this.dialogRole)}" aria-labelledby="${o(this.dialogLabel ? 'dialogLabel' : undefined)}">
|
|
3557
3722
|
${this.dialogLabel ? u$2`<span id="dialogLabel" class="util_displayHiddenVisually">${this.dialogLabel}</span>` : ''}
|
|
3558
3723
|
<slot></slot>
|
|
3559
3724
|
<span id="srAnnouncement" class="util_displayHiddenVisually" aria-live="polite" role="status"></span>
|
|
@@ -3804,7 +3969,7 @@ class AuroHelpText extends i {
|
|
|
3804
3969
|
}
|
|
3805
3970
|
}
|
|
3806
3971
|
|
|
3807
|
-
var formkitVersion = '
|
|
3972
|
+
var formkitVersion = '202607092329';
|
|
3808
3973
|
|
|
3809
3974
|
class AuroElement extends i {
|
|
3810
3975
|
static get properties() {
|
|
@@ -4558,10 +4723,7 @@ class AuroDropdown extends AuroElement {
|
|
|
4558
4723
|
}
|
|
4559
4724
|
|
|
4560
4725
|
|
|
4561
|
-
|
|
4562
|
-
// — restoring to the trigger would trap the user on this dropdown, forcing
|
|
4563
|
-
// an extra Tab to move on. Escape and outside-click still restore.
|
|
4564
|
-
if (!this.isPopoverVisible && eventType !== "focusloss") {
|
|
4726
|
+
if (!this.isPopoverVisible) {
|
|
4565
4727
|
// wait til the bib gets fully closed and rendered
|
|
4566
4728
|
setTimeout(() => {
|
|
4567
4729
|
// Skip if the bib re-opened, or if focus moved intentionally outside the dropdown (not to body).
|
|
@@ -4791,16 +4953,15 @@ class AuroDropdown extends AuroElement {
|
|
|
4791
4953
|
}
|
|
4792
4954
|
});
|
|
4793
4955
|
} else {
|
|
4794
|
-
// Normal desktop
|
|
4795
|
-
//
|
|
4796
|
-
//
|
|
4797
|
-
//
|
|
4798
|
-
//
|
|
4799
|
-
|
|
4956
|
+
// Normal desktop: use FocusTrap on the bib element.
|
|
4957
|
+
// Defer focusFirstElement to the next frame because the popover
|
|
4958
|
+
// is positioned asynchronously by Floating UI — calling focus()
|
|
4959
|
+
// synchronously here would target elements with zero dimensions
|
|
4960
|
+
// and the focus call would be silently ignored.
|
|
4961
|
+
this.focusTrap = new FocusTrap(this.bibContent);
|
|
4800
4962
|
requestAnimationFrame(() => {
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
focusables[0].focus();
|
|
4963
|
+
if (this.focusTrap) {
|
|
4964
|
+
this.focusTrap.focusFirstElement();
|
|
4804
4965
|
}
|
|
4805
4966
|
});
|
|
4806
4967
|
}
|