@surdeddd/bottom-sheet 0.7.0 → 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/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;
@@ -321,6 +322,11 @@ type BottomSheetProps<TId extends string = string> = {
321
322
  backdropRange?: [number, number];
322
323
  radius?: string | number;
323
324
  maxHeight?: string | number;
325
+ persistent?: boolean;
326
+ disableClose?: boolean;
327
+ disableDrag?: boolean;
328
+ closeOnRouteChange?: boolean;
329
+ returnFocusTo?: string;
324
330
  backdrop?: boolean;
325
331
  closeOnBackdrop?: boolean;
326
332
  ariaLabel?: string;
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
@@ -2910,40 +2911,32 @@ var BottomSheetEngine = class {
2910
2911
  }
2911
2912
  return out;
2912
2913
  }
2913
- measureContentExtent(vertical) {
2914
+ measureSheetNatural(vertical) {
2915
+ const el = this.element;
2914
2916
  const content = this.scrollContainer;
2915
- if (!content) return 0;
2916
- const targets = this.contentTargets();
2917
- if (targets.length === 0) {
2918
- return vertical ? content.scrollHeight : content.scrollWidth;
2919
- }
2920
- let min = Infinity;
2921
- let max = -Infinity;
2922
- for (const el of targets) {
2923
- const r = el.getBoundingClientRect();
2924
- if (vertical) {
2925
- if (r.top < min) min = r.top;
2926
- if (r.bottom > max) max = r.bottom;
2927
- } else {
2928
- if (r.left < min) min = r.left;
2929
- if (r.right > max) max = r.right;
2930
- }
2931
- }
2932
- if (!isFinite(min) || !isFinite(max) || max <= min) {
2933
- return vertical ? content.scrollHeight : content.scrollWidth;
2934
- }
2935
- let pad = 0;
2936
- if (typeof getComputedStyle !== "undefined") {
2937
- const cs = getComputedStyle(content);
2938
- pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
2939
- }
2940
- 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;
2941
2936
  }
2942
2937
  measureFitSize() {
2943
2938
  const vertical = layoutAxis(this.mode) === "height";
2944
- const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2945
- const content = this.scrollContainer;
2946
- const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2939
+ const natural = this.measureSheetNatural(vertical);
2947
2940
  const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
2948
2941
  if (typeof window === "undefined") return capped;
2949
2942
  const viewport = vertical ? window.innerHeight : window.innerWidth;
@@ -3029,6 +3022,10 @@ var BottomSheetEngine = class {
3029
3022
  this.backdrop.style.opacity = "";
3030
3023
  this.backdrop.style.pointerEvents = "";
3031
3024
  }
3025
+ if (this.anchorHost) {
3026
+ this.anchorHost.style.removeProperty("--bs-size");
3027
+ this.anchorHost.style.removeProperty("--bs-progress");
3028
+ }
3032
3029
  if (this.screenComponent) {
3033
3030
  this.screenComponent.style.opacity = "";
3034
3031
  this.screenComponent.style.display = "";
@@ -3040,6 +3037,7 @@ var BottomSheetEngine = class {
3040
3037
  this.bus.emit(event, payload);
3041
3038
  }
3042
3039
  newCycle() {
3040
+ this.allowOvershoot = false;
3043
3041
  this.currentAbort.abort();
3044
3042
  this.currentAbort = new AbortController();
3045
3043
  return this.currentAbort.signal;
@@ -3105,6 +3103,7 @@ var BottomSheetEngine = class {
3105
3103
  seen.add(p.id);
3106
3104
  }
3107
3105
  this.snaps.setRaw(this.snapPointsRaw);
3106
+ this.clampToMaxHeight();
3108
3107
  this.scrim.invalidateOpacityCache();
3109
3108
  }
3110
3109
  getAllowedRange() {
@@ -3311,9 +3310,13 @@ var BottomSheetEngine = class {
3311
3310
  this.opening = true;
3312
3311
  sheetStack.promote(this.id);
3313
3312
  }
3314
- void this.animation.animateTo(target.size, velocity).then(() => {
3315
- this.opening = false;
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(() => {
3316
3317
  if (signal.aborted) return;
3318
+ this.allowOvershoot = false;
3319
+ this.opening = false;
3317
3320
  this.scrollCache.restore(target.id, previousSize, target.size);
3318
3321
  this.updateAriaSlider();
3319
3322
  this.emit("snap", {
@@ -3345,7 +3348,7 @@ var BottomSheetEngine = class {
3345
3348
  }
3346
3349
  applySize(size) {
3347
3350
  const cap = this.snaps.getMaxAxisSize();
3348
- const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
3351
+ const clamped = cap > 0 && size > cap && !this.gesture?.isDragging && !this.allowOvershoot ? cap : size;
3349
3352
  this.size = clamped;
3350
3353
  const offset = cap - clamped;
3351
3354
  const style = this.element.style;
@@ -3473,7 +3476,12 @@ var BottomSheet = (props) => {
3473
3476
  rubberBand: props.rubberBand,
3474
3477
  backdropRange: props.backdropRange,
3475
3478
  radius: props.radius,
3476
- maxHeight: props.maxHeight
3479
+ maxHeight: props.maxHeight,
3480
+ persistent: props.persistent,
3481
+ disableClose: props.disableClose,
3482
+ disableDrag: props.disableDrag,
3483
+ closeOnRouteChange: props.closeOnRouteChange,
3484
+ returnFocusTo: props.returnFocusTo
3477
3485
  };
3478
3486
  engine = new BottomSheetEngine(engineOpts);
3479
3487
  props.engineRef?.(engine);
@@ -3494,7 +3502,7 @@ var BottomSheet = (props) => {
3494
3502
  engine.on("dragend", sync);
3495
3503
  if (props.backdrop !== false && props.closeOnBackdrop !== false && backdropEl) {
3496
3504
  const onBackdropClick = () => {
3497
- void engine?.close();
3505
+ if (engine?.canDismiss()) void engine.close("backdrop");
3498
3506
  };
3499
3507
  backdropEl.addEventListener("click", onBackdropClick);
3500
3508
  onCleanup(() => {
@@ -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
@@ -2912,40 +2913,32 @@ var BottomSheetEngine = class {
2912
2913
  }
2913
2914
  return out;
2914
2915
  }
2915
- measureContentExtent(vertical) {
2916
+ measureSheetNatural(vertical) {
2917
+ const el = this.element;
2916
2918
  const content = this.scrollContainer;
2917
- if (!content) return 0;
2918
- const targets = this.contentTargets();
2919
- if (targets.length === 0) {
2920
- return vertical ? content.scrollHeight : content.scrollWidth;
2921
- }
2922
- let min = Infinity;
2923
- let max = -Infinity;
2924
- for (const el of targets) {
2925
- const r = el.getBoundingClientRect();
2926
- if (vertical) {
2927
- if (r.top < min) min = r.top;
2928
- if (r.bottom > max) max = r.bottom;
2929
- } else {
2930
- if (r.left < min) min = r.left;
2931
- if (r.right > max) max = r.right;
2932
- }
2933
- }
2934
- if (!isFinite(min) || !isFinite(max) || max <= min) {
2935
- return vertical ? content.scrollHeight : content.scrollWidth;
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;
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;
2943
2938
  }
2944
2939
  measureFitSize() {
2945
2940
  const vertical = layoutAxis(this.mode) === "height";
2946
- const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2947
- const content = this.scrollContainer;
2948
- const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2941
+ const natural = this.measureSheetNatural(vertical);
2949
2942
  const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
2950
2943
  if (typeof window === "undefined") return capped;
2951
2944
  const viewport = vertical ? window.innerHeight : window.innerWidth;
@@ -3031,6 +3024,10 @@ var BottomSheetEngine = class {
3031
3024
  this.backdrop.style.opacity = "";
3032
3025
  this.backdrop.style.pointerEvents = "";
3033
3026
  }
3027
+ if (this.anchorHost) {
3028
+ this.anchorHost.style.removeProperty("--bs-size");
3029
+ this.anchorHost.style.removeProperty("--bs-progress");
3030
+ }
3034
3031
  if (this.screenComponent) {
3035
3032
  this.screenComponent.style.opacity = "";
3036
3033
  this.screenComponent.style.display = "";
@@ -3042,6 +3039,7 @@ var BottomSheetEngine = class {
3042
3039
  this.bus.emit(event, payload);
3043
3040
  }
3044
3041
  newCycle() {
3042
+ this.allowOvershoot = false;
3045
3043
  this.currentAbort.abort();
3046
3044
  this.currentAbort = new AbortController();
3047
3045
  return this.currentAbort.signal;
@@ -3107,6 +3105,7 @@ var BottomSheetEngine = class {
3107
3105
  seen.add(p.id);
3108
3106
  }
3109
3107
  this.snaps.setRaw(this.snapPointsRaw);
3108
+ this.clampToMaxHeight();
3110
3109
  this.scrim.invalidateOpacityCache();
3111
3110
  }
3112
3111
  getAllowedRange() {
@@ -3313,9 +3312,13 @@ var BottomSheetEngine = class {
3313
3312
  this.opening = true;
3314
3313
  sheetStack.promote(this.id);
3315
3314
  }
3316
- void this.animation.animateTo(target.size, velocity).then(() => {
3317
- 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(() => {
3318
3319
  if (signal.aborted) return;
3320
+ this.allowOvershoot = false;
3321
+ this.opening = false;
3319
3322
  this.scrollCache.restore(target.id, previousSize, target.size);
3320
3323
  this.updateAriaSlider();
3321
3324
  this.emit("snap", {
@@ -3347,7 +3350,7 @@ var BottomSheetEngine = class {
3347
3350
  }
3348
3351
  applySize(size) {
3349
3352
  const cap = this.snaps.getMaxAxisSize();
3350
- const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
3353
+ const clamped = cap > 0 && size > cap && !this.gesture?.isDragging && !this.allowOvershoot ? cap : size;
3351
3354
  this.size = clamped;
3352
3355
  const offset = cap - clamped;
3353
3356
  const style = this.element.style;
@@ -3471,7 +3474,12 @@ var BottomSheet = (props) => {
3471
3474
  rubberBand: props.rubberBand,
3472
3475
  backdropRange: props.backdropRange,
3473
3476
  radius: props.radius,
3474
- maxHeight: props.maxHeight
3477
+ maxHeight: props.maxHeight,
3478
+ persistent: props.persistent,
3479
+ disableClose: props.disableClose,
3480
+ disableDrag: props.disableDrag,
3481
+ closeOnRouteChange: props.closeOnRouteChange,
3482
+ returnFocusTo: props.returnFocusTo
3475
3483
  };
3476
3484
  engine = new BottomSheetEngine(engineOpts);
3477
3485
  props.engineRef?.(engine);
@@ -3490,7 +3498,7 @@ var BottomSheet = (props) => {
3490
3498
  engine.on("dragend", sync);
3491
3499
  if (props.backdrop !== false && props.closeOnBackdrop !== false && backdropEl) {
3492
3500
  const onBackdropClick = () => {
3493
- void engine?.close();
3501
+ if (engine?.canDismiss()) void engine.close("backdrop");
3494
3502
  };
3495
3503
  backdropEl.addEventListener("click", onBackdropClick);
3496
3504
  onCleanup(() => {
@@ -2359,6 +2359,7 @@ var BottomSheetEngine = class {
2359
2359
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2360
2360
  __publicField(this, "isTopSheet", true);
2361
2361
  __publicField(this, "opening", false);
2362
+ __publicField(this, "allowOvershoot", false);
2362
2363
  __publicField(this, "progressPayload", {
2363
2364
  value: 0,
2364
2365
  size: 0
@@ -2911,40 +2912,32 @@ var BottomSheetEngine = class {
2911
2912
  }
2912
2913
  return out;
2913
2914
  }
2914
- measureContentExtent(vertical) {
2915
+ measureSheetNatural(vertical) {
2916
+ const el = this.element;
2915
2917
  const content = this.scrollContainer;
2916
- if (!content) return 0;
2917
- const targets = this.contentTargets();
2918
- if (targets.length === 0) {
2919
- return vertical ? content.scrollHeight : content.scrollWidth;
2920
- }
2921
- let min = Infinity;
2922
- let max = -Infinity;
2923
- for (const el of targets) {
2924
- const r = el.getBoundingClientRect();
2925
- if (vertical) {
2926
- if (r.top < min) min = r.top;
2927
- if (r.bottom > max) max = r.bottom;
2928
- } else {
2929
- if (r.left < min) min = r.left;
2930
- if (r.right > max) max = r.right;
2931
- }
2932
- }
2933
- if (!isFinite(min) || !isFinite(max) || max <= min) {
2934
- return vertical ? content.scrollHeight : content.scrollWidth;
2935
- }
2936
- let pad = 0;
2937
- if (typeof getComputedStyle !== "undefined") {
2938
- const cs = getComputedStyle(content);
2939
- pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
2940
- }
2941
- return max - min + pad;
2918
+ if (!content) {
2919
+ return vertical ? el.offsetHeight : el.offsetWidth;
2920
+ }
2921
+ const axis = vertical ? "height" : "width";
2922
+ const sheetStyle = el.style;
2923
+ const cs = content.style;
2924
+ const prevSheet = sheetStyle[axis];
2925
+ const prevFlex = cs.flex;
2926
+ const prevContent = vertical ? cs.height : cs.width;
2927
+ sheetStyle[axis] = "auto";
2928
+ cs.flex = "none";
2929
+ if (vertical) cs.height = "auto";
2930
+ else cs.width = "auto";
2931
+ const natural = vertical ? el.offsetHeight : el.offsetWidth;
2932
+ sheetStyle[axis] = prevSheet;
2933
+ cs.flex = prevFlex;
2934
+ if (vertical) cs.height = prevContent;
2935
+ else cs.width = prevContent;
2936
+ return natural;
2942
2937
  }
2943
2938
  measureFitSize() {
2944
2939
  const vertical = layoutAxis(this.mode) === "height";
2945
- const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2946
- const content = this.scrollContainer;
2947
- const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2940
+ const natural = this.measureSheetNatural(vertical);
2948
2941
  const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
2949
2942
  if (typeof window === "undefined") return capped;
2950
2943
  const viewport = vertical ? window.innerHeight : window.innerWidth;
@@ -3030,6 +3023,10 @@ var BottomSheetEngine = class {
3030
3023
  this.backdrop.style.opacity = "";
3031
3024
  this.backdrop.style.pointerEvents = "";
3032
3025
  }
3026
+ if (this.anchorHost) {
3027
+ this.anchorHost.style.removeProperty("--bs-size");
3028
+ this.anchorHost.style.removeProperty("--bs-progress");
3029
+ }
3033
3030
  if (this.screenComponent) {
3034
3031
  this.screenComponent.style.opacity = "";
3035
3032
  this.screenComponent.style.display = "";
@@ -3041,6 +3038,7 @@ var BottomSheetEngine = class {
3041
3038
  this.bus.emit(event, payload);
3042
3039
  }
3043
3040
  newCycle() {
3041
+ this.allowOvershoot = false;
3044
3042
  this.currentAbort.abort();
3045
3043
  this.currentAbort = new AbortController();
3046
3044
  return this.currentAbort.signal;
@@ -3106,6 +3104,7 @@ var BottomSheetEngine = class {
3106
3104
  seen.add(p.id);
3107
3105
  }
3108
3106
  this.snaps.setRaw(this.snapPointsRaw);
3107
+ this.clampToMaxHeight();
3109
3108
  this.scrim.invalidateOpacityCache();
3110
3109
  }
3111
3110
  getAllowedRange() {
@@ -3312,9 +3311,13 @@ var BottomSheetEngine = class {
3312
3311
  this.opening = true;
3313
3312
  sheetStack.promote(this.id);
3314
3313
  }
3315
- void this.animation.animateTo(target.size, velocity).then(() => {
3316
- this.opening = false;
3314
+ const settleCap = this.snaps.getMaxAxisSize();
3315
+ const settleSize = settleCap > 0 ? Math.min(target.size, settleCap) : target.size;
3316
+ this.allowOvershoot = true;
3317
+ void this.animation.animateTo(settleSize, velocity).then(() => {
3317
3318
  if (signal.aborted) return;
3319
+ this.allowOvershoot = false;
3320
+ this.opening = false;
3318
3321
  this.scrollCache.restore(target.id, previousSize, target.size);
3319
3322
  this.updateAriaSlider();
3320
3323
  this.emit("snap", {
@@ -3346,7 +3349,7 @@ var BottomSheetEngine = class {
3346
3349
  }
3347
3350
  applySize(size) {
3348
3351
  const cap = this.snaps.getMaxAxisSize();
3349
- const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
3352
+ const clamped = cap > 0 && size > cap && !this.gesture?.isDragging && !this.allowOvershoot ? cap : size;
3350
3353
  this.size = clamped;
3351
3354
  const offset = cap - clamped;
3352
3355
  const style = this.element.style;
@@ -2357,6 +2357,7 @@ var BottomSheetEngine = class {
2357
2357
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2358
2358
  __publicField(this, "isTopSheet", true);
2359
2359
  __publicField(this, "opening", false);
2360
+ __publicField(this, "allowOvershoot", false);
2360
2361
  __publicField(this, "progressPayload", {
2361
2362
  value: 0,
2362
2363
  size: 0
@@ -2909,40 +2910,32 @@ var BottomSheetEngine = class {
2909
2910
  }
2910
2911
  return out;
2911
2912
  }
2912
- measureContentExtent(vertical) {
2913
+ measureSheetNatural(vertical) {
2914
+ const el = this.element;
2913
2915
  const content = this.scrollContainer;
2914
- if (!content) return 0;
2915
- const targets = this.contentTargets();
2916
- if (targets.length === 0) {
2917
- return vertical ? content.scrollHeight : content.scrollWidth;
2918
- }
2919
- let min = Infinity;
2920
- let max = -Infinity;
2921
- for (const el of targets) {
2922
- const r = el.getBoundingClientRect();
2923
- if (vertical) {
2924
- if (r.top < min) min = r.top;
2925
- if (r.bottom > max) max = r.bottom;
2926
- } else {
2927
- if (r.left < min) min = r.left;
2928
- if (r.right > max) max = r.right;
2929
- }
2930
- }
2931
- if (!isFinite(min) || !isFinite(max) || max <= min) {
2932
- return vertical ? content.scrollHeight : content.scrollWidth;
2933
- }
2934
- let pad = 0;
2935
- if (typeof getComputedStyle !== "undefined") {
2936
- const cs = getComputedStyle(content);
2937
- pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
2938
- }
2939
- return max - min + pad;
2916
+ if (!content) {
2917
+ return vertical ? el.offsetHeight : el.offsetWidth;
2918
+ }
2919
+ const axis = vertical ? "height" : "width";
2920
+ const sheetStyle = el.style;
2921
+ const cs = content.style;
2922
+ const prevSheet = sheetStyle[axis];
2923
+ const prevFlex = cs.flex;
2924
+ const prevContent = vertical ? cs.height : cs.width;
2925
+ sheetStyle[axis] = "auto";
2926
+ cs.flex = "none";
2927
+ if (vertical) cs.height = "auto";
2928
+ else cs.width = "auto";
2929
+ const natural = vertical ? el.offsetHeight : el.offsetWidth;
2930
+ sheetStyle[axis] = prevSheet;
2931
+ cs.flex = prevFlex;
2932
+ if (vertical) cs.height = prevContent;
2933
+ else cs.width = prevContent;
2934
+ return natural;
2940
2935
  }
2941
2936
  measureFitSize() {
2942
2937
  const vertical = layoutAxis(this.mode) === "height";
2943
- const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2944
- const content = this.scrollContainer;
2945
- const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2938
+ const natural = this.measureSheetNatural(vertical);
2946
2939
  const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
2947
2940
  if (typeof window === "undefined") return capped;
2948
2941
  const viewport = vertical ? window.innerHeight : window.innerWidth;
@@ -3028,6 +3021,10 @@ var BottomSheetEngine = class {
3028
3021
  this.backdrop.style.opacity = "";
3029
3022
  this.backdrop.style.pointerEvents = "";
3030
3023
  }
3024
+ if (this.anchorHost) {
3025
+ this.anchorHost.style.removeProperty("--bs-size");
3026
+ this.anchorHost.style.removeProperty("--bs-progress");
3027
+ }
3031
3028
  if (this.screenComponent) {
3032
3029
  this.screenComponent.style.opacity = "";
3033
3030
  this.screenComponent.style.display = "";
@@ -3039,6 +3036,7 @@ var BottomSheetEngine = class {
3039
3036
  this.bus.emit(event, payload);
3040
3037
  }
3041
3038
  newCycle() {
3039
+ this.allowOvershoot = false;
3042
3040
  this.currentAbort.abort();
3043
3041
  this.currentAbort = new AbortController();
3044
3042
  return this.currentAbort.signal;
@@ -3104,6 +3102,7 @@ var BottomSheetEngine = class {
3104
3102
  seen.add(p.id);
3105
3103
  }
3106
3104
  this.snaps.setRaw(this.snapPointsRaw);
3105
+ this.clampToMaxHeight();
3107
3106
  this.scrim.invalidateOpacityCache();
3108
3107
  }
3109
3108
  getAllowedRange() {
@@ -3310,9 +3309,13 @@ var BottomSheetEngine = class {
3310
3309
  this.opening = true;
3311
3310
  sheetStack.promote(this.id);
3312
3311
  }
3313
- void this.animation.animateTo(target.size, velocity).then(() => {
3314
- this.opening = false;
3312
+ const settleCap = this.snaps.getMaxAxisSize();
3313
+ const settleSize = settleCap > 0 ? Math.min(target.size, settleCap) : target.size;
3314
+ this.allowOvershoot = true;
3315
+ void this.animation.animateTo(settleSize, velocity).then(() => {
3315
3316
  if (signal.aborted) return;
3317
+ this.allowOvershoot = false;
3318
+ this.opening = false;
3316
3319
  this.scrollCache.restore(target.id, previousSize, target.size);
3317
3320
  this.updateAriaSlider();
3318
3321
  this.emit("snap", {
@@ -3344,7 +3347,7 @@ var BottomSheetEngine = class {
3344
3347
  }
3345
3348
  applySize(size) {
3346
3349
  const cap = this.snaps.getMaxAxisSize();
3347
- const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
3350
+ const clamped = cap > 0 && size > cap && !this.gesture?.isDragging && !this.allowOvershoot ? cap : size;
3348
3351
  this.size = clamped;
3349
3352
  const offset = cap - clamped;
3350
3353
  const style = this.element.style;
@@ -238,12 +238,6 @@
238
238
  else if (!next && isOpen) void engine.close();
239
239
  });
240
240
 
241
- let allowedIds = $derived(
242
- allowed && allowed.length > 0
243
- ? allowed
244
- : snapPoints.map(s => s.id),
245
- );
246
- let activeIdx = $derived(allowedIds.indexOf(viewState.activeId));
247
241
  let isVerticalAxis = $derived(mode === "bottom" || mode === "top");
248
242
  </script>
249
243
 
@@ -282,10 +276,6 @@
282
276
  tabindex="0"
283
277
  aria-label="Resize sheet"
284
278
  aria-orientation={isVerticalAxis ? "vertical" : "horizontal"}
285
- aria-valuemin={0}
286
- aria-valuemax={Math.max(0, allowedIds.length - 1)}
287
- aria-valuenow={Math.max(0, activeIdx)}
288
- aria-valuetext={viewState.activeId}
289
279
  ></div>
290
280
  {#if header}<div class="bs-header">{@render header(viewState)}</div>{/if}
291
281
  <!-- svelte-ignore a11y_no_noninteractive_tabindex -->