@surdeddd/bottom-sheet 0.6.1 → 0.8.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 +31 -3
- package/dist/{BottomSheetEngine-CqiCz64W.d.cts → BottomSheetEngine-BD1mSExI.d.cts} +2 -1
- package/dist/{BottomSheetEngine-BHjKFtnM.d.ts → BottomSheetEngine-BDGRWa2i.d.ts} +2 -1
- package/dist/element.cjs +62 -57
- 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 +62 -57
- package/dist/index.cjs +62 -57
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +62 -57
- 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/preact.d.cts +1 -1
- package/dist/preact.d.ts +1 -1
- package/dist/qwik.cjs +89 -59
- package/dist/qwik.d.cts +8 -3
- package/dist/qwik.d.ts +8 -3
- package/dist/qwik.js +89 -59
- package/dist/react.cjs +74 -57
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +74 -57
- package/dist/solid.cjs +71 -59
- package/dist/solid.d.cts +9 -1
- package/dist/solid.d.ts +9 -1
- package/dist/solid.js +71 -59
- package/dist/solid.source.jsx +71 -59
- package/dist/styles.css +4 -4
- package/dist/svelte-core.cjs +62 -57
- package/dist/svelte-core.js +62 -57
- package/dist/svelte-src/BottomSheet.svelte +0 -10
- package/dist/svelte.cjs +70 -77
- package/dist/svelte.js +70 -77
- package/dist/vue.cjs +62 -73
- package/dist/vue.js +62 -73
- package/package.json +1 -1
package/dist/solid.js
CHANGED
|
@@ -2358,6 +2358,7 @@ var BottomSheetEngine = class {
|
|
|
2358
2358
|
__publicField(this, "progressWriteSentinel", new WriteSentinel());
|
|
2359
2359
|
__publicField(this, "isTopSheet", true);
|
|
2360
2360
|
__publicField(this, "opening", false);
|
|
2361
|
+
__publicField(this, "allowOvershoot", false);
|
|
2361
2362
|
__publicField(this, "progressPayload", {
|
|
2362
2363
|
value: 0,
|
|
2363
2364
|
size: 0
|
|
@@ -2648,8 +2649,8 @@ var BottomSheetEngine = class {
|
|
|
2648
2649
|
this.updateAriaSlider();
|
|
2649
2650
|
this.emit("snap", {
|
|
2650
2651
|
id,
|
|
2651
|
-
size:
|
|
2652
|
-
progress: this.computeProgress(
|
|
2652
|
+
size: this.size,
|
|
2653
|
+
progress: this.computeProgress(this.size)
|
|
2653
2654
|
});
|
|
2654
2655
|
if (wasClosed && target.size > 0) {
|
|
2655
2656
|
this.emit("open", { id });
|
|
@@ -2728,12 +2729,12 @@ var BottomSheetEngine = class {
|
|
|
2728
2729
|
const value = typeof h === "number" ? `${h}px` : h;
|
|
2729
2730
|
const axis = layoutAxis(this.mode);
|
|
2730
2731
|
this.element.style.setProperty(
|
|
2731
|
-
axis === "height" ? "
|
|
2732
|
+
axis === "height" ? "max-height" : "max-width",
|
|
2732
2733
|
value
|
|
2733
2734
|
);
|
|
2734
2735
|
if (typeof h === "number") {
|
|
2735
2736
|
this.maxHeightCap = h;
|
|
2736
|
-
this.
|
|
2737
|
+
this.recompute();
|
|
2737
2738
|
} else if (typeof window !== "undefined") {
|
|
2738
2739
|
const probe2 = document.createElement("div");
|
|
2739
2740
|
probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
|
|
@@ -2741,7 +2742,7 @@ var BottomSheetEngine = class {
|
|
|
2741
2742
|
const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
|
|
2742
2743
|
probe2.remove();
|
|
2743
2744
|
this.maxHeightCap = measured > 0 ? measured : void 0;
|
|
2744
|
-
this.
|
|
2745
|
+
this.recompute();
|
|
2745
2746
|
}
|
|
2746
2747
|
}
|
|
2747
2748
|
clampToMaxHeight() {
|
|
@@ -2749,9 +2750,6 @@ var BottomSheetEngine = class {
|
|
|
2749
2750
|
if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
|
|
2750
2751
|
this.snaps.setMaxAxisSize(this.maxHeightCap);
|
|
2751
2752
|
}
|
|
2752
|
-
if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
|
|
2753
|
-
this.applySize(this.maxHeightCap);
|
|
2754
|
-
}
|
|
2755
2753
|
}
|
|
2756
2754
|
setAllowed(ids, snap) {
|
|
2757
2755
|
if (this.destroyed) return;
|
|
@@ -2889,6 +2887,7 @@ var BottomSheetEngine = class {
|
|
|
2889
2887
|
recompute() {
|
|
2890
2888
|
if (this.destroyed) return;
|
|
2891
2889
|
this.snaps.recompute();
|
|
2890
|
+
this.clampToMaxHeight();
|
|
2892
2891
|
this.scrim.invalidateOpacityCache();
|
|
2893
2892
|
if (this.gesture?.isDragging) return;
|
|
2894
2893
|
const current = this.snaps.findById(this.activeId);
|
|
@@ -2912,43 +2911,36 @@ var BottomSheetEngine = class {
|
|
|
2912
2911
|
}
|
|
2913
2912
|
return out;
|
|
2914
2913
|
}
|
|
2915
|
-
|
|
2914
|
+
measureSheetNatural(vertical) {
|
|
2915
|
+
const el = this.element;
|
|
2916
2916
|
const content = this.scrollContainer;
|
|
2917
|
-
if (!content)
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
}
|
|
2937
|
-
let pad = 0;
|
|
2938
|
-
if (typeof getComputedStyle !== "undefined") {
|
|
2939
|
-
const cs = getComputedStyle(content);
|
|
2940
|
-
pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
|
|
2941
|
-
}
|
|
2942
|
-
return max - min + pad;
|
|
2917
|
+
if (!content) {
|
|
2918
|
+
return vertical ? el.offsetHeight : el.offsetWidth;
|
|
2919
|
+
}
|
|
2920
|
+
const axis = vertical ? "height" : "width";
|
|
2921
|
+
const sheetStyle = el.style;
|
|
2922
|
+
const cs = content.style;
|
|
2923
|
+
const prevSheet = sheetStyle[axis];
|
|
2924
|
+
const prevFlex = cs.flex;
|
|
2925
|
+
const prevContent = vertical ? cs.height : cs.width;
|
|
2926
|
+
sheetStyle[axis] = "auto";
|
|
2927
|
+
cs.flex = "none";
|
|
2928
|
+
if (vertical) cs.height = "auto";
|
|
2929
|
+
else cs.width = "auto";
|
|
2930
|
+
const natural = vertical ? el.offsetHeight : el.offsetWidth;
|
|
2931
|
+
sheetStyle[axis] = prevSheet;
|
|
2932
|
+
cs.flex = prevFlex;
|
|
2933
|
+
if (vertical) cs.height = prevContent;
|
|
2934
|
+
else cs.width = prevContent;
|
|
2935
|
+
return natural;
|
|
2943
2936
|
}
|
|
2944
2937
|
measureFitSize() {
|
|
2945
2938
|
const vertical = layoutAxis(this.mode) === "height";
|
|
2946
|
-
const
|
|
2947
|
-
const
|
|
2948
|
-
|
|
2949
|
-
if (typeof window === "undefined") return natural;
|
|
2939
|
+
const natural = this.measureSheetNatural(vertical);
|
|
2940
|
+
const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
|
|
2941
|
+
if (typeof window === "undefined") return capped;
|
|
2950
2942
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
2951
|
-
return viewport > 0 ? Math.min(
|
|
2943
|
+
return viewport > 0 ? Math.min(capped, viewport) : capped;
|
|
2952
2944
|
}
|
|
2953
2945
|
installFitObserver() {
|
|
2954
2946
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3030,6 +3022,10 @@ var BottomSheetEngine = class {
|
|
|
3030
3022
|
this.backdrop.style.opacity = "";
|
|
3031
3023
|
this.backdrop.style.pointerEvents = "";
|
|
3032
3024
|
}
|
|
3025
|
+
if (this.anchorHost) {
|
|
3026
|
+
this.anchorHost.style.removeProperty("--bs-size");
|
|
3027
|
+
this.anchorHost.style.removeProperty("--bs-progress");
|
|
3028
|
+
}
|
|
3033
3029
|
if (this.screenComponent) {
|
|
3034
3030
|
this.screenComponent.style.opacity = "";
|
|
3035
3031
|
this.screenComponent.style.display = "";
|
|
@@ -3041,6 +3037,7 @@ var BottomSheetEngine = class {
|
|
|
3041
3037
|
this.bus.emit(event, payload);
|
|
3042
3038
|
}
|
|
3043
3039
|
newCycle() {
|
|
3040
|
+
this.allowOvershoot = false;
|
|
3044
3041
|
this.currentAbort.abort();
|
|
3045
3042
|
this.currentAbort = new AbortController();
|
|
3046
3043
|
return this.currentAbort.signal;
|
|
@@ -3106,6 +3103,7 @@ var BottomSheetEngine = class {
|
|
|
3106
3103
|
seen.add(p.id);
|
|
3107
3104
|
}
|
|
3108
3105
|
this.snaps.setRaw(this.snapPointsRaw);
|
|
3106
|
+
this.clampToMaxHeight();
|
|
3109
3107
|
this.scrim.invalidateOpacityCache();
|
|
3110
3108
|
}
|
|
3111
3109
|
getAllowedRange() {
|
|
@@ -3312,15 +3310,19 @@ var BottomSheetEngine = class {
|
|
|
3312
3310
|
this.opening = true;
|
|
3313
3311
|
sheetStack.promote(this.id);
|
|
3314
3312
|
}
|
|
3315
|
-
|
|
3316
|
-
|
|
3313
|
+
const settleCap = this.snaps.getMaxAxisSize();
|
|
3314
|
+
const settleSize = settleCap > 0 ? Math.min(target.size, settleCap) : target.size;
|
|
3315
|
+
this.allowOvershoot = true;
|
|
3316
|
+
void this.animation.animateTo(settleSize, velocity).then(() => {
|
|
3317
3317
|
if (signal.aborted) return;
|
|
3318
|
+
this.allowOvershoot = false;
|
|
3319
|
+
this.opening = false;
|
|
3318
3320
|
this.scrollCache.restore(target.id, previousSize, target.size);
|
|
3319
3321
|
this.updateAriaSlider();
|
|
3320
3322
|
this.emit("snap", {
|
|
3321
3323
|
id: target.id,
|
|
3322
|
-
size:
|
|
3323
|
-
progress: this.computeProgress(
|
|
3324
|
+
size: this.size,
|
|
3325
|
+
progress: this.computeProgress(this.size)
|
|
3324
3326
|
});
|
|
3325
3327
|
this.haptic();
|
|
3326
3328
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
@@ -3345,23 +3347,25 @@ var BottomSheetEngine = class {
|
|
|
3345
3347
|
}
|
|
3346
3348
|
}
|
|
3347
3349
|
applySize(size) {
|
|
3348
|
-
|
|
3349
|
-
const
|
|
3350
|
+
const cap = this.snaps.getMaxAxisSize();
|
|
3351
|
+
const clamped = cap > 0 && size > cap && !this.gesture?.isDragging && !this.allowOvershoot ? cap : size;
|
|
3352
|
+
this.size = clamped;
|
|
3353
|
+
const offset = cap - clamped;
|
|
3350
3354
|
const style = this.element.style;
|
|
3351
3355
|
style.transform = this.transformTemplate(offset);
|
|
3352
|
-
if (this.sizeWriteSentinel.shouldWrite(
|
|
3353
|
-
style.setProperty("--bs-size", `${
|
|
3356
|
+
if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
|
|
3357
|
+
style.setProperty("--bs-size", `${clamped}px`);
|
|
3354
3358
|
if (this.scrimParent) {
|
|
3355
|
-
this.scrimParent.style.setProperty("--bs-size", `${
|
|
3359
|
+
this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
|
|
3356
3360
|
}
|
|
3357
3361
|
if (this.anchorHost && this.anchorHost !== this.scrimParent) {
|
|
3358
|
-
this.anchorHost.style.setProperty("--bs-size", `${
|
|
3362
|
+
this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
|
|
3359
3363
|
}
|
|
3360
3364
|
if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
|
|
3361
|
-
this.rootEl.style.setProperty("--bs-size", `${
|
|
3365
|
+
this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
|
|
3362
3366
|
}
|
|
3363
3367
|
}
|
|
3364
|
-
const progress = this.computeProgress(
|
|
3368
|
+
const progress = this.computeProgress(clamped);
|
|
3365
3369
|
const progressChanged = this.progressWriteSentinel.shouldWrite(
|
|
3366
3370
|
progress,
|
|
3367
3371
|
OPACITY_WRITE_EPSILON
|
|
@@ -3378,14 +3382,15 @@ var BottomSheetEngine = class {
|
|
|
3378
3382
|
this.scrim.applyOpacity(progress, progressChanged);
|
|
3379
3383
|
if (progressChanged && this.bus.listenerCount("progress") > 0) {
|
|
3380
3384
|
this.progressPayload.value = progress;
|
|
3381
|
-
this.progressPayload.size =
|
|
3385
|
+
this.progressPayload.size = clamped;
|
|
3382
3386
|
this.emit("progress", this.progressPayload);
|
|
3383
3387
|
}
|
|
3384
3388
|
}
|
|
3385
3389
|
computeProgress(size) {
|
|
3386
3390
|
const { min, max } = this.getAllowedRange();
|
|
3387
|
-
|
|
3388
|
-
|
|
3391
|
+
const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
|
|
3392
|
+
if (reachableMax <= min) return 0;
|
|
3393
|
+
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
3389
3394
|
}
|
|
3390
3395
|
handleOpen() {
|
|
3391
3396
|
sheetStack.promote(this.id);
|
|
@@ -3409,8 +3414,8 @@ var BottomSheetEngine = class {
|
|
|
3409
3414
|
this.updateAriaSlider();
|
|
3410
3415
|
this.emit("snap", {
|
|
3411
3416
|
id: target.id,
|
|
3412
|
-
size:
|
|
3413
|
-
progress: this.computeProgress(
|
|
3417
|
+
size: this.size,
|
|
3418
|
+
progress: this.computeProgress(this.size)
|
|
3414
3419
|
});
|
|
3415
3420
|
if (target.size > 0 && !this.lifecycle.isInstalled) {
|
|
3416
3421
|
this.emit("open", { id: target.id });
|
|
@@ -3469,7 +3474,14 @@ var BottomSheet = (props) => {
|
|
|
3469
3474
|
closeOnBack: props.closeOnBack,
|
|
3470
3475
|
lockBodyScroll: props.lockBodyScroll,
|
|
3471
3476
|
rubberBand: props.rubberBand,
|
|
3472
|
-
backdropRange: props.backdropRange
|
|
3477
|
+
backdropRange: props.backdropRange,
|
|
3478
|
+
radius: props.radius,
|
|
3479
|
+
maxHeight: props.maxHeight,
|
|
3480
|
+
persistent: props.persistent,
|
|
3481
|
+
disableClose: props.disableClose,
|
|
3482
|
+
disableDrag: props.disableDrag,
|
|
3483
|
+
closeOnRouteChange: props.closeOnRouteChange,
|
|
3484
|
+
returnFocusTo: props.returnFocusTo
|
|
3473
3485
|
};
|
|
3474
3486
|
engine = new BottomSheetEngine(engineOpts);
|
|
3475
3487
|
props.engineRef?.(engine);
|
|
@@ -3490,7 +3502,7 @@ var BottomSheet = (props) => {
|
|
|
3490
3502
|
engine.on("dragend", sync);
|
|
3491
3503
|
if (props.backdrop !== false && props.closeOnBackdrop !== false && backdropEl) {
|
|
3492
3504
|
const onBackdropClick = () => {
|
|
3493
|
-
void engine
|
|
3505
|
+
if (engine?.canDismiss()) void engine.close("backdrop");
|
|
3494
3506
|
};
|
|
3495
3507
|
backdropEl.addEventListener("click", onBackdropClick);
|
|
3496
3508
|
onCleanup(() => {
|
package/dist/solid.source.jsx
CHANGED
|
@@ -2359,6 +2359,7 @@ var BottomSheetEngine = class {
|
|
|
2359
2359
|
progressWriteSentinel = new WriteSentinel();
|
|
2360
2360
|
isTopSheet = true;
|
|
2361
2361
|
opening = false;
|
|
2362
|
+
allowOvershoot = false;
|
|
2362
2363
|
progressPayload = {
|
|
2363
2364
|
value: 0,
|
|
2364
2365
|
size: 0
|
|
@@ -2650,8 +2651,8 @@ var BottomSheetEngine = class {
|
|
|
2650
2651
|
this.updateAriaSlider();
|
|
2651
2652
|
this.emit("snap", {
|
|
2652
2653
|
id,
|
|
2653
|
-
size:
|
|
2654
|
-
progress: this.computeProgress(
|
|
2654
|
+
size: this.size,
|
|
2655
|
+
progress: this.computeProgress(this.size)
|
|
2655
2656
|
});
|
|
2656
2657
|
if (wasClosed && target.size > 0) {
|
|
2657
2658
|
this.emit("open", { id });
|
|
@@ -2730,12 +2731,12 @@ var BottomSheetEngine = class {
|
|
|
2730
2731
|
const value = typeof h === "number" ? `${h}px` : h;
|
|
2731
2732
|
const axis = layoutAxis(this.mode);
|
|
2732
2733
|
this.element.style.setProperty(
|
|
2733
|
-
axis === "height" ? "
|
|
2734
|
+
axis === "height" ? "max-height" : "max-width",
|
|
2734
2735
|
value
|
|
2735
2736
|
);
|
|
2736
2737
|
if (typeof h === "number") {
|
|
2737
2738
|
this.maxHeightCap = h;
|
|
2738
|
-
this.
|
|
2739
|
+
this.recompute();
|
|
2739
2740
|
} else if (typeof window !== "undefined") {
|
|
2740
2741
|
const probe2 = document.createElement("div");
|
|
2741
2742
|
probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
|
|
@@ -2743,7 +2744,7 @@ var BottomSheetEngine = class {
|
|
|
2743
2744
|
const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
|
|
2744
2745
|
probe2.remove();
|
|
2745
2746
|
this.maxHeightCap = measured > 0 ? measured : void 0;
|
|
2746
|
-
this.
|
|
2747
|
+
this.recompute();
|
|
2747
2748
|
}
|
|
2748
2749
|
}
|
|
2749
2750
|
clampToMaxHeight() {
|
|
@@ -2751,9 +2752,6 @@ var BottomSheetEngine = class {
|
|
|
2751
2752
|
if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
|
|
2752
2753
|
this.snaps.setMaxAxisSize(this.maxHeightCap);
|
|
2753
2754
|
}
|
|
2754
|
-
if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
|
|
2755
|
-
this.applySize(this.maxHeightCap);
|
|
2756
|
-
}
|
|
2757
2755
|
}
|
|
2758
2756
|
setAllowed(ids, snap) {
|
|
2759
2757
|
if (this.destroyed) return;
|
|
@@ -2891,6 +2889,7 @@ var BottomSheetEngine = class {
|
|
|
2891
2889
|
recompute() {
|
|
2892
2890
|
if (this.destroyed) return;
|
|
2893
2891
|
this.snaps.recompute();
|
|
2892
|
+
this.clampToMaxHeight();
|
|
2894
2893
|
this.scrim.invalidateOpacityCache();
|
|
2895
2894
|
if (this.gesture?.isDragging) return;
|
|
2896
2895
|
const current = this.snaps.findById(this.activeId);
|
|
@@ -2914,43 +2913,36 @@ var BottomSheetEngine = class {
|
|
|
2914
2913
|
}
|
|
2915
2914
|
return out;
|
|
2916
2915
|
}
|
|
2917
|
-
|
|
2916
|
+
measureSheetNatural(vertical) {
|
|
2917
|
+
const el = this.element;
|
|
2918
2918
|
const content = this.scrollContainer;
|
|
2919
|
-
if (!content)
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
}
|
|
2939
|
-
let pad = 0;
|
|
2940
|
-
if (typeof getComputedStyle !== "undefined") {
|
|
2941
|
-
const cs = getComputedStyle(content);
|
|
2942
|
-
pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
|
|
2943
|
-
}
|
|
2944
|
-
return max - min + pad;
|
|
2919
|
+
if (!content) {
|
|
2920
|
+
return vertical ? el.offsetHeight : el.offsetWidth;
|
|
2921
|
+
}
|
|
2922
|
+
const axis = vertical ? "height" : "width";
|
|
2923
|
+
const sheetStyle = el.style;
|
|
2924
|
+
const cs = content.style;
|
|
2925
|
+
const prevSheet = sheetStyle[axis];
|
|
2926
|
+
const prevFlex = cs.flex;
|
|
2927
|
+
const prevContent = vertical ? cs.height : cs.width;
|
|
2928
|
+
sheetStyle[axis] = "auto";
|
|
2929
|
+
cs.flex = "none";
|
|
2930
|
+
if (vertical) cs.height = "auto";
|
|
2931
|
+
else cs.width = "auto";
|
|
2932
|
+
const natural = vertical ? el.offsetHeight : el.offsetWidth;
|
|
2933
|
+
sheetStyle[axis] = prevSheet;
|
|
2934
|
+
cs.flex = prevFlex;
|
|
2935
|
+
if (vertical) cs.height = prevContent;
|
|
2936
|
+
else cs.width = prevContent;
|
|
2937
|
+
return natural;
|
|
2945
2938
|
}
|
|
2946
2939
|
measureFitSize() {
|
|
2947
2940
|
const vertical = layoutAxis(this.mode) === "height";
|
|
2948
|
-
const
|
|
2949
|
-
const
|
|
2950
|
-
|
|
2951
|
-
if (typeof window === "undefined") return natural;
|
|
2941
|
+
const natural = this.measureSheetNatural(vertical);
|
|
2942
|
+
const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
|
|
2943
|
+
if (typeof window === "undefined") return capped;
|
|
2952
2944
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
2953
|
-
return viewport > 0 ? Math.min(
|
|
2945
|
+
return viewport > 0 ? Math.min(capped, viewport) : capped;
|
|
2954
2946
|
}
|
|
2955
2947
|
installFitObserver() {
|
|
2956
2948
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3032,6 +3024,10 @@ var BottomSheetEngine = class {
|
|
|
3032
3024
|
this.backdrop.style.opacity = "";
|
|
3033
3025
|
this.backdrop.style.pointerEvents = "";
|
|
3034
3026
|
}
|
|
3027
|
+
if (this.anchorHost) {
|
|
3028
|
+
this.anchorHost.style.removeProperty("--bs-size");
|
|
3029
|
+
this.anchorHost.style.removeProperty("--bs-progress");
|
|
3030
|
+
}
|
|
3035
3031
|
if (this.screenComponent) {
|
|
3036
3032
|
this.screenComponent.style.opacity = "";
|
|
3037
3033
|
this.screenComponent.style.display = "";
|
|
@@ -3043,6 +3039,7 @@ var BottomSheetEngine = class {
|
|
|
3043
3039
|
this.bus.emit(event, payload);
|
|
3044
3040
|
}
|
|
3045
3041
|
newCycle() {
|
|
3042
|
+
this.allowOvershoot = false;
|
|
3046
3043
|
this.currentAbort.abort();
|
|
3047
3044
|
this.currentAbort = new AbortController();
|
|
3048
3045
|
return this.currentAbort.signal;
|
|
@@ -3108,6 +3105,7 @@ var BottomSheetEngine = class {
|
|
|
3108
3105
|
seen.add(p.id);
|
|
3109
3106
|
}
|
|
3110
3107
|
this.snaps.setRaw(this.snapPointsRaw);
|
|
3108
|
+
this.clampToMaxHeight();
|
|
3111
3109
|
this.scrim.invalidateOpacityCache();
|
|
3112
3110
|
}
|
|
3113
3111
|
getAllowedRange() {
|
|
@@ -3314,15 +3312,19 @@ var BottomSheetEngine = class {
|
|
|
3314
3312
|
this.opening = true;
|
|
3315
3313
|
sheetStack.promote(this.id);
|
|
3316
3314
|
}
|
|
3317
|
-
|
|
3318
|
-
|
|
3315
|
+
const settleCap = this.snaps.getMaxAxisSize();
|
|
3316
|
+
const settleSize = settleCap > 0 ? Math.min(target.size, settleCap) : target.size;
|
|
3317
|
+
this.allowOvershoot = true;
|
|
3318
|
+
void this.animation.animateTo(settleSize, velocity).then(() => {
|
|
3319
3319
|
if (signal.aborted) return;
|
|
3320
|
+
this.allowOvershoot = false;
|
|
3321
|
+
this.opening = false;
|
|
3320
3322
|
this.scrollCache.restore(target.id, previousSize, target.size);
|
|
3321
3323
|
this.updateAriaSlider();
|
|
3322
3324
|
this.emit("snap", {
|
|
3323
3325
|
id: target.id,
|
|
3324
|
-
size:
|
|
3325
|
-
progress: this.computeProgress(
|
|
3326
|
+
size: this.size,
|
|
3327
|
+
progress: this.computeProgress(this.size)
|
|
3326
3328
|
});
|
|
3327
3329
|
this.haptic();
|
|
3328
3330
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
@@ -3347,23 +3349,25 @@ var BottomSheetEngine = class {
|
|
|
3347
3349
|
}
|
|
3348
3350
|
}
|
|
3349
3351
|
applySize(size) {
|
|
3350
|
-
|
|
3351
|
-
const
|
|
3352
|
+
const cap = this.snaps.getMaxAxisSize();
|
|
3353
|
+
const clamped = cap > 0 && size > cap && !this.gesture?.isDragging && !this.allowOvershoot ? cap : size;
|
|
3354
|
+
this.size = clamped;
|
|
3355
|
+
const offset = cap - clamped;
|
|
3352
3356
|
const style = this.element.style;
|
|
3353
3357
|
style.transform = this.transformTemplate(offset);
|
|
3354
|
-
if (this.sizeWriteSentinel.shouldWrite(
|
|
3355
|
-
style.setProperty("--bs-size", `${
|
|
3358
|
+
if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
|
|
3359
|
+
style.setProperty("--bs-size", `${clamped}px`);
|
|
3356
3360
|
if (this.scrimParent) {
|
|
3357
|
-
this.scrimParent.style.setProperty("--bs-size", `${
|
|
3361
|
+
this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
|
|
3358
3362
|
}
|
|
3359
3363
|
if (this.anchorHost && this.anchorHost !== this.scrimParent) {
|
|
3360
|
-
this.anchorHost.style.setProperty("--bs-size", `${
|
|
3364
|
+
this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
|
|
3361
3365
|
}
|
|
3362
3366
|
if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
|
|
3363
|
-
this.rootEl.style.setProperty("--bs-size", `${
|
|
3367
|
+
this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
|
|
3364
3368
|
}
|
|
3365
3369
|
}
|
|
3366
|
-
const progress = this.computeProgress(
|
|
3370
|
+
const progress = this.computeProgress(clamped);
|
|
3367
3371
|
const progressChanged = this.progressWriteSentinel.shouldWrite(
|
|
3368
3372
|
progress,
|
|
3369
3373
|
OPACITY_WRITE_EPSILON
|
|
@@ -3380,14 +3384,15 @@ var BottomSheetEngine = class {
|
|
|
3380
3384
|
this.scrim.applyOpacity(progress, progressChanged);
|
|
3381
3385
|
if (progressChanged && this.bus.listenerCount("progress") > 0) {
|
|
3382
3386
|
this.progressPayload.value = progress;
|
|
3383
|
-
this.progressPayload.size =
|
|
3387
|
+
this.progressPayload.size = clamped;
|
|
3384
3388
|
this.emit("progress", this.progressPayload);
|
|
3385
3389
|
}
|
|
3386
3390
|
}
|
|
3387
3391
|
computeProgress(size) {
|
|
3388
3392
|
const { min, max } = this.getAllowedRange();
|
|
3389
|
-
|
|
3390
|
-
|
|
3393
|
+
const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
|
|
3394
|
+
if (reachableMax <= min) return 0;
|
|
3395
|
+
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
3391
3396
|
}
|
|
3392
3397
|
handleOpen() {
|
|
3393
3398
|
sheetStack.promote(this.id);
|
|
@@ -3411,8 +3416,8 @@ var BottomSheetEngine = class {
|
|
|
3411
3416
|
this.updateAriaSlider();
|
|
3412
3417
|
this.emit("snap", {
|
|
3413
3418
|
id: target.id,
|
|
3414
|
-
size:
|
|
3415
|
-
progress: this.computeProgress(
|
|
3419
|
+
size: this.size,
|
|
3420
|
+
progress: this.computeProgress(this.size)
|
|
3416
3421
|
});
|
|
3417
3422
|
if (target.size > 0 && !this.lifecycle.isInstalled) {
|
|
3418
3423
|
this.emit("open", { id: target.id });
|
|
@@ -3467,7 +3472,14 @@ var BottomSheet = (props) => {
|
|
|
3467
3472
|
closeOnBack: props.closeOnBack,
|
|
3468
3473
|
lockBodyScroll: props.lockBodyScroll,
|
|
3469
3474
|
rubberBand: props.rubberBand,
|
|
3470
|
-
backdropRange: props.backdropRange
|
|
3475
|
+
backdropRange: props.backdropRange,
|
|
3476
|
+
radius: props.radius,
|
|
3477
|
+
maxHeight: props.maxHeight,
|
|
3478
|
+
persistent: props.persistent,
|
|
3479
|
+
disableClose: props.disableClose,
|
|
3480
|
+
disableDrag: props.disableDrag,
|
|
3481
|
+
closeOnRouteChange: props.closeOnRouteChange,
|
|
3482
|
+
returnFocusTo: props.returnFocusTo
|
|
3471
3483
|
};
|
|
3472
3484
|
engine = new BottomSheetEngine(engineOpts);
|
|
3473
3485
|
props.engineRef?.(engine);
|
|
@@ -3486,7 +3498,7 @@ var BottomSheet = (props) => {
|
|
|
3486
3498
|
engine.on("dragend", sync);
|
|
3487
3499
|
if (props.backdrop !== false && props.closeOnBackdrop !== false && backdropEl) {
|
|
3488
3500
|
const onBackdropClick = () => {
|
|
3489
|
-
void engine
|
|
3501
|
+
if (engine?.canDismiss()) void engine.close("backdrop");
|
|
3490
3502
|
};
|
|
3491
3503
|
backdropEl.addEventListener("click", onBackdropClick);
|
|
3492
3504
|
onCleanup(() => {
|
package/dist/styles.css
CHANGED
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
display: flex;
|
|
119
119
|
flex-direction: column;
|
|
120
120
|
justify-content: center;
|
|
121
|
-
padding: 8px 16px 4px;
|
|
121
|
+
padding: var(--bs-handle-padding, 8px 16px 4px);
|
|
122
122
|
cursor: grab;
|
|
123
123
|
touch-action: none;
|
|
124
124
|
user-select: none;
|
|
@@ -246,7 +246,7 @@
|
|
|
246
246
|
|
|
247
247
|
.bs-header {
|
|
248
248
|
flex: 0 0 auto;
|
|
249
|
-
padding: 0 16px 8px;
|
|
249
|
+
padding: var(--bs-header-padding, 0 16px 8px);
|
|
250
250
|
background: var(--bs-surface, var(--bs-surface-d));
|
|
251
251
|
}
|
|
252
252
|
|
|
@@ -257,12 +257,12 @@
|
|
|
257
257
|
-webkit-overflow-scrolling: touch;
|
|
258
258
|
overscroll-behavior: contain;
|
|
259
259
|
user-select: text;
|
|
260
|
-
padding: 0 16px 16px;
|
|
260
|
+
padding: var(--bs-content-padding, 0 16px 16px);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
.bs-footer {
|
|
264
264
|
flex: 0 0 auto;
|
|
265
|
-
padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
|
|
265
|
+
padding: var(--bs-footer-padding, 12px 16px calc(12px + env(safe-area-inset-bottom)));
|
|
266
266
|
border-top: 1px solid var(--bs-surface-border, var(--bs-surface-border-d));
|
|
267
267
|
background: var(--bs-surface, var(--bs-surface-d));
|
|
268
268
|
}
|