@surdeddd/bottom-sheet 0.10.0 → 0.12.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/README.md +52 -35
- package/dist/{BottomSheetEngine-DzsIwD28.d.cts → BottomSheetEngine-D6oiEfZ4.d.cts} +1 -0
- package/dist/{BottomSheetEngine-DRjCU73e.d.ts → BottomSheetEngine-Dhy0X_e9.d.ts} +1 -0
- package/dist/element.cjs +250 -136
- package/dist/element.d.cts +1 -1
- package/dist/element.d.ts +1 -1
- package/dist/element.iife.global.js +2 -2
- package/dist/element.js +250 -136
- package/dist/index.cjs +257 -164
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +257 -164
- package/dist/integrations/formik.d.cts +1 -1
- package/dist/integrations/formik.d.ts +1 -1
- package/dist/integrations/react-hook-form.d.cts +1 -1
- package/dist/integrations/react-hook-form.d.ts +1 -1
- package/dist/overlay.cjs +161 -33
- package/dist/overlay.d.cts +1 -3
- package/dist/overlay.d.ts +1 -3
- package/dist/overlay.js +161 -33
- package/dist/preact.d.cts +1 -1
- package/dist/preact.d.ts +1 -1
- package/dist/qwik.cjs +240 -131
- package/dist/qwik.d.cts +2 -2
- package/dist/qwik.d.ts +2 -2
- package/dist/qwik.js +240 -131
- package/dist/react.cjs +257 -164
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +257 -164
- package/dist/solid.cjs +240 -131
- package/dist/solid.d.cts +1 -0
- package/dist/solid.d.ts +1 -0
- package/dist/solid.js +240 -131
- package/dist/solid.source.jsx +240 -131
- package/dist/svelte-core.cjs +240 -131
- package/dist/svelte-core.js +240 -131
- package/dist/svelte.cjs +252 -143
- package/dist/svelte.js +252 -143
- package/dist/vue.cjs +240 -131
- package/dist/vue.js +240 -131
- package/package.json +10 -8
package/dist/index.js
CHANGED
|
@@ -442,46 +442,202 @@ function notifyLinkedSheets(sheets, self) {
|
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
-
// src/core/features/
|
|
446
|
-
var
|
|
447
|
-
var
|
|
445
|
+
// src/core/features/history-coordinator.ts
|
|
446
|
+
var entries = [];
|
|
447
|
+
var subscribers = /* @__PURE__ */ new Set();
|
|
448
448
|
var suppress = 0;
|
|
449
|
-
var
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
449
|
+
var internalDepth = 0;
|
|
450
|
+
var pendingRebrand = null;
|
|
451
|
+
var listenerInstalled = false;
|
|
452
|
+
var patchInstalled = false;
|
|
453
|
+
var origPushState = null;
|
|
454
|
+
var origReplaceState = null;
|
|
455
|
+
var patchedPushState = null;
|
|
456
|
+
var patchedReplaceState = null;
|
|
457
|
+
var hasWindow = () => typeof window !== "undefined";
|
|
458
|
+
var hasHistory = () => typeof history !== "undefined";
|
|
459
|
+
var brandMarker = (surface) => ({
|
|
460
|
+
...surface.markerState(),
|
|
461
|
+
__bs: true
|
|
462
|
+
});
|
|
463
|
+
var runInternal = (fn) => {
|
|
464
|
+
internalDepth += 1;
|
|
465
|
+
try {
|
|
466
|
+
fn();
|
|
467
|
+
} finally {
|
|
468
|
+
internalDepth -= 1;
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
var notifyRouteChange = () => {
|
|
472
|
+
const snapshot = Array.from(subscribers);
|
|
473
|
+
for (const fn of snapshot) fn();
|
|
474
|
+
};
|
|
475
|
+
var ensureListener = () => {
|
|
476
|
+
if (listenerInstalled || !hasWindow()) return;
|
|
477
|
+
window.addEventListener("popstate", onPopState);
|
|
478
|
+
listenerInstalled = true;
|
|
479
|
+
};
|
|
480
|
+
var maybeTeardownListener = () => {
|
|
481
|
+
if (!listenerInstalled) return;
|
|
482
|
+
if (entries.length > 0 || subscribers.size > 0 || suppress > 0) return;
|
|
483
|
+
if (hasWindow()) window.removeEventListener("popstate", onPopState);
|
|
484
|
+
listenerInstalled = false;
|
|
485
|
+
};
|
|
486
|
+
var installPatch = () => {
|
|
487
|
+
if (patchInstalled || !hasHistory()) return;
|
|
488
|
+
origPushState = history.pushState;
|
|
489
|
+
origReplaceState = history.replaceState;
|
|
490
|
+
patchedPushState = function(...args) {
|
|
491
|
+
origPushState.apply(this, args);
|
|
492
|
+
if (internalDepth === 0) notifyRouteChange();
|
|
493
|
+
};
|
|
494
|
+
patchedReplaceState = function(...args) {
|
|
495
|
+
origReplaceState.apply(this, args);
|
|
496
|
+
if (internalDepth === 0) notifyRouteChange();
|
|
497
|
+
};
|
|
498
|
+
history.pushState = patchedPushState;
|
|
499
|
+
history.replaceState = patchedReplaceState;
|
|
500
|
+
patchInstalled = true;
|
|
501
|
+
};
|
|
502
|
+
var removePatch = () => {
|
|
503
|
+
if (!patchInstalled) return;
|
|
504
|
+
if (history.pushState === patchedPushState && origPushState) {
|
|
505
|
+
history.pushState = origPushState;
|
|
506
|
+
}
|
|
507
|
+
if (history.replaceState === patchedReplaceState && origReplaceState) {
|
|
508
|
+
history.replaceState = origReplaceState;
|
|
509
|
+
}
|
|
510
|
+
origPushState = null;
|
|
511
|
+
origReplaceState = null;
|
|
512
|
+
patchedPushState = null;
|
|
513
|
+
patchedReplaceState = null;
|
|
514
|
+
patchInstalled = false;
|
|
515
|
+
};
|
|
516
|
+
function onPopState() {
|
|
517
|
+
if (suppress > 0) {
|
|
518
|
+
suppress -= 1;
|
|
519
|
+
const rebrand = pendingRebrand;
|
|
520
|
+
pendingRebrand = null;
|
|
521
|
+
if (rebrand) rebrand();
|
|
522
|
+
maybeTeardownListener();
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
if (entries.length === 0) {
|
|
526
|
+
notifyRouteChange();
|
|
527
|
+
maybeTeardownListener();
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
let target = null;
|
|
531
|
+
let targetIdx = -1;
|
|
532
|
+
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
533
|
+
const entry = entries[i];
|
|
534
|
+
if (!entry.surface.isOpen()) continue;
|
|
535
|
+
if (!target) {
|
|
536
|
+
target = entry;
|
|
537
|
+
targetIdx = i;
|
|
456
538
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
if (!target) target = c;
|
|
462
|
-
if (c.isTop()) {
|
|
463
|
-
target = c;
|
|
464
|
-
break;
|
|
465
|
-
}
|
|
539
|
+
if (entry.surface.isTop()) {
|
|
540
|
+
target = entry;
|
|
541
|
+
targetIdx = i;
|
|
542
|
+
break;
|
|
466
543
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
if (
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
544
|
+
}
|
|
545
|
+
if (!target) {
|
|
546
|
+
const removed = entries.pop();
|
|
547
|
+
if (removed) removed.live = false;
|
|
548
|
+
maybeTeardownListener();
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
target.live = false;
|
|
552
|
+
entries.splice(targetIdx, 1);
|
|
553
|
+
const settled = target;
|
|
554
|
+
void Promise.resolve(settled.surface.close()).then(() => {
|
|
555
|
+
if (settled.surface.isOpen()) restore(settled);
|
|
475
556
|
});
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
557
|
+
maybeTeardownListener();
|
|
558
|
+
}
|
|
559
|
+
function restore(entry) {
|
|
560
|
+
if (!hasWindow() || !hasHistory()) return;
|
|
561
|
+
entry.live = true;
|
|
562
|
+
runInternal(() => {
|
|
563
|
+
try {
|
|
564
|
+
history.pushState(brandMarker(entry.surface), "", entry.surface.url);
|
|
565
|
+
} catch {
|
|
566
|
+
entry.live = false;
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
if (entry.live) {
|
|
570
|
+
entries.push(entry);
|
|
571
|
+
ensureListener();
|
|
483
572
|
}
|
|
484
|
-
}
|
|
573
|
+
}
|
|
574
|
+
function pushBackMarker(surface) {
|
|
575
|
+
const entry = { surface, priorUrl: void 0, live: false };
|
|
576
|
+
if (!hasWindow() || !hasHistory()) {
|
|
577
|
+
return entry;
|
|
578
|
+
}
|
|
579
|
+
entry.priorUrl = surface.url !== void 0 ? location.href : void 0;
|
|
580
|
+
runInternal(() => {
|
|
581
|
+
try {
|
|
582
|
+
history.pushState(brandMarker(surface), "", surface.url);
|
|
583
|
+
entry.live = true;
|
|
584
|
+
} catch {
|
|
585
|
+
entry.live = false;
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
if (entry.live) {
|
|
589
|
+
entries.push(entry);
|
|
590
|
+
ensureListener();
|
|
591
|
+
}
|
|
592
|
+
return entry;
|
|
593
|
+
}
|
|
594
|
+
function popBackMarker(handle) {
|
|
595
|
+
if (!hasWindow() || !hasHistory()) return;
|
|
596
|
+
const entry = handle;
|
|
597
|
+
const idx = entries.indexOf(entry);
|
|
598
|
+
if (idx === -1 || !entry.live) return;
|
|
599
|
+
const last = entries.length - 1;
|
|
600
|
+
entry.live = false;
|
|
601
|
+
entries.splice(idx, 1);
|
|
602
|
+
if (idx !== last) {
|
|
603
|
+
const rebrandSurface = entries[entries.length - 1].surface;
|
|
604
|
+
const rebrandUrl = entry.priorUrl;
|
|
605
|
+
pendingRebrand = () => {
|
|
606
|
+
runInternal(() => {
|
|
607
|
+
history.replaceState(
|
|
608
|
+
brandMarker(rebrandSurface),
|
|
609
|
+
"",
|
|
610
|
+
rebrandUrl !== void 0 ? rebrandUrl : location.href
|
|
611
|
+
);
|
|
612
|
+
});
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
suppress += 1;
|
|
616
|
+
runInternal(() => {
|
|
617
|
+
try {
|
|
618
|
+
history.back();
|
|
619
|
+
} catch {
|
|
620
|
+
suppress = Math.max(0, suppress - 1);
|
|
621
|
+
pendingRebrand = null;
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
maybeTeardownListener();
|
|
625
|
+
}
|
|
626
|
+
function subscribeRouteChange(fn) {
|
|
627
|
+
if (!hasWindow() || !hasHistory()) return () => {
|
|
628
|
+
};
|
|
629
|
+
subscribers.add(fn);
|
|
630
|
+
if (subscribers.size === 1) installPatch();
|
|
631
|
+
ensureListener();
|
|
632
|
+
return () => {
|
|
633
|
+
if (!subscribers.has(fn)) return;
|
|
634
|
+
subscribers.delete(fn);
|
|
635
|
+
if (subscribers.size === 0) removePatch();
|
|
636
|
+
maybeTeardownListener();
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// src/core/features/route.ts
|
|
485
641
|
function installRoute(deps) {
|
|
486
642
|
if (typeof window === "undefined") {
|
|
487
643
|
return () => {
|
|
@@ -491,92 +647,39 @@ function installRoute(deps) {
|
|
|
491
647
|
return () => {
|
|
492
648
|
};
|
|
493
649
|
}
|
|
494
|
-
let
|
|
495
|
-
let closer = null;
|
|
496
|
-
const teardownEntry = () => {
|
|
497
|
-
if (closer) {
|
|
498
|
-
const idx = closers.indexOf(closer);
|
|
499
|
-
if (idx !== -1) closers.splice(idx, 1);
|
|
500
|
-
}
|
|
501
|
-
const wasConsumed = closer?.consumed ?? false;
|
|
502
|
-
closer = null;
|
|
503
|
-
if (pushed && !wasConsumed) {
|
|
504
|
-
pushed = false;
|
|
505
|
-
programmaticBack();
|
|
506
|
-
} else {
|
|
507
|
-
pushed = false;
|
|
508
|
-
}
|
|
509
|
-
};
|
|
510
|
-
const pushEntry = () => {
|
|
511
|
-
try {
|
|
512
|
-
if (deps.routedTo !== void 0) {
|
|
513
|
-
history.pushState({ __bsRouted: deps.sheetId }, "", deps.routedTo);
|
|
514
|
-
} else {
|
|
515
|
-
history.pushState({ __bsSheet: deps.sheetId }, "");
|
|
516
|
-
}
|
|
517
|
-
pushed = true;
|
|
518
|
-
} catch {
|
|
519
|
-
pushed = false;
|
|
520
|
-
}
|
|
521
|
-
};
|
|
650
|
+
let handle = null;
|
|
522
651
|
const onOpen = () => {
|
|
523
|
-
if (
|
|
524
|
-
|
|
652
|
+
if (handle) return;
|
|
653
|
+
handle = pushBackMarker({
|
|
525
654
|
isOpen: () => !deps.isDestroyed() && deps.getSize() > 0,
|
|
526
|
-
isTop:
|
|
527
|
-
close:
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
closer = self;
|
|
537
|
-
ensureHandler();
|
|
538
|
-
closers.push(self);
|
|
539
|
-
pushEntry();
|
|
655
|
+
isTop: deps.isTopSheet,
|
|
656
|
+
close: deps.close,
|
|
657
|
+
markerState: () => deps.routedTo !== void 0 ? { __bsRouted: deps.sheetId } : { __bsSheet: deps.sheetId },
|
|
658
|
+
url: deps.routedTo
|
|
659
|
+
});
|
|
660
|
+
};
|
|
661
|
+
const onClose = () => {
|
|
662
|
+
if (!handle) return;
|
|
663
|
+
popBackMarker(handle);
|
|
664
|
+
handle = null;
|
|
540
665
|
};
|
|
541
666
|
const unsubscribeOpen = deps.on("open", onOpen);
|
|
542
|
-
const unsubscribeClose = deps.on("close",
|
|
667
|
+
const unsubscribeClose = deps.on("close", onClose);
|
|
543
668
|
if (deps.getSize() > 0) onOpen();
|
|
544
669
|
return () => {
|
|
545
670
|
unsubscribeOpen();
|
|
546
671
|
unsubscribeClose();
|
|
547
|
-
|
|
672
|
+
if (handle) {
|
|
673
|
+
popBackMarker(handle);
|
|
674
|
+
handle = null;
|
|
675
|
+
}
|
|
548
676
|
};
|
|
549
677
|
}
|
|
550
678
|
function installRouteChange(deps) {
|
|
551
|
-
|
|
552
|
-
return () => {
|
|
553
|
-
};
|
|
554
|
-
}
|
|
555
|
-
const onChange = () => {
|
|
679
|
+
return subscribeRouteChange(() => {
|
|
556
680
|
if (deps.isDestroyed() || deps.getSize() <= 0) return;
|
|
557
681
|
void deps.close();
|
|
558
|
-
};
|
|
559
|
-
const wrap = (key) => {
|
|
560
|
-
const original = history[key];
|
|
561
|
-
const patched = function(...args) {
|
|
562
|
-
original.apply(this, args);
|
|
563
|
-
onChange();
|
|
564
|
-
};
|
|
565
|
-
history[key] = patched;
|
|
566
|
-
return () => {
|
|
567
|
-
if (history[key] === patched) {
|
|
568
|
-
history[key] = original;
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
};
|
|
572
|
-
window.addEventListener("popstate", onChange);
|
|
573
|
-
const restorePush = wrap("pushState");
|
|
574
|
-
const restoreReplace = wrap("replaceState");
|
|
575
|
-
return () => {
|
|
576
|
-
window.removeEventListener("popstate", onChange);
|
|
577
|
-
restorePush();
|
|
578
|
-
restoreReplace();
|
|
579
|
-
};
|
|
682
|
+
});
|
|
580
683
|
}
|
|
581
684
|
|
|
582
685
|
// src/core/features/content-swipe.ts
|
|
@@ -846,11 +949,15 @@ function createMaxHeightController(deps) {
|
|
|
846
949
|
|
|
847
950
|
// src/core/features/fit-measurement.ts
|
|
848
951
|
var measureSheetNatural = (element, content, vertical) => {
|
|
849
|
-
if (!content) {
|
|
850
|
-
return vertical ? element.offsetHeight : element.offsetWidth;
|
|
851
|
-
}
|
|
852
952
|
const axis = vertical ? "height" : "width";
|
|
853
953
|
const sheetStyle = element.style;
|
|
954
|
+
if (!content) {
|
|
955
|
+
const prev = sheetStyle[axis];
|
|
956
|
+
sheetStyle[axis] = "auto";
|
|
957
|
+
const poked2 = vertical ? element.offsetHeight : element.offsetWidth;
|
|
958
|
+
sheetStyle[axis] = prev;
|
|
959
|
+
return poked2;
|
|
960
|
+
}
|
|
854
961
|
const cs = content.style;
|
|
855
962
|
const prevSheet = sheetStyle[axis];
|
|
856
963
|
const prevFlex = cs.flex;
|
|
@@ -2430,7 +2537,7 @@ var matchesRange = (def, progress) => {
|
|
|
2430
2537
|
};
|
|
2431
2538
|
function installScrimStages(deps, opts) {
|
|
2432
2539
|
const doc = deps.host.ownerDocument;
|
|
2433
|
-
const
|
|
2540
|
+
const entries2 = opts.stages.map((def) => {
|
|
2434
2541
|
const wrapper = doc.createElement("div");
|
|
2435
2542
|
wrapper.className = "bs-scrim-stage";
|
|
2436
2543
|
const ws = wrapper.style;
|
|
@@ -2451,9 +2558,9 @@ function installScrimStages(deps, opts) {
|
|
|
2451
2558
|
const resolveActive = () => {
|
|
2452
2559
|
const state = deps.getState();
|
|
2453
2560
|
if (state.size === 0) {
|
|
2454
|
-
return
|
|
2561
|
+
return entries2.find((e) => matchesId(e.def, state.activeId)) ?? null;
|
|
2455
2562
|
}
|
|
2456
|
-
return
|
|
2563
|
+
return entries2.find((e) => matchesId(e.def, state.activeId)) ?? entries2.find((e) => matchesRange(e.def, state.progress)) ?? null;
|
|
2457
2564
|
};
|
|
2458
2565
|
const hide = (entry, animate) => {
|
|
2459
2566
|
entry.inFlight?.cancel();
|
|
@@ -2502,13 +2609,13 @@ function installScrimStages(deps, opts) {
|
|
|
2502
2609
|
deps.on("open", () => update(true)),
|
|
2503
2610
|
deps.on("close", () => update(true))
|
|
2504
2611
|
];
|
|
2505
|
-
if (
|
|
2612
|
+
if (entries2.some((e) => e.def.forRange)) {
|
|
2506
2613
|
offs.push(deps.on("progress", () => update(true)));
|
|
2507
2614
|
}
|
|
2508
2615
|
update(false);
|
|
2509
2616
|
return () => {
|
|
2510
2617
|
offs.forEach((off) => off());
|
|
2511
|
-
for (const entry of
|
|
2618
|
+
for (const entry of entries2) {
|
|
2512
2619
|
entry.inFlight?.cancel();
|
|
2513
2620
|
entry.inFlight = null;
|
|
2514
2621
|
if (entry.wrapper.parentNode) {
|
|
@@ -2767,17 +2874,12 @@ var BottomSheetEngine = class {
|
|
|
2767
2874
|
this.attach();
|
|
2768
2875
|
this.registerInStack();
|
|
2769
2876
|
if (this.snaps.getMaxAxisSize() === 0 && typeof IntersectionObserver !== "undefined" && typeof document !== "undefined") {
|
|
2770
|
-
const io = new IntersectionObserver((
|
|
2771
|
-
for (const entry of
|
|
2877
|
+
const io = new IntersectionObserver((entries2) => {
|
|
2878
|
+
for (const entry of entries2) {
|
|
2772
2879
|
if (!entry.isIntersecting) continue;
|
|
2773
2880
|
if (this.destroyed) return;
|
|
2774
2881
|
this.snaps.recompute();
|
|
2775
|
-
|
|
2776
|
-
if (current) {
|
|
2777
|
-
this.size = current.size;
|
|
2778
|
-
this.applySize(this.size);
|
|
2779
|
-
this.updateAriaSlider();
|
|
2780
|
-
}
|
|
2882
|
+
this.healActiveSnap();
|
|
2781
2883
|
io.disconnect();
|
|
2782
2884
|
return;
|
|
2783
2885
|
}
|
|
@@ -2941,6 +3043,8 @@ var BottomSheetEngine = class {
|
|
|
2941
3043
|
const vt = document.startViewTransition(() => {
|
|
2942
3044
|
this.applySize(target.size);
|
|
2943
3045
|
});
|
|
3046
|
+
vt.ready?.catch(() => {
|
|
3047
|
+
});
|
|
2944
3048
|
this.currentViewTransition = vt;
|
|
2945
3049
|
try {
|
|
2946
3050
|
await vt.finished;
|
|
@@ -3192,11 +3296,16 @@ var BottomSheetEngine = class {
|
|
|
3192
3296
|
this.maxHeight.clampTo();
|
|
3193
3297
|
this.scrim.invalidateOpacityCache();
|
|
3194
3298
|
if (this.gesture?.isDragging) return;
|
|
3299
|
+
this.healActiveSnap();
|
|
3300
|
+
}
|
|
3301
|
+
healActiveSnap() {
|
|
3195
3302
|
const current = this.snaps.findById(this.activeId);
|
|
3196
|
-
if (current)
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3303
|
+
if (!current) return;
|
|
3304
|
+
this.size = current.size;
|
|
3305
|
+
this.applySize(this.size);
|
|
3306
|
+
this.updateAriaSlider();
|
|
3307
|
+
if (this.size > 0 && !this.lifecycle.isInstalled && !this.opening && !this.animation.isAnimating) {
|
|
3308
|
+
this.emitOpenSequence(this.activeId);
|
|
3200
3309
|
}
|
|
3201
3310
|
}
|
|
3202
3311
|
destroy() {
|
|
@@ -3485,9 +3594,9 @@ var BottomSheetEngine = class {
|
|
|
3485
3594
|
return;
|
|
3486
3595
|
}
|
|
3487
3596
|
if (this.emitBeforeSnap(target, previousId)) {
|
|
3488
|
-
const
|
|
3489
|
-
if (
|
|
3490
|
-
void this.animation.animateTo(
|
|
3597
|
+
const restore2 = this.snaps.findById(previousId);
|
|
3598
|
+
if (restore2) {
|
|
3599
|
+
void this.animation.animateTo(restore2.size, 0);
|
|
3491
3600
|
}
|
|
3492
3601
|
return;
|
|
3493
3602
|
}
|
|
@@ -3793,7 +3902,7 @@ var OverlayEngine = class {
|
|
|
3793
3902
|
__publicField(this, "detachSwipe", null);
|
|
3794
3903
|
__publicField(this, "respectReducedMotionEnabled");
|
|
3795
3904
|
__publicField(this, "isTop", true);
|
|
3796
|
-
__publicField(this, "
|
|
3905
|
+
__publicField(this, "backMarker", null);
|
|
3797
3906
|
__publicField(this, "movedToTarget", false);
|
|
3798
3907
|
__publicField(this, "onOpenCb");
|
|
3799
3908
|
__publicField(this, "onCloseCb");
|
|
@@ -3805,7 +3914,6 @@ var OverlayEngine = class {
|
|
|
3805
3914
|
__publicField(this, "bus", createEventBus());
|
|
3806
3915
|
__publicField(this, "detachEscape", null);
|
|
3807
3916
|
__publicField(this, "detachBackdrop", null);
|
|
3808
|
-
__publicField(this, "detachHardwareBack", null);
|
|
3809
3917
|
__publicField(this, "releaseStackEntry", null);
|
|
3810
3918
|
__publicField(this, "lifecycle");
|
|
3811
3919
|
this.element = opts.element;
|
|
@@ -3959,7 +4067,10 @@ var OverlayEngine = class {
|
|
|
3959
4067
|
this.isOpen_ = false;
|
|
3960
4068
|
this.isAnimating_ = true;
|
|
3961
4069
|
sheetStack.update();
|
|
3962
|
-
this.
|
|
4070
|
+
if (reason !== "back" && this.backMarker) {
|
|
4071
|
+
popBackMarker(this.backMarker);
|
|
4072
|
+
}
|
|
4073
|
+
this.backMarker = null;
|
|
3963
4074
|
this.element.setAttribute("data-state", "exiting");
|
|
3964
4075
|
const dur = this.effectiveDuration();
|
|
3965
4076
|
const transitionStr = `transform ${dur}ms ${this.exitEasing}, opacity ${dur}ms ease-in`;
|
|
@@ -4017,6 +4128,10 @@ var OverlayEngine = class {
|
|
|
4017
4128
|
this.bus.clear();
|
|
4018
4129
|
this.setWillChange(false);
|
|
4019
4130
|
this.releaseInteractiveListeners();
|
|
4131
|
+
if (this.backMarker) {
|
|
4132
|
+
popBackMarker(this.backMarker);
|
|
4133
|
+
this.backMarker = null;
|
|
4134
|
+
}
|
|
4020
4135
|
this.releaseStackEntry?.();
|
|
4021
4136
|
this.releaseStackEntry = null;
|
|
4022
4137
|
const hadOriginalParent = this.originalParent !== null;
|
|
@@ -4178,19 +4293,6 @@ var OverlayEngine = class {
|
|
|
4178
4293
|
effectiveDuration() {
|
|
4179
4294
|
return this.respectReducedMotionEnabled && prefersReducedMotion() ? 0 : this.duration;
|
|
4180
4295
|
}
|
|
4181
|
-
popBackMarker(reason) {
|
|
4182
|
-
if (!this.backPushed) return;
|
|
4183
|
-
this.backPushed = false;
|
|
4184
|
-
if (reason === "back") return;
|
|
4185
|
-
const state = history.state;
|
|
4186
|
-
if (state && state.__bsOverlay === this.id) {
|
|
4187
|
-
try {
|
|
4188
|
-
history.back();
|
|
4189
|
-
} catch {
|
|
4190
|
-
return;
|
|
4191
|
-
}
|
|
4192
|
-
}
|
|
4193
|
-
}
|
|
4194
4296
|
resolvePeekPx(raw) {
|
|
4195
4297
|
if (typeof raw === "number") return Math.max(0, raw);
|
|
4196
4298
|
try {
|
|
@@ -4306,21 +4408,6 @@ var OverlayEngine = class {
|
|
|
4306
4408
|
this.backdrop.addEventListener("click", handler);
|
|
4307
4409
|
this.detachBackdrop = () => this.backdrop?.removeEventListener("click", handler);
|
|
4308
4410
|
}
|
|
4309
|
-
if (this.closeOnBackEnabled && typeof window !== "undefined" && !this.detachHardwareBack) {
|
|
4310
|
-
try {
|
|
4311
|
-
history.pushState({ __bsOverlay: this.id }, "");
|
|
4312
|
-
this.backPushed = true;
|
|
4313
|
-
} catch {
|
|
4314
|
-
}
|
|
4315
|
-
const onPop = () => {
|
|
4316
|
-
if (this.isOpen_ && this.isTop) {
|
|
4317
|
-
this.backPushed = false;
|
|
4318
|
-
void this.close("back");
|
|
4319
|
-
}
|
|
4320
|
-
};
|
|
4321
|
-
window.addEventListener("popstate", onPop);
|
|
4322
|
-
this.detachHardwareBack = () => window.removeEventListener("popstate", onPop);
|
|
4323
|
-
}
|
|
4324
4411
|
if (this.closeOnOutsidePointerEnabled && !this.detachOutsidePointer) {
|
|
4325
4412
|
const handler = (e) => {
|
|
4326
4413
|
if (!this.isOpen_) return;
|
|
@@ -4333,14 +4420,20 @@ var OverlayEngine = class {
|
|
|
4333
4420
|
document.addEventListener("pointerdown", handler, true);
|
|
4334
4421
|
this.detachOutsidePointer = () => document.removeEventListener("pointerdown", handler, true);
|
|
4335
4422
|
}
|
|
4423
|
+
if (this.closeOnBackEnabled && this.backMarker === null && typeof window !== "undefined") {
|
|
4424
|
+
this.backMarker = pushBackMarker({
|
|
4425
|
+
isOpen: () => this.isOpen_,
|
|
4426
|
+
isTop: () => this.isTop,
|
|
4427
|
+
close: () => this.close("back"),
|
|
4428
|
+
markerState: () => ({ __bsOverlay: this.id })
|
|
4429
|
+
});
|
|
4430
|
+
}
|
|
4336
4431
|
}
|
|
4337
4432
|
releaseInteractiveListeners() {
|
|
4338
4433
|
this.detachEscape?.();
|
|
4339
4434
|
this.detachEscape = null;
|
|
4340
4435
|
this.detachBackdrop?.();
|
|
4341
4436
|
this.detachBackdrop = null;
|
|
4342
|
-
this.detachHardwareBack?.();
|
|
4343
|
-
this.detachHardwareBack = null;
|
|
4344
4437
|
this.detachSwipe?.();
|
|
4345
4438
|
this.detachSwipe = null;
|
|
4346
4439
|
this.detachOutsidePointer?.();
|