@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/react.js
CHANGED
|
@@ -446,46 +446,202 @@ function notifyLinkedSheets(sheets, self) {
|
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
|
|
449
|
-
// src/core/features/
|
|
450
|
-
var
|
|
451
|
-
var
|
|
449
|
+
// src/core/features/history-coordinator.ts
|
|
450
|
+
var entries = [];
|
|
451
|
+
var subscribers = /* @__PURE__ */ new Set();
|
|
452
452
|
var suppress = 0;
|
|
453
|
-
var
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
453
|
+
var internalDepth = 0;
|
|
454
|
+
var pendingRebrand = null;
|
|
455
|
+
var listenerInstalled = false;
|
|
456
|
+
var patchInstalled = false;
|
|
457
|
+
var origPushState = null;
|
|
458
|
+
var origReplaceState = null;
|
|
459
|
+
var patchedPushState = null;
|
|
460
|
+
var patchedReplaceState = null;
|
|
461
|
+
var hasWindow = () => typeof window !== "undefined";
|
|
462
|
+
var hasHistory = () => typeof history !== "undefined";
|
|
463
|
+
var brandMarker = (surface) => ({
|
|
464
|
+
...surface.markerState(),
|
|
465
|
+
__bs: true
|
|
466
|
+
});
|
|
467
|
+
var runInternal = (fn) => {
|
|
468
|
+
internalDepth += 1;
|
|
469
|
+
try {
|
|
470
|
+
fn();
|
|
471
|
+
} finally {
|
|
472
|
+
internalDepth -= 1;
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
var notifyRouteChange = () => {
|
|
476
|
+
const snapshot = Array.from(subscribers);
|
|
477
|
+
for (const fn of snapshot) fn();
|
|
478
|
+
};
|
|
479
|
+
var ensureListener = () => {
|
|
480
|
+
if (listenerInstalled || !hasWindow()) return;
|
|
481
|
+
window.addEventListener("popstate", onPopState);
|
|
482
|
+
listenerInstalled = true;
|
|
483
|
+
};
|
|
484
|
+
var maybeTeardownListener = () => {
|
|
485
|
+
if (!listenerInstalled) return;
|
|
486
|
+
if (entries.length > 0 || subscribers.size > 0 || suppress > 0) return;
|
|
487
|
+
if (hasWindow()) window.removeEventListener("popstate", onPopState);
|
|
488
|
+
listenerInstalled = false;
|
|
489
|
+
};
|
|
490
|
+
var installPatch = () => {
|
|
491
|
+
if (patchInstalled || !hasHistory()) return;
|
|
492
|
+
origPushState = history.pushState;
|
|
493
|
+
origReplaceState = history.replaceState;
|
|
494
|
+
patchedPushState = function(...args) {
|
|
495
|
+
origPushState.apply(this, args);
|
|
496
|
+
if (internalDepth === 0) notifyRouteChange();
|
|
497
|
+
};
|
|
498
|
+
patchedReplaceState = function(...args) {
|
|
499
|
+
origReplaceState.apply(this, args);
|
|
500
|
+
if (internalDepth === 0) notifyRouteChange();
|
|
501
|
+
};
|
|
502
|
+
history.pushState = patchedPushState;
|
|
503
|
+
history.replaceState = patchedReplaceState;
|
|
504
|
+
patchInstalled = true;
|
|
505
|
+
};
|
|
506
|
+
var removePatch = () => {
|
|
507
|
+
if (!patchInstalled) return;
|
|
508
|
+
if (history.pushState === patchedPushState && origPushState) {
|
|
509
|
+
history.pushState = origPushState;
|
|
510
|
+
}
|
|
511
|
+
if (history.replaceState === patchedReplaceState && origReplaceState) {
|
|
512
|
+
history.replaceState = origReplaceState;
|
|
513
|
+
}
|
|
514
|
+
origPushState = null;
|
|
515
|
+
origReplaceState = null;
|
|
516
|
+
patchedPushState = null;
|
|
517
|
+
patchedReplaceState = null;
|
|
518
|
+
patchInstalled = false;
|
|
519
|
+
};
|
|
520
|
+
function onPopState() {
|
|
521
|
+
if (suppress > 0) {
|
|
522
|
+
suppress -= 1;
|
|
523
|
+
const rebrand = pendingRebrand;
|
|
524
|
+
pendingRebrand = null;
|
|
525
|
+
if (rebrand) rebrand();
|
|
526
|
+
maybeTeardownListener();
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
if (entries.length === 0) {
|
|
530
|
+
notifyRouteChange();
|
|
531
|
+
maybeTeardownListener();
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
let target = null;
|
|
535
|
+
let targetIdx = -1;
|
|
536
|
+
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
537
|
+
const entry = entries[i];
|
|
538
|
+
if (!entry.surface.isOpen()) continue;
|
|
539
|
+
if (!target) {
|
|
540
|
+
target = entry;
|
|
541
|
+
targetIdx = i;
|
|
460
542
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
if (!target) target = c;
|
|
466
|
-
if (c.isTop()) {
|
|
467
|
-
target = c;
|
|
468
|
-
break;
|
|
469
|
-
}
|
|
543
|
+
if (entry.surface.isTop()) {
|
|
544
|
+
target = entry;
|
|
545
|
+
targetIdx = i;
|
|
546
|
+
break;
|
|
470
547
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
const
|
|
474
|
-
if (
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
548
|
+
}
|
|
549
|
+
if (!target) {
|
|
550
|
+
const removed = entries.pop();
|
|
551
|
+
if (removed) removed.live = false;
|
|
552
|
+
maybeTeardownListener();
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
target.live = false;
|
|
556
|
+
entries.splice(targetIdx, 1);
|
|
557
|
+
const settled = target;
|
|
558
|
+
void Promise.resolve(settled.surface.close()).then(() => {
|
|
559
|
+
if (settled.surface.isOpen()) restore(settled);
|
|
479
560
|
});
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
561
|
+
maybeTeardownListener();
|
|
562
|
+
}
|
|
563
|
+
function restore(entry) {
|
|
564
|
+
if (!hasWindow() || !hasHistory()) return;
|
|
565
|
+
entry.live = true;
|
|
566
|
+
runInternal(() => {
|
|
567
|
+
try {
|
|
568
|
+
history.pushState(brandMarker(entry.surface), "", entry.surface.url);
|
|
569
|
+
} catch {
|
|
570
|
+
entry.live = false;
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
if (entry.live) {
|
|
574
|
+
entries.push(entry);
|
|
575
|
+
ensureListener();
|
|
487
576
|
}
|
|
488
|
-
}
|
|
577
|
+
}
|
|
578
|
+
function pushBackMarker(surface) {
|
|
579
|
+
const entry = { surface, priorUrl: void 0, live: false };
|
|
580
|
+
if (!hasWindow() || !hasHistory()) {
|
|
581
|
+
return entry;
|
|
582
|
+
}
|
|
583
|
+
entry.priorUrl = surface.url !== void 0 ? location.href : void 0;
|
|
584
|
+
runInternal(() => {
|
|
585
|
+
try {
|
|
586
|
+
history.pushState(brandMarker(surface), "", surface.url);
|
|
587
|
+
entry.live = true;
|
|
588
|
+
} catch {
|
|
589
|
+
entry.live = false;
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
if (entry.live) {
|
|
593
|
+
entries.push(entry);
|
|
594
|
+
ensureListener();
|
|
595
|
+
}
|
|
596
|
+
return entry;
|
|
597
|
+
}
|
|
598
|
+
function popBackMarker(handle) {
|
|
599
|
+
if (!hasWindow() || !hasHistory()) return;
|
|
600
|
+
const entry = handle;
|
|
601
|
+
const idx = entries.indexOf(entry);
|
|
602
|
+
if (idx === -1 || !entry.live) return;
|
|
603
|
+
const last = entries.length - 1;
|
|
604
|
+
entry.live = false;
|
|
605
|
+
entries.splice(idx, 1);
|
|
606
|
+
if (idx !== last) {
|
|
607
|
+
const rebrandSurface = entries[entries.length - 1].surface;
|
|
608
|
+
const rebrandUrl = entry.priorUrl;
|
|
609
|
+
pendingRebrand = () => {
|
|
610
|
+
runInternal(() => {
|
|
611
|
+
history.replaceState(
|
|
612
|
+
brandMarker(rebrandSurface),
|
|
613
|
+
"",
|
|
614
|
+
rebrandUrl !== void 0 ? rebrandUrl : location.href
|
|
615
|
+
);
|
|
616
|
+
});
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
suppress += 1;
|
|
620
|
+
runInternal(() => {
|
|
621
|
+
try {
|
|
622
|
+
history.back();
|
|
623
|
+
} catch {
|
|
624
|
+
suppress = Math.max(0, suppress - 1);
|
|
625
|
+
pendingRebrand = null;
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
maybeTeardownListener();
|
|
629
|
+
}
|
|
630
|
+
function subscribeRouteChange(fn) {
|
|
631
|
+
if (!hasWindow() || !hasHistory()) return () => {
|
|
632
|
+
};
|
|
633
|
+
subscribers.add(fn);
|
|
634
|
+
if (subscribers.size === 1) installPatch();
|
|
635
|
+
ensureListener();
|
|
636
|
+
return () => {
|
|
637
|
+
if (!subscribers.has(fn)) return;
|
|
638
|
+
subscribers.delete(fn);
|
|
639
|
+
if (subscribers.size === 0) removePatch();
|
|
640
|
+
maybeTeardownListener();
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// src/core/features/route.ts
|
|
489
645
|
function installRoute(deps) {
|
|
490
646
|
if (typeof window === "undefined") {
|
|
491
647
|
return () => {
|
|
@@ -495,92 +651,39 @@ function installRoute(deps) {
|
|
|
495
651
|
return () => {
|
|
496
652
|
};
|
|
497
653
|
}
|
|
498
|
-
let
|
|
499
|
-
let closer = null;
|
|
500
|
-
const teardownEntry = () => {
|
|
501
|
-
if (closer) {
|
|
502
|
-
const idx = closers.indexOf(closer);
|
|
503
|
-
if (idx !== -1) closers.splice(idx, 1);
|
|
504
|
-
}
|
|
505
|
-
const wasConsumed = closer?.consumed ?? false;
|
|
506
|
-
closer = null;
|
|
507
|
-
if (pushed && !wasConsumed) {
|
|
508
|
-
pushed = false;
|
|
509
|
-
programmaticBack();
|
|
510
|
-
} else {
|
|
511
|
-
pushed = false;
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
const pushEntry = () => {
|
|
515
|
-
try {
|
|
516
|
-
if (deps.routedTo !== void 0) {
|
|
517
|
-
history.pushState({ __bsRouted: deps.sheetId }, "", deps.routedTo);
|
|
518
|
-
} else {
|
|
519
|
-
history.pushState({ __bsSheet: deps.sheetId }, "");
|
|
520
|
-
}
|
|
521
|
-
pushed = true;
|
|
522
|
-
} catch {
|
|
523
|
-
pushed = false;
|
|
524
|
-
}
|
|
525
|
-
};
|
|
654
|
+
let handle = null;
|
|
526
655
|
const onOpen = () => {
|
|
527
|
-
if (
|
|
528
|
-
|
|
656
|
+
if (handle) return;
|
|
657
|
+
handle = pushBackMarker({
|
|
529
658
|
isOpen: () => !deps.isDestroyed() && deps.getSize() > 0,
|
|
530
|
-
isTop:
|
|
531
|
-
close:
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
closer = self;
|
|
541
|
-
ensureHandler();
|
|
542
|
-
closers.push(self);
|
|
543
|
-
pushEntry();
|
|
659
|
+
isTop: deps.isTopSheet,
|
|
660
|
+
close: deps.close,
|
|
661
|
+
markerState: () => deps.routedTo !== void 0 ? { __bsRouted: deps.sheetId } : { __bsSheet: deps.sheetId },
|
|
662
|
+
url: deps.routedTo
|
|
663
|
+
});
|
|
664
|
+
};
|
|
665
|
+
const onClose = () => {
|
|
666
|
+
if (!handle) return;
|
|
667
|
+
popBackMarker(handle);
|
|
668
|
+
handle = null;
|
|
544
669
|
};
|
|
545
670
|
const unsubscribeOpen = deps.on("open", onOpen);
|
|
546
|
-
const unsubscribeClose = deps.on("close",
|
|
671
|
+
const unsubscribeClose = deps.on("close", onClose);
|
|
547
672
|
if (deps.getSize() > 0) onOpen();
|
|
548
673
|
return () => {
|
|
549
674
|
unsubscribeOpen();
|
|
550
675
|
unsubscribeClose();
|
|
551
|
-
|
|
676
|
+
if (handle) {
|
|
677
|
+
popBackMarker(handle);
|
|
678
|
+
handle = null;
|
|
679
|
+
}
|
|
552
680
|
};
|
|
553
681
|
}
|
|
554
682
|
function installRouteChange(deps) {
|
|
555
|
-
|
|
556
|
-
return () => {
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
const onChange = () => {
|
|
683
|
+
return subscribeRouteChange(() => {
|
|
560
684
|
if (deps.isDestroyed() || deps.getSize() <= 0) return;
|
|
561
685
|
void deps.close();
|
|
562
|
-
};
|
|
563
|
-
const wrap = (key) => {
|
|
564
|
-
const original = history[key];
|
|
565
|
-
const patched = function(...args) {
|
|
566
|
-
original.apply(this, args);
|
|
567
|
-
onChange();
|
|
568
|
-
};
|
|
569
|
-
history[key] = patched;
|
|
570
|
-
return () => {
|
|
571
|
-
if (history[key] === patched) {
|
|
572
|
-
history[key] = original;
|
|
573
|
-
}
|
|
574
|
-
};
|
|
575
|
-
};
|
|
576
|
-
window.addEventListener("popstate", onChange);
|
|
577
|
-
const restorePush = wrap("pushState");
|
|
578
|
-
const restoreReplace = wrap("replaceState");
|
|
579
|
-
return () => {
|
|
580
|
-
window.removeEventListener("popstate", onChange);
|
|
581
|
-
restorePush();
|
|
582
|
-
restoreReplace();
|
|
583
|
-
};
|
|
686
|
+
});
|
|
584
687
|
}
|
|
585
688
|
|
|
586
689
|
// src/core/features/content-swipe.ts
|
|
@@ -850,11 +953,15 @@ function createMaxHeightController(deps) {
|
|
|
850
953
|
|
|
851
954
|
// src/core/features/fit-measurement.ts
|
|
852
955
|
var measureSheetNatural = (element, content, vertical) => {
|
|
853
|
-
if (!content) {
|
|
854
|
-
return vertical ? element.offsetHeight : element.offsetWidth;
|
|
855
|
-
}
|
|
856
956
|
const axis = vertical ? "height" : "width";
|
|
857
957
|
const sheetStyle = element.style;
|
|
958
|
+
if (!content) {
|
|
959
|
+
const prev = sheetStyle[axis];
|
|
960
|
+
sheetStyle[axis] = "auto";
|
|
961
|
+
const poked2 = vertical ? element.offsetHeight : element.offsetWidth;
|
|
962
|
+
sheetStyle[axis] = prev;
|
|
963
|
+
return poked2;
|
|
964
|
+
}
|
|
858
965
|
const cs = content.style;
|
|
859
966
|
const prevSheet = sheetStyle[axis];
|
|
860
967
|
const prevFlex = cs.flex;
|
|
@@ -2433,7 +2540,7 @@ var matchesRange = (def, progress) => {
|
|
|
2433
2540
|
};
|
|
2434
2541
|
function installScrimStages(deps, opts) {
|
|
2435
2542
|
const doc = deps.host.ownerDocument;
|
|
2436
|
-
const
|
|
2543
|
+
const entries2 = opts.stages.map((def) => {
|
|
2437
2544
|
const wrapper = doc.createElement("div");
|
|
2438
2545
|
wrapper.className = "bs-scrim-stage";
|
|
2439
2546
|
const ws = wrapper.style;
|
|
@@ -2454,9 +2561,9 @@ function installScrimStages(deps, opts) {
|
|
|
2454
2561
|
const resolveActive = () => {
|
|
2455
2562
|
const state = deps.getState();
|
|
2456
2563
|
if (state.size === 0) {
|
|
2457
|
-
return
|
|
2564
|
+
return entries2.find((e) => matchesId(e.def, state.activeId)) ?? null;
|
|
2458
2565
|
}
|
|
2459
|
-
return
|
|
2566
|
+
return entries2.find((e) => matchesId(e.def, state.activeId)) ?? entries2.find((e) => matchesRange(e.def, state.progress)) ?? null;
|
|
2460
2567
|
};
|
|
2461
2568
|
const hide = (entry, animate) => {
|
|
2462
2569
|
entry.inFlight?.cancel();
|
|
@@ -2505,13 +2612,13 @@ function installScrimStages(deps, opts) {
|
|
|
2505
2612
|
deps.on("open", () => update(true)),
|
|
2506
2613
|
deps.on("close", () => update(true))
|
|
2507
2614
|
];
|
|
2508
|
-
if (
|
|
2615
|
+
if (entries2.some((e) => e.def.forRange)) {
|
|
2509
2616
|
offs.push(deps.on("progress", () => update(true)));
|
|
2510
2617
|
}
|
|
2511
2618
|
update(false);
|
|
2512
2619
|
return () => {
|
|
2513
2620
|
offs.forEach((off) => off());
|
|
2514
|
-
for (const entry of
|
|
2621
|
+
for (const entry of entries2) {
|
|
2515
2622
|
entry.inFlight?.cancel();
|
|
2516
2623
|
entry.inFlight = null;
|
|
2517
2624
|
if (entry.wrapper.parentNode) {
|
|
@@ -2770,17 +2877,12 @@ var BottomSheetEngine = class {
|
|
|
2770
2877
|
this.attach();
|
|
2771
2878
|
this.registerInStack();
|
|
2772
2879
|
if (this.snaps.getMaxAxisSize() === 0 && typeof IntersectionObserver !== "undefined" && typeof document !== "undefined") {
|
|
2773
|
-
const io = new IntersectionObserver((
|
|
2774
|
-
for (const entry of
|
|
2880
|
+
const io = new IntersectionObserver((entries2) => {
|
|
2881
|
+
for (const entry of entries2) {
|
|
2775
2882
|
if (!entry.isIntersecting) continue;
|
|
2776
2883
|
if (this.destroyed) return;
|
|
2777
2884
|
this.snaps.recompute();
|
|
2778
|
-
|
|
2779
|
-
if (current) {
|
|
2780
|
-
this.size = current.size;
|
|
2781
|
-
this.applySize(this.size);
|
|
2782
|
-
this.updateAriaSlider();
|
|
2783
|
-
}
|
|
2885
|
+
this.healActiveSnap();
|
|
2784
2886
|
io.disconnect();
|
|
2785
2887
|
return;
|
|
2786
2888
|
}
|
|
@@ -2944,6 +3046,8 @@ var BottomSheetEngine = class {
|
|
|
2944
3046
|
const vt = document.startViewTransition(() => {
|
|
2945
3047
|
this.applySize(target.size);
|
|
2946
3048
|
});
|
|
3049
|
+
vt.ready?.catch(() => {
|
|
3050
|
+
});
|
|
2947
3051
|
this.currentViewTransition = vt;
|
|
2948
3052
|
try {
|
|
2949
3053
|
await vt.finished;
|
|
@@ -3195,11 +3299,16 @@ var BottomSheetEngine = class {
|
|
|
3195
3299
|
this.maxHeight.clampTo();
|
|
3196
3300
|
this.scrim.invalidateOpacityCache();
|
|
3197
3301
|
if (this.gesture?.isDragging) return;
|
|
3302
|
+
this.healActiveSnap();
|
|
3303
|
+
}
|
|
3304
|
+
healActiveSnap() {
|
|
3198
3305
|
const current = this.snaps.findById(this.activeId);
|
|
3199
|
-
if (current)
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3306
|
+
if (!current) return;
|
|
3307
|
+
this.size = current.size;
|
|
3308
|
+
this.applySize(this.size);
|
|
3309
|
+
this.updateAriaSlider();
|
|
3310
|
+
if (this.size > 0 && !this.lifecycle.isInstalled && !this.opening && !this.animation.isAnimating) {
|
|
3311
|
+
this.emitOpenSequence(this.activeId);
|
|
3203
3312
|
}
|
|
3204
3313
|
}
|
|
3205
3314
|
destroy() {
|
|
@@ -3488,9 +3597,9 @@ var BottomSheetEngine = class {
|
|
|
3488
3597
|
return;
|
|
3489
3598
|
}
|
|
3490
3599
|
if (this.emitBeforeSnap(target, previousId)) {
|
|
3491
|
-
const
|
|
3492
|
-
if (
|
|
3493
|
-
void this.animation.animateTo(
|
|
3600
|
+
const restore2 = this.snaps.findById(previousId);
|
|
3601
|
+
if (restore2) {
|
|
3602
|
+
void this.animation.animateTo(restore2.size, 0);
|
|
3494
3603
|
}
|
|
3495
3604
|
return;
|
|
3496
3605
|
}
|
|
@@ -4327,7 +4436,7 @@ var OverlayEngine = class {
|
|
|
4327
4436
|
__publicField(this, "detachSwipe", null);
|
|
4328
4437
|
__publicField(this, "respectReducedMotionEnabled");
|
|
4329
4438
|
__publicField(this, "isTop", true);
|
|
4330
|
-
__publicField(this, "
|
|
4439
|
+
__publicField(this, "backMarker", null);
|
|
4331
4440
|
__publicField(this, "movedToTarget", false);
|
|
4332
4441
|
__publicField(this, "onOpenCb");
|
|
4333
4442
|
__publicField(this, "onCloseCb");
|
|
@@ -4339,7 +4448,6 @@ var OverlayEngine = class {
|
|
|
4339
4448
|
__publicField(this, "bus", createEventBus());
|
|
4340
4449
|
__publicField(this, "detachEscape", null);
|
|
4341
4450
|
__publicField(this, "detachBackdrop", null);
|
|
4342
|
-
__publicField(this, "detachHardwareBack", null);
|
|
4343
4451
|
__publicField(this, "releaseStackEntry", null);
|
|
4344
4452
|
__publicField(this, "lifecycle");
|
|
4345
4453
|
this.element = opts.element;
|
|
@@ -4493,7 +4601,10 @@ var OverlayEngine = class {
|
|
|
4493
4601
|
this.isOpen_ = false;
|
|
4494
4602
|
this.isAnimating_ = true;
|
|
4495
4603
|
sheetStack.update();
|
|
4496
|
-
this.
|
|
4604
|
+
if (reason !== "back" && this.backMarker) {
|
|
4605
|
+
popBackMarker(this.backMarker);
|
|
4606
|
+
}
|
|
4607
|
+
this.backMarker = null;
|
|
4497
4608
|
this.element.setAttribute("data-state", "exiting");
|
|
4498
4609
|
const dur = this.effectiveDuration();
|
|
4499
4610
|
const transitionStr = `transform ${dur}ms ${this.exitEasing}, opacity ${dur}ms ease-in`;
|
|
@@ -4551,6 +4662,10 @@ var OverlayEngine = class {
|
|
|
4551
4662
|
this.bus.clear();
|
|
4552
4663
|
this.setWillChange(false);
|
|
4553
4664
|
this.releaseInteractiveListeners();
|
|
4665
|
+
if (this.backMarker) {
|
|
4666
|
+
popBackMarker(this.backMarker);
|
|
4667
|
+
this.backMarker = null;
|
|
4668
|
+
}
|
|
4554
4669
|
this.releaseStackEntry?.();
|
|
4555
4670
|
this.releaseStackEntry = null;
|
|
4556
4671
|
const hadOriginalParent = this.originalParent !== null;
|
|
@@ -4712,19 +4827,6 @@ var OverlayEngine = class {
|
|
|
4712
4827
|
effectiveDuration() {
|
|
4713
4828
|
return this.respectReducedMotionEnabled && prefersReducedMotion() ? 0 : this.duration;
|
|
4714
4829
|
}
|
|
4715
|
-
popBackMarker(reason) {
|
|
4716
|
-
if (!this.backPushed) return;
|
|
4717
|
-
this.backPushed = false;
|
|
4718
|
-
if (reason === "back") return;
|
|
4719
|
-
const state = history.state;
|
|
4720
|
-
if (state && state.__bsOverlay === this.id) {
|
|
4721
|
-
try {
|
|
4722
|
-
history.back();
|
|
4723
|
-
} catch {
|
|
4724
|
-
return;
|
|
4725
|
-
}
|
|
4726
|
-
}
|
|
4727
|
-
}
|
|
4728
4830
|
resolvePeekPx(raw) {
|
|
4729
4831
|
if (typeof raw === "number") return Math.max(0, raw);
|
|
4730
4832
|
try {
|
|
@@ -4840,21 +4942,6 @@ var OverlayEngine = class {
|
|
|
4840
4942
|
this.backdrop.addEventListener("click", handler);
|
|
4841
4943
|
this.detachBackdrop = () => this.backdrop?.removeEventListener("click", handler);
|
|
4842
4944
|
}
|
|
4843
|
-
if (this.closeOnBackEnabled && typeof window !== "undefined" && !this.detachHardwareBack) {
|
|
4844
|
-
try {
|
|
4845
|
-
history.pushState({ __bsOverlay: this.id }, "");
|
|
4846
|
-
this.backPushed = true;
|
|
4847
|
-
} catch {
|
|
4848
|
-
}
|
|
4849
|
-
const onPop = () => {
|
|
4850
|
-
if (this.isOpen_ && this.isTop) {
|
|
4851
|
-
this.backPushed = false;
|
|
4852
|
-
void this.close("back");
|
|
4853
|
-
}
|
|
4854
|
-
};
|
|
4855
|
-
window.addEventListener("popstate", onPop);
|
|
4856
|
-
this.detachHardwareBack = () => window.removeEventListener("popstate", onPop);
|
|
4857
|
-
}
|
|
4858
4945
|
if (this.closeOnOutsidePointerEnabled && !this.detachOutsidePointer) {
|
|
4859
4946
|
const handler = (e) => {
|
|
4860
4947
|
if (!this.isOpen_) return;
|
|
@@ -4867,14 +4954,20 @@ var OverlayEngine = class {
|
|
|
4867
4954
|
document.addEventListener("pointerdown", handler, true);
|
|
4868
4955
|
this.detachOutsidePointer = () => document.removeEventListener("pointerdown", handler, true);
|
|
4869
4956
|
}
|
|
4957
|
+
if (this.closeOnBackEnabled && this.backMarker === null && typeof window !== "undefined") {
|
|
4958
|
+
this.backMarker = pushBackMarker({
|
|
4959
|
+
isOpen: () => this.isOpen_,
|
|
4960
|
+
isTop: () => this.isTop,
|
|
4961
|
+
close: () => this.close("back"),
|
|
4962
|
+
markerState: () => ({ __bsOverlay: this.id })
|
|
4963
|
+
});
|
|
4964
|
+
}
|
|
4870
4965
|
}
|
|
4871
4966
|
releaseInteractiveListeners() {
|
|
4872
4967
|
this.detachEscape?.();
|
|
4873
4968
|
this.detachEscape = null;
|
|
4874
4969
|
this.detachBackdrop?.();
|
|
4875
4970
|
this.detachBackdrop = null;
|
|
4876
|
-
this.detachHardwareBack?.();
|
|
4877
|
-
this.detachHardwareBack = null;
|
|
4878
4971
|
this.detachSwipe?.();
|
|
4879
4972
|
this.detachSwipe = null;
|
|
4880
4973
|
this.detachOutsidePointer?.();
|