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