@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/dist/react.js CHANGED
@@ -2365,6 +2365,7 @@ var BottomSheetEngine = class {
2365
2365
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2366
2366
  __publicField(this, "isTopSheet", true);
2367
2367
  __publicField(this, "opening", false);
2368
+ __publicField(this, "allowOvershoot", false);
2368
2369
  __publicField(this, "progressPayload", {
2369
2370
  value: 0,
2370
2371
  size: 0
@@ -2655,8 +2656,8 @@ var BottomSheetEngine = class {
2655
2656
  this.updateAriaSlider();
2656
2657
  this.emit("snap", {
2657
2658
  id,
2658
- size: target.size,
2659
- progress: this.computeProgress(target.size)
2659
+ size: this.size,
2660
+ progress: this.computeProgress(this.size)
2660
2661
  });
2661
2662
  if (wasClosed && target.size > 0) {
2662
2663
  this.emit("open", { id });
@@ -2735,12 +2736,12 @@ var BottomSheetEngine = class {
2735
2736
  const value = typeof h === "number" ? `${h}px` : h;
2736
2737
  const axis = layoutAxis(this.mode);
2737
2738
  this.element.style.setProperty(
2738
- axis === "height" ? "maxHeight" : "maxWidth",
2739
+ axis === "height" ? "max-height" : "max-width",
2739
2740
  value
2740
2741
  );
2741
2742
  if (typeof h === "number") {
2742
2743
  this.maxHeightCap = h;
2743
- this.clampToMaxHeight();
2744
+ this.recompute();
2744
2745
  } else if (typeof window !== "undefined") {
2745
2746
  const probe2 = document.createElement("div");
2746
2747
  probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
@@ -2748,7 +2749,7 @@ var BottomSheetEngine = class {
2748
2749
  const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
2749
2750
  probe2.remove();
2750
2751
  this.maxHeightCap = measured > 0 ? measured : void 0;
2751
- this.clampToMaxHeight();
2752
+ this.recompute();
2752
2753
  }
2753
2754
  }
2754
2755
  clampToMaxHeight() {
@@ -2756,9 +2757,6 @@ var BottomSheetEngine = class {
2756
2757
  if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
2757
2758
  this.snaps.setMaxAxisSize(this.maxHeightCap);
2758
2759
  }
2759
- if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
2760
- this.applySize(this.maxHeightCap);
2761
- }
2762
2760
  }
2763
2761
  setAllowed(ids, snap) {
2764
2762
  if (this.destroyed) return;
@@ -2896,6 +2894,7 @@ var BottomSheetEngine = class {
2896
2894
  recompute() {
2897
2895
  if (this.destroyed) return;
2898
2896
  this.snaps.recompute();
2897
+ this.clampToMaxHeight();
2899
2898
  this.scrim.invalidateOpacityCache();
2900
2899
  if (this.gesture?.isDragging) return;
2901
2900
  const current = this.snaps.findById(this.activeId);
@@ -2919,43 +2918,36 @@ var BottomSheetEngine = class {
2919
2918
  }
2920
2919
  return out;
2921
2920
  }
2922
- measureContentExtent(vertical) {
2921
+ measureSheetNatural(vertical) {
2922
+ const el = this.element;
2923
2923
  const content = this.scrollContainer;
2924
- if (!content) return 0;
2925
- const targets = this.contentTargets();
2926
- if (targets.length === 0) {
2927
- return vertical ? content.scrollHeight : content.scrollWidth;
2928
- }
2929
- let min = Infinity;
2930
- let max = -Infinity;
2931
- for (const el of targets) {
2932
- const r = el.getBoundingClientRect();
2933
- if (vertical) {
2934
- if (r.top < min) min = r.top;
2935
- if (r.bottom > max) max = r.bottom;
2936
- } else {
2937
- if (r.left < min) min = r.left;
2938
- if (r.right > max) max = r.right;
2939
- }
2940
- }
2941
- if (!isFinite(min) || !isFinite(max) || max <= min) {
2942
- return vertical ? content.scrollHeight : content.scrollWidth;
2943
- }
2944
- let pad = 0;
2945
- if (typeof getComputedStyle !== "undefined") {
2946
- const cs = getComputedStyle(content);
2947
- pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
2948
- }
2949
- return max - min + pad;
2924
+ if (!content) {
2925
+ return vertical ? el.offsetHeight : el.offsetWidth;
2926
+ }
2927
+ const axis = vertical ? "height" : "width";
2928
+ const sheetStyle = el.style;
2929
+ const cs = content.style;
2930
+ const prevSheet = sheetStyle[axis];
2931
+ const prevFlex = cs.flex;
2932
+ const prevContent = vertical ? cs.height : cs.width;
2933
+ sheetStyle[axis] = "auto";
2934
+ cs.flex = "none";
2935
+ if (vertical) cs.height = "auto";
2936
+ else cs.width = "auto";
2937
+ const natural = vertical ? el.offsetHeight : el.offsetWidth;
2938
+ sheetStyle[axis] = prevSheet;
2939
+ cs.flex = prevFlex;
2940
+ if (vertical) cs.height = prevContent;
2941
+ else cs.width = prevContent;
2942
+ return natural;
2950
2943
  }
2951
2944
  measureFitSize() {
2952
2945
  const vertical = layoutAxis(this.mode) === "height";
2953
- const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2954
- const content = this.scrollContainer;
2955
- const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2956
- if (typeof window === "undefined") return natural;
2946
+ const natural = this.measureSheetNatural(vertical);
2947
+ const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
2948
+ if (typeof window === "undefined") return capped;
2957
2949
  const viewport = vertical ? window.innerHeight : window.innerWidth;
2958
- return viewport > 0 ? Math.min(natural, viewport) : natural;
2950
+ return viewport > 0 ? Math.min(capped, viewport) : capped;
2959
2951
  }
2960
2952
  installFitObserver() {
2961
2953
  if (typeof ResizeObserver === "undefined") return;
@@ -3037,6 +3029,10 @@ var BottomSheetEngine = class {
3037
3029
  this.backdrop.style.opacity = "";
3038
3030
  this.backdrop.style.pointerEvents = "";
3039
3031
  }
3032
+ if (this.anchorHost) {
3033
+ this.anchorHost.style.removeProperty("--bs-size");
3034
+ this.anchorHost.style.removeProperty("--bs-progress");
3035
+ }
3040
3036
  if (this.screenComponent) {
3041
3037
  this.screenComponent.style.opacity = "";
3042
3038
  this.screenComponent.style.display = "";
@@ -3048,6 +3044,7 @@ var BottomSheetEngine = class {
3048
3044
  this.bus.emit(event, payload);
3049
3045
  }
3050
3046
  newCycle() {
3047
+ this.allowOvershoot = false;
3051
3048
  this.currentAbort.abort();
3052
3049
  this.currentAbort = new AbortController();
3053
3050
  return this.currentAbort.signal;
@@ -3113,6 +3110,7 @@ var BottomSheetEngine = class {
3113
3110
  seen.add(p.id);
3114
3111
  }
3115
3112
  this.snaps.setRaw(this.snapPointsRaw);
3113
+ this.clampToMaxHeight();
3116
3114
  this.scrim.invalidateOpacityCache();
3117
3115
  }
3118
3116
  getAllowedRange() {
@@ -3319,15 +3317,19 @@ var BottomSheetEngine = class {
3319
3317
  this.opening = true;
3320
3318
  sheetStack.promote(this.id);
3321
3319
  }
3322
- void this.animation.animateTo(target.size, velocity).then(() => {
3323
- this.opening = false;
3320
+ const settleCap = this.snaps.getMaxAxisSize();
3321
+ const settleSize = settleCap > 0 ? Math.min(target.size, settleCap) : target.size;
3322
+ this.allowOvershoot = true;
3323
+ void this.animation.animateTo(settleSize, velocity).then(() => {
3324
3324
  if (signal.aborted) return;
3325
+ this.allowOvershoot = false;
3326
+ this.opening = false;
3325
3327
  this.scrollCache.restore(target.id, previousSize, target.size);
3326
3328
  this.updateAriaSlider();
3327
3329
  this.emit("snap", {
3328
3330
  id: target.id,
3329
- size: target.size,
3330
- progress: this.computeProgress(target.size)
3331
+ size: this.size,
3332
+ progress: this.computeProgress(this.size)
3331
3333
  });
3332
3334
  this.haptic();
3333
3335
  if (previousSnapSize === 0 && target.size > 0) {
@@ -3352,23 +3354,25 @@ var BottomSheetEngine = class {
3352
3354
  }
3353
3355
  }
3354
3356
  applySize(size) {
3355
- this.size = size;
3356
- const offset = this.snaps.getMaxAxisSize() - size;
3357
+ const cap = this.snaps.getMaxAxisSize();
3358
+ const clamped = cap > 0 && size > cap && !this.gesture?.isDragging && !this.allowOvershoot ? cap : size;
3359
+ this.size = clamped;
3360
+ const offset = cap - clamped;
3357
3361
  const style = this.element.style;
3358
3362
  style.transform = this.transformTemplate(offset);
3359
- if (this.sizeWriteSentinel.shouldWrite(size, SIZE_WRITE_EPSILON)) {
3360
- style.setProperty("--bs-size", `${size}px`);
3363
+ if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
3364
+ style.setProperty("--bs-size", `${clamped}px`);
3361
3365
  if (this.scrimParent) {
3362
- this.scrimParent.style.setProperty("--bs-size", `${size}px`);
3366
+ this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
3363
3367
  }
3364
3368
  if (this.anchorHost && this.anchorHost !== this.scrimParent) {
3365
- this.anchorHost.style.setProperty("--bs-size", `${size}px`);
3369
+ this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
3366
3370
  }
3367
3371
  if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
3368
- this.rootEl.style.setProperty("--bs-size", `${size}px`);
3372
+ this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
3369
3373
  }
3370
3374
  }
3371
- const progress = this.computeProgress(size);
3375
+ const progress = this.computeProgress(clamped);
3372
3376
  const progressChanged = this.progressWriteSentinel.shouldWrite(
3373
3377
  progress,
3374
3378
  OPACITY_WRITE_EPSILON
@@ -3385,14 +3389,15 @@ var BottomSheetEngine = class {
3385
3389
  this.scrim.applyOpacity(progress, progressChanged);
3386
3390
  if (progressChanged && this.bus.listenerCount("progress") > 0) {
3387
3391
  this.progressPayload.value = progress;
3388
- this.progressPayload.size = size;
3392
+ this.progressPayload.size = clamped;
3389
3393
  this.emit("progress", this.progressPayload);
3390
3394
  }
3391
3395
  }
3392
3396
  computeProgress(size) {
3393
3397
  const { min, max } = this.getAllowedRange();
3394
- if (max <= min) return 0;
3395
- return Math.min(Math.max((size - min) / (max - min), 0), 1);
3398
+ const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
3399
+ if (reachableMax <= min) return 0;
3400
+ return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
3396
3401
  }
3397
3402
  handleOpen() {
3398
3403
  sheetStack.promote(this.id);
@@ -3416,8 +3421,8 @@ var BottomSheetEngine = class {
3416
3421
  this.updateAriaSlider();
3417
3422
  this.emit("snap", {
3418
3423
  id: target.id,
3419
- size: target.size,
3420
- progress: this.computeProgress(target.size)
3424
+ size: this.size,
3425
+ progress: this.computeProgress(this.size)
3421
3426
  });
3422
3427
  if (target.size > 0 && !this.lifecycle.isInstalled) {
3423
3428
  this.emit("open", { id: target.id });
@@ -3572,6 +3577,18 @@ function useBottomSheet(opts) {
3572
3577
  engineRef.current.setBackdropRange([0, opts.backdropOpacity]);
3573
3578
  }
3574
3579
  }, [opts.backdropOpacity]);
3580
+ useEffect(() => {
3581
+ if (!engineRef.current) return;
3582
+ if (opts.radius !== void 0) {
3583
+ engineRef.current.setRadius(opts.radius);
3584
+ }
3585
+ }, [opts.radius]);
3586
+ useEffect(() => {
3587
+ if (!engineRef.current) return;
3588
+ if (opts.maxHeight !== void 0) {
3589
+ engineRef.current.setMaxHeight(opts.maxHeight);
3590
+ }
3591
+ }, [opts.maxHeight]);
3575
3592
  const subscribe = useCallback((fn) => {
3576
3593
  subscribersRef.current.add(fn);
3577
3594
  return () => subscribersRef.current.delete(fn);
package/dist/solid.cjs CHANGED
@@ -2360,6 +2360,7 @@ var BottomSheetEngine = class {
2360
2360
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2361
2361
  __publicField(this, "isTopSheet", true);
2362
2362
  __publicField(this, "opening", false);
2363
+ __publicField(this, "allowOvershoot", false);
2363
2364
  __publicField(this, "progressPayload", {
2364
2365
  value: 0,
2365
2366
  size: 0
@@ -2650,8 +2651,8 @@ var BottomSheetEngine = class {
2650
2651
  this.updateAriaSlider();
2651
2652
  this.emit("snap", {
2652
2653
  id,
2653
- size: target.size,
2654
- progress: this.computeProgress(target.size)
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" ? "maxHeight" : "maxWidth",
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.clampToMaxHeight();
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.clampToMaxHeight();
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
- measureContentExtent(vertical) {
2916
+ measureSheetNatural(vertical) {
2917
+ const el = this.element;
2918
2918
  const content = this.scrollContainer;
2919
- if (!content) return 0;
2920
- const targets = this.contentTargets();
2921
- if (targets.length === 0) {
2922
- return vertical ? content.scrollHeight : content.scrollWidth;
2923
- }
2924
- let min = Infinity;
2925
- let max = -Infinity;
2926
- for (const el of targets) {
2927
- const r = el.getBoundingClientRect();
2928
- if (vertical) {
2929
- if (r.top < min) min = r.top;
2930
- if (r.bottom > max) max = r.bottom;
2931
- } else {
2932
- if (r.left < min) min = r.left;
2933
- if (r.right > max) max = r.right;
2934
- }
2935
- }
2936
- if (!isFinite(min) || !isFinite(max) || max <= min) {
2937
- return vertical ? content.scrollHeight : content.scrollWidth;
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 handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2949
- const content = this.scrollContainer;
2950
- const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
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(natural, viewport) : natural;
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
- void this.animation.animateTo(target.size, velocity).then(() => {
3318
- this.opening = false;
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: target.size,
3325
- progress: this.computeProgress(target.size)
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
- this.size = size;
3351
- const offset = this.snaps.getMaxAxisSize() - size;
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(size, SIZE_WRITE_EPSILON)) {
3355
- style.setProperty("--bs-size", `${size}px`);
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", `${size}px`);
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", `${size}px`);
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", `${size}px`);
3367
+ this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
3364
3368
  }
3365
3369
  }
3366
- const progress = this.computeProgress(size);
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 = 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
- if (max <= min) return 0;
3390
- return Math.min(Math.max((size - min) / (max - min), 0), 1);
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: target.size,
3415
- progress: this.computeProgress(target.size)
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 });
@@ -3471,7 +3476,14 @@ var BottomSheet = (props) => {
3471
3476
  closeOnBack: props.closeOnBack,
3472
3477
  lockBodyScroll: props.lockBodyScroll,
3473
3478
  rubberBand: props.rubberBand,
3474
- backdropRange: props.backdropRange
3479
+ backdropRange: props.backdropRange,
3480
+ radius: props.radius,
3481
+ maxHeight: props.maxHeight,
3482
+ persistent: props.persistent,
3483
+ disableClose: props.disableClose,
3484
+ disableDrag: props.disableDrag,
3485
+ closeOnRouteChange: props.closeOnRouteChange,
3486
+ returnFocusTo: props.returnFocusTo
3475
3487
  };
3476
3488
  engine = new BottomSheetEngine(engineOpts);
3477
3489
  props.engineRef?.(engine);
@@ -3492,7 +3504,7 @@ var BottomSheet = (props) => {
3492
3504
  engine.on("dragend", sync);
3493
3505
  if (props.backdrop !== false && props.closeOnBackdrop !== false && backdropEl) {
3494
3506
  const onBackdropClick = () => {
3495
- void engine?.close();
3507
+ if (engine?.canDismiss()) void engine.close("backdrop");
3496
3508
  };
3497
3509
  backdropEl.addEventListener("click", onBackdropClick);
3498
3510
  solidJs.onCleanup(() => {
package/dist/solid.d.cts CHANGED
@@ -216,6 +216,7 @@ declare class BottomSheetEngine {
216
216
  private progressWriteSentinel;
217
217
  private isTopSheet;
218
218
  private opening;
219
+ private allowOvershoot;
219
220
  private progressPayload;
220
221
  private dragContextBuf;
221
222
  private bus;
@@ -274,7 +275,7 @@ declare class BottomSheetEngine {
274
275
  setSnapPoints(points: EngineOptions["snapPoints"], allowed?: string[]): void;
275
276
  recompute(): void;
276
277
  private contentTargets;
277
- private measureContentExtent;
278
+ private measureSheetNatural;
278
279
  private measureFitSize;
279
280
  private installFitObserver;
280
281
  destroy(): void;
@@ -319,6 +320,13 @@ type BottomSheetProps<TId extends string = string> = {
319
320
  lockBodyScroll?: boolean;
320
321
  rubberBand?: boolean;
321
322
  backdropRange?: [number, number];
323
+ radius?: string | number;
324
+ maxHeight?: string | number;
325
+ persistent?: boolean;
326
+ disableClose?: boolean;
327
+ disableDrag?: boolean;
328
+ closeOnRouteChange?: boolean;
329
+ returnFocusTo?: string;
322
330
  backdrop?: boolean;
323
331
  closeOnBackdrop?: boolean;
324
332
  ariaLabel?: string;
package/dist/solid.d.ts CHANGED
@@ -216,6 +216,7 @@ declare class BottomSheetEngine {
216
216
  private progressWriteSentinel;
217
217
  private isTopSheet;
218
218
  private opening;
219
+ private allowOvershoot;
219
220
  private progressPayload;
220
221
  private dragContextBuf;
221
222
  private bus;
@@ -274,7 +275,7 @@ declare class BottomSheetEngine {
274
275
  setSnapPoints(points: EngineOptions["snapPoints"], allowed?: string[]): void;
275
276
  recompute(): void;
276
277
  private contentTargets;
277
- private measureContentExtent;
278
+ private measureSheetNatural;
278
279
  private measureFitSize;
279
280
  private installFitObserver;
280
281
  destroy(): void;
@@ -319,6 +320,13 @@ type BottomSheetProps<TId extends string = string> = {
319
320
  lockBodyScroll?: boolean;
320
321
  rubberBand?: boolean;
321
322
  backdropRange?: [number, number];
323
+ radius?: string | number;
324
+ maxHeight?: string | number;
325
+ persistent?: boolean;
326
+ disableClose?: boolean;
327
+ disableDrag?: boolean;
328
+ closeOnRouteChange?: boolean;
329
+ returnFocusTo?: string;
322
330
  backdrop?: boolean;
323
331
  closeOnBackdrop?: boolean;
324
332
  ariaLabel?: string;