@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/overlay.cjs
CHANGED
|
@@ -529,6 +529,150 @@ function installOverlaySwipe(deps) {
|
|
|
529
529
|
};
|
|
530
530
|
}
|
|
531
531
|
|
|
532
|
+
// src/core/features/history-coordinator.ts
|
|
533
|
+
var entries = [];
|
|
534
|
+
var subscribers = /* @__PURE__ */ new Set();
|
|
535
|
+
var suppress = 0;
|
|
536
|
+
var pendingRebrand = null;
|
|
537
|
+
var listenerInstalled = false;
|
|
538
|
+
var hasWindow = () => typeof window !== "undefined";
|
|
539
|
+
var hasHistory = () => typeof history !== "undefined";
|
|
540
|
+
var brandMarker = (surface) => ({
|
|
541
|
+
...surface.markerState(),
|
|
542
|
+
__bs: true
|
|
543
|
+
});
|
|
544
|
+
var runInternal = (fn) => {
|
|
545
|
+
try {
|
|
546
|
+
fn();
|
|
547
|
+
} finally {
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
var notifyRouteChange = () => {
|
|
551
|
+
const snapshot = Array.from(subscribers);
|
|
552
|
+
for (const fn of snapshot) fn();
|
|
553
|
+
};
|
|
554
|
+
var ensureListener = () => {
|
|
555
|
+
if (listenerInstalled || !hasWindow()) return;
|
|
556
|
+
window.addEventListener("popstate", onPopState);
|
|
557
|
+
listenerInstalled = true;
|
|
558
|
+
};
|
|
559
|
+
var maybeTeardownListener = () => {
|
|
560
|
+
if (!listenerInstalled) return;
|
|
561
|
+
if (entries.length > 0 || subscribers.size > 0 || suppress > 0) return;
|
|
562
|
+
if (hasWindow()) window.removeEventListener("popstate", onPopState);
|
|
563
|
+
listenerInstalled = false;
|
|
564
|
+
};
|
|
565
|
+
function onPopState() {
|
|
566
|
+
if (suppress > 0) {
|
|
567
|
+
suppress -= 1;
|
|
568
|
+
const rebrand = pendingRebrand;
|
|
569
|
+
pendingRebrand = null;
|
|
570
|
+
if (rebrand) rebrand();
|
|
571
|
+
maybeTeardownListener();
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
if (entries.length === 0) {
|
|
575
|
+
notifyRouteChange();
|
|
576
|
+
maybeTeardownListener();
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
let target = null;
|
|
580
|
+
let targetIdx = -1;
|
|
581
|
+
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
582
|
+
const entry = entries[i];
|
|
583
|
+
if (!entry.surface.isOpen()) continue;
|
|
584
|
+
if (!target) {
|
|
585
|
+
target = entry;
|
|
586
|
+
targetIdx = i;
|
|
587
|
+
}
|
|
588
|
+
if (entry.surface.isTop()) {
|
|
589
|
+
target = entry;
|
|
590
|
+
targetIdx = i;
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (!target) {
|
|
595
|
+
const removed = entries.pop();
|
|
596
|
+
if (removed) removed.live = false;
|
|
597
|
+
maybeTeardownListener();
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
target.live = false;
|
|
601
|
+
entries.splice(targetIdx, 1);
|
|
602
|
+
const settled = target;
|
|
603
|
+
void Promise.resolve(settled.surface.close()).then(() => {
|
|
604
|
+
if (settled.surface.isOpen()) restore(settled);
|
|
605
|
+
});
|
|
606
|
+
maybeTeardownListener();
|
|
607
|
+
}
|
|
608
|
+
function restore(entry) {
|
|
609
|
+
if (!hasWindow() || !hasHistory()) return;
|
|
610
|
+
entry.live = true;
|
|
611
|
+
runInternal(() => {
|
|
612
|
+
try {
|
|
613
|
+
history.pushState(brandMarker(entry.surface), "", entry.surface.url);
|
|
614
|
+
} catch {
|
|
615
|
+
entry.live = false;
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
if (entry.live) {
|
|
619
|
+
entries.push(entry);
|
|
620
|
+
ensureListener();
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
function pushBackMarker(surface) {
|
|
624
|
+
const entry = { surface, priorUrl: void 0, live: false };
|
|
625
|
+
if (!hasWindow() || !hasHistory()) {
|
|
626
|
+
return entry;
|
|
627
|
+
}
|
|
628
|
+
entry.priorUrl = surface.url !== void 0 ? location.href : void 0;
|
|
629
|
+
runInternal(() => {
|
|
630
|
+
try {
|
|
631
|
+
history.pushState(brandMarker(surface), "", surface.url);
|
|
632
|
+
entry.live = true;
|
|
633
|
+
} catch {
|
|
634
|
+
entry.live = false;
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
if (entry.live) {
|
|
638
|
+
entries.push(entry);
|
|
639
|
+
ensureListener();
|
|
640
|
+
}
|
|
641
|
+
return entry;
|
|
642
|
+
}
|
|
643
|
+
function popBackMarker(handle) {
|
|
644
|
+
if (!hasWindow() || !hasHistory()) return;
|
|
645
|
+
const entry = handle;
|
|
646
|
+
const idx = entries.indexOf(entry);
|
|
647
|
+
if (idx === -1 || !entry.live) return;
|
|
648
|
+
const last = entries.length - 1;
|
|
649
|
+
entry.live = false;
|
|
650
|
+
entries.splice(idx, 1);
|
|
651
|
+
if (idx !== last) {
|
|
652
|
+
const rebrandSurface = entries[entries.length - 1].surface;
|
|
653
|
+
const rebrandUrl = entry.priorUrl;
|
|
654
|
+
pendingRebrand = () => {
|
|
655
|
+
runInternal(() => {
|
|
656
|
+
history.replaceState(
|
|
657
|
+
brandMarker(rebrandSurface),
|
|
658
|
+
"",
|
|
659
|
+
rebrandUrl !== void 0 ? rebrandUrl : location.href
|
|
660
|
+
);
|
|
661
|
+
});
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
suppress += 1;
|
|
665
|
+
runInternal(() => {
|
|
666
|
+
try {
|
|
667
|
+
history.back();
|
|
668
|
+
} catch {
|
|
669
|
+
suppress = Math.max(0, suppress - 1);
|
|
670
|
+
pendingRebrand = null;
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
maybeTeardownListener();
|
|
674
|
+
}
|
|
675
|
+
|
|
532
676
|
// src/core/overlay-options.ts
|
|
533
677
|
var OVERLAY_PRESETS = Object.freeze({
|
|
534
678
|
sheet: Object.freeze({
|
|
@@ -596,7 +740,7 @@ var OverlayEngine = class {
|
|
|
596
740
|
__publicField(this, "detachSwipe", null);
|
|
597
741
|
__publicField(this, "respectReducedMotionEnabled");
|
|
598
742
|
__publicField(this, "isTop", true);
|
|
599
|
-
__publicField(this, "
|
|
743
|
+
__publicField(this, "backMarker", null);
|
|
600
744
|
__publicField(this, "movedToTarget", false);
|
|
601
745
|
__publicField(this, "onOpenCb");
|
|
602
746
|
__publicField(this, "onCloseCb");
|
|
@@ -608,7 +752,6 @@ var OverlayEngine = class {
|
|
|
608
752
|
__publicField(this, "bus", createEventBus());
|
|
609
753
|
__publicField(this, "detachEscape", null);
|
|
610
754
|
__publicField(this, "detachBackdrop", null);
|
|
611
|
-
__publicField(this, "detachHardwareBack", null);
|
|
612
755
|
__publicField(this, "releaseStackEntry", null);
|
|
613
756
|
__publicField(this, "lifecycle");
|
|
614
757
|
this.element = opts.element;
|
|
@@ -762,7 +905,10 @@ var OverlayEngine = class {
|
|
|
762
905
|
this.isOpen_ = false;
|
|
763
906
|
this.isAnimating_ = true;
|
|
764
907
|
sheetStack.update();
|
|
765
|
-
this.
|
|
908
|
+
if (reason !== "back" && this.backMarker) {
|
|
909
|
+
popBackMarker(this.backMarker);
|
|
910
|
+
}
|
|
911
|
+
this.backMarker = null;
|
|
766
912
|
this.element.setAttribute("data-state", "exiting");
|
|
767
913
|
const dur = this.effectiveDuration();
|
|
768
914
|
const transitionStr = `transform ${dur}ms ${this.exitEasing}, opacity ${dur}ms ease-in`;
|
|
@@ -820,6 +966,10 @@ var OverlayEngine = class {
|
|
|
820
966
|
this.bus.clear();
|
|
821
967
|
this.setWillChange(false);
|
|
822
968
|
this.releaseInteractiveListeners();
|
|
969
|
+
if (this.backMarker) {
|
|
970
|
+
popBackMarker(this.backMarker);
|
|
971
|
+
this.backMarker = null;
|
|
972
|
+
}
|
|
823
973
|
this.releaseStackEntry?.();
|
|
824
974
|
this.releaseStackEntry = null;
|
|
825
975
|
const hadOriginalParent = this.originalParent !== null;
|
|
@@ -981,19 +1131,6 @@ var OverlayEngine = class {
|
|
|
981
1131
|
effectiveDuration() {
|
|
982
1132
|
return this.respectReducedMotionEnabled && prefersReducedMotion() ? 0 : this.duration;
|
|
983
1133
|
}
|
|
984
|
-
popBackMarker(reason) {
|
|
985
|
-
if (!this.backPushed) return;
|
|
986
|
-
this.backPushed = false;
|
|
987
|
-
if (reason === "back") return;
|
|
988
|
-
const state = history.state;
|
|
989
|
-
if (state && state.__bsOverlay === this.id) {
|
|
990
|
-
try {
|
|
991
|
-
history.back();
|
|
992
|
-
} catch {
|
|
993
|
-
return;
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
1134
|
resolvePeekPx(raw) {
|
|
998
1135
|
if (typeof raw === "number") return Math.max(0, raw);
|
|
999
1136
|
try {
|
|
@@ -1109,21 +1246,6 @@ var OverlayEngine = class {
|
|
|
1109
1246
|
this.backdrop.addEventListener("click", handler);
|
|
1110
1247
|
this.detachBackdrop = () => this.backdrop?.removeEventListener("click", handler);
|
|
1111
1248
|
}
|
|
1112
|
-
if (this.closeOnBackEnabled && typeof window !== "undefined" && !this.detachHardwareBack) {
|
|
1113
|
-
try {
|
|
1114
|
-
history.pushState({ __bsOverlay: this.id }, "");
|
|
1115
|
-
this.backPushed = true;
|
|
1116
|
-
} catch {
|
|
1117
|
-
}
|
|
1118
|
-
const onPop = () => {
|
|
1119
|
-
if (this.isOpen_ && this.isTop) {
|
|
1120
|
-
this.backPushed = false;
|
|
1121
|
-
void this.close("back");
|
|
1122
|
-
}
|
|
1123
|
-
};
|
|
1124
|
-
window.addEventListener("popstate", onPop);
|
|
1125
|
-
this.detachHardwareBack = () => window.removeEventListener("popstate", onPop);
|
|
1126
|
-
}
|
|
1127
1249
|
if (this.closeOnOutsidePointerEnabled && !this.detachOutsidePointer) {
|
|
1128
1250
|
const handler = (e) => {
|
|
1129
1251
|
if (!this.isOpen_) return;
|
|
@@ -1136,14 +1258,20 @@ var OverlayEngine = class {
|
|
|
1136
1258
|
document.addEventListener("pointerdown", handler, true);
|
|
1137
1259
|
this.detachOutsidePointer = () => document.removeEventListener("pointerdown", handler, true);
|
|
1138
1260
|
}
|
|
1261
|
+
if (this.closeOnBackEnabled && this.backMarker === null && typeof window !== "undefined") {
|
|
1262
|
+
this.backMarker = pushBackMarker({
|
|
1263
|
+
isOpen: () => this.isOpen_,
|
|
1264
|
+
isTop: () => this.isTop,
|
|
1265
|
+
close: () => this.close("back"),
|
|
1266
|
+
markerState: () => ({ __bsOverlay: this.id })
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1139
1269
|
}
|
|
1140
1270
|
releaseInteractiveListeners() {
|
|
1141
1271
|
this.detachEscape?.();
|
|
1142
1272
|
this.detachEscape = null;
|
|
1143
1273
|
this.detachBackdrop?.();
|
|
1144
1274
|
this.detachBackdrop = null;
|
|
1145
|
-
this.detachHardwareBack?.();
|
|
1146
|
-
this.detachHardwareBack = null;
|
|
1147
1275
|
this.detachSwipe?.();
|
|
1148
1276
|
this.detachSwipe = null;
|
|
1149
1277
|
this.detachOutsidePointer?.();
|
package/dist/overlay.d.cts
CHANGED
|
@@ -110,7 +110,7 @@ declare class OverlayEngine {
|
|
|
110
110
|
private detachSwipe;
|
|
111
111
|
private respectReducedMotionEnabled;
|
|
112
112
|
private isTop;
|
|
113
|
-
private
|
|
113
|
+
private backMarker;
|
|
114
114
|
private movedToTarget;
|
|
115
115
|
private onOpenCb?;
|
|
116
116
|
private onCloseCb?;
|
|
@@ -122,7 +122,6 @@ declare class OverlayEngine {
|
|
|
122
122
|
private bus;
|
|
123
123
|
private detachEscape;
|
|
124
124
|
private detachBackdrop;
|
|
125
|
-
private detachHardwareBack;
|
|
126
125
|
private releaseStackEntry;
|
|
127
126
|
private lifecycle;
|
|
128
127
|
constructor(opts: OverlayOptions);
|
|
@@ -144,7 +143,6 @@ declare class OverlayEngine {
|
|
|
144
143
|
private assignSwipeFromConfig;
|
|
145
144
|
private emit;
|
|
146
145
|
private effectiveDuration;
|
|
147
|
-
private popBackMarker;
|
|
148
146
|
private resolvePeekPx;
|
|
149
147
|
private maybeMount;
|
|
150
148
|
private restoreMount;
|
package/dist/overlay.d.ts
CHANGED
|
@@ -110,7 +110,7 @@ declare class OverlayEngine {
|
|
|
110
110
|
private detachSwipe;
|
|
111
111
|
private respectReducedMotionEnabled;
|
|
112
112
|
private isTop;
|
|
113
|
-
private
|
|
113
|
+
private backMarker;
|
|
114
114
|
private movedToTarget;
|
|
115
115
|
private onOpenCb?;
|
|
116
116
|
private onCloseCb?;
|
|
@@ -122,7 +122,6 @@ declare class OverlayEngine {
|
|
|
122
122
|
private bus;
|
|
123
123
|
private detachEscape;
|
|
124
124
|
private detachBackdrop;
|
|
125
|
-
private detachHardwareBack;
|
|
126
125
|
private releaseStackEntry;
|
|
127
126
|
private lifecycle;
|
|
128
127
|
constructor(opts: OverlayOptions);
|
|
@@ -144,7 +143,6 @@ declare class OverlayEngine {
|
|
|
144
143
|
private assignSwipeFromConfig;
|
|
145
144
|
private emit;
|
|
146
145
|
private effectiveDuration;
|
|
147
|
-
private popBackMarker;
|
|
148
146
|
private resolvePeekPx;
|
|
149
147
|
private maybeMount;
|
|
150
148
|
private restoreMount;
|
package/dist/overlay.js
CHANGED
|
@@ -527,6 +527,150 @@ function installOverlaySwipe(deps) {
|
|
|
527
527
|
};
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
+
// src/core/features/history-coordinator.ts
|
|
531
|
+
var entries = [];
|
|
532
|
+
var subscribers = /* @__PURE__ */ new Set();
|
|
533
|
+
var suppress = 0;
|
|
534
|
+
var pendingRebrand = null;
|
|
535
|
+
var listenerInstalled = false;
|
|
536
|
+
var hasWindow = () => typeof window !== "undefined";
|
|
537
|
+
var hasHistory = () => typeof history !== "undefined";
|
|
538
|
+
var brandMarker = (surface) => ({
|
|
539
|
+
...surface.markerState(),
|
|
540
|
+
__bs: true
|
|
541
|
+
});
|
|
542
|
+
var runInternal = (fn) => {
|
|
543
|
+
try {
|
|
544
|
+
fn();
|
|
545
|
+
} finally {
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
var notifyRouteChange = () => {
|
|
549
|
+
const snapshot = Array.from(subscribers);
|
|
550
|
+
for (const fn of snapshot) fn();
|
|
551
|
+
};
|
|
552
|
+
var ensureListener = () => {
|
|
553
|
+
if (listenerInstalled || !hasWindow()) return;
|
|
554
|
+
window.addEventListener("popstate", onPopState);
|
|
555
|
+
listenerInstalled = true;
|
|
556
|
+
};
|
|
557
|
+
var maybeTeardownListener = () => {
|
|
558
|
+
if (!listenerInstalled) return;
|
|
559
|
+
if (entries.length > 0 || subscribers.size > 0 || suppress > 0) return;
|
|
560
|
+
if (hasWindow()) window.removeEventListener("popstate", onPopState);
|
|
561
|
+
listenerInstalled = false;
|
|
562
|
+
};
|
|
563
|
+
function onPopState() {
|
|
564
|
+
if (suppress > 0) {
|
|
565
|
+
suppress -= 1;
|
|
566
|
+
const rebrand = pendingRebrand;
|
|
567
|
+
pendingRebrand = null;
|
|
568
|
+
if (rebrand) rebrand();
|
|
569
|
+
maybeTeardownListener();
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
if (entries.length === 0) {
|
|
573
|
+
notifyRouteChange();
|
|
574
|
+
maybeTeardownListener();
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
let target = null;
|
|
578
|
+
let targetIdx = -1;
|
|
579
|
+
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
580
|
+
const entry = entries[i];
|
|
581
|
+
if (!entry.surface.isOpen()) continue;
|
|
582
|
+
if (!target) {
|
|
583
|
+
target = entry;
|
|
584
|
+
targetIdx = i;
|
|
585
|
+
}
|
|
586
|
+
if (entry.surface.isTop()) {
|
|
587
|
+
target = entry;
|
|
588
|
+
targetIdx = i;
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (!target) {
|
|
593
|
+
const removed = entries.pop();
|
|
594
|
+
if (removed) removed.live = false;
|
|
595
|
+
maybeTeardownListener();
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
target.live = false;
|
|
599
|
+
entries.splice(targetIdx, 1);
|
|
600
|
+
const settled = target;
|
|
601
|
+
void Promise.resolve(settled.surface.close()).then(() => {
|
|
602
|
+
if (settled.surface.isOpen()) restore(settled);
|
|
603
|
+
});
|
|
604
|
+
maybeTeardownListener();
|
|
605
|
+
}
|
|
606
|
+
function restore(entry) {
|
|
607
|
+
if (!hasWindow() || !hasHistory()) return;
|
|
608
|
+
entry.live = true;
|
|
609
|
+
runInternal(() => {
|
|
610
|
+
try {
|
|
611
|
+
history.pushState(brandMarker(entry.surface), "", entry.surface.url);
|
|
612
|
+
} catch {
|
|
613
|
+
entry.live = false;
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
if (entry.live) {
|
|
617
|
+
entries.push(entry);
|
|
618
|
+
ensureListener();
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
function pushBackMarker(surface) {
|
|
622
|
+
const entry = { surface, priorUrl: void 0, live: false };
|
|
623
|
+
if (!hasWindow() || !hasHistory()) {
|
|
624
|
+
return entry;
|
|
625
|
+
}
|
|
626
|
+
entry.priorUrl = surface.url !== void 0 ? location.href : void 0;
|
|
627
|
+
runInternal(() => {
|
|
628
|
+
try {
|
|
629
|
+
history.pushState(brandMarker(surface), "", surface.url);
|
|
630
|
+
entry.live = true;
|
|
631
|
+
} catch {
|
|
632
|
+
entry.live = false;
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
if (entry.live) {
|
|
636
|
+
entries.push(entry);
|
|
637
|
+
ensureListener();
|
|
638
|
+
}
|
|
639
|
+
return entry;
|
|
640
|
+
}
|
|
641
|
+
function popBackMarker(handle) {
|
|
642
|
+
if (!hasWindow() || !hasHistory()) return;
|
|
643
|
+
const entry = handle;
|
|
644
|
+
const idx = entries.indexOf(entry);
|
|
645
|
+
if (idx === -1 || !entry.live) return;
|
|
646
|
+
const last = entries.length - 1;
|
|
647
|
+
entry.live = false;
|
|
648
|
+
entries.splice(idx, 1);
|
|
649
|
+
if (idx !== last) {
|
|
650
|
+
const rebrandSurface = entries[entries.length - 1].surface;
|
|
651
|
+
const rebrandUrl = entry.priorUrl;
|
|
652
|
+
pendingRebrand = () => {
|
|
653
|
+
runInternal(() => {
|
|
654
|
+
history.replaceState(
|
|
655
|
+
brandMarker(rebrandSurface),
|
|
656
|
+
"",
|
|
657
|
+
rebrandUrl !== void 0 ? rebrandUrl : location.href
|
|
658
|
+
);
|
|
659
|
+
});
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
suppress += 1;
|
|
663
|
+
runInternal(() => {
|
|
664
|
+
try {
|
|
665
|
+
history.back();
|
|
666
|
+
} catch {
|
|
667
|
+
suppress = Math.max(0, suppress - 1);
|
|
668
|
+
pendingRebrand = null;
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
maybeTeardownListener();
|
|
672
|
+
}
|
|
673
|
+
|
|
530
674
|
// src/core/overlay-options.ts
|
|
531
675
|
var OVERLAY_PRESETS = Object.freeze({
|
|
532
676
|
sheet: Object.freeze({
|
|
@@ -594,7 +738,7 @@ var OverlayEngine = class {
|
|
|
594
738
|
__publicField(this, "detachSwipe", null);
|
|
595
739
|
__publicField(this, "respectReducedMotionEnabled");
|
|
596
740
|
__publicField(this, "isTop", true);
|
|
597
|
-
__publicField(this, "
|
|
741
|
+
__publicField(this, "backMarker", null);
|
|
598
742
|
__publicField(this, "movedToTarget", false);
|
|
599
743
|
__publicField(this, "onOpenCb");
|
|
600
744
|
__publicField(this, "onCloseCb");
|
|
@@ -606,7 +750,6 @@ var OverlayEngine = class {
|
|
|
606
750
|
__publicField(this, "bus", createEventBus());
|
|
607
751
|
__publicField(this, "detachEscape", null);
|
|
608
752
|
__publicField(this, "detachBackdrop", null);
|
|
609
|
-
__publicField(this, "detachHardwareBack", null);
|
|
610
753
|
__publicField(this, "releaseStackEntry", null);
|
|
611
754
|
__publicField(this, "lifecycle");
|
|
612
755
|
this.element = opts.element;
|
|
@@ -760,7 +903,10 @@ var OverlayEngine = class {
|
|
|
760
903
|
this.isOpen_ = false;
|
|
761
904
|
this.isAnimating_ = true;
|
|
762
905
|
sheetStack.update();
|
|
763
|
-
this.
|
|
906
|
+
if (reason !== "back" && this.backMarker) {
|
|
907
|
+
popBackMarker(this.backMarker);
|
|
908
|
+
}
|
|
909
|
+
this.backMarker = null;
|
|
764
910
|
this.element.setAttribute("data-state", "exiting");
|
|
765
911
|
const dur = this.effectiveDuration();
|
|
766
912
|
const transitionStr = `transform ${dur}ms ${this.exitEasing}, opacity ${dur}ms ease-in`;
|
|
@@ -818,6 +964,10 @@ var OverlayEngine = class {
|
|
|
818
964
|
this.bus.clear();
|
|
819
965
|
this.setWillChange(false);
|
|
820
966
|
this.releaseInteractiveListeners();
|
|
967
|
+
if (this.backMarker) {
|
|
968
|
+
popBackMarker(this.backMarker);
|
|
969
|
+
this.backMarker = null;
|
|
970
|
+
}
|
|
821
971
|
this.releaseStackEntry?.();
|
|
822
972
|
this.releaseStackEntry = null;
|
|
823
973
|
const hadOriginalParent = this.originalParent !== null;
|
|
@@ -979,19 +1129,6 @@ var OverlayEngine = class {
|
|
|
979
1129
|
effectiveDuration() {
|
|
980
1130
|
return this.respectReducedMotionEnabled && prefersReducedMotion() ? 0 : this.duration;
|
|
981
1131
|
}
|
|
982
|
-
popBackMarker(reason) {
|
|
983
|
-
if (!this.backPushed) return;
|
|
984
|
-
this.backPushed = false;
|
|
985
|
-
if (reason === "back") return;
|
|
986
|
-
const state = history.state;
|
|
987
|
-
if (state && state.__bsOverlay === this.id) {
|
|
988
|
-
try {
|
|
989
|
-
history.back();
|
|
990
|
-
} catch {
|
|
991
|
-
return;
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
1132
|
resolvePeekPx(raw) {
|
|
996
1133
|
if (typeof raw === "number") return Math.max(0, raw);
|
|
997
1134
|
try {
|
|
@@ -1107,21 +1244,6 @@ var OverlayEngine = class {
|
|
|
1107
1244
|
this.backdrop.addEventListener("click", handler);
|
|
1108
1245
|
this.detachBackdrop = () => this.backdrop?.removeEventListener("click", handler);
|
|
1109
1246
|
}
|
|
1110
|
-
if (this.closeOnBackEnabled && typeof window !== "undefined" && !this.detachHardwareBack) {
|
|
1111
|
-
try {
|
|
1112
|
-
history.pushState({ __bsOverlay: this.id }, "");
|
|
1113
|
-
this.backPushed = true;
|
|
1114
|
-
} catch {
|
|
1115
|
-
}
|
|
1116
|
-
const onPop = () => {
|
|
1117
|
-
if (this.isOpen_ && this.isTop) {
|
|
1118
|
-
this.backPushed = false;
|
|
1119
|
-
void this.close("back");
|
|
1120
|
-
}
|
|
1121
|
-
};
|
|
1122
|
-
window.addEventListener("popstate", onPop);
|
|
1123
|
-
this.detachHardwareBack = () => window.removeEventListener("popstate", onPop);
|
|
1124
|
-
}
|
|
1125
1247
|
if (this.closeOnOutsidePointerEnabled && !this.detachOutsidePointer) {
|
|
1126
1248
|
const handler = (e) => {
|
|
1127
1249
|
if (!this.isOpen_) return;
|
|
@@ -1134,14 +1256,20 @@ var OverlayEngine = class {
|
|
|
1134
1256
|
document.addEventListener("pointerdown", handler, true);
|
|
1135
1257
|
this.detachOutsidePointer = () => document.removeEventListener("pointerdown", handler, true);
|
|
1136
1258
|
}
|
|
1259
|
+
if (this.closeOnBackEnabled && this.backMarker === null && typeof window !== "undefined") {
|
|
1260
|
+
this.backMarker = pushBackMarker({
|
|
1261
|
+
isOpen: () => this.isOpen_,
|
|
1262
|
+
isTop: () => this.isTop,
|
|
1263
|
+
close: () => this.close("back"),
|
|
1264
|
+
markerState: () => ({ __bsOverlay: this.id })
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1137
1267
|
}
|
|
1138
1268
|
releaseInteractiveListeners() {
|
|
1139
1269
|
this.detachEscape?.();
|
|
1140
1270
|
this.detachEscape = null;
|
|
1141
1271
|
this.detachBackdrop?.();
|
|
1142
1272
|
this.detachBackdrop = null;
|
|
1143
|
-
this.detachHardwareBack?.();
|
|
1144
|
-
this.detachHardwareBack = null;
|
|
1145
1273
|
this.detachSwipe?.();
|
|
1146
1274
|
this.detachSwipe = null;
|
|
1147
1275
|
this.detachOutsidePointer?.();
|
package/dist/preact.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BottomSheet, BottomSheetFromConfig, BottomSheetFromConfigProps, BottomSheetHandle, BottomSheetProps, HeaderProp, Overlay, OverlayHandle, OverlayProps, SheetConfig, UseBottomSheetRefs, UseBottomSheetReturn, UseOverlayReturn, useBottomSheet, useOverlay } from './react.cjs';
|
|
2
|
-
export { E as EngineState, b as SheetMode, e as SnapPoint, a as SnapPointDef } from './BottomSheetEngine-
|
|
2
|
+
export { E as EngineState, b as SheetMode, e as SnapPoint, a as SnapPointDef } from './BottomSheetEngine-D6oiEfZ4.cjs';
|
|
3
3
|
export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.cjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
import './teleport-7uYNiEAT.cjs';
|
package/dist/preact.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BottomSheet, BottomSheetFromConfig, BottomSheetFromConfigProps, BottomSheetHandle, BottomSheetProps, HeaderProp, Overlay, OverlayHandle, OverlayProps, SheetConfig, UseBottomSheetRefs, UseBottomSheetReturn, UseOverlayReturn, useBottomSheet, useOverlay } from './react.js';
|
|
2
|
-
export { E as EngineState, b as SheetMode, e as SnapPoint, a as SnapPointDef } from './BottomSheetEngine-
|
|
2
|
+
export { E as EngineState, b as SheetMode, e as SnapPoint, a as SnapPointDef } from './BottomSheetEngine-Dhy0X_e9.js';
|
|
3
3
|
export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import './teleport-7uYNiEAT.js';
|