@surdeddd/bottom-sheet 0.6.0 → 0.7.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/qwik.js CHANGED
@@ -2621,7 +2621,9 @@ var BottomSheetEngine = class {
2621
2621
  const previousSize = this.size;
2622
2622
  this.scrollCache.cache(previousId, previousSize, target.size);
2623
2623
  this.activeId = id;
2624
- if (wasClosed && target.size > 0) {
2624
+ const rawTargetSize = this.snapPointsRaw.find((p) => p.id === id)?.size;
2625
+ const opensToRest = id === "closed" || rawTargetSize === 0;
2626
+ if (wasClosed && !opensToRest) {
2625
2627
  this.opening = true;
2626
2628
  sheetStack.promote(this.id);
2627
2629
  }
@@ -2646,8 +2648,8 @@ var BottomSheetEngine = class {
2646
2648
  this.updateAriaSlider();
2647
2649
  this.emit("snap", {
2648
2650
  id,
2649
- size: target.size,
2650
- progress: this.computeProgress(target.size)
2651
+ size: this.size,
2652
+ progress: this.computeProgress(this.size)
2651
2653
  });
2652
2654
  if (wasClosed && target.size > 0) {
2653
2655
  this.emit("open", { id });
@@ -2726,12 +2728,12 @@ var BottomSheetEngine = class {
2726
2728
  const value = typeof h === "number" ? `${h}px` : h;
2727
2729
  const axis = layoutAxis(this.mode);
2728
2730
  this.element.style.setProperty(
2729
- axis === "height" ? "maxHeight" : "maxWidth",
2731
+ axis === "height" ? "max-height" : "max-width",
2730
2732
  value
2731
2733
  );
2732
2734
  if (typeof h === "number") {
2733
2735
  this.maxHeightCap = h;
2734
- this.clampToMaxHeight();
2736
+ this.recompute();
2735
2737
  } else if (typeof window !== "undefined") {
2736
2738
  const probe2 = document.createElement("div");
2737
2739
  probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
@@ -2739,7 +2741,7 @@ var BottomSheetEngine = class {
2739
2741
  const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
2740
2742
  probe2.remove();
2741
2743
  this.maxHeightCap = measured > 0 ? measured : void 0;
2742
- this.clampToMaxHeight();
2744
+ this.recompute();
2743
2745
  }
2744
2746
  }
2745
2747
  clampToMaxHeight() {
@@ -2747,9 +2749,6 @@ var BottomSheetEngine = class {
2747
2749
  if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
2748
2750
  this.snaps.setMaxAxisSize(this.maxHeightCap);
2749
2751
  }
2750
- if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
2751
- this.applySize(this.maxHeightCap);
2752
- }
2753
2752
  }
2754
2753
  setAllowed(ids, snap) {
2755
2754
  if (this.destroyed) return;
@@ -2887,6 +2886,7 @@ var BottomSheetEngine = class {
2887
2886
  recompute() {
2888
2887
  if (this.destroyed) return;
2889
2888
  this.snaps.recompute();
2889
+ this.clampToMaxHeight();
2890
2890
  this.scrim.invalidateOpacityCache();
2891
2891
  if (this.gesture?.isDragging) return;
2892
2892
  const current = this.snaps.findById(this.activeId);
@@ -2944,9 +2944,10 @@ var BottomSheetEngine = class {
2944
2944
  const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2945
2945
  const content = this.scrollContainer;
2946
2946
  const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2947
- if (typeof window === "undefined") return natural;
2947
+ const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
2948
+ if (typeof window === "undefined") return capped;
2948
2949
  const viewport = vertical ? window.innerHeight : window.innerWidth;
2949
- return viewport > 0 ? Math.min(natural, viewport) : natural;
2950
+ return viewport > 0 ? Math.min(capped, viewport) : capped;
2950
2951
  }
2951
2952
  installFitObserver() {
2952
2953
  if (typeof ResizeObserver === "undefined") return;
@@ -3317,8 +3318,8 @@ var BottomSheetEngine = class {
3317
3318
  this.updateAriaSlider();
3318
3319
  this.emit("snap", {
3319
3320
  id: target.id,
3320
- size: target.size,
3321
- progress: this.computeProgress(target.size)
3321
+ size: this.size,
3322
+ progress: this.computeProgress(this.size)
3322
3323
  });
3323
3324
  this.haptic();
3324
3325
  if (previousSnapSize === 0 && target.size > 0) {
@@ -3343,23 +3344,25 @@ var BottomSheetEngine = class {
3343
3344
  }
3344
3345
  }
3345
3346
  applySize(size) {
3346
- this.size = size;
3347
- const offset = this.snaps.getMaxAxisSize() - size;
3347
+ const cap = this.snaps.getMaxAxisSize();
3348
+ const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
3349
+ this.size = clamped;
3350
+ const offset = cap - clamped;
3348
3351
  const style = this.element.style;
3349
3352
  style.transform = this.transformTemplate(offset);
3350
- if (this.sizeWriteSentinel.shouldWrite(size, SIZE_WRITE_EPSILON)) {
3351
- style.setProperty("--bs-size", `${size}px`);
3353
+ if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
3354
+ style.setProperty("--bs-size", `${clamped}px`);
3352
3355
  if (this.scrimParent) {
3353
- this.scrimParent.style.setProperty("--bs-size", `${size}px`);
3356
+ this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
3354
3357
  }
3355
3358
  if (this.anchorHost && this.anchorHost !== this.scrimParent) {
3356
- this.anchorHost.style.setProperty("--bs-size", `${size}px`);
3359
+ this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
3357
3360
  }
3358
3361
  if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
3359
- this.rootEl.style.setProperty("--bs-size", `${size}px`);
3362
+ this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
3360
3363
  }
3361
3364
  }
3362
- const progress = this.computeProgress(size);
3365
+ const progress = this.computeProgress(clamped);
3363
3366
  const progressChanged = this.progressWriteSentinel.shouldWrite(
3364
3367
  progress,
3365
3368
  OPACITY_WRITE_EPSILON
@@ -3376,14 +3379,15 @@ var BottomSheetEngine = class {
3376
3379
  this.scrim.applyOpacity(progress, progressChanged);
3377
3380
  if (progressChanged && this.bus.listenerCount("progress") > 0) {
3378
3381
  this.progressPayload.value = progress;
3379
- this.progressPayload.size = size;
3382
+ this.progressPayload.size = clamped;
3380
3383
  this.emit("progress", this.progressPayload);
3381
3384
  }
3382
3385
  }
3383
3386
  computeProgress(size) {
3384
3387
  const { min, max } = this.getAllowedRange();
3385
- if (max <= min) return 0;
3386
- return Math.min(Math.max((size - min) / (max - min), 0), 1);
3388
+ const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
3389
+ if (reachableMax <= min) return 0;
3390
+ return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
3387
3391
  }
3388
3392
  handleOpen() {
3389
3393
  sheetStack.promote(this.id);
@@ -3407,8 +3411,8 @@ var BottomSheetEngine = class {
3407
3411
  this.updateAriaSlider();
3408
3412
  this.emit("snap", {
3409
3413
  id: target.id,
3410
- size: target.size,
3411
- progress: this.computeProgress(target.size)
3414
+ size: this.size,
3415
+ progress: this.computeProgress(this.size)
3412
3416
  });
3413
3417
  if (target.size > 0 && !this.lifecycle.isInstalled) {
3414
3418
  this.emit("open", { id: target.id });
package/dist/react.cjs CHANGED
@@ -2630,7 +2630,9 @@ var BottomSheetEngine = class {
2630
2630
  const previousSize = this.size;
2631
2631
  this.scrollCache.cache(previousId, previousSize, target.size);
2632
2632
  this.activeId = id;
2633
- if (wasClosed && target.size > 0) {
2633
+ const rawTargetSize = this.snapPointsRaw.find((p) => p.id === id)?.size;
2634
+ const opensToRest = id === "closed" || rawTargetSize === 0;
2635
+ if (wasClosed && !opensToRest) {
2634
2636
  this.opening = true;
2635
2637
  sheetStack.promote(this.id);
2636
2638
  }
@@ -2655,8 +2657,8 @@ var BottomSheetEngine = class {
2655
2657
  this.updateAriaSlider();
2656
2658
  this.emit("snap", {
2657
2659
  id,
2658
- size: target.size,
2659
- progress: this.computeProgress(target.size)
2660
+ size: this.size,
2661
+ progress: this.computeProgress(this.size)
2660
2662
  });
2661
2663
  if (wasClosed && target.size > 0) {
2662
2664
  this.emit("open", { id });
@@ -2735,12 +2737,12 @@ var BottomSheetEngine = class {
2735
2737
  const value = typeof h === "number" ? `${h}px` : h;
2736
2738
  const axis = layoutAxis(this.mode);
2737
2739
  this.element.style.setProperty(
2738
- axis === "height" ? "maxHeight" : "maxWidth",
2740
+ axis === "height" ? "max-height" : "max-width",
2739
2741
  value
2740
2742
  );
2741
2743
  if (typeof h === "number") {
2742
2744
  this.maxHeightCap = h;
2743
- this.clampToMaxHeight();
2745
+ this.recompute();
2744
2746
  } else if (typeof window !== "undefined") {
2745
2747
  const probe2 = document.createElement("div");
2746
2748
  probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
@@ -2748,7 +2750,7 @@ var BottomSheetEngine = class {
2748
2750
  const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
2749
2751
  probe2.remove();
2750
2752
  this.maxHeightCap = measured > 0 ? measured : void 0;
2751
- this.clampToMaxHeight();
2753
+ this.recompute();
2752
2754
  }
2753
2755
  }
2754
2756
  clampToMaxHeight() {
@@ -2756,9 +2758,6 @@ var BottomSheetEngine = class {
2756
2758
  if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
2757
2759
  this.snaps.setMaxAxisSize(this.maxHeightCap);
2758
2760
  }
2759
- if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
2760
- this.applySize(this.maxHeightCap);
2761
- }
2762
2761
  }
2763
2762
  setAllowed(ids, snap) {
2764
2763
  if (this.destroyed) return;
@@ -2896,6 +2895,7 @@ var BottomSheetEngine = class {
2896
2895
  recompute() {
2897
2896
  if (this.destroyed) return;
2898
2897
  this.snaps.recompute();
2898
+ this.clampToMaxHeight();
2899
2899
  this.scrim.invalidateOpacityCache();
2900
2900
  if (this.gesture?.isDragging) return;
2901
2901
  const current = this.snaps.findById(this.activeId);
@@ -2953,9 +2953,10 @@ var BottomSheetEngine = class {
2953
2953
  const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2954
2954
  const content = this.scrollContainer;
2955
2955
  const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2956
- if (typeof window === "undefined") return natural;
2956
+ const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
2957
+ if (typeof window === "undefined") return capped;
2957
2958
  const viewport = vertical ? window.innerHeight : window.innerWidth;
2958
- return viewport > 0 ? Math.min(natural, viewport) : natural;
2959
+ return viewport > 0 ? Math.min(capped, viewport) : capped;
2959
2960
  }
2960
2961
  installFitObserver() {
2961
2962
  if (typeof ResizeObserver === "undefined") return;
@@ -3326,8 +3327,8 @@ var BottomSheetEngine = class {
3326
3327
  this.updateAriaSlider();
3327
3328
  this.emit("snap", {
3328
3329
  id: target.id,
3329
- size: target.size,
3330
- progress: this.computeProgress(target.size)
3330
+ size: this.size,
3331
+ progress: this.computeProgress(this.size)
3331
3332
  });
3332
3333
  this.haptic();
3333
3334
  if (previousSnapSize === 0 && target.size > 0) {
@@ -3352,23 +3353,25 @@ var BottomSheetEngine = class {
3352
3353
  }
3353
3354
  }
3354
3355
  applySize(size) {
3355
- this.size = size;
3356
- const offset = this.snaps.getMaxAxisSize() - size;
3356
+ const cap = this.snaps.getMaxAxisSize();
3357
+ const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
3358
+ this.size = clamped;
3359
+ const offset = cap - clamped;
3357
3360
  const style = this.element.style;
3358
3361
  style.transform = this.transformTemplate(offset);
3359
- if (this.sizeWriteSentinel.shouldWrite(size, SIZE_WRITE_EPSILON)) {
3360
- style.setProperty("--bs-size", `${size}px`);
3362
+ if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
3363
+ style.setProperty("--bs-size", `${clamped}px`);
3361
3364
  if (this.scrimParent) {
3362
- this.scrimParent.style.setProperty("--bs-size", `${size}px`);
3365
+ this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
3363
3366
  }
3364
3367
  if (this.anchorHost && this.anchorHost !== this.scrimParent) {
3365
- this.anchorHost.style.setProperty("--bs-size", `${size}px`);
3368
+ this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
3366
3369
  }
3367
3370
  if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
3368
- this.rootEl.style.setProperty("--bs-size", `${size}px`);
3371
+ this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
3369
3372
  }
3370
3373
  }
3371
- const progress = this.computeProgress(size);
3374
+ const progress = this.computeProgress(clamped);
3372
3375
  const progressChanged = this.progressWriteSentinel.shouldWrite(
3373
3376
  progress,
3374
3377
  OPACITY_WRITE_EPSILON
@@ -3385,14 +3388,15 @@ var BottomSheetEngine = class {
3385
3388
  this.scrim.applyOpacity(progress, progressChanged);
3386
3389
  if (progressChanged && this.bus.listenerCount("progress") > 0) {
3387
3390
  this.progressPayload.value = progress;
3388
- this.progressPayload.size = size;
3391
+ this.progressPayload.size = clamped;
3389
3392
  this.emit("progress", this.progressPayload);
3390
3393
  }
3391
3394
  }
3392
3395
  computeProgress(size) {
3393
3396
  const { min, max } = this.getAllowedRange();
3394
- if (max <= min) return 0;
3395
- return Math.min(Math.max((size - min) / (max - min), 0), 1);
3397
+ const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
3398
+ if (reachableMax <= min) return 0;
3399
+ return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
3396
3400
  }
3397
3401
  handleOpen() {
3398
3402
  sheetStack.promote(this.id);
@@ -3416,8 +3420,8 @@ var BottomSheetEngine = class {
3416
3420
  this.updateAriaSlider();
3417
3421
  this.emit("snap", {
3418
3422
  id: target.id,
3419
- size: target.size,
3420
- progress: this.computeProgress(target.size)
3423
+ size: this.size,
3424
+ progress: this.computeProgress(this.size)
3421
3425
  });
3422
3426
  if (target.size > 0 && !this.lifecycle.isInstalled) {
3423
3427
  this.emit("open", { id: target.id });
package/dist/react.js CHANGED
@@ -2628,7 +2628,9 @@ var BottomSheetEngine = class {
2628
2628
  const previousSize = this.size;
2629
2629
  this.scrollCache.cache(previousId, previousSize, target.size);
2630
2630
  this.activeId = id;
2631
- if (wasClosed && target.size > 0) {
2631
+ const rawTargetSize = this.snapPointsRaw.find((p) => p.id === id)?.size;
2632
+ const opensToRest = id === "closed" || rawTargetSize === 0;
2633
+ if (wasClosed && !opensToRest) {
2632
2634
  this.opening = true;
2633
2635
  sheetStack.promote(this.id);
2634
2636
  }
@@ -2653,8 +2655,8 @@ var BottomSheetEngine = class {
2653
2655
  this.updateAriaSlider();
2654
2656
  this.emit("snap", {
2655
2657
  id,
2656
- size: target.size,
2657
- progress: this.computeProgress(target.size)
2658
+ size: this.size,
2659
+ progress: this.computeProgress(this.size)
2658
2660
  });
2659
2661
  if (wasClosed && target.size > 0) {
2660
2662
  this.emit("open", { id });
@@ -2733,12 +2735,12 @@ var BottomSheetEngine = class {
2733
2735
  const value = typeof h === "number" ? `${h}px` : h;
2734
2736
  const axis = layoutAxis(this.mode);
2735
2737
  this.element.style.setProperty(
2736
- axis === "height" ? "maxHeight" : "maxWidth",
2738
+ axis === "height" ? "max-height" : "max-width",
2737
2739
  value
2738
2740
  );
2739
2741
  if (typeof h === "number") {
2740
2742
  this.maxHeightCap = h;
2741
- this.clampToMaxHeight();
2743
+ this.recompute();
2742
2744
  } else if (typeof window !== "undefined") {
2743
2745
  const probe2 = document.createElement("div");
2744
2746
  probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
@@ -2746,7 +2748,7 @@ var BottomSheetEngine = class {
2746
2748
  const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
2747
2749
  probe2.remove();
2748
2750
  this.maxHeightCap = measured > 0 ? measured : void 0;
2749
- this.clampToMaxHeight();
2751
+ this.recompute();
2750
2752
  }
2751
2753
  }
2752
2754
  clampToMaxHeight() {
@@ -2754,9 +2756,6 @@ var BottomSheetEngine = class {
2754
2756
  if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
2755
2757
  this.snaps.setMaxAxisSize(this.maxHeightCap);
2756
2758
  }
2757
- if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
2758
- this.applySize(this.maxHeightCap);
2759
- }
2760
2759
  }
2761
2760
  setAllowed(ids, snap) {
2762
2761
  if (this.destroyed) return;
@@ -2894,6 +2893,7 @@ var BottomSheetEngine = class {
2894
2893
  recompute() {
2895
2894
  if (this.destroyed) return;
2896
2895
  this.snaps.recompute();
2896
+ this.clampToMaxHeight();
2897
2897
  this.scrim.invalidateOpacityCache();
2898
2898
  if (this.gesture?.isDragging) return;
2899
2899
  const current = this.snaps.findById(this.activeId);
@@ -2951,9 +2951,10 @@ var BottomSheetEngine = class {
2951
2951
  const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2952
2952
  const content = this.scrollContainer;
2953
2953
  const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2954
- if (typeof window === "undefined") return natural;
2954
+ const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
2955
+ if (typeof window === "undefined") return capped;
2955
2956
  const viewport = vertical ? window.innerHeight : window.innerWidth;
2956
- return viewport > 0 ? Math.min(natural, viewport) : natural;
2957
+ return viewport > 0 ? Math.min(capped, viewport) : capped;
2957
2958
  }
2958
2959
  installFitObserver() {
2959
2960
  if (typeof ResizeObserver === "undefined") return;
@@ -3324,8 +3325,8 @@ var BottomSheetEngine = class {
3324
3325
  this.updateAriaSlider();
3325
3326
  this.emit("snap", {
3326
3327
  id: target.id,
3327
- size: target.size,
3328
- progress: this.computeProgress(target.size)
3328
+ size: this.size,
3329
+ progress: this.computeProgress(this.size)
3329
3330
  });
3330
3331
  this.haptic();
3331
3332
  if (previousSnapSize === 0 && target.size > 0) {
@@ -3350,23 +3351,25 @@ var BottomSheetEngine = class {
3350
3351
  }
3351
3352
  }
3352
3353
  applySize(size) {
3353
- this.size = size;
3354
- const offset = this.snaps.getMaxAxisSize() - size;
3354
+ const cap = this.snaps.getMaxAxisSize();
3355
+ const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
3356
+ this.size = clamped;
3357
+ const offset = cap - clamped;
3355
3358
  const style = this.element.style;
3356
3359
  style.transform = this.transformTemplate(offset);
3357
- if (this.sizeWriteSentinel.shouldWrite(size, SIZE_WRITE_EPSILON)) {
3358
- style.setProperty("--bs-size", `${size}px`);
3360
+ if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
3361
+ style.setProperty("--bs-size", `${clamped}px`);
3359
3362
  if (this.scrimParent) {
3360
- this.scrimParent.style.setProperty("--bs-size", `${size}px`);
3363
+ this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
3361
3364
  }
3362
3365
  if (this.anchorHost && this.anchorHost !== this.scrimParent) {
3363
- this.anchorHost.style.setProperty("--bs-size", `${size}px`);
3366
+ this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
3364
3367
  }
3365
3368
  if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
3366
- this.rootEl.style.setProperty("--bs-size", `${size}px`);
3369
+ this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
3367
3370
  }
3368
3371
  }
3369
- const progress = this.computeProgress(size);
3372
+ const progress = this.computeProgress(clamped);
3370
3373
  const progressChanged = this.progressWriteSentinel.shouldWrite(
3371
3374
  progress,
3372
3375
  OPACITY_WRITE_EPSILON
@@ -3383,14 +3386,15 @@ var BottomSheetEngine = class {
3383
3386
  this.scrim.applyOpacity(progress, progressChanged);
3384
3387
  if (progressChanged && this.bus.listenerCount("progress") > 0) {
3385
3388
  this.progressPayload.value = progress;
3386
- this.progressPayload.size = size;
3389
+ this.progressPayload.size = clamped;
3387
3390
  this.emit("progress", this.progressPayload);
3388
3391
  }
3389
3392
  }
3390
3393
  computeProgress(size) {
3391
3394
  const { min, max } = this.getAllowedRange();
3392
- if (max <= min) return 0;
3393
- return Math.min(Math.max((size - min) / (max - min), 0), 1);
3395
+ const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
3396
+ if (reachableMax <= min) return 0;
3397
+ return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
3394
3398
  }
3395
3399
  handleOpen() {
3396
3400
  sheetStack.promote(this.id);
@@ -3414,8 +3418,8 @@ var BottomSheetEngine = class {
3414
3418
  this.updateAriaSlider();
3415
3419
  this.emit("snap", {
3416
3420
  id: target.id,
3417
- size: target.size,
3418
- progress: this.computeProgress(target.size)
3421
+ size: this.size,
3422
+ progress: this.computeProgress(this.size)
3419
3423
  });
3420
3424
  if (target.size > 0 && !this.lifecycle.isInstalled) {
3421
3425
  this.emit("open", { id: target.id });
package/dist/solid.cjs CHANGED
@@ -2623,7 +2623,9 @@ var BottomSheetEngine = class {
2623
2623
  const previousSize = this.size;
2624
2624
  this.scrollCache.cache(previousId, previousSize, target.size);
2625
2625
  this.activeId = id;
2626
- if (wasClosed && target.size > 0) {
2626
+ const rawTargetSize = this.snapPointsRaw.find((p) => p.id === id)?.size;
2627
+ const opensToRest = id === "closed" || rawTargetSize === 0;
2628
+ if (wasClosed && !opensToRest) {
2627
2629
  this.opening = true;
2628
2630
  sheetStack.promote(this.id);
2629
2631
  }
@@ -2648,8 +2650,8 @@ var BottomSheetEngine = class {
2648
2650
  this.updateAriaSlider();
2649
2651
  this.emit("snap", {
2650
2652
  id,
2651
- size: target.size,
2652
- progress: this.computeProgress(target.size)
2653
+ size: this.size,
2654
+ progress: this.computeProgress(this.size)
2653
2655
  });
2654
2656
  if (wasClosed && target.size > 0) {
2655
2657
  this.emit("open", { id });
@@ -2728,12 +2730,12 @@ var BottomSheetEngine = class {
2728
2730
  const value = typeof h === "number" ? `${h}px` : h;
2729
2731
  const axis = layoutAxis(this.mode);
2730
2732
  this.element.style.setProperty(
2731
- axis === "height" ? "maxHeight" : "maxWidth",
2733
+ axis === "height" ? "max-height" : "max-width",
2732
2734
  value
2733
2735
  );
2734
2736
  if (typeof h === "number") {
2735
2737
  this.maxHeightCap = h;
2736
- this.clampToMaxHeight();
2738
+ this.recompute();
2737
2739
  } else if (typeof window !== "undefined") {
2738
2740
  const probe2 = document.createElement("div");
2739
2741
  probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
@@ -2741,7 +2743,7 @@ var BottomSheetEngine = class {
2741
2743
  const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
2742
2744
  probe2.remove();
2743
2745
  this.maxHeightCap = measured > 0 ? measured : void 0;
2744
- this.clampToMaxHeight();
2746
+ this.recompute();
2745
2747
  }
2746
2748
  }
2747
2749
  clampToMaxHeight() {
@@ -2749,9 +2751,6 @@ var BottomSheetEngine = class {
2749
2751
  if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
2750
2752
  this.snaps.setMaxAxisSize(this.maxHeightCap);
2751
2753
  }
2752
- if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
2753
- this.applySize(this.maxHeightCap);
2754
- }
2755
2754
  }
2756
2755
  setAllowed(ids, snap) {
2757
2756
  if (this.destroyed) return;
@@ -2889,6 +2888,7 @@ var BottomSheetEngine = class {
2889
2888
  recompute() {
2890
2889
  if (this.destroyed) return;
2891
2890
  this.snaps.recompute();
2891
+ this.clampToMaxHeight();
2892
2892
  this.scrim.invalidateOpacityCache();
2893
2893
  if (this.gesture?.isDragging) return;
2894
2894
  const current = this.snaps.findById(this.activeId);
@@ -2946,9 +2946,10 @@ var BottomSheetEngine = class {
2946
2946
  const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2947
2947
  const content = this.scrollContainer;
2948
2948
  const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2949
- if (typeof window === "undefined") return natural;
2949
+ const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
2950
+ if (typeof window === "undefined") return capped;
2950
2951
  const viewport = vertical ? window.innerHeight : window.innerWidth;
2951
- return viewport > 0 ? Math.min(natural, viewport) : natural;
2952
+ return viewport > 0 ? Math.min(capped, viewport) : capped;
2952
2953
  }
2953
2954
  installFitObserver() {
2954
2955
  if (typeof ResizeObserver === "undefined") return;
@@ -3319,8 +3320,8 @@ var BottomSheetEngine = class {
3319
3320
  this.updateAriaSlider();
3320
3321
  this.emit("snap", {
3321
3322
  id: target.id,
3322
- size: target.size,
3323
- progress: this.computeProgress(target.size)
3323
+ size: this.size,
3324
+ progress: this.computeProgress(this.size)
3324
3325
  });
3325
3326
  this.haptic();
3326
3327
  if (previousSnapSize === 0 && target.size > 0) {
@@ -3345,23 +3346,25 @@ var BottomSheetEngine = class {
3345
3346
  }
3346
3347
  }
3347
3348
  applySize(size) {
3348
- this.size = size;
3349
- const offset = this.snaps.getMaxAxisSize() - size;
3349
+ const cap = this.snaps.getMaxAxisSize();
3350
+ const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
3351
+ this.size = clamped;
3352
+ const offset = cap - clamped;
3350
3353
  const style = this.element.style;
3351
3354
  style.transform = this.transformTemplate(offset);
3352
- if (this.sizeWriteSentinel.shouldWrite(size, SIZE_WRITE_EPSILON)) {
3353
- style.setProperty("--bs-size", `${size}px`);
3355
+ if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
3356
+ style.setProperty("--bs-size", `${clamped}px`);
3354
3357
  if (this.scrimParent) {
3355
- this.scrimParent.style.setProperty("--bs-size", `${size}px`);
3358
+ this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
3356
3359
  }
3357
3360
  if (this.anchorHost && this.anchorHost !== this.scrimParent) {
3358
- this.anchorHost.style.setProperty("--bs-size", `${size}px`);
3361
+ this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
3359
3362
  }
3360
3363
  if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
3361
- this.rootEl.style.setProperty("--bs-size", `${size}px`);
3364
+ this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
3362
3365
  }
3363
3366
  }
3364
- const progress = this.computeProgress(size);
3367
+ const progress = this.computeProgress(clamped);
3365
3368
  const progressChanged = this.progressWriteSentinel.shouldWrite(
3366
3369
  progress,
3367
3370
  OPACITY_WRITE_EPSILON
@@ -3378,14 +3381,15 @@ var BottomSheetEngine = class {
3378
3381
  this.scrim.applyOpacity(progress, progressChanged);
3379
3382
  if (progressChanged && this.bus.listenerCount("progress") > 0) {
3380
3383
  this.progressPayload.value = progress;
3381
- this.progressPayload.size = size;
3384
+ this.progressPayload.size = clamped;
3382
3385
  this.emit("progress", this.progressPayload);
3383
3386
  }
3384
3387
  }
3385
3388
  computeProgress(size) {
3386
3389
  const { min, max } = this.getAllowedRange();
3387
- if (max <= min) return 0;
3388
- return Math.min(Math.max((size - min) / (max - min), 0), 1);
3390
+ const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
3391
+ if (reachableMax <= min) return 0;
3392
+ return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
3389
3393
  }
3390
3394
  handleOpen() {
3391
3395
  sheetStack.promote(this.id);
@@ -3409,8 +3413,8 @@ var BottomSheetEngine = class {
3409
3413
  this.updateAriaSlider();
3410
3414
  this.emit("snap", {
3411
3415
  id: target.id,
3412
- size: target.size,
3413
- progress: this.computeProgress(target.size)
3416
+ size: this.size,
3417
+ progress: this.computeProgress(this.size)
3414
3418
  });
3415
3419
  if (target.size > 0 && !this.lifecycle.isInstalled) {
3416
3420
  this.emit("open", { id: target.id });
@@ -3469,7 +3473,9 @@ var BottomSheet = (props) => {
3469
3473
  closeOnBack: props.closeOnBack,
3470
3474
  lockBodyScroll: props.lockBodyScroll,
3471
3475
  rubberBand: props.rubberBand,
3472
- backdropRange: props.backdropRange
3476
+ backdropRange: props.backdropRange,
3477
+ radius: props.radius,
3478
+ maxHeight: props.maxHeight
3473
3479
  };
3474
3480
  engine = new BottomSheetEngine(engineOpts);
3475
3481
  props.engineRef?.(engine);
package/dist/solid.d.cts CHANGED
@@ -319,6 +319,8 @@ type BottomSheetProps<TId extends string = string> = {
319
319
  lockBodyScroll?: boolean;
320
320
  rubberBand?: boolean;
321
321
  backdropRange?: [number, number];
322
+ radius?: string | number;
323
+ maxHeight?: string | number;
322
324
  backdrop?: boolean;
323
325
  closeOnBackdrop?: boolean;
324
326
  ariaLabel?: string;
package/dist/solid.d.ts CHANGED
@@ -319,6 +319,8 @@ type BottomSheetProps<TId extends string = string> = {
319
319
  lockBodyScroll?: boolean;
320
320
  rubberBand?: boolean;
321
321
  backdropRange?: [number, number];
322
+ radius?: string | number;
323
+ maxHeight?: string | number;
322
324
  backdrop?: boolean;
323
325
  closeOnBackdrop?: boolean;
324
326
  ariaLabel?: string;