@aurodesignsystem/auro-dialog 4.2.1 → 4.2.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/CHANGELOG.md +2 -3
- package/README.md +70 -82
- package/demo/accessibility.md +7 -2
- package/demo/accessibility.min.js +338 -48
- package/demo/api.md +2 -2
- package/demo/customize.min.js +338 -48
- package/demo/design.min.js +338 -48
- package/demo/index.md +1 -0
- package/demo/index.min.js +338 -48
- package/demo/readme.min.js +338 -48
- package/dist/{auro-dialog-T9I85UZL.js → auro-dialog-FFeXiEB1.js} +4 -4
- package/dist/index.d.ts +16 -8
- package/dist/index.js +1 -1
- package/dist/registered.js +1 -1
- package/package.json +2 -2
|
@@ -2217,6 +2217,48 @@ const computePosition = (reference, floating, options) => {
|
|
|
2217
2217
|
});
|
|
2218
2218
|
};
|
|
2219
2219
|
|
|
2220
|
+
/**
|
|
2221
|
+
* Generates a v4 UUID with a three-tier fallback for insecure contexts.
|
|
2222
|
+
*
|
|
2223
|
+
* Tier 1 (secure contexts): crypto.randomUUID() — native, fully random.
|
|
2224
|
+
* Tier 2 (insecure contexts): crypto.getRandomValues() — available on all
|
|
2225
|
+
* modern browsers regardless of secure-context status.
|
|
2226
|
+
* Tier 3 (last resort, no crypto API): new Date().getTime() — lower entropy,
|
|
2227
|
+
* but sufficient for element IDs where collision risk is negligible.
|
|
2228
|
+
*
|
|
2229
|
+
* See: https://w3c.github.io/webcrypto/#dom-crypto-randomuuid (secure-context restriction)
|
|
2230
|
+
*/
|
|
2231
|
+
function generateUUID() {
|
|
2232
|
+
let uuid;
|
|
2233
|
+
|
|
2234
|
+
if (
|
|
2235
|
+
typeof crypto !== "undefined" &&
|
|
2236
|
+
typeof crypto.randomUUID === "function"
|
|
2237
|
+
) {
|
|
2238
|
+
uuid = crypto.randomUUID();
|
|
2239
|
+
} else if (
|
|
2240
|
+
typeof crypto !== "undefined" &&
|
|
2241
|
+
typeof crypto.getRandomValues === "function"
|
|
2242
|
+
) {
|
|
2243
|
+
const bytes = new Uint8Array(16);
|
|
2244
|
+
crypto.getRandomValues(bytes);
|
|
2245
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
2246
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
2247
|
+
const hex = Array.from(bytes).map((b) => b.toString(16).padStart(2, "0"));
|
|
2248
|
+
uuid = `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
2249
|
+
} else {
|
|
2250
|
+
let d = new Date().getTime();
|
|
2251
|
+
uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
2252
|
+
const r = (d % 16) | 0;
|
|
2253
|
+
d = (d - r) / 16 || new Date().getTime();
|
|
2254
|
+
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
|
|
2255
|
+
});
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
// CSS selectors require IDs starting with a letter; replace a leading digit with 'a'.
|
|
2259
|
+
return /^[0-9]/.test(uuid) ? `a${uuid.slice(1)}` : uuid;
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2220
2262
|
/* eslint-disable line-comment-position, no-inline-comments */
|
|
2221
2263
|
|
|
2222
2264
|
|
|
@@ -2504,30 +2546,61 @@ class AuroFloatingUI {
|
|
|
2504
2546
|
|
|
2505
2547
|
/**
|
|
2506
2548
|
* @private
|
|
2507
|
-
*
|
|
2508
|
-
*
|
|
2549
|
+
* Mirrors `aria-modal` onto the `<dialog>` inside the bib, tracking the page
|
|
2550
|
+
* scroll lock: an overlay that holds the page hides it from assistive tech.
|
|
2551
|
+
*
|
|
2552
|
+
* The removal is called only from inside lockScroll()'s ownership guard: run
|
|
2553
|
+
* outside it, it fired on every autoUpdate tick of every NON-owning instance,
|
|
2554
|
+
* and a repositioning dropdown stripped `aria-modal` off an open modal dialog
|
|
2555
|
+
* it had nothing to do with. The write is unguarded by design — see the call
|
|
2556
|
+
* site — but is skipped when the attribute already reads correctly, so the
|
|
2557
|
+
* repeat costs no mutation record.
|
|
2558
|
+
* @param {Boolean} modal - True to mark the dialog modal; false to unmark it.
|
|
2509
2559
|
*/
|
|
2510
|
-
|
|
2560
|
+
mirrorAriaModal(modal) {
|
|
2511
2561
|
const element = this.element;
|
|
2562
|
+
const dialog = element?.bib
|
|
2563
|
+
? (element.bib?.shadowRoot || element.bib || element).querySelector(
|
|
2564
|
+
"dialog",
|
|
2565
|
+
)
|
|
2566
|
+
: undefined;
|
|
2512
2567
|
|
|
2513
|
-
if (!
|
|
2568
|
+
if (!dialog) {
|
|
2514
2569
|
return;
|
|
2515
2570
|
}
|
|
2516
2571
|
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
element.bib ||
|
|
2520
|
-
element
|
|
2521
|
-
).querySelector("dialog");
|
|
2522
|
-
if (dialog) {
|
|
2523
|
-
if (lock) {
|
|
2572
|
+
if (modal) {
|
|
2573
|
+
if (dialog.getAttribute("aria-modal") !== "true") {
|
|
2524
2574
|
dialog.setAttribute("aria-modal", "true");
|
|
2525
|
-
} else {
|
|
2526
|
-
dialog.removeAttribute("aria-modal");
|
|
2527
2575
|
}
|
|
2576
|
+
} else {
|
|
2577
|
+
dialog.removeAttribute("aria-modal");
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
/**
|
|
2582
|
+
* @private
|
|
2583
|
+
* Controls whether to lock the scrolling for the document's body.
|
|
2584
|
+
* @param {Boolean} lock - If true, locks the body's scrolling functionlity; otherwise, unlock.
|
|
2585
|
+
*/
|
|
2586
|
+
lockScroll(lock = true) {
|
|
2587
|
+
const element = this.element;
|
|
2588
|
+
|
|
2589
|
+
// Locking needs a bib to lock around; unlocking must not, or a bib that has
|
|
2590
|
+
// already been detached would leave the page frozen with no way back.
|
|
2591
|
+
if (lock && !element?.bib) {
|
|
2592
|
+
return;
|
|
2528
2593
|
}
|
|
2529
2594
|
|
|
2530
2595
|
if (lock) {
|
|
2596
|
+
// Re-asserted on every lock call rather than only on the unlocked ->
|
|
2597
|
+
// locked transition. If the bib's inner <dialog> is replaced while this
|
|
2598
|
+
// instance still holds the lock, the replacement would otherwise go
|
|
2599
|
+
// unmarked until a full unlock/lock cycle. Safe to repeat: it targets
|
|
2600
|
+
// this instance's own element, so it cannot reach another overlay's
|
|
2601
|
+
// dialog, and mirrorAriaModal() skips the write when already correct.
|
|
2602
|
+
this.mirrorAriaModal(true);
|
|
2603
|
+
|
|
2531
2604
|
if (!this._scrollLocked) {
|
|
2532
2605
|
this._scrollLocked = true;
|
|
2533
2606
|
this._savedScrollY = window.scrollY;
|
|
@@ -2585,6 +2658,8 @@ class AuroFloatingUI {
|
|
|
2585
2658
|
}
|
|
2586
2659
|
} else {
|
|
2587
2660
|
if (this._scrollLocked) {
|
|
2661
|
+
this.mirrorAriaModal(false);
|
|
2662
|
+
|
|
2588
2663
|
if (this._viewportHandler && window.visualViewport) {
|
|
2589
2664
|
window.visualViewport.removeEventListener(
|
|
2590
2665
|
"resize",
|
|
@@ -2697,15 +2772,47 @@ class AuroFloatingUI {
|
|
|
2697
2772
|
} else if (this.configureTrial < MAX_CONFIGURATION_COUNT) {
|
|
2698
2773
|
this.configureTrial += 1;
|
|
2699
2774
|
|
|
2700
|
-
|
|
2775
|
+
// The id is retained so disconnect() can cancel it. A retry that fires
|
|
2776
|
+
// after teardown re-enters this method with isPopoverVisible still true
|
|
2777
|
+
// — nothing clears it on the teardown path — and takes the page scroll
|
|
2778
|
+
// lock back, with no owner left to release it.
|
|
2779
|
+
//
|
|
2780
|
+
// This is not the rare timing race it reads as: the lookup above wants
|
|
2781
|
+
// a `.container` inside the BIB's own shadow root, which only a bib
|
|
2782
|
+
// that is itself a custom element has. A consumer whose bib is a plain
|
|
2783
|
+
// element (auro-dialog's `#bib` is a div, with its `.container` a
|
|
2784
|
+
// sibling in the host's shadow root) can never satisfy it, so it
|
|
2785
|
+
// retries the full MAX_CONFIGURATION_COUNT every time. Correcting the
|
|
2786
|
+
// lookup would change bib sizing for those consumers and is tracked
|
|
2787
|
+
// separately; cancelling the timer is what keeps it from freezing the
|
|
2788
|
+
// page.
|
|
2789
|
+
this._configureRetryId = setTimeout(() => {
|
|
2790
|
+
this._configureRetryId = undefined;
|
|
2701
2791
|
this.configureBibStrategy(value);
|
|
2702
2792
|
}, 0);
|
|
2703
2793
|
}
|
|
2704
2794
|
|
|
2705
2795
|
if (element.isPopoverVisible) {
|
|
2706
|
-
|
|
2796
|
+
// Positioning strategy is not scroll ownership. Both "fullscreen" and
|
|
2797
|
+
// "dialog" lay the bib over the page and trap focus inside it, so both
|
|
2798
|
+
// must freeze the page behind them (AB#1647843). Gating this on
|
|
2799
|
+
// "fullscreen" alone left dismissible desktop dialogs and drawers
|
|
2800
|
+
// scrollable, and actively released the lock on every reposition
|
|
2801
|
+
// (AB#1625424, AB#1625435). The nested "cover" strategy takes the else
|
|
2802
|
+
// branch and stays scrollable by design — it sits inside its parent
|
|
2803
|
+
// rather than over the page.
|
|
2804
|
+
this.lockScroll(true);
|
|
2707
2805
|
}
|
|
2708
2806
|
} else {
|
|
2807
|
+
// The mirror of the lock above: a strategy that does not own the page must
|
|
2808
|
+
// hand the lock back, not merely decline to take it. autoUpdate re-runs
|
|
2809
|
+
// this method on every resize tick, and getPositioningStrategy() flips
|
|
2810
|
+
// "fullscreen" -> "floating" across the breakpoint for dropdown behavior —
|
|
2811
|
+
// so an overlay that locked while narrow can land here while still open.
|
|
2812
|
+
// Without this, the page stays frozen behind a small floating bib until
|
|
2813
|
+
// hideBib() happens to run.
|
|
2814
|
+
this.lockScroll(false);
|
|
2815
|
+
|
|
2709
2816
|
element.bib.style.position = "";
|
|
2710
2817
|
element.bib.removeAttribute("isfullscreen");
|
|
2711
2818
|
element.isBibFullscreen = false;
|
|
@@ -2815,6 +2922,46 @@ class AuroFloatingUI {
|
|
|
2815
2922
|
this.hideBib("focusloss");
|
|
2816
2923
|
}
|
|
2817
2924
|
|
|
2925
|
+
/**
|
|
2926
|
+
* @private
|
|
2927
|
+
* Installs the handlers that dismiss an open overlay.
|
|
2928
|
+
*
|
|
2929
|
+
* Shared by showBib(), which opens the overlay, and configure(), which has to
|
|
2930
|
+
* put these back after a rewire tore them down under an overlay that is still
|
|
2931
|
+
* open. A non-modal overlay dismisses on outside click, focus loss and
|
|
2932
|
+
* Escape; a modal one instead swallows Escape so the native dialog's
|
|
2933
|
+
* CloseWatcher never sees it (AB#1613688).
|
|
2934
|
+
*/
|
|
2935
|
+
setupDismissHandlers() {
|
|
2936
|
+
const element = this.element;
|
|
2937
|
+
if (!element) {
|
|
2938
|
+
return;
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2941
|
+
if (!element.modal) {
|
|
2942
|
+
this.setupHideHandlers();
|
|
2943
|
+
return;
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
if (this.keyDownHandler) {
|
|
2947
|
+
document.removeEventListener("keydown", this.keyDownHandler);
|
|
2948
|
+
}
|
|
2949
|
+
this.keyDownHandler = (evt) => {
|
|
2950
|
+
if (evt.key === "Escape" && element.isPopoverVisible) {
|
|
2951
|
+
// Intercept at keydown so CloseWatcher never sees the keystroke.
|
|
2952
|
+
// Canceling `cancel` alone is insufficient — a second Esc with no
|
|
2953
|
+
// intervening user activation triggers the anti-trap and fires `close`
|
|
2954
|
+
// directly, bypassing any `cancel` preventDefault (AB#1613688).
|
|
2955
|
+
// stopImmediatePropagation is intentional: it prevents other document
|
|
2956
|
+
// keydown handlers (e.g. consumer code, auro-dialog) from also acting
|
|
2957
|
+
// on Escape while the modal owns the key.
|
|
2958
|
+
evt.preventDefault();
|
|
2959
|
+
evt.stopImmediatePropagation();
|
|
2960
|
+
}
|
|
2961
|
+
};
|
|
2962
|
+
document.addEventListener("keydown", this.keyDownHandler);
|
|
2963
|
+
}
|
|
2964
|
+
|
|
2818
2965
|
setupHideHandlers() {
|
|
2819
2966
|
const element = this.element;
|
|
2820
2967
|
if (!element) {
|
|
@@ -2987,27 +3134,7 @@ class AuroFloatingUI {
|
|
|
2987
3134
|
|
|
2988
3135
|
// prevent double showing: isPopovervisible gets first and showBib gets called later
|
|
2989
3136
|
if (!this.showing) {
|
|
2990
|
-
|
|
2991
|
-
this.setupHideHandlers();
|
|
2992
|
-
} else {
|
|
2993
|
-
if (this.keyDownHandler) {
|
|
2994
|
-
document.removeEventListener("keydown", this.keyDownHandler);
|
|
2995
|
-
}
|
|
2996
|
-
this.keyDownHandler = (evt) => {
|
|
2997
|
-
if (evt.key === "Escape" && element.isPopoverVisible) {
|
|
2998
|
-
// Intercept at keydown so CloseWatcher never sees the keystroke.
|
|
2999
|
-
// Canceling `cancel` alone is insufficient — a second Esc with no
|
|
3000
|
-
// intervening user activation triggers the anti-trap and fires `close`
|
|
3001
|
-
// directly, bypassing any `cancel` preventDefault (AB#1613688).
|
|
3002
|
-
// stopImmediatePropagation is intentional: it prevents other document
|
|
3003
|
-
// keydown handlers (e.g. consumer code, auro-dialog) from also acting
|
|
3004
|
-
// on Escape while the modal owns the key.
|
|
3005
|
-
evt.preventDefault();
|
|
3006
|
-
evt.stopImmediatePropagation();
|
|
3007
|
-
}
|
|
3008
|
-
};
|
|
3009
|
-
document.addEventListener("keydown", this.keyDownHandler);
|
|
3010
|
-
}
|
|
3137
|
+
this.setupDismissHandlers();
|
|
3011
3138
|
this.showing = true;
|
|
3012
3139
|
element.isPopoverVisible = true;
|
|
3013
3140
|
this.position();
|
|
@@ -3235,7 +3362,7 @@ class AuroFloatingUI {
|
|
|
3235
3362
|
|
|
3236
3363
|
this.id = element.getAttribute("id");
|
|
3237
3364
|
if (!this.id) {
|
|
3238
|
-
this.id =
|
|
3365
|
+
this.id = generateUUID();
|
|
3239
3366
|
element.setAttribute("id", this.id);
|
|
3240
3367
|
}
|
|
3241
3368
|
|
|
@@ -3247,7 +3374,35 @@ class AuroFloatingUI {
|
|
|
3247
3374
|
this.enableKeyboardHandling = enableKeyboardHandling;
|
|
3248
3375
|
|
|
3249
3376
|
this.eventPrefix = eventPrefix;
|
|
3250
|
-
|
|
3377
|
+
|
|
3378
|
+
// A retained scroll lock's saved body styles were captured for whichever
|
|
3379
|
+
// element held it, so only a same-element rewire may keep it. An actual
|
|
3380
|
+
// element swap has to take the full teardown, or this instance is left
|
|
3381
|
+
// holding a lock that no longer describes the page it points at — with no
|
|
3382
|
+
// owner able to release it (AB#1647843).
|
|
3383
|
+
const rewiringSameElement = this.element === elem;
|
|
3384
|
+
|
|
3385
|
+
if (!rewiringSameElement) {
|
|
3386
|
+
// Tear down against the outgoing element, before this.element is
|
|
3387
|
+
// repointed. Everything disconnect() releases is element-scoped:
|
|
3388
|
+
// aria-modal on that element's inner dialog, the bib transform saved for
|
|
3389
|
+
// it, its autoUpdate loop and its trigger listeners. Repointing first
|
|
3390
|
+
// aimed all of it at the incoming element — the outgoing dialog kept
|
|
3391
|
+
// aria-modal="true" for good, its bib stayed transformed, and the
|
|
3392
|
+
// incoming bib had the outgoing element's saved transform written onto
|
|
3393
|
+
// it. The trigger gate below read the incoming element's trigger, which
|
|
3394
|
+
// is not assigned until later in this method, so on a swap teardown was
|
|
3395
|
+
// usually skipped outright and the page stayed locked with no owner.
|
|
3396
|
+
if (this.element?.trigger) {
|
|
3397
|
+
this.disconnect({ teardown: true });
|
|
3398
|
+
}
|
|
3399
|
+
|
|
3400
|
+
// disconnect() does not clear this.showing, and the rewire block at the
|
|
3401
|
+
// end of this method only runs for a same-element rewire. Left true, the
|
|
3402
|
+
// incoming element's first showBib() is silently dropped by its
|
|
3403
|
+
// `!this.showing` guard and the overlay never opens.
|
|
3404
|
+
this.showing = false;
|
|
3405
|
+
|
|
3251
3406
|
this.element = elem;
|
|
3252
3407
|
}
|
|
3253
3408
|
|
|
@@ -3260,8 +3415,10 @@ class AuroFloatingUI {
|
|
|
3260
3415
|
this.behavior = element.behavior;
|
|
3261
3416
|
}
|
|
3262
3417
|
|
|
3263
|
-
if (element.trigger) {
|
|
3264
|
-
|
|
3418
|
+
if (rewiringSameElement && element.trigger) {
|
|
3419
|
+
// Rewiring, not tearing down — an overlay that is open right now keeps
|
|
3420
|
+
// its page scroll lock across a trigger change.
|
|
3421
|
+
this.disconnect({ teardown: false });
|
|
3265
3422
|
}
|
|
3266
3423
|
element.trigger =
|
|
3267
3424
|
element.triggerElement ||
|
|
@@ -3290,11 +3447,61 @@ class AuroFloatingUI {
|
|
|
3290
3447
|
element.trigger.addEventListener("focus", this.handleEvent);
|
|
3291
3448
|
element.trigger.addEventListener("blur", this.handleEvent);
|
|
3292
3449
|
}
|
|
3450
|
+
|
|
3451
|
+
// disconnect() above stripped the dismissal handlers and killed the
|
|
3452
|
+
// autoUpdate loop; the trigger listeners re-registered here replace
|
|
3453
|
+
// neither. An overlay that is open right now would otherwise be left on
|
|
3454
|
+
// screen with outside-click, focus-loss and Escape all dead and its
|
|
3455
|
+
// position frozen — and, since the lock is deliberately retained, holding
|
|
3456
|
+
// the page with only its original trigger able to give it back.
|
|
3457
|
+
if (rewiringSameElement && this.showing) {
|
|
3458
|
+
this.setupDismissHandlers();
|
|
3459
|
+
|
|
3460
|
+
if (element.bib && (element.trigger || element.parentNode)) {
|
|
3461
|
+
element.cleanup = autoUpdate(
|
|
3462
|
+
element.trigger || element.parentNode,
|
|
3463
|
+
element.bib,
|
|
3464
|
+
() => {
|
|
3465
|
+
this.position();
|
|
3466
|
+
},
|
|
3467
|
+
);
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3293
3470
|
}
|
|
3294
3471
|
|
|
3295
|
-
|
|
3472
|
+
/**
|
|
3473
|
+
* Tears the floater's connections down.
|
|
3474
|
+
*
|
|
3475
|
+
* Two callers with different intent share this: a real teardown, which must
|
|
3476
|
+
* release the page scroll lock, and configure(), which re-runs it purely to
|
|
3477
|
+
* rewire a changed trigger and must leave an open overlay's lock alone.
|
|
3478
|
+
* @param {Object} [options] - Teardown options.
|
|
3479
|
+
* @param {Boolean} [options.teardown] - False when only rewiring; keeps the
|
|
3480
|
+
* page scroll lock held for an overlay that is still open.
|
|
3481
|
+
* @returns {void}
|
|
3482
|
+
*/
|
|
3483
|
+
disconnect({ teardown = true } = {}) {
|
|
3296
3484
|
this.cleanupHideHandlers();
|
|
3297
3485
|
|
|
3486
|
+
// Cancel any pending configureBibStrategy() retry. It would otherwise fire
|
|
3487
|
+
// a macrotask after the unlock below, re-lock the page, and leave it frozen
|
|
3488
|
+
// with the floater already gone. Cancelled on a rewire too: configure()
|
|
3489
|
+
// re-runs position() itself, so a stale retry has nothing to contribute.
|
|
3490
|
+
if (this._configureRetryId !== undefined) {
|
|
3491
|
+
clearTimeout(this._configureRetryId);
|
|
3492
|
+
this._configureRetryId = undefined;
|
|
3493
|
+
}
|
|
3494
|
+
|
|
3495
|
+
// Tearing down while the bib is still open would otherwise strand
|
|
3496
|
+
// body{position:fixed} and leave the page permanently unscrollable —
|
|
3497
|
+
// hideBib() is the only other unlock, and it never runs in this path.
|
|
3498
|
+
// Skipped when merely rewiring: configure() routes through here on every
|
|
3499
|
+
// triggerElement change, and releasing the lock there would unlock the page
|
|
3500
|
+
// behind an overlay that is still open (AB#1625424, AB#1625435).
|
|
3501
|
+
if (teardown) {
|
|
3502
|
+
this.lockScroll(false);
|
|
3503
|
+
}
|
|
3504
|
+
|
|
3298
3505
|
const element = this.element;
|
|
3299
3506
|
if (!element) {
|
|
3300
3507
|
return;
|
|
@@ -3449,6 +3656,14 @@ class ComponentBase extends i$2 {
|
|
|
3449
3656
|
this.isBibFullscreen = false;
|
|
3450
3657
|
this.floater = new AuroFloatingUI(this, 'dialog');
|
|
3451
3658
|
|
|
3659
|
+
/**
|
|
3660
|
+
* @private
|
|
3661
|
+
* True once _teardown() has released the floater and nothing has rewired
|
|
3662
|
+
* it. Read by connectedCallback() to rewire a remounted dialog, and by
|
|
3663
|
+
* _teardown() to stay idempotent.
|
|
3664
|
+
*/
|
|
3665
|
+
this._floaterTornDown = false;
|
|
3666
|
+
|
|
3452
3667
|
const versioning = new AuroDependencyVersioning();
|
|
3453
3668
|
|
|
3454
3669
|
/**
|
|
@@ -3509,10 +3724,12 @@ class ComponentBase extends i$2 {
|
|
|
3509
3724
|
|
|
3510
3725
|
/**
|
|
3511
3726
|
* DEPRECATED - use `close-button-appearance="inverse" instead.
|
|
3727
|
+
* @deprecated Use `close-button-appearance="inverse"` instead.
|
|
3512
3728
|
*/
|
|
3513
3729
|
onDark: {
|
|
3514
3730
|
type: Boolean,
|
|
3515
|
-
reflect: true
|
|
3731
|
+
reflect: true,
|
|
3732
|
+
attribute: 'ondark'
|
|
3516
3733
|
},
|
|
3517
3734
|
|
|
3518
3735
|
/**
|
|
@@ -3530,7 +3747,8 @@ class ComponentBase extends i$2 {
|
|
|
3530
3747
|
*/
|
|
3531
3748
|
isBibFullscreen: {
|
|
3532
3749
|
type: Boolean,
|
|
3533
|
-
reflect: true
|
|
3750
|
+
reflect: true,
|
|
3751
|
+
attribute: 'isbibfullscreen'
|
|
3534
3752
|
},
|
|
3535
3753
|
|
|
3536
3754
|
/**
|
|
@@ -3599,7 +3817,7 @@ class ComponentBase extends i$2 {
|
|
|
3599
3817
|
slotWrapper.classList.remove("dialog-footer");
|
|
3600
3818
|
}
|
|
3601
3819
|
|
|
3602
|
-
this.
|
|
3820
|
+
this._configureFloater();
|
|
3603
3821
|
|
|
3604
3822
|
// Forward FloatingUI toggle event to backward-compatible 'toggle' event
|
|
3605
3823
|
this.addEventListener('auroDialog-toggled', (event) => {
|
|
@@ -3608,9 +3826,15 @@ class ComponentBase extends i$2 {
|
|
|
3608
3826
|
}
|
|
3609
3827
|
});
|
|
3610
3828
|
|
|
3611
|
-
//
|
|
3612
|
-
//
|
|
3613
|
-
//
|
|
3829
|
+
// Defense-in-depth for the native ESC/cancel event. In practice neither
|
|
3830
|
+
// branch fires today: auro-library's floatingUI binds its own document-level
|
|
3831
|
+
// keydown handler, which closes a non-modal dialog via hideBib("keydown")
|
|
3832
|
+
// and, for a modal, swallows the keystroke with preventDefault() +
|
|
3833
|
+
// stopImmediatePropagation() before the platform CloseWatcher ever sees it
|
|
3834
|
+
// (AB#1613688). This listener is kept rather than deleted because it is the
|
|
3835
|
+
// component-side guarantee that a modal never self-closes on ESC: if the
|
|
3836
|
+
// library stops swallowing, the platform `cancel` would otherwise close a
|
|
3837
|
+
// modal dialog, which is exactly the behavior `modal` exists to prevent.
|
|
3614
3838
|
this.dialog.addEventListener('cancel', (e) => {
|
|
3615
3839
|
e.preventDefault();
|
|
3616
3840
|
if (!this.modal) {
|
|
@@ -3657,12 +3881,78 @@ class ComponentBase extends i$2 {
|
|
|
3657
3881
|
}
|
|
3658
3882
|
|
|
3659
3883
|
if (changedProperties.has('triggerElement')) {
|
|
3660
|
-
this.
|
|
3884
|
+
this._configureFloater();
|
|
3885
|
+
}
|
|
3886
|
+
}
|
|
3887
|
+
|
|
3888
|
+
/**
|
|
3889
|
+
* @private
|
|
3890
|
+
* Wires the floater to this element and records that it is live, so a later
|
|
3891
|
+
* reconnect can tell a torn-down floater from one that never lost its wiring.
|
|
3892
|
+
* @returns {void}
|
|
3893
|
+
*/
|
|
3894
|
+
_configureFloater() {
|
|
3895
|
+
this._floaterTornDown = false;
|
|
3896
|
+
this.floater.configure(this, this.floaterConfig.prefix);
|
|
3897
|
+
}
|
|
3898
|
+
|
|
3899
|
+
connectedCallback() {
|
|
3900
|
+
super.connectedCallback();
|
|
3901
|
+
|
|
3902
|
+
// Lit does not re-run firstUpdated() on reconnect, so without this a host
|
|
3903
|
+
// that removes and re-inserts the dialog across separate tasks — Vue
|
|
3904
|
+
// <keep-alive>, caching tab/accordion hosts, virtualized lists, or anything
|
|
3905
|
+
// that parks the node in a DocumentFragment in one task and inserts it in
|
|
3906
|
+
// the next — gets back a dead element: _teardown() dropped the trigger
|
|
3907
|
+
// listeners, ran element.cleanup(), tore down autoUpdate and released the
|
|
3908
|
+
// page scroll lock, and nothing rewired any of it.
|
|
3909
|
+
//
|
|
3910
|
+
// Only re-configure when a teardown actually ran. On the normal first
|
|
3911
|
+
// connect the flag is false and firstUpdated() owns the single configure
|
|
3912
|
+
// call; on a same-task DOM move the deferred teardown never runs, so the
|
|
3913
|
+
// flag stays false here too and the move is still a no-op.
|
|
3914
|
+
if (this.hasUpdated && this._floaterTornDown) {
|
|
3915
|
+
this._configureFloater();
|
|
3661
3916
|
}
|
|
3662
3917
|
}
|
|
3663
3918
|
|
|
3664
3919
|
disconnectedCallback() {
|
|
3665
3920
|
super.disconnectedCallback();
|
|
3921
|
+
|
|
3922
|
+
// A same-document DOM move (appendChild of an already-parented node) fires
|
|
3923
|
+
// disconnectedCallback and reconnects within the same task. Defer the
|
|
3924
|
+
// teardown one microtask and bail if the element came back, so a reparent
|
|
3925
|
+
// does not dismantle a dialog that is still open: floater.disconnect()
|
|
3926
|
+
// releases the page scroll lock and tears down autoUpdate, which would
|
|
3927
|
+
// leave the dialog visible over a scrollable page with nothing left to
|
|
3928
|
+
// re-lock it — the AB#1625424 symptom returning by a different route.
|
|
3929
|
+
//
|
|
3930
|
+
// A host that removes and re-inserts across tasks (not a move) is treated
|
|
3931
|
+
// as a real unmount, which is the correct reading of that sequence.
|
|
3932
|
+
queueMicrotask(() => {
|
|
3933
|
+
if (this.isConnected) {
|
|
3934
|
+
return;
|
|
3935
|
+
}
|
|
3936
|
+
this._teardown();
|
|
3937
|
+
});
|
|
3938
|
+
}
|
|
3939
|
+
|
|
3940
|
+
/**
|
|
3941
|
+
* @private
|
|
3942
|
+
* Releases everything the dialog owns outside its own shadow root.
|
|
3943
|
+
* Split out of disconnectedCallback so a DOM move can skip it.
|
|
3944
|
+
*
|
|
3945
|
+
* Idempotent: a repeated disconnect in the same task must not invoke
|
|
3946
|
+
* floater.disconnect() twice, and connectedCallback() reads the same flag to
|
|
3947
|
+
* decide whether the floater needs rewiring.
|
|
3948
|
+
* @returns {void}
|
|
3949
|
+
*/
|
|
3950
|
+
_teardown() {
|
|
3951
|
+
if (this._floaterTornDown) {
|
|
3952
|
+
return;
|
|
3953
|
+
}
|
|
3954
|
+
this._floaterTornDown = true;
|
|
3955
|
+
|
|
3666
3956
|
if (this._hidePopoverTimerId) {
|
|
3667
3957
|
clearTimeout(this._hidePopoverTimerId);
|
|
3668
3958
|
this._hidePopoverTimerId = undefined;
|
package/demo/api.md
CHANGED
|
@@ -14,11 +14,11 @@ The `auro-dialog` appears on top of the page and presents information that requi
|
|
|
14
14
|
| lg | lg | | boolean | | Sets dialog box to large style. Adding both lg and sm/md will set the dialog to lg for mobile and sm/md for desktop.<br>Must be used in conjunction with sm or md to have an effect. |
|
|
15
15
|
| md | md | | boolean | | Sets dialog box to medium style. Adding both md and lg will set the dialog to md for desktop and lg for mobile. |
|
|
16
16
|
| modal | modal | | boolean | | Modal dialog restricts the user to take an action (no default close actions). |
|
|
17
|
-
| onDark | onDark | | boolean | | DEPRECATED - use `close-button-appearance="inverse" instead. |
|
|
18
17
|
| sm | sm | | boolean | | Sets dialog box to small style. Adding both sm and lg will set the dialog to sm for desktop and lg for mobile. |
|
|
19
18
|
| triggerElement | | | HTMLElement | | The element to focus when the dialog is closed. If not set, defaults to the value of document.activeElement when the dialog is opened. |
|
|
20
19
|
| unformatted | unformatted | | boolean | | Unformatted dialog window, edge-to-edge fill for content. |
|
|
21
|
-
|
|
|
20
|
+
| onDark | ondark | | boolean | | DEPRECATED - use `close-button-appearance="inverse" instead. |
|
|
21
|
+
| | isbibfullscreen | | boolean | | If true, the dialog bib is in fullscreen mode. |
|
|
22
22
|
|
|
23
23
|
### Methods
|
|
24
24
|
|