@aurodesignsystem-dev/auro-formkit 0.0.0-pr1552.0 → 0.0.0-pr1553.1
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 +46 -207
- package/components/combobox/demo/getting-started.min.js +46 -207
- package/components/combobox/demo/index.min.js +46 -207
- package/components/combobox/dist/index.js +46 -207
- package/components/combobox/dist/registered.js +46 -207
- package/components/counter/demo/customize.min.js +59 -222
- package/components/counter/demo/index.min.js +59 -222
- package/components/counter/dist/auro-counter.d.ts +0 -8
- package/components/counter/dist/index.js +59 -222
- package/components/counter/dist/registered.js +59 -222
- package/components/datepicker/demo/customize.min.js +46 -207
- package/components/datepicker/demo/index.min.js +46 -207
- package/components/datepicker/dist/index.js +46 -207
- package/components/datepicker/dist/registered.js +46 -207
- package/components/dropdown/demo/customize.min.js +44 -205
- package/components/dropdown/demo/getting-started.min.js +44 -205
- package/components/dropdown/demo/index.min.js +44 -205
- package/components/dropdown/dist/index.js +44 -205
- package/components/dropdown/dist/registered.js +44 -205
- package/components/form/demo/customize.min.js +199 -845
- package/components/form/demo/getting-started.min.js +199 -845
- package/components/form/demo/index.min.js +199 -845
- package/components/form/demo/registerDemoDeps.min.js +199 -845
- 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 +45 -206
- package/components/select/demo/getting-started.min.js +45 -206
- package/components/select/demo/index.min.js +45 -206
- package/components/select/dist/index.js +45 -206
- package/components/select/dist/registered.js +45 -206
- package/custom-elements.json +1499 -1514
- package/package.json +2 -2
|
@@ -2295,12 +2295,40 @@ 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
|
+
|
|
2298
2323
|
// if fullscreen bib is in fullscreen mode, do not close
|
|
2299
2324
|
if (element.bib.hasAttribute("isfullscreen")) {
|
|
2300
2325
|
return;
|
|
2301
2326
|
}
|
|
2302
2327
|
|
|
2303
|
-
|
|
2328
|
+
// eventType "focusloss" distinguishes a Tab/click-driven close from an
|
|
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");
|
|
2304
2332
|
}
|
|
2305
2333
|
|
|
2306
2334
|
setupHideHandlers() {
|
|
@@ -2970,199 +2998,6 @@ function getFocusableElements(container) {
|
|
|
2970
2998
|
return tabIndexedUniqueElements;
|
|
2971
2999
|
}
|
|
2972
3000
|
|
|
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
|
-
|
|
3166
3001
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
3167
3002
|
// See LICENSE in the project root for license information.
|
|
3168
3003
|
|
|
@@ -3691,7 +3526,7 @@ class AuroDropdownBib extends i {
|
|
|
3691
3526
|
classes[`shape-${this.shape}`] = true;
|
|
3692
3527
|
|
|
3693
3528
|
return u$2`
|
|
3694
|
-
<dialog class="${e$4(classes)}" part="bibContainer" role="${o(this.dialogRole)}" aria-labelledby="${o(this.dialogLabel ? 'dialogLabel' : undefined)}">
|
|
3529
|
+
<dialog tabindex="-1" class="${e$4(classes)}" part="bibContainer" role="${o(this.dialogRole)}" aria-labelledby="${o(this.dialogLabel ? 'dialogLabel' : undefined)}">
|
|
3695
3530
|
${this.dialogLabel ? u$2`<span id="dialogLabel" class="util_displayHiddenVisually">${this.dialogLabel}</span>` : ''}
|
|
3696
3531
|
<slot></slot>
|
|
3697
3532
|
<span id="srAnnouncement" class="util_displayHiddenVisually" aria-live="polite" role="status"></span>
|
|
@@ -3942,7 +3777,7 @@ class AuroHelpText extends i {
|
|
|
3942
3777
|
}
|
|
3943
3778
|
}
|
|
3944
3779
|
|
|
3945
|
-
var formkitVersion = '
|
|
3780
|
+
var formkitVersion = '202607102138';
|
|
3946
3781
|
|
|
3947
3782
|
class AuroElement extends i {
|
|
3948
3783
|
static get properties() {
|
|
@@ -4696,7 +4531,10 @@ class AuroDropdown extends AuroElement {
|
|
|
4696
4531
|
}
|
|
4697
4532
|
|
|
4698
4533
|
|
|
4699
|
-
|
|
4534
|
+
// On Tab-driven close (eventType "focusloss"), let focus advance naturally
|
|
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") {
|
|
4700
4538
|
// wait til the bib gets fully closed and rendered
|
|
4701
4539
|
setTimeout(() => {
|
|
4702
4540
|
// Skip if the bib re-opened, or if focus moved intentionally outside the dropdown (not to body).
|
|
@@ -4926,15 +4764,16 @@ class AuroDropdown extends AuroElement {
|
|
|
4926
4764
|
}
|
|
4927
4765
|
});
|
|
4928
4766
|
} else {
|
|
4929
|
-
// Normal desktop:
|
|
4930
|
-
//
|
|
4931
|
-
//
|
|
4932
|
-
//
|
|
4933
|
-
//
|
|
4934
|
-
|
|
4767
|
+
// Normal desktop (non-modal): move initial focus into the bib but
|
|
4768
|
+
// don't trap Tab. Tab should exit the bib and let the floater's
|
|
4769
|
+
// handleFocusLoss close it, matching native <select>/<details>
|
|
4770
|
+
// behavior. Deferred one frame because Floating UI positions the
|
|
4771
|
+
// popover asynchronously — a synchronous focus() would target
|
|
4772
|
+
// zero-dimension elements and be silently ignored.
|
|
4935
4773
|
requestAnimationFrame(() => {
|
|
4936
|
-
|
|
4937
|
-
|
|
4774
|
+
const focusables = getFocusableElements(this.bibContent);
|
|
4775
|
+
if (focusables.length) {
|
|
4776
|
+
focusables[0].focus();
|
|
4938
4777
|
}
|
|
4939
4778
|
});
|
|
4940
4779
|
}
|
|
@@ -2322,12 +2322,40 @@ 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
|
+
|
|
2325
2350
|
// if fullscreen bib is in fullscreen mode, do not close
|
|
2326
2351
|
if (element.bib.hasAttribute("isfullscreen")) {
|
|
2327
2352
|
return;
|
|
2328
2353
|
}
|
|
2329
2354
|
|
|
2330
|
-
|
|
2355
|
+
// eventType "focusloss" distinguishes a Tab/click-driven close from an
|
|
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");
|
|
2331
2359
|
}
|
|
2332
2360
|
|
|
2333
2361
|
setupHideHandlers() {
|
|
@@ -2997,199 +3025,6 @@ function getFocusableElements(container) {
|
|
|
2997
3025
|
return tabIndexedUniqueElements;
|
|
2998
3026
|
}
|
|
2999
3027
|
|
|
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
|
-
|
|
3193
3028
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
3194
3029
|
// See LICENSE in the project root for license information.
|
|
3195
3030
|
|
|
@@ -3718,7 +3553,7 @@ class AuroDropdownBib extends i {
|
|
|
3718
3553
|
classes[`shape-${this.shape}`] = true;
|
|
3719
3554
|
|
|
3720
3555
|
return u$2`
|
|
3721
|
-
<dialog class="${e$4(classes)}" part="bibContainer" role="${o(this.dialogRole)}" aria-labelledby="${o(this.dialogLabel ? 'dialogLabel' : undefined)}">
|
|
3556
|
+
<dialog tabindex="-1" class="${e$4(classes)}" part="bibContainer" role="${o(this.dialogRole)}" aria-labelledby="${o(this.dialogLabel ? 'dialogLabel' : undefined)}">
|
|
3722
3557
|
${this.dialogLabel ? u$2`<span id="dialogLabel" class="util_displayHiddenVisually">${this.dialogLabel}</span>` : ''}
|
|
3723
3558
|
<slot></slot>
|
|
3724
3559
|
<span id="srAnnouncement" class="util_displayHiddenVisually" aria-live="polite" role="status"></span>
|
|
@@ -3969,7 +3804,7 @@ class AuroHelpText extends i {
|
|
|
3969
3804
|
}
|
|
3970
3805
|
}
|
|
3971
3806
|
|
|
3972
|
-
var formkitVersion = '
|
|
3807
|
+
var formkitVersion = '202607102138';
|
|
3973
3808
|
|
|
3974
3809
|
class AuroElement extends i {
|
|
3975
3810
|
static get properties() {
|
|
@@ -4723,7 +4558,10 @@ class AuroDropdown extends AuroElement {
|
|
|
4723
4558
|
}
|
|
4724
4559
|
|
|
4725
4560
|
|
|
4726
|
-
|
|
4561
|
+
// On Tab-driven close (eventType "focusloss"), let focus advance naturally
|
|
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") {
|
|
4727
4565
|
// wait til the bib gets fully closed and rendered
|
|
4728
4566
|
setTimeout(() => {
|
|
4729
4567
|
// Skip if the bib re-opened, or if focus moved intentionally outside the dropdown (not to body).
|
|
@@ -4953,15 +4791,16 @@ class AuroDropdown extends AuroElement {
|
|
|
4953
4791
|
}
|
|
4954
4792
|
});
|
|
4955
4793
|
} else {
|
|
4956
|
-
// Normal desktop:
|
|
4957
|
-
//
|
|
4958
|
-
//
|
|
4959
|
-
//
|
|
4960
|
-
//
|
|
4961
|
-
|
|
4794
|
+
// Normal desktop (non-modal): move initial focus into the bib but
|
|
4795
|
+
// don't trap Tab. Tab should exit the bib and let the floater's
|
|
4796
|
+
// handleFocusLoss close it, matching native <select>/<details>
|
|
4797
|
+
// behavior. Deferred one frame because Floating UI positions the
|
|
4798
|
+
// popover asynchronously — a synchronous focus() would target
|
|
4799
|
+
// zero-dimension elements and be silently ignored.
|
|
4962
4800
|
requestAnimationFrame(() => {
|
|
4963
|
-
|
|
4964
|
-
|
|
4801
|
+
const focusables = getFocusableElements(this.bibContent);
|
|
4802
|
+
if (focusables.length) {
|
|
4803
|
+
focusables[0].focus();
|
|
4965
4804
|
}
|
|
4966
4805
|
});
|
|
4967
4806
|
}
|