@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.cjs
CHANGED
|
@@ -444,46 +444,202 @@ function notifyLinkedSheets(sheets, self) {
|
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
// src/core/features/
|
|
448
|
-
var
|
|
449
|
-
var
|
|
447
|
+
// src/core/features/history-coordinator.ts
|
|
448
|
+
var entries = [];
|
|
449
|
+
var subscribers = /* @__PURE__ */ new Set();
|
|
450
450
|
var suppress = 0;
|
|
451
|
-
var
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
451
|
+
var internalDepth = 0;
|
|
452
|
+
var pendingRebrand = null;
|
|
453
|
+
var listenerInstalled = false;
|
|
454
|
+
var patchInstalled = false;
|
|
455
|
+
var origPushState = null;
|
|
456
|
+
var origReplaceState = null;
|
|
457
|
+
var patchedPushState = null;
|
|
458
|
+
var patchedReplaceState = null;
|
|
459
|
+
var hasWindow = () => typeof window !== "undefined";
|
|
460
|
+
var hasHistory = () => typeof history !== "undefined";
|
|
461
|
+
var brandMarker = (surface) => ({
|
|
462
|
+
...surface.markerState(),
|
|
463
|
+
__bs: true
|
|
464
|
+
});
|
|
465
|
+
var runInternal = (fn) => {
|
|
466
|
+
internalDepth += 1;
|
|
467
|
+
try {
|
|
468
|
+
fn();
|
|
469
|
+
} finally {
|
|
470
|
+
internalDepth -= 1;
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
var notifyRouteChange = () => {
|
|
474
|
+
const snapshot = Array.from(subscribers);
|
|
475
|
+
for (const fn of snapshot) fn();
|
|
476
|
+
};
|
|
477
|
+
var ensureListener = () => {
|
|
478
|
+
if (listenerInstalled || !hasWindow()) return;
|
|
479
|
+
window.addEventListener("popstate", onPopState);
|
|
480
|
+
listenerInstalled = true;
|
|
481
|
+
};
|
|
482
|
+
var maybeTeardownListener = () => {
|
|
483
|
+
if (!listenerInstalled) return;
|
|
484
|
+
if (entries.length > 0 || subscribers.size > 0 || suppress > 0) return;
|
|
485
|
+
if (hasWindow()) window.removeEventListener("popstate", onPopState);
|
|
486
|
+
listenerInstalled = false;
|
|
487
|
+
};
|
|
488
|
+
var installPatch = () => {
|
|
489
|
+
if (patchInstalled || !hasHistory()) return;
|
|
490
|
+
origPushState = history.pushState;
|
|
491
|
+
origReplaceState = history.replaceState;
|
|
492
|
+
patchedPushState = function(...args) {
|
|
493
|
+
origPushState.apply(this, args);
|
|
494
|
+
if (internalDepth === 0) notifyRouteChange();
|
|
495
|
+
};
|
|
496
|
+
patchedReplaceState = function(...args) {
|
|
497
|
+
origReplaceState.apply(this, args);
|
|
498
|
+
if (internalDepth === 0) notifyRouteChange();
|
|
499
|
+
};
|
|
500
|
+
history.pushState = patchedPushState;
|
|
501
|
+
history.replaceState = patchedReplaceState;
|
|
502
|
+
patchInstalled = true;
|
|
503
|
+
};
|
|
504
|
+
var removePatch = () => {
|
|
505
|
+
if (!patchInstalled) return;
|
|
506
|
+
if (history.pushState === patchedPushState && origPushState) {
|
|
507
|
+
history.pushState = origPushState;
|
|
508
|
+
}
|
|
509
|
+
if (history.replaceState === patchedReplaceState && origReplaceState) {
|
|
510
|
+
history.replaceState = origReplaceState;
|
|
511
|
+
}
|
|
512
|
+
origPushState = null;
|
|
513
|
+
origReplaceState = null;
|
|
514
|
+
patchedPushState = null;
|
|
515
|
+
patchedReplaceState = null;
|
|
516
|
+
patchInstalled = false;
|
|
517
|
+
};
|
|
518
|
+
function onPopState() {
|
|
519
|
+
if (suppress > 0) {
|
|
520
|
+
suppress -= 1;
|
|
521
|
+
const rebrand = pendingRebrand;
|
|
522
|
+
pendingRebrand = null;
|
|
523
|
+
if (rebrand) rebrand();
|
|
524
|
+
maybeTeardownListener();
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
if (entries.length === 0) {
|
|
528
|
+
notifyRouteChange();
|
|
529
|
+
maybeTeardownListener();
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
let target = null;
|
|
533
|
+
let targetIdx = -1;
|
|
534
|
+
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
535
|
+
const entry = entries[i];
|
|
536
|
+
if (!entry.surface.isOpen()) continue;
|
|
537
|
+
if (!target) {
|
|
538
|
+
target = entry;
|
|
539
|
+
targetIdx = i;
|
|
458
540
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
if (!target) target = c;
|
|
464
|
-
if (c.isTop()) {
|
|
465
|
-
target = c;
|
|
466
|
-
break;
|
|
467
|
-
}
|
|
541
|
+
if (entry.surface.isTop()) {
|
|
542
|
+
target = entry;
|
|
543
|
+
targetIdx = i;
|
|
544
|
+
break;
|
|
468
545
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
546
|
+
}
|
|
547
|
+
if (!target) {
|
|
548
|
+
const removed = entries.pop();
|
|
549
|
+
if (removed) removed.live = false;
|
|
550
|
+
maybeTeardownListener();
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
target.live = false;
|
|
554
|
+
entries.splice(targetIdx, 1);
|
|
555
|
+
const settled = target;
|
|
556
|
+
void Promise.resolve(settled.surface.close()).then(() => {
|
|
557
|
+
if (settled.surface.isOpen()) restore(settled);
|
|
477
558
|
});
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
559
|
+
maybeTeardownListener();
|
|
560
|
+
}
|
|
561
|
+
function restore(entry) {
|
|
562
|
+
if (!hasWindow() || !hasHistory()) return;
|
|
563
|
+
entry.live = true;
|
|
564
|
+
runInternal(() => {
|
|
565
|
+
try {
|
|
566
|
+
history.pushState(brandMarker(entry.surface), "", entry.surface.url);
|
|
567
|
+
} catch {
|
|
568
|
+
entry.live = false;
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
if (entry.live) {
|
|
572
|
+
entries.push(entry);
|
|
573
|
+
ensureListener();
|
|
485
574
|
}
|
|
486
|
-
}
|
|
575
|
+
}
|
|
576
|
+
function pushBackMarker(surface) {
|
|
577
|
+
const entry = { surface, priorUrl: void 0, live: false };
|
|
578
|
+
if (!hasWindow() || !hasHistory()) {
|
|
579
|
+
return entry;
|
|
580
|
+
}
|
|
581
|
+
entry.priorUrl = surface.url !== void 0 ? location.href : void 0;
|
|
582
|
+
runInternal(() => {
|
|
583
|
+
try {
|
|
584
|
+
history.pushState(brandMarker(surface), "", surface.url);
|
|
585
|
+
entry.live = true;
|
|
586
|
+
} catch {
|
|
587
|
+
entry.live = false;
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
if (entry.live) {
|
|
591
|
+
entries.push(entry);
|
|
592
|
+
ensureListener();
|
|
593
|
+
}
|
|
594
|
+
return entry;
|
|
595
|
+
}
|
|
596
|
+
function popBackMarker(handle) {
|
|
597
|
+
if (!hasWindow() || !hasHistory()) return;
|
|
598
|
+
const entry = handle;
|
|
599
|
+
const idx = entries.indexOf(entry);
|
|
600
|
+
if (idx === -1 || !entry.live) return;
|
|
601
|
+
const last = entries.length - 1;
|
|
602
|
+
entry.live = false;
|
|
603
|
+
entries.splice(idx, 1);
|
|
604
|
+
if (idx !== last) {
|
|
605
|
+
const rebrandSurface = entries[entries.length - 1].surface;
|
|
606
|
+
const rebrandUrl = entry.priorUrl;
|
|
607
|
+
pendingRebrand = () => {
|
|
608
|
+
runInternal(() => {
|
|
609
|
+
history.replaceState(
|
|
610
|
+
brandMarker(rebrandSurface),
|
|
611
|
+
"",
|
|
612
|
+
rebrandUrl !== void 0 ? rebrandUrl : location.href
|
|
613
|
+
);
|
|
614
|
+
});
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
suppress += 1;
|
|
618
|
+
runInternal(() => {
|
|
619
|
+
try {
|
|
620
|
+
history.back();
|
|
621
|
+
} catch {
|
|
622
|
+
suppress = Math.max(0, suppress - 1);
|
|
623
|
+
pendingRebrand = null;
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
maybeTeardownListener();
|
|
627
|
+
}
|
|
628
|
+
function subscribeRouteChange(fn) {
|
|
629
|
+
if (!hasWindow() || !hasHistory()) return () => {
|
|
630
|
+
};
|
|
631
|
+
subscribers.add(fn);
|
|
632
|
+
if (subscribers.size === 1) installPatch();
|
|
633
|
+
ensureListener();
|
|
634
|
+
return () => {
|
|
635
|
+
if (!subscribers.has(fn)) return;
|
|
636
|
+
subscribers.delete(fn);
|
|
637
|
+
if (subscribers.size === 0) removePatch();
|
|
638
|
+
maybeTeardownListener();
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// src/core/features/route.ts
|
|
487
643
|
function installRoute(deps) {
|
|
488
644
|
if (typeof window === "undefined") {
|
|
489
645
|
return () => {
|
|
@@ -493,92 +649,39 @@ function installRoute(deps) {
|
|
|
493
649
|
return () => {
|
|
494
650
|
};
|
|
495
651
|
}
|
|
496
|
-
let
|
|
497
|
-
let closer = null;
|
|
498
|
-
const teardownEntry = () => {
|
|
499
|
-
if (closer) {
|
|
500
|
-
const idx = closers.indexOf(closer);
|
|
501
|
-
if (idx !== -1) closers.splice(idx, 1);
|
|
502
|
-
}
|
|
503
|
-
const wasConsumed = closer?.consumed ?? false;
|
|
504
|
-
closer = null;
|
|
505
|
-
if (pushed && !wasConsumed) {
|
|
506
|
-
pushed = false;
|
|
507
|
-
programmaticBack();
|
|
508
|
-
} else {
|
|
509
|
-
pushed = false;
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
const pushEntry = () => {
|
|
513
|
-
try {
|
|
514
|
-
if (deps.routedTo !== void 0) {
|
|
515
|
-
history.pushState({ __bsRouted: deps.sheetId }, "", deps.routedTo);
|
|
516
|
-
} else {
|
|
517
|
-
history.pushState({ __bsSheet: deps.sheetId }, "");
|
|
518
|
-
}
|
|
519
|
-
pushed = true;
|
|
520
|
-
} catch {
|
|
521
|
-
pushed = false;
|
|
522
|
-
}
|
|
523
|
-
};
|
|
652
|
+
let handle = null;
|
|
524
653
|
const onOpen = () => {
|
|
525
|
-
if (
|
|
526
|
-
|
|
654
|
+
if (handle) return;
|
|
655
|
+
handle = pushBackMarker({
|
|
527
656
|
isOpen: () => !deps.isDestroyed() && deps.getSize() > 0,
|
|
528
|
-
isTop:
|
|
529
|
-
close:
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
closer = self;
|
|
539
|
-
ensureHandler();
|
|
540
|
-
closers.push(self);
|
|
541
|
-
pushEntry();
|
|
657
|
+
isTop: deps.isTopSheet,
|
|
658
|
+
close: deps.close,
|
|
659
|
+
markerState: () => deps.routedTo !== void 0 ? { __bsRouted: deps.sheetId } : { __bsSheet: deps.sheetId },
|
|
660
|
+
url: deps.routedTo
|
|
661
|
+
});
|
|
662
|
+
};
|
|
663
|
+
const onClose = () => {
|
|
664
|
+
if (!handle) return;
|
|
665
|
+
popBackMarker(handle);
|
|
666
|
+
handle = null;
|
|
542
667
|
};
|
|
543
668
|
const unsubscribeOpen = deps.on("open", onOpen);
|
|
544
|
-
const unsubscribeClose = deps.on("close",
|
|
669
|
+
const unsubscribeClose = deps.on("close", onClose);
|
|
545
670
|
if (deps.getSize() > 0) onOpen();
|
|
546
671
|
return () => {
|
|
547
672
|
unsubscribeOpen();
|
|
548
673
|
unsubscribeClose();
|
|
549
|
-
|
|
674
|
+
if (handle) {
|
|
675
|
+
popBackMarker(handle);
|
|
676
|
+
handle = null;
|
|
677
|
+
}
|
|
550
678
|
};
|
|
551
679
|
}
|
|
552
680
|
function installRouteChange(deps) {
|
|
553
|
-
|
|
554
|
-
return () => {
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
const onChange = () => {
|
|
681
|
+
return subscribeRouteChange(() => {
|
|
558
682
|
if (deps.isDestroyed() || deps.getSize() <= 0) return;
|
|
559
683
|
void deps.close();
|
|
560
|
-
};
|
|
561
|
-
const wrap = (key) => {
|
|
562
|
-
const original = history[key];
|
|
563
|
-
const patched = function(...args) {
|
|
564
|
-
original.apply(this, args);
|
|
565
|
-
onChange();
|
|
566
|
-
};
|
|
567
|
-
history[key] = patched;
|
|
568
|
-
return () => {
|
|
569
|
-
if (history[key] === patched) {
|
|
570
|
-
history[key] = original;
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
};
|
|
574
|
-
window.addEventListener("popstate", onChange);
|
|
575
|
-
const restorePush = wrap("pushState");
|
|
576
|
-
const restoreReplace = wrap("replaceState");
|
|
577
|
-
return () => {
|
|
578
|
-
window.removeEventListener("popstate", onChange);
|
|
579
|
-
restorePush();
|
|
580
|
-
restoreReplace();
|
|
581
|
-
};
|
|
684
|
+
});
|
|
582
685
|
}
|
|
583
686
|
|
|
584
687
|
// src/core/features/content-swipe.ts
|
|
@@ -848,11 +951,15 @@ function createMaxHeightController(deps) {
|
|
|
848
951
|
|
|
849
952
|
// src/core/features/fit-measurement.ts
|
|
850
953
|
var measureSheetNatural = (element, content, vertical) => {
|
|
851
|
-
if (!content) {
|
|
852
|
-
return vertical ? element.offsetHeight : element.offsetWidth;
|
|
853
|
-
}
|
|
854
954
|
const axis = vertical ? "height" : "width";
|
|
855
955
|
const sheetStyle = element.style;
|
|
956
|
+
if (!content) {
|
|
957
|
+
const prev = sheetStyle[axis];
|
|
958
|
+
sheetStyle[axis] = "auto";
|
|
959
|
+
const poked2 = vertical ? element.offsetHeight : element.offsetWidth;
|
|
960
|
+
sheetStyle[axis] = prev;
|
|
961
|
+
return poked2;
|
|
962
|
+
}
|
|
856
963
|
const cs = content.style;
|
|
857
964
|
const prevSheet = sheetStyle[axis];
|
|
858
965
|
const prevFlex = cs.flex;
|
|
@@ -2432,7 +2539,7 @@ var matchesRange = (def, progress) => {
|
|
|
2432
2539
|
};
|
|
2433
2540
|
function installScrimStages(deps, opts) {
|
|
2434
2541
|
const doc = deps.host.ownerDocument;
|
|
2435
|
-
const
|
|
2542
|
+
const entries2 = opts.stages.map((def) => {
|
|
2436
2543
|
const wrapper = doc.createElement("div");
|
|
2437
2544
|
wrapper.className = "bs-scrim-stage";
|
|
2438
2545
|
const ws = wrapper.style;
|
|
@@ -2453,9 +2560,9 @@ function installScrimStages(deps, opts) {
|
|
|
2453
2560
|
const resolveActive = () => {
|
|
2454
2561
|
const state = deps.getState();
|
|
2455
2562
|
if (state.size === 0) {
|
|
2456
|
-
return
|
|
2563
|
+
return entries2.find((e) => matchesId(e.def, state.activeId)) ?? null;
|
|
2457
2564
|
}
|
|
2458
|
-
return
|
|
2565
|
+
return entries2.find((e) => matchesId(e.def, state.activeId)) ?? entries2.find((e) => matchesRange(e.def, state.progress)) ?? null;
|
|
2459
2566
|
};
|
|
2460
2567
|
const hide = (entry, animate) => {
|
|
2461
2568
|
entry.inFlight?.cancel();
|
|
@@ -2504,13 +2611,13 @@ function installScrimStages(deps, opts) {
|
|
|
2504
2611
|
deps.on("open", () => update(true)),
|
|
2505
2612
|
deps.on("close", () => update(true))
|
|
2506
2613
|
];
|
|
2507
|
-
if (
|
|
2614
|
+
if (entries2.some((e) => e.def.forRange)) {
|
|
2508
2615
|
offs.push(deps.on("progress", () => update(true)));
|
|
2509
2616
|
}
|
|
2510
2617
|
update(false);
|
|
2511
2618
|
return () => {
|
|
2512
2619
|
offs.forEach((off) => off());
|
|
2513
|
-
for (const entry of
|
|
2620
|
+
for (const entry of entries2) {
|
|
2514
2621
|
entry.inFlight?.cancel();
|
|
2515
2622
|
entry.inFlight = null;
|
|
2516
2623
|
if (entry.wrapper.parentNode) {
|
|
@@ -2769,17 +2876,12 @@ var BottomSheetEngine = class {
|
|
|
2769
2876
|
this.attach();
|
|
2770
2877
|
this.registerInStack();
|
|
2771
2878
|
if (this.snaps.getMaxAxisSize() === 0 && typeof IntersectionObserver !== "undefined" && typeof document !== "undefined") {
|
|
2772
|
-
const io = new IntersectionObserver((
|
|
2773
|
-
for (const entry of
|
|
2879
|
+
const io = new IntersectionObserver((entries2) => {
|
|
2880
|
+
for (const entry of entries2) {
|
|
2774
2881
|
if (!entry.isIntersecting) continue;
|
|
2775
2882
|
if (this.destroyed) return;
|
|
2776
2883
|
this.snaps.recompute();
|
|
2777
|
-
|
|
2778
|
-
if (current) {
|
|
2779
|
-
this.size = current.size;
|
|
2780
|
-
this.applySize(this.size);
|
|
2781
|
-
this.updateAriaSlider();
|
|
2782
|
-
}
|
|
2884
|
+
this.healActiveSnap();
|
|
2783
2885
|
io.disconnect();
|
|
2784
2886
|
return;
|
|
2785
2887
|
}
|
|
@@ -2943,6 +3045,8 @@ var BottomSheetEngine = class {
|
|
|
2943
3045
|
const vt = document.startViewTransition(() => {
|
|
2944
3046
|
this.applySize(target.size);
|
|
2945
3047
|
});
|
|
3048
|
+
vt.ready?.catch(() => {
|
|
3049
|
+
});
|
|
2946
3050
|
this.currentViewTransition = vt;
|
|
2947
3051
|
try {
|
|
2948
3052
|
await vt.finished;
|
|
@@ -3194,11 +3298,16 @@ var BottomSheetEngine = class {
|
|
|
3194
3298
|
this.maxHeight.clampTo();
|
|
3195
3299
|
this.scrim.invalidateOpacityCache();
|
|
3196
3300
|
if (this.gesture?.isDragging) return;
|
|
3301
|
+
this.healActiveSnap();
|
|
3302
|
+
}
|
|
3303
|
+
healActiveSnap() {
|
|
3197
3304
|
const current = this.snaps.findById(this.activeId);
|
|
3198
|
-
if (current)
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3305
|
+
if (!current) return;
|
|
3306
|
+
this.size = current.size;
|
|
3307
|
+
this.applySize(this.size);
|
|
3308
|
+
this.updateAriaSlider();
|
|
3309
|
+
if (this.size > 0 && !this.lifecycle.isInstalled && !this.opening && !this.animation.isAnimating) {
|
|
3310
|
+
this.emitOpenSequence(this.activeId);
|
|
3202
3311
|
}
|
|
3203
3312
|
}
|
|
3204
3313
|
destroy() {
|
|
@@ -3487,9 +3596,9 @@ var BottomSheetEngine = class {
|
|
|
3487
3596
|
return;
|
|
3488
3597
|
}
|
|
3489
3598
|
if (this.emitBeforeSnap(target, previousId)) {
|
|
3490
|
-
const
|
|
3491
|
-
if (
|
|
3492
|
-
void this.animation.animateTo(
|
|
3599
|
+
const restore2 = this.snaps.findById(previousId);
|
|
3600
|
+
if (restore2) {
|
|
3601
|
+
void this.animation.animateTo(restore2.size, 0);
|
|
3493
3602
|
}
|
|
3494
3603
|
return;
|
|
3495
3604
|
}
|
|
@@ -3795,7 +3904,7 @@ var OverlayEngine = class {
|
|
|
3795
3904
|
__publicField(this, "detachSwipe", null);
|
|
3796
3905
|
__publicField(this, "respectReducedMotionEnabled");
|
|
3797
3906
|
__publicField(this, "isTop", true);
|
|
3798
|
-
__publicField(this, "
|
|
3907
|
+
__publicField(this, "backMarker", null);
|
|
3799
3908
|
__publicField(this, "movedToTarget", false);
|
|
3800
3909
|
__publicField(this, "onOpenCb");
|
|
3801
3910
|
__publicField(this, "onCloseCb");
|
|
@@ -3807,7 +3916,6 @@ var OverlayEngine = class {
|
|
|
3807
3916
|
__publicField(this, "bus", createEventBus());
|
|
3808
3917
|
__publicField(this, "detachEscape", null);
|
|
3809
3918
|
__publicField(this, "detachBackdrop", null);
|
|
3810
|
-
__publicField(this, "detachHardwareBack", null);
|
|
3811
3919
|
__publicField(this, "releaseStackEntry", null);
|
|
3812
3920
|
__publicField(this, "lifecycle");
|
|
3813
3921
|
this.element = opts.element;
|
|
@@ -3961,7 +4069,10 @@ var OverlayEngine = class {
|
|
|
3961
4069
|
this.isOpen_ = false;
|
|
3962
4070
|
this.isAnimating_ = true;
|
|
3963
4071
|
sheetStack.update();
|
|
3964
|
-
this.
|
|
4072
|
+
if (reason !== "back" && this.backMarker) {
|
|
4073
|
+
popBackMarker(this.backMarker);
|
|
4074
|
+
}
|
|
4075
|
+
this.backMarker = null;
|
|
3965
4076
|
this.element.setAttribute("data-state", "exiting");
|
|
3966
4077
|
const dur = this.effectiveDuration();
|
|
3967
4078
|
const transitionStr = `transform ${dur}ms ${this.exitEasing}, opacity ${dur}ms ease-in`;
|
|
@@ -4019,6 +4130,10 @@ var OverlayEngine = class {
|
|
|
4019
4130
|
this.bus.clear();
|
|
4020
4131
|
this.setWillChange(false);
|
|
4021
4132
|
this.releaseInteractiveListeners();
|
|
4133
|
+
if (this.backMarker) {
|
|
4134
|
+
popBackMarker(this.backMarker);
|
|
4135
|
+
this.backMarker = null;
|
|
4136
|
+
}
|
|
4022
4137
|
this.releaseStackEntry?.();
|
|
4023
4138
|
this.releaseStackEntry = null;
|
|
4024
4139
|
const hadOriginalParent = this.originalParent !== null;
|
|
@@ -4180,19 +4295,6 @@ var OverlayEngine = class {
|
|
|
4180
4295
|
effectiveDuration() {
|
|
4181
4296
|
return this.respectReducedMotionEnabled && prefersReducedMotion() ? 0 : this.duration;
|
|
4182
4297
|
}
|
|
4183
|
-
popBackMarker(reason) {
|
|
4184
|
-
if (!this.backPushed) return;
|
|
4185
|
-
this.backPushed = false;
|
|
4186
|
-
if (reason === "back") return;
|
|
4187
|
-
const state = history.state;
|
|
4188
|
-
if (state && state.__bsOverlay === this.id) {
|
|
4189
|
-
try {
|
|
4190
|
-
history.back();
|
|
4191
|
-
} catch {
|
|
4192
|
-
return;
|
|
4193
|
-
}
|
|
4194
|
-
}
|
|
4195
|
-
}
|
|
4196
4298
|
resolvePeekPx(raw) {
|
|
4197
4299
|
if (typeof raw === "number") return Math.max(0, raw);
|
|
4198
4300
|
try {
|
|
@@ -4308,21 +4410,6 @@ var OverlayEngine = class {
|
|
|
4308
4410
|
this.backdrop.addEventListener("click", handler);
|
|
4309
4411
|
this.detachBackdrop = () => this.backdrop?.removeEventListener("click", handler);
|
|
4310
4412
|
}
|
|
4311
|
-
if (this.closeOnBackEnabled && typeof window !== "undefined" && !this.detachHardwareBack) {
|
|
4312
|
-
try {
|
|
4313
|
-
history.pushState({ __bsOverlay: this.id }, "");
|
|
4314
|
-
this.backPushed = true;
|
|
4315
|
-
} catch {
|
|
4316
|
-
}
|
|
4317
|
-
const onPop = () => {
|
|
4318
|
-
if (this.isOpen_ && this.isTop) {
|
|
4319
|
-
this.backPushed = false;
|
|
4320
|
-
void this.close("back");
|
|
4321
|
-
}
|
|
4322
|
-
};
|
|
4323
|
-
window.addEventListener("popstate", onPop);
|
|
4324
|
-
this.detachHardwareBack = () => window.removeEventListener("popstate", onPop);
|
|
4325
|
-
}
|
|
4326
4413
|
if (this.closeOnOutsidePointerEnabled && !this.detachOutsidePointer) {
|
|
4327
4414
|
const handler = (e) => {
|
|
4328
4415
|
if (!this.isOpen_) return;
|
|
@@ -4335,14 +4422,20 @@ var OverlayEngine = class {
|
|
|
4335
4422
|
document.addEventListener("pointerdown", handler, true);
|
|
4336
4423
|
this.detachOutsidePointer = () => document.removeEventListener("pointerdown", handler, true);
|
|
4337
4424
|
}
|
|
4425
|
+
if (this.closeOnBackEnabled && this.backMarker === null && typeof window !== "undefined") {
|
|
4426
|
+
this.backMarker = pushBackMarker({
|
|
4427
|
+
isOpen: () => this.isOpen_,
|
|
4428
|
+
isTop: () => this.isTop,
|
|
4429
|
+
close: () => this.close("back"),
|
|
4430
|
+
markerState: () => ({ __bsOverlay: this.id })
|
|
4431
|
+
});
|
|
4432
|
+
}
|
|
4338
4433
|
}
|
|
4339
4434
|
releaseInteractiveListeners() {
|
|
4340
4435
|
this.detachEscape?.();
|
|
4341
4436
|
this.detachEscape = null;
|
|
4342
4437
|
this.detachBackdrop?.();
|
|
4343
4438
|
this.detachBackdrop = null;
|
|
4344
|
-
this.detachHardwareBack?.();
|
|
4345
|
-
this.detachHardwareBack = null;
|
|
4346
4439
|
this.detachSwipe?.();
|
|
4347
4440
|
this.detachSwipe = null;
|
|
4348
4441
|
this.detachOutsidePointer?.();
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as SnapPoint, b as SheetMode, a as SnapPointDef, c as EngineOptions, f as ScrimOverlayPosition } from './BottomSheetEngine-
|
|
2
|
-
export { g as AnchorAnimationPreset, h as AnchorAnimationSpec, i as AnchorHandle, A as AnchorOptions, j as AnchorPosition, k as AnchorState, B as BottomSheetEngine, C as CloseReason, E as EngineState, P as Plugin, l as SCRIM_PRESETS, m as ScrimOverlayOptions, n as ScrimPreset, o as ScrimPresetConfig, p as ScrimStageDef, S as ScrimStagesOptions, q as ScrimUpdate, d as SheetEventMap, r as SnapId, T as TeardownScope, s as runAnchorTransition } from './BottomSheetEngine-
|
|
1
|
+
import { e as SnapPoint, b as SheetMode, a as SnapPointDef, c as EngineOptions, f as ScrimOverlayPosition } from './BottomSheetEngine-D6oiEfZ4.cjs';
|
|
2
|
+
export { g as AnchorAnimationPreset, h as AnchorAnimationSpec, i as AnchorHandle, A as AnchorOptions, j as AnchorPosition, k as AnchorState, B as BottomSheetEngine, C as CloseReason, E as EngineState, P as Plugin, l as SCRIM_PRESETS, m as ScrimOverlayOptions, n as ScrimPreset, o as ScrimPresetConfig, p as ScrimStageDef, S as ScrimStagesOptions, q as ScrimUpdate, d as SheetEventMap, r as SnapId, T as TeardownScope, s as runAnchorTransition } from './BottomSheetEngine-D6oiEfZ4.cjs';
|
|
3
3
|
export { OVERLAY_PRESETS, Overlay, OverlayAnimation, OverlayCloseReason, OverlayEdge, Overlay as OverlayEngine, OverlayEventMap, OverlayMountTarget, OverlayOptions, OverlayPreset, OverlayState, OverlayUpdate, SwipeToCloseConfig, createOverlay } from './overlay.cjs';
|
|
4
4
|
import './transform-jVfAikE9.cjs';
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as SnapPoint, b as SheetMode, a as SnapPointDef, c as EngineOptions, f as ScrimOverlayPosition } from './BottomSheetEngine-
|
|
2
|
-
export { g as AnchorAnimationPreset, h as AnchorAnimationSpec, i as AnchorHandle, A as AnchorOptions, j as AnchorPosition, k as AnchorState, B as BottomSheetEngine, C as CloseReason, E as EngineState, P as Plugin, l as SCRIM_PRESETS, m as ScrimOverlayOptions, n as ScrimPreset, o as ScrimPresetConfig, p as ScrimStageDef, S as ScrimStagesOptions, q as ScrimUpdate, d as SheetEventMap, r as SnapId, T as TeardownScope, s as runAnchorTransition } from './BottomSheetEngine-
|
|
1
|
+
import { e as SnapPoint, b as SheetMode, a as SnapPointDef, c as EngineOptions, f as ScrimOverlayPosition } from './BottomSheetEngine-Dhy0X_e9.js';
|
|
2
|
+
export { g as AnchorAnimationPreset, h as AnchorAnimationSpec, i as AnchorHandle, A as AnchorOptions, j as AnchorPosition, k as AnchorState, B as BottomSheetEngine, C as CloseReason, E as EngineState, P as Plugin, l as SCRIM_PRESETS, m as ScrimOverlayOptions, n as ScrimPreset, o as ScrimPresetConfig, p as ScrimStageDef, S as ScrimStagesOptions, q as ScrimUpdate, d as SheetEventMap, r as SnapId, T as TeardownScope, s as runAnchorTransition } from './BottomSheetEngine-Dhy0X_e9.js';
|
|
3
3
|
export { OVERLAY_PRESETS, Overlay, OverlayAnimation, OverlayCloseReason, OverlayEdge, Overlay as OverlayEngine, OverlayEventMap, OverlayMountTarget, OverlayOptions, OverlayPreset, OverlayState, OverlayUpdate, SwipeToCloseConfig, createOverlay } from './overlay.js';
|
|
4
4
|
import './transform-jVfAikE9.js';
|
|
5
5
|
|