@aurodesignsystem-dev/auro-formkit 0.0.0-pr1425.0 → 0.0.0-pr1428.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/api.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/api.min.js +276 -165
- package/components/combobox/demo/index.min.js +276 -165
- package/components/combobox/dist/index.js +276 -165
- package/components/combobox/dist/registered.js +276 -165
- package/components/counter/demo/api.min.js +275 -164
- package/components/counter/demo/index.min.js +275 -164
- package/components/counter/dist/index.js +275 -164
- package/components/counter/dist/registered.js +275 -164
- package/components/datepicker/demo/api.min.js +276 -165
- package/components/datepicker/demo/index.min.js +276 -165
- package/components/datepicker/dist/index.js +276 -165
- package/components/datepicker/dist/registered.js +276 -165
- package/components/dropdown/demo/api.min.js +275 -164
- package/components/dropdown/demo/index.min.js +275 -164
- package/components/dropdown/dist/index.js +275 -164
- package/components/dropdown/dist/registered.js +275 -164
- package/components/form/demo/api.min.js +1105 -661
- package/components/form/demo/index.min.js +1105 -661
- package/components/input/demo/api.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/api.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/api.min.js +275 -164
- package/components/select/demo/index.min.js +275 -164
- package/components/select/dist/index.js +275 -164
- package/components/select/dist/registered.js +275 -164
- package/custom-elements.json +244 -244
- package/package.json +2 -2
|
@@ -1964,11 +1964,19 @@ class AuroFloatingUI {
|
|
|
1964
1964
|
* This ensures that the bib content has the same dimensions as the sizer element.
|
|
1965
1965
|
*/
|
|
1966
1966
|
mirrorSize() {
|
|
1967
|
+
const element = this.element;
|
|
1968
|
+
if (!element) {
|
|
1969
|
+
return;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1967
1972
|
// mirror the boxsize from bibSizer
|
|
1968
|
-
if (
|
|
1969
|
-
const sizerStyle = window.getComputedStyle(
|
|
1970
|
-
const bibContent =
|
|
1971
|
-
|
|
1973
|
+
if (element.bibSizer && element.matchWidth && element.bib?.shadowRoot) {
|
|
1974
|
+
const sizerStyle = window.getComputedStyle(element.bibSizer);
|
|
1975
|
+
const bibContent = element.bib.shadowRoot.querySelector(".container");
|
|
1976
|
+
if (!bibContent) {
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1972
1980
|
if (sizerStyle.width !== "0px") {
|
|
1973
1981
|
bibContent.style.width = sizerStyle.width;
|
|
1974
1982
|
}
|
|
@@ -1990,9 +1998,14 @@ class AuroFloatingUI {
|
|
|
1990
1998
|
* @returns {String} The positioning strategy, one of 'fullscreen', 'floating', 'cover'.
|
|
1991
1999
|
*/
|
|
1992
2000
|
getPositioningStrategy() {
|
|
2001
|
+
const element = this.element;
|
|
2002
|
+
if (!element) {
|
|
2003
|
+
return "floating";
|
|
2004
|
+
}
|
|
2005
|
+
|
|
1993
2006
|
const breakpoint =
|
|
1994
|
-
|
|
1995
|
-
|
|
2007
|
+
element.bib?.mobileFullscreenBreakpoint ||
|
|
2008
|
+
element.floaterConfig?.fullscreenBreakpoint;
|
|
1996
2009
|
switch (this.behavior) {
|
|
1997
2010
|
case "tooltip":
|
|
1998
2011
|
return "floating";
|
|
@@ -2003,9 +2016,9 @@ class AuroFloatingUI {
|
|
|
2003
2016
|
`(max-width: ${breakpoint})`,
|
|
2004
2017
|
).matches;
|
|
2005
2018
|
|
|
2006
|
-
|
|
2019
|
+
element.expanded = smallerThanBreakpoint;
|
|
2007
2020
|
}
|
|
2008
|
-
if (
|
|
2021
|
+
if (element.nested) {
|
|
2009
2022
|
return "cover";
|
|
2010
2023
|
}
|
|
2011
2024
|
return "fullscreen";
|
|
@@ -2035,42 +2048,65 @@ class AuroFloatingUI {
|
|
|
2035
2048
|
* and applies the calculated position to the bib's style.
|
|
2036
2049
|
*/
|
|
2037
2050
|
position() {
|
|
2051
|
+
const element = this.element;
|
|
2052
|
+
if (!element) {
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2038
2056
|
const strategy = this.getPositioningStrategy();
|
|
2039
2057
|
this.configureBibStrategy(strategy);
|
|
2040
2058
|
|
|
2041
2059
|
if (strategy === "floating") {
|
|
2060
|
+
if (!element.trigger || !element.bib) {
|
|
2061
|
+
return;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2042
2064
|
this.mirrorSize();
|
|
2043
2065
|
// Define the middlware for the floater configuration
|
|
2044
2066
|
const middleware = [
|
|
2045
|
-
offset(
|
|
2046
|
-
...(
|
|
2047
|
-
...(
|
|
2048
|
-
...(
|
|
2067
|
+
offset(element.floaterConfig?.offset || 0),
|
|
2068
|
+
...(element.floaterConfig?.shift ? [shift()] : []), // Add shift middleware if shift is enabled.
|
|
2069
|
+
...(element.floaterConfig?.flip ? [flip()] : []), // Add flip middleware if flip is enabled.
|
|
2070
|
+
...(element.floaterConfig?.autoPlacement ? [autoPlacement()] : []), // Add autoPlacement middleware if autoPlacement is enabled.
|
|
2049
2071
|
];
|
|
2050
2072
|
|
|
2051
2073
|
// Compute the position of the bib
|
|
2052
|
-
computePosition(
|
|
2053
|
-
strategy:
|
|
2054
|
-
placement:
|
|
2074
|
+
computePosition(element.trigger, element.bib, {
|
|
2075
|
+
strategy: element.floaterConfig?.strategy || "fixed",
|
|
2076
|
+
placement: element.floaterConfig?.placement,
|
|
2055
2077
|
middleware: middleware || [],
|
|
2056
2078
|
}).then(({ x, y }) => {
|
|
2057
2079
|
// eslint-disable-line id-length
|
|
2058
|
-
|
|
2080
|
+
const currentElement = this.element;
|
|
2081
|
+
if (!currentElement?.bib) {
|
|
2082
|
+
return;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
Object.assign(currentElement.bib.style, {
|
|
2059
2086
|
left: `${x}px`,
|
|
2060
2087
|
top: `${y}px`,
|
|
2061
2088
|
});
|
|
2062
2089
|
});
|
|
2063
2090
|
} else if (strategy === "cover") {
|
|
2091
|
+
if (!element.parentNode || !element.bib) {
|
|
2092
|
+
return;
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2064
2095
|
// Compute the position of the bib
|
|
2065
|
-
computePosition(
|
|
2096
|
+
computePosition(element.parentNode, element.bib, {
|
|
2066
2097
|
placement: "bottom-start",
|
|
2067
2098
|
}).then(({ x, y }) => {
|
|
2068
2099
|
// eslint-disable-line id-length
|
|
2069
|
-
|
|
2100
|
+
const currentElement = this.element;
|
|
2101
|
+
if (!currentElement?.bib || !currentElement.parentNode) {
|
|
2102
|
+
return;
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
Object.assign(currentElement.bib.style, {
|
|
2070
2106
|
left: `${x}px`,
|
|
2071
|
-
top: `${y -
|
|
2072
|
-
width: `${
|
|
2073
|
-
height: `${
|
|
2107
|
+
top: `${y - currentElement.parentNode.offsetHeight}px`,
|
|
2108
|
+
width: `${currentElement.parentNode.offsetWidth}px`,
|
|
2109
|
+
height: `${currentElement.parentNode.offsetHeight}px`,
|
|
2074
2110
|
});
|
|
2075
2111
|
});
|
|
2076
2112
|
}
|
|
@@ -2082,11 +2118,17 @@ class AuroFloatingUI {
|
|
|
2082
2118
|
* @param {Boolean} lock - If true, locks the body's scrolling functionlity; otherwise, unlock.
|
|
2083
2119
|
*/
|
|
2084
2120
|
lockScroll(lock = true) {
|
|
2121
|
+
const element = this.element;
|
|
2122
|
+
|
|
2085
2123
|
if (lock) {
|
|
2124
|
+
if (!element?.bib) {
|
|
2125
|
+
return;
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2086
2128
|
document.body.style.overflow = "hidden"; // hide body's scrollbar
|
|
2087
2129
|
|
|
2088
2130
|
// Move `bib` by the amount the viewport is shifted to stay aligned in fullscreen.
|
|
2089
|
-
|
|
2131
|
+
element.bib.style.transform = `translateY(${window?.visualViewport?.offsetTop}px)`;
|
|
2090
2132
|
} else {
|
|
2091
2133
|
document.body.style.overflow = "";
|
|
2092
2134
|
}
|
|
@@ -2102,20 +2144,24 @@ class AuroFloatingUI {
|
|
|
2102
2144
|
* @param {string} strategy - The positioning strategy ('fullscreen' or 'floating').
|
|
2103
2145
|
*/
|
|
2104
2146
|
configureBibStrategy(value) {
|
|
2147
|
+
const element = this.element;
|
|
2148
|
+
if (!element?.bib) {
|
|
2149
|
+
return;
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2105
2152
|
if (value === "fullscreen") {
|
|
2106
|
-
|
|
2153
|
+
element.isBibFullscreen = true;
|
|
2107
2154
|
// reset the prev position
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2155
|
+
element.bib.setAttribute("isfullscreen", "");
|
|
2156
|
+
element.bib.style.position = "fixed";
|
|
2157
|
+
element.bib.style.top = "0px";
|
|
2158
|
+
element.bib.style.left = "0px";
|
|
2159
|
+
element.bib.style.width = "";
|
|
2160
|
+
element.bib.style.height = "";
|
|
2161
|
+
element.style.contain = "";
|
|
2115
2162
|
|
|
2116
2163
|
// reset the size that was mirroring `size` css-part
|
|
2117
|
-
const bibContent =
|
|
2118
|
-
this.element.bib.shadowRoot.querySelector(".container");
|
|
2164
|
+
const bibContent = element.bib.shadowRoot?.querySelector(".container");
|
|
2119
2165
|
if (bibContent) {
|
|
2120
2166
|
bibContent.style.width = "";
|
|
2121
2167
|
bibContent.style.height = "";
|
|
@@ -2130,14 +2176,14 @@ class AuroFloatingUI {
|
|
|
2130
2176
|
}, 0);
|
|
2131
2177
|
}
|
|
2132
2178
|
|
|
2133
|
-
if (
|
|
2179
|
+
if (element.isPopoverVisible) {
|
|
2134
2180
|
this.lockScroll(true);
|
|
2135
2181
|
}
|
|
2136
2182
|
} else {
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2183
|
+
element.bib.style.position = "";
|
|
2184
|
+
element.bib.removeAttribute("isfullscreen");
|
|
2185
|
+
element.isBibFullscreen = false;
|
|
2186
|
+
element.style.contain = "layout";
|
|
2141
2187
|
}
|
|
2142
2188
|
|
|
2143
2189
|
const isChanged = this.strategy && this.strategy !== value;
|
|
@@ -2155,16 +2201,21 @@ class AuroFloatingUI {
|
|
|
2155
2201
|
},
|
|
2156
2202
|
);
|
|
2157
2203
|
|
|
2158
|
-
|
|
2204
|
+
element.dispatchEvent(event);
|
|
2159
2205
|
}
|
|
2160
2206
|
}
|
|
2161
2207
|
|
|
2162
2208
|
updateState() {
|
|
2163
|
-
const
|
|
2209
|
+
const element = this.element;
|
|
2210
|
+
if (!element) {
|
|
2211
|
+
return;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
const isVisible = element.isPopoverVisible;
|
|
2164
2215
|
if (!isVisible) {
|
|
2165
2216
|
this.cleanupHideHandlers();
|
|
2166
2217
|
try {
|
|
2167
|
-
|
|
2218
|
+
element.cleanup?.();
|
|
2168
2219
|
} catch (error) {
|
|
2169
2220
|
// Do nothing
|
|
2170
2221
|
}
|
|
@@ -2180,28 +2231,30 @@ class AuroFloatingUI {
|
|
|
2180
2231
|
* If not, and if the bib isn't in fullscreen mode with focus lost, it hides the bib.
|
|
2181
2232
|
*/
|
|
2182
2233
|
handleFocusLoss() {
|
|
2234
|
+
const element = this.element;
|
|
2235
|
+
if (!element?.bib) {
|
|
2236
|
+
return;
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2183
2239
|
// if mouse is being pressed, skip and let click event to handle the action
|
|
2184
2240
|
if (AuroFloatingUI.isMousePressed) {
|
|
2185
2241
|
return;
|
|
2186
2242
|
}
|
|
2187
2243
|
|
|
2188
2244
|
if (
|
|
2189
|
-
|
|
2190
|
-
|
|
2245
|
+
element.noHideOnThisFocusLoss ||
|
|
2246
|
+
element.hasAttribute("noHideOnThisFocusLoss")
|
|
2191
2247
|
) {
|
|
2192
2248
|
return;
|
|
2193
2249
|
}
|
|
2194
2250
|
|
|
2195
2251
|
// if focus is still inside of trigger or bib, do not close
|
|
2196
|
-
if (
|
|
2197
|
-
this.element.matches(":focus") ||
|
|
2198
|
-
this.element.matches(":focus-within")
|
|
2199
|
-
) {
|
|
2252
|
+
if (element.matches(":focus") || element.matches(":focus-within")) {
|
|
2200
2253
|
return;
|
|
2201
2254
|
}
|
|
2202
2255
|
|
|
2203
2256
|
// if fullscreen bib is in fullscreen mode, do not close
|
|
2204
|
-
if (
|
|
2257
|
+
if (element.bib.hasAttribute("isfullscreen")) {
|
|
2205
2258
|
return;
|
|
2206
2259
|
}
|
|
2207
2260
|
|
|
@@ -2209,23 +2262,33 @@ class AuroFloatingUI {
|
|
|
2209
2262
|
}
|
|
2210
2263
|
|
|
2211
2264
|
setupHideHandlers() {
|
|
2265
|
+
const element = this.element;
|
|
2266
|
+
if (!element) {
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2212
2270
|
// Define handlers & store references
|
|
2213
2271
|
this.focusHandler = () => this.handleFocusLoss();
|
|
2214
2272
|
|
|
2215
2273
|
this.clickHandler = (evt) => {
|
|
2274
|
+
const element = this.element;
|
|
2275
|
+
if (!element?.bib) {
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2216
2279
|
// When the bib is fullscreen (modal dialog), don't close on outside
|
|
2217
2280
|
// clicks. VoiceOver's synthetic click events inside a top-layer modal
|
|
2218
2281
|
// <dialog> may not include the bib in composedPath(), causing false
|
|
2219
2282
|
// positives. This mirrors the fullscreen guard in handleFocusLoss().
|
|
2220
|
-
if (
|
|
2283
|
+
if (element.bib.hasAttribute("isfullscreen")) {
|
|
2221
2284
|
return;
|
|
2222
2285
|
}
|
|
2223
2286
|
|
|
2224
2287
|
if (
|
|
2225
|
-
(!evt.composedPath().includes(
|
|
2226
|
-
!evt.composedPath().includes(
|
|
2227
|
-
(
|
|
2228
|
-
evt.composedPath().includes(
|
|
2288
|
+
(!evt.composedPath().includes(element.trigger) &&
|
|
2289
|
+
!evt.composedPath().includes(element.bib)) ||
|
|
2290
|
+
(element.bib.backdrop &&
|
|
2291
|
+
evt.composedPath().includes(element.bib.backdrop))
|
|
2229
2292
|
) {
|
|
2230
2293
|
const existedVisibleFloatingUI =
|
|
2231
2294
|
document.expandedAuroFormkitDropdown || document.expandedAuroFloater;
|
|
@@ -2246,7 +2309,12 @@ class AuroFloatingUI {
|
|
|
2246
2309
|
|
|
2247
2310
|
// ESC key handler
|
|
2248
2311
|
this.keyDownHandler = (evt) => {
|
|
2249
|
-
|
|
2312
|
+
const element = this.element;
|
|
2313
|
+
if (!element) {
|
|
2314
|
+
return;
|
|
2315
|
+
}
|
|
2316
|
+
|
|
2317
|
+
if (evt.key === "Escape" && element.isPopoverVisible) {
|
|
2250
2318
|
const existedVisibleFloatingUI =
|
|
2251
2319
|
document.expandedAuroFormkitDropdown || document.expandedAuroFloater;
|
|
2252
2320
|
if (
|
|
@@ -2303,6 +2371,10 @@ class AuroFloatingUI {
|
|
|
2303
2371
|
}
|
|
2304
2372
|
|
|
2305
2373
|
updateCurrentExpandedDropdown() {
|
|
2374
|
+
if (!this.element) {
|
|
2375
|
+
return;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2306
2378
|
// Close any other dropdown that is already open
|
|
2307
2379
|
const existedVisibleFloatingUI =
|
|
2308
2380
|
document.expandedAuroFormkitDropdown || document.expandedAuroFloater;
|
|
@@ -2319,25 +2391,34 @@ class AuroFloatingUI {
|
|
|
2319
2391
|
}
|
|
2320
2392
|
|
|
2321
2393
|
showBib() {
|
|
2322
|
-
|
|
2394
|
+
const element = this.element;
|
|
2395
|
+
if (!element) {
|
|
2396
|
+
return;
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
if (!element.bib || (!element.trigger && !element.parentNode)) {
|
|
2400
|
+
return;
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
if (!element.disabled && !this.showing) {
|
|
2323
2404
|
this.updateCurrentExpandedDropdown();
|
|
2324
|
-
|
|
2405
|
+
element.triggerChevron?.setAttribute("data-expanded", true);
|
|
2325
2406
|
|
|
2326
2407
|
// prevent double showing: isPopovervisible gets first and showBib gets called later
|
|
2327
2408
|
if (!this.showing) {
|
|
2328
|
-
if (!
|
|
2409
|
+
if (!element.modal) {
|
|
2329
2410
|
this.setupHideHandlers();
|
|
2330
2411
|
}
|
|
2331
2412
|
this.showing = true;
|
|
2332
|
-
|
|
2413
|
+
element.isPopoverVisible = true;
|
|
2333
2414
|
this.position();
|
|
2334
2415
|
this.dispatchEventDropdownToggle();
|
|
2335
2416
|
}
|
|
2336
2417
|
|
|
2337
2418
|
// Setup auto update to handle resize and scroll
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2419
|
+
element.cleanup = autoUpdate(
|
|
2420
|
+
element.trigger || element.parentNode,
|
|
2421
|
+
element.bib,
|
|
2341
2422
|
() => {
|
|
2342
2423
|
this.position();
|
|
2343
2424
|
},
|
|
@@ -2350,22 +2431,27 @@ class AuroFloatingUI {
|
|
|
2350
2431
|
* @param {String} eventType - The event type that triggered the hiding action.
|
|
2351
2432
|
*/
|
|
2352
2433
|
hideBib(eventType = "unknown") {
|
|
2353
|
-
|
|
2434
|
+
const element = this.element;
|
|
2435
|
+
if (!element) {
|
|
2436
|
+
return;
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
if (element.disabled) {
|
|
2354
2440
|
return;
|
|
2355
2441
|
}
|
|
2356
2442
|
|
|
2357
2443
|
// noToggle dropdowns should not close when the trigger is clicked (the
|
|
2358
2444
|
// "toggle" behavior), but they CAN still close via other interactions like
|
|
2359
2445
|
// Escape key or focus loss.
|
|
2360
|
-
if (
|
|
2446
|
+
if (element.noToggle && eventType === "click") {
|
|
2361
2447
|
return;
|
|
2362
2448
|
}
|
|
2363
2449
|
|
|
2364
2450
|
this.lockScroll(false);
|
|
2365
|
-
|
|
2451
|
+
element.triggerChevron?.removeAttribute("data-expanded");
|
|
2366
2452
|
|
|
2367
|
-
if (
|
|
2368
|
-
|
|
2453
|
+
if (element.isPopoverVisible) {
|
|
2454
|
+
element.isPopoverVisible = false;
|
|
2369
2455
|
}
|
|
2370
2456
|
if (this.showing) {
|
|
2371
2457
|
this.cleanupHideHandlers();
|
|
@@ -2385,6 +2471,11 @@ class AuroFloatingUI {
|
|
|
2385
2471
|
* @param {String} eventType - The event type that triggered the toggle action.
|
|
2386
2472
|
*/
|
|
2387
2473
|
dispatchEventDropdownToggle(eventType) {
|
|
2474
|
+
const element = this.element;
|
|
2475
|
+
if (!element) {
|
|
2476
|
+
return;
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2388
2479
|
const event = new CustomEvent(
|
|
2389
2480
|
this.eventPrefix ? `${this.eventPrefix}-toggled` : "toggled",
|
|
2390
2481
|
{
|
|
@@ -2396,11 +2487,16 @@ class AuroFloatingUI {
|
|
|
2396
2487
|
},
|
|
2397
2488
|
);
|
|
2398
2489
|
|
|
2399
|
-
|
|
2490
|
+
element.dispatchEvent(event);
|
|
2400
2491
|
}
|
|
2401
2492
|
|
|
2402
2493
|
handleClick() {
|
|
2403
|
-
|
|
2494
|
+
const element = this.element;
|
|
2495
|
+
if (!element) {
|
|
2496
|
+
return;
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
if (element.isPopoverVisible) {
|
|
2404
2500
|
this.hideBib("click");
|
|
2405
2501
|
} else {
|
|
2406
2502
|
this.showBib();
|
|
@@ -2411,63 +2507,66 @@ class AuroFloatingUI {
|
|
|
2411
2507
|
{
|
|
2412
2508
|
composed: true,
|
|
2413
2509
|
detail: {
|
|
2414
|
-
expanded:
|
|
2510
|
+
expanded: element.isPopoverVisible,
|
|
2415
2511
|
},
|
|
2416
2512
|
},
|
|
2417
2513
|
);
|
|
2418
2514
|
|
|
2419
|
-
|
|
2515
|
+
element.dispatchEvent(event);
|
|
2420
2516
|
}
|
|
2421
2517
|
|
|
2422
2518
|
handleEvent(event) {
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
case "mouseenter":
|
|
2440
|
-
if (this.element.hoverToggle) {
|
|
2441
|
-
this.showBib();
|
|
2442
|
-
}
|
|
2443
|
-
break;
|
|
2444
|
-
case "mouseleave":
|
|
2445
|
-
if (this.element.hoverToggle) {
|
|
2446
|
-
this.hideBib("mouseleave");
|
|
2447
|
-
}
|
|
2448
|
-
break;
|
|
2449
|
-
case "focus":
|
|
2450
|
-
if (this.element.focusShow) {
|
|
2451
|
-
/*
|
|
2452
|
-
This needs to better handle clicking that gives focus -
|
|
2453
|
-
currently it shows and then immediately hides the bib
|
|
2454
|
-
*/
|
|
2455
|
-
this.showBib();
|
|
2456
|
-
}
|
|
2457
|
-
break;
|
|
2458
|
-
case "blur":
|
|
2459
|
-
// send this task 100ms later queue to
|
|
2460
|
-
// wait a frame in case focus moves within the floating element/bib
|
|
2461
|
-
setTimeout(() => this.handleFocusLoss(), 0);
|
|
2462
|
-
break;
|
|
2463
|
-
case "click":
|
|
2464
|
-
if (document.activeElement === document.body) {
|
|
2465
|
-
event.currentTarget.focus();
|
|
2466
|
-
}
|
|
2519
|
+
const element = this.element;
|
|
2520
|
+
if (!element || element.disableEventShow) {
|
|
2521
|
+
return;
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
switch (event.type) {
|
|
2525
|
+
case "keydown": {
|
|
2526
|
+
// Support both Enter and Space keys for accessibility
|
|
2527
|
+
// Space is included as it's expected behavior for interactive elements
|
|
2528
|
+
|
|
2529
|
+
const origin = event.composedPath()[0];
|
|
2530
|
+
if (
|
|
2531
|
+
event.key === "Enter" ||
|
|
2532
|
+
(event.key === " " && (!origin || origin.tagName !== "INPUT"))
|
|
2533
|
+
) {
|
|
2534
|
+
event.preventDefault();
|
|
2467
2535
|
this.handleClick();
|
|
2468
|
-
|
|
2469
|
-
|
|
2536
|
+
}
|
|
2537
|
+
break;
|
|
2470
2538
|
}
|
|
2539
|
+
case "mouseenter":
|
|
2540
|
+
if (element.hoverToggle) {
|
|
2541
|
+
this.showBib();
|
|
2542
|
+
}
|
|
2543
|
+
break;
|
|
2544
|
+
case "mouseleave":
|
|
2545
|
+
if (element.hoverToggle) {
|
|
2546
|
+
this.hideBib("mouseleave");
|
|
2547
|
+
}
|
|
2548
|
+
break;
|
|
2549
|
+
case "focus":
|
|
2550
|
+
if (element.focusShow) {
|
|
2551
|
+
/*
|
|
2552
|
+
This needs to better handle clicking that gives focus -
|
|
2553
|
+
currently it shows and then immediately hides the bib
|
|
2554
|
+
*/
|
|
2555
|
+
this.showBib();
|
|
2556
|
+
}
|
|
2557
|
+
break;
|
|
2558
|
+
case "blur":
|
|
2559
|
+
// send this task 100ms later queue to
|
|
2560
|
+
// wait a frame in case focus moves within the floating element/bib
|
|
2561
|
+
setTimeout(() => this.handleFocusLoss(), 0);
|
|
2562
|
+
break;
|
|
2563
|
+
case "click":
|
|
2564
|
+
if (document.activeElement === document.body) {
|
|
2565
|
+
event.currentTarget.focus();
|
|
2566
|
+
}
|
|
2567
|
+
this.handleClick();
|
|
2568
|
+
break;
|
|
2569
|
+
// Do nothing
|
|
2471
2570
|
}
|
|
2472
2571
|
}
|
|
2473
2572
|
|
|
@@ -2478,6 +2577,11 @@ class AuroFloatingUI {
|
|
|
2478
2577
|
* This prevents the component itself from being focusable when the trigger element already handles focus.
|
|
2479
2578
|
*/
|
|
2480
2579
|
handleTriggerTabIndex() {
|
|
2580
|
+
const element = this.element;
|
|
2581
|
+
if (!element) {
|
|
2582
|
+
return;
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2481
2585
|
const focusableElementSelectors = [
|
|
2482
2586
|
"a",
|
|
2483
2587
|
"button",
|
|
@@ -2490,7 +2594,7 @@ class AuroFloatingUI {
|
|
|
2490
2594
|
"auro-hyperlink",
|
|
2491
2595
|
];
|
|
2492
2596
|
|
|
2493
|
-
const triggerNode =
|
|
2597
|
+
const triggerNode = element.querySelectorAll('[slot="trigger"]')[0];
|
|
2494
2598
|
if (!triggerNode) {
|
|
2495
2599
|
return;
|
|
2496
2600
|
}
|
|
@@ -2499,13 +2603,13 @@ class AuroFloatingUI {
|
|
|
2499
2603
|
focusableElementSelectors.forEach((selector) => {
|
|
2500
2604
|
// Check if the trigger node element is focusable
|
|
2501
2605
|
if (triggerNodeTagName === selector) {
|
|
2502
|
-
|
|
2606
|
+
element.tabIndex = -1;
|
|
2503
2607
|
return;
|
|
2504
2608
|
}
|
|
2505
2609
|
|
|
2506
2610
|
// Check if any child is focusable
|
|
2507
2611
|
if (triggerNode.querySelector(selector)) {
|
|
2508
|
-
|
|
2612
|
+
element.tabIndex = -1;
|
|
2509
2613
|
}
|
|
2510
2614
|
});
|
|
2511
2615
|
}
|
|
@@ -2515,13 +2619,18 @@ class AuroFloatingUI {
|
|
|
2515
2619
|
* @param {*} eventPrefix
|
|
2516
2620
|
*/
|
|
2517
2621
|
regenerateBibId() {
|
|
2518
|
-
|
|
2622
|
+
const element = this.element;
|
|
2623
|
+
if (!element) {
|
|
2624
|
+
return;
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
this.id = element.getAttribute("id");
|
|
2519
2628
|
if (!this.id) {
|
|
2520
2629
|
this.id = window.crypto.randomUUID();
|
|
2521
|
-
|
|
2630
|
+
element.setAttribute("id", this.id);
|
|
2522
2631
|
}
|
|
2523
2632
|
|
|
2524
|
-
|
|
2633
|
+
element.bib?.setAttribute("id", `${this.id}-floater-bib`);
|
|
2525
2634
|
}
|
|
2526
2635
|
|
|
2527
2636
|
configure(elem, eventPrefix, enableKeyboardHandling = true) {
|
|
@@ -2533,67 +2642,69 @@ class AuroFloatingUI {
|
|
|
2533
2642
|
this.element = elem;
|
|
2534
2643
|
}
|
|
2535
2644
|
|
|
2536
|
-
|
|
2537
|
-
|
|
2645
|
+
const element = this.element;
|
|
2646
|
+
if (!element) {
|
|
2647
|
+
return;
|
|
2538
2648
|
}
|
|
2539
2649
|
|
|
2540
|
-
if (this.element.
|
|
2541
|
-
this.
|
|
2650
|
+
if (this.behavior !== element.behavior) {
|
|
2651
|
+
this.behavior = element.behavior;
|
|
2542
2652
|
}
|
|
2543
|
-
this.element.trigger =
|
|
2544
|
-
this.element.triggerElement ||
|
|
2545
|
-
this.element.shadowRoot.querySelector("#trigger") ||
|
|
2546
|
-
this.element.trigger;
|
|
2547
|
-
this.element.bib =
|
|
2548
|
-
this.element.shadowRoot.querySelector("#bib") || this.element.bib;
|
|
2549
|
-
this.element.bibSizer = this.element.shadowRoot.querySelector("#bibSizer");
|
|
2550
|
-
this.element.triggerChevron =
|
|
2551
|
-
this.element.shadowRoot.querySelector("#showStateIcon");
|
|
2552
2653
|
|
|
2553
|
-
if (
|
|
2554
|
-
this.
|
|
2654
|
+
if (element.trigger) {
|
|
2655
|
+
this.disconnect();
|
|
2656
|
+
}
|
|
2657
|
+
element.trigger =
|
|
2658
|
+
element.triggerElement ||
|
|
2659
|
+
element.shadowRoot?.querySelector("#trigger") ||
|
|
2660
|
+
element.trigger;
|
|
2661
|
+
element.bib = element.shadowRoot?.querySelector("#bib") || element.bib;
|
|
2662
|
+
element.bibSizer = element.shadowRoot?.querySelector("#bibSizer");
|
|
2663
|
+
element.triggerChevron =
|
|
2664
|
+
element.shadowRoot?.querySelector("#showStateIcon");
|
|
2665
|
+
|
|
2666
|
+
if (element.floaterConfig) {
|
|
2667
|
+
element.hoverToggle = element.floaterConfig.hoverToggle;
|
|
2555
2668
|
}
|
|
2556
2669
|
|
|
2557
2670
|
this.regenerateBibId();
|
|
2558
2671
|
this.handleTriggerTabIndex();
|
|
2559
2672
|
|
|
2560
2673
|
this.handleEvent = this.handleEvent.bind(this);
|
|
2561
|
-
if (
|
|
2674
|
+
if (element.trigger) {
|
|
2562
2675
|
if (this.enableKeyboardHandling) {
|
|
2563
|
-
|
|
2676
|
+
element.trigger.addEventListener("keydown", this.handleEvent);
|
|
2564
2677
|
}
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2678
|
+
element.trigger.addEventListener("click", this.handleEvent);
|
|
2679
|
+
element.trigger.addEventListener("mouseenter", this.handleEvent);
|
|
2680
|
+
element.trigger.addEventListener("mouseleave", this.handleEvent);
|
|
2681
|
+
element.trigger.addEventListener("focus", this.handleEvent);
|
|
2682
|
+
element.trigger.addEventListener("blur", this.handleEvent);
|
|
2570
2683
|
}
|
|
2571
2684
|
}
|
|
2572
2685
|
|
|
2573
2686
|
disconnect() {
|
|
2574
2687
|
this.cleanupHideHandlers();
|
|
2575
|
-
if (this.element) {
|
|
2576
|
-
this.element.cleanup?.();
|
|
2577
2688
|
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2689
|
+
const element = this.element;
|
|
2690
|
+
if (!element) {
|
|
2691
|
+
return;
|
|
2692
|
+
}
|
|
2581
2693
|
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
}
|
|
2694
|
+
element.cleanup?.();
|
|
2695
|
+
|
|
2696
|
+
if (element.bib && element.shadowRoot) {
|
|
2697
|
+
element.shadowRoot.append(element.bib);
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
// Remove event & keyboard listeners
|
|
2701
|
+
if (element.trigger) {
|
|
2702
|
+
element.trigger.removeEventListener("keydown", this.handleEvent);
|
|
2703
|
+
element.trigger.removeEventListener("click", this.handleEvent);
|
|
2704
|
+
element.trigger.removeEventListener("mouseenter", this.handleEvent);
|
|
2705
|
+
element.trigger.removeEventListener("mouseleave", this.handleEvent);
|
|
2706
|
+
element.trigger.removeEventListener("focus", this.handleEvent);
|
|
2707
|
+
element.trigger.removeEventListener("blur", this.handleEvent);
|
|
2597
2708
|
}
|
|
2598
2709
|
}
|
|
2599
2710
|
}
|
|
@@ -3752,7 +3863,7 @@ class AuroHelpText extends i {
|
|
|
3752
3863
|
}
|
|
3753
3864
|
}
|
|
3754
3865
|
|
|
3755
|
-
var formkitVersion = '
|
|
3866
|
+
var formkitVersion = '202604081417';
|
|
3756
3867
|
|
|
3757
3868
|
class AuroElement extends i {
|
|
3758
3869
|
static get properties() {
|