@surdeddd/bottom-sheet 0.21.1 → 0.22.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.
Files changed (62) hide show
  1. package/README.md +32 -0
  2. package/dist/{BottomSheetCore-CK_mq14p.d.ts → BottomSheetCore-9i-Uh6T3.d.ts} +4 -1
  3. package/dist/{BottomSheetCore-BHv6LPmS.d.cts → BottomSheetCore-CQStdVy2.d.cts} +4 -1
  4. package/dist/{BottomSheetEngine-mmFzIK1Z.d.cts → BottomSheetEngine-CsQWHLNb.d.cts} +1 -1
  5. package/dist/{BottomSheetEngine-wLn6Q2kA.d.ts → BottomSheetEngine-Dn6h-7gF.d.ts} +1 -1
  6. package/dist/core.cjs +25 -7
  7. package/dist/core.d.cts +2 -2
  8. package/dist/core.d.ts +2 -2
  9. package/dist/core.js +25 -7
  10. package/dist/debug.d.cts +1 -1
  11. package/dist/debug.d.ts +1 -1
  12. package/dist/default-features-C3cilcW9.d.ts +11 -0
  13. package/dist/default-features-DkG9aho0.d.cts +11 -0
  14. package/dist/element.cjs +106 -15
  15. package/dist/element.d.cts +2 -2
  16. package/dist/element.d.ts +2 -2
  17. package/dist/element.iife.global.js +2 -2
  18. package/dist/element.js +106 -15
  19. package/dist/features.cjs +65 -1
  20. package/dist/features.d.cts +5 -10
  21. package/dist/features.d.ts +5 -10
  22. package/dist/features.js +65 -2
  23. package/dist/{index-juAyT76E.d.cts → index-CVGC5B5D.d.cts} +1 -1
  24. package/dist/{index-CWKv1Xy4.d.ts → index-CnsJQZp2.d.ts} +1 -1
  25. package/dist/index.cjs +89 -8
  26. package/dist/index.d.cts +5 -5
  27. package/dist/index.d.ts +5 -5
  28. package/dist/index.js +89 -8
  29. package/dist/integrations/formik.d.cts +1 -1
  30. package/dist/integrations/formik.d.ts +1 -1
  31. package/dist/integrations/react-hook-form.d.cts +1 -1
  32. package/dist/integrations/react-hook-form.d.ts +1 -1
  33. package/dist/preact.d.cts +2 -2
  34. package/dist/preact.d.ts +2 -2
  35. package/dist/qwik-lib/index.qwik.cjs +84 -6
  36. package/dist/qwik-lib/index.qwik.mjs +84 -6
  37. package/dist/qwik.cjs +90 -8
  38. package/dist/qwik.d.cts +3 -2
  39. package/dist/qwik.d.ts +3 -2
  40. package/dist/qwik.js +90 -8
  41. package/dist/react.cjs +89 -8
  42. package/dist/react.d.cts +3 -3
  43. package/dist/react.d.ts +3 -3
  44. package/dist/react.js +89 -8
  45. package/dist/solid.cjs +90 -8
  46. package/dist/solid.d.cts +4 -0
  47. package/dist/solid.d.ts +4 -0
  48. package/dist/solid.js +90 -8
  49. package/dist/solid.source.jsx +90 -8
  50. package/dist/styles.css +11 -0
  51. package/dist/svelte-core.cjs +89 -8
  52. package/dist/svelte-core.js +89 -8
  53. package/dist/svelte-src/BottomSheet.svelte +3 -0
  54. package/dist/svelte.cjs +90 -8
  55. package/dist/svelte.d.cts +1 -0
  56. package/dist/svelte.d.ts +1 -0
  57. package/dist/svelte.js +90 -8
  58. package/dist/vue.cjs +93 -8
  59. package/dist/vue.js +93 -8
  60. package/dist/webgl.d.cts +1 -1
  61. package/dist/webgl.d.ts +1 -1
  62. package/package.json +9 -9
package/dist/svelte.cjs CHANGED
@@ -399,14 +399,26 @@ function notifyLinkedSheets(sheets, self) {
399
399
  }
400
400
  }
401
401
 
402
+ // src/core/primitives/hot-path-thresholds.ts
403
+ var SIZE_WRITE_EPSILON = 0.5;
404
+ var OPACITY_WRITE_EPSILON = 5e-3;
405
+ var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
406
+ var RANGE_DIVISION_EPSILON = 1e-4;
407
+
402
408
  // src/core/features/resize-observer.ts
403
409
  function installResizeObserver(deps) {
404
410
  if (typeof window === "undefined") {
405
411
  return () => {
406
412
  };
407
413
  }
414
+ const seatFor = () => {
415
+ const snap = deps.resolveActiveSnap();
416
+ const max = deps.getMaxAxisSize();
417
+ return { target: snap ? Math.min(snap.size, max) : null, max };
418
+ };
408
419
  const onResize = () => {
409
420
  if (deps.isDestroyed()) return;
421
+ const before = seatFor();
410
422
  deps.recomputeSnaps();
411
423
  const mode = deps.getMode();
412
424
  const isVerticalAxis = mode === "bottom" || mode === "top";
@@ -415,6 +427,10 @@ function installResizeObserver(deps) {
415
427
  if (viewportSize2 > 0 && viewportSize2 < max) {
416
428
  deps.setMaxAxisSize(viewportSize2);
417
429
  }
430
+ const after = seatFor();
431
+ if (before.target !== null && after.target !== null && Math.abs(after.target - before.target) < SIZE_WRITE_EPSILON && Math.abs(after.max - before.max) < SIZE_WRITE_EPSILON) {
432
+ return;
433
+ }
418
434
  const wasAnimating = deps.isAnimating?.() ?? false;
419
435
  deps.cancelInFlight();
420
436
  deps.newCycle();
@@ -683,12 +699,6 @@ var SCRIM_PRESETS = Object.freeze({
683
699
  }
684
700
  });
685
701
 
686
- // src/core/primitives/hot-path-thresholds.ts
687
- var SIZE_WRITE_EPSILON = 0.5;
688
- var OPACITY_WRITE_EPSILON = 5e-3;
689
- var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
690
- var RANGE_DIVISION_EPSILON = 1e-4;
691
-
692
702
  // src/core/primitives/opacity-dedup.ts
693
703
  var WriteSentinel = class {
694
704
  constructor() {
@@ -2618,6 +2628,7 @@ var BottomSheetCore = class {
2618
2628
  __publicField(this, "lifecycle");
2619
2629
  __publicField(this, "closeOnBack");
2620
2630
  __publicField(this, "routedTo");
2631
+ __publicField(this, "fitContentToSnap");
2621
2632
  __publicField(this, "persistent");
2622
2633
  __publicField(this, "disableCloseFlag");
2623
2634
  __publicField(this, "disableDragFlag");
@@ -2731,6 +2742,7 @@ var BottomSheetCore = class {
2731
2742
  );
2732
2743
  this.closeOnBack = resolved.closeOnBack;
2733
2744
  this.routedTo = opts.routedTo;
2745
+ this.fitContentToSnap = opts.fitContentToSnap === true;
2734
2746
  this.persistent = resolved.persistent;
2735
2747
  this.disableCloseFlag = resolved.disableClose;
2736
2748
  this.disableDragFlag = resolved.disableDrag;
@@ -2832,7 +2844,8 @@ var BottomSheetCore = class {
2832
2844
  closeOnBack: this.closeOnBack,
2833
2845
  closeOnRouteChange: this.closeOnRouteChange,
2834
2846
  persistKey: this.persistKey,
2835
- autoCollapseAfter
2847
+ autoCollapseAfter,
2848
+ fitContentToSnap: this.fitContentToSnap
2836
2849
  },
2837
2850
  isDestroyed: () => this.destroyed,
2838
2851
  isDragging: () => this.isDraggingAny(),
@@ -2884,6 +2897,11 @@ var BottomSheetCore = class {
2884
2897
  "[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
2885
2898
  );
2886
2899
  }
2900
+ if (this.fitContentToSnap && !names.has("content-fit")) {
2901
+ devWarn(
2902
+ "[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
2903
+ );
2904
+ }
2887
2905
  if (this.persistKey && !names.has("persist")) {
2888
2906
  devWarn(
2889
2907
  "[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
@@ -4241,6 +4259,68 @@ function visualViewportFeature() {
4241
4259
  };
4242
4260
  }
4243
4261
 
4262
+ // src/core/features/content-fit.ts
4263
+ var INSET_VAR = "--bs-content-inset";
4264
+ var FIT_ATTR = "data-bs-fit-content";
4265
+ function contentFitFeature() {
4266
+ return {
4267
+ name: "content-fit",
4268
+ install: (ctx) => {
4269
+ const scroller = ctx.scrollContainer;
4270
+ if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
4271
+ return;
4272
+ }
4273
+ const sheet = ctx.element;
4274
+ let inset = 0;
4275
+ let unpaddedMax = -1;
4276
+ let top = 0;
4277
+ const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
4278
+ const follow = (size) => {
4279
+ if (unpaddedMax < 0) {
4280
+ unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
4281
+ top = scroller.scrollTop;
4282
+ }
4283
+ const limit = Math.max(0, unpaddedMax + hiddenAt(size));
4284
+ if (top > limit) {
4285
+ if (scroller.scrollTop > limit) scroller.scrollTop = limit;
4286
+ top = limit;
4287
+ }
4288
+ };
4289
+ const settle = () => {
4290
+ if (ctx.isDestroyed()) return;
4291
+ const size = ctx.getSize();
4292
+ unpaddedMax = -1;
4293
+ follow(size);
4294
+ inset = hiddenAt(size);
4295
+ sheet.style.setProperty(INSET_VAR, `${inset}px`);
4296
+ unpaddedMax = -1;
4297
+ };
4298
+ const moving = () => ctx.isAnimating() || ctx.isDragging();
4299
+ const whenIdle = () => {
4300
+ if (!moving()) settle();
4301
+ };
4302
+ sheet.setAttribute(FIT_ATTR, "");
4303
+ settle();
4304
+ const offProgress = ctx.on(
4305
+ "progress",
4306
+ (p) => moving() ? follow(p.size) : settle()
4307
+ );
4308
+ const offSnap = ctx.on("snap", settle);
4309
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
4310
+ observer?.observe(document.documentElement);
4311
+ window.addEventListener("orientationchange", whenIdle);
4312
+ return () => {
4313
+ offProgress();
4314
+ offSnap();
4315
+ observer?.disconnect();
4316
+ window.removeEventListener("orientationchange", whenIdle);
4317
+ sheet.removeAttribute(FIT_ATTR);
4318
+ sheet.style.removeProperty(INSET_VAR);
4319
+ };
4320
+ }
4321
+ };
4322
+ }
4323
+
4244
4324
  // src/core/default-features.ts
4245
4325
  function defaultEngineFeatures() {
4246
4326
  return [
@@ -4248,7 +4328,8 @@ function defaultEngineFeatures() {
4248
4328
  visualViewportFeature(),
4249
4329
  persistFeature(),
4250
4330
  autoCollapseFeature(),
4251
- routeFeature()
4331
+ routeFeature(),
4332
+ contentFitFeature()
4252
4333
  ];
4253
4334
  }
4254
4335
 
@@ -4424,6 +4505,7 @@ function BottomSheet($$anchor, $$props) {
4424
4505
  disableDrag: disableDrag(),
4425
4506
  dragFrom: $$props.dragFrom,
4426
4507
  dragFromContent: $$props.dragFromContent,
4508
+ fitContentToSnap: $$props.fitContentToSnap,
4427
4509
  closeOnRouteChange: closeOnRouteChange(),
4428
4510
  stackEffect: stackEffect(),
4429
4511
  radius: $$props.radius,
package/dist/svelte.d.cts CHANGED
@@ -90,6 +90,7 @@ export type BottomSheetProps<TId extends string = string> = {
90
90
  disableDrag?: boolean;
91
91
  dragFrom?: "handle" | "sheet" | "zones";
92
92
  dragFromContent?: boolean;
93
+ fitContentToSnap?: boolean;
93
94
  closeOnRouteChange?: boolean;
94
95
  stackEffect?: boolean;
95
96
  teleport?: boolean;
package/dist/svelte.d.ts CHANGED
@@ -90,6 +90,7 @@ export type BottomSheetProps<TId extends string = string> = {
90
90
  disableDrag?: boolean;
91
91
  dragFrom?: "handle" | "sheet" | "zones";
92
92
  dragFromContent?: boolean;
93
+ fitContentToSnap?: boolean;
93
94
  closeOnRouteChange?: boolean;
94
95
  stackEffect?: boolean;
95
96
  teleport?: boolean;
package/dist/svelte.js CHANGED
@@ -377,14 +377,26 @@ function notifyLinkedSheets(sheets, self) {
377
377
  }
378
378
  }
379
379
 
380
+ // src/core/primitives/hot-path-thresholds.ts
381
+ var SIZE_WRITE_EPSILON = 0.5;
382
+ var OPACITY_WRITE_EPSILON = 5e-3;
383
+ var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
384
+ var RANGE_DIVISION_EPSILON = 1e-4;
385
+
380
386
  // src/core/features/resize-observer.ts
381
387
  function installResizeObserver(deps) {
382
388
  if (typeof window === "undefined") {
383
389
  return () => {
384
390
  };
385
391
  }
392
+ const seatFor = () => {
393
+ const snap = deps.resolveActiveSnap();
394
+ const max = deps.getMaxAxisSize();
395
+ return { target: snap ? Math.min(snap.size, max) : null, max };
396
+ };
386
397
  const onResize = () => {
387
398
  if (deps.isDestroyed()) return;
399
+ const before = seatFor();
388
400
  deps.recomputeSnaps();
389
401
  const mode = deps.getMode();
390
402
  const isVerticalAxis = mode === "bottom" || mode === "top";
@@ -393,6 +405,10 @@ function installResizeObserver(deps) {
393
405
  if (viewportSize2 > 0 && viewportSize2 < max) {
394
406
  deps.setMaxAxisSize(viewportSize2);
395
407
  }
408
+ const after = seatFor();
409
+ if (before.target !== null && after.target !== null && Math.abs(after.target - before.target) < SIZE_WRITE_EPSILON && Math.abs(after.max - before.max) < SIZE_WRITE_EPSILON) {
410
+ return;
411
+ }
396
412
  const wasAnimating = deps.isAnimating?.() ?? false;
397
413
  deps.cancelInFlight();
398
414
  deps.newCycle();
@@ -661,12 +677,6 @@ var SCRIM_PRESETS = Object.freeze({
661
677
  }
662
678
  });
663
679
 
664
- // src/core/primitives/hot-path-thresholds.ts
665
- var SIZE_WRITE_EPSILON = 0.5;
666
- var OPACITY_WRITE_EPSILON = 5e-3;
667
- var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
668
- var RANGE_DIVISION_EPSILON = 1e-4;
669
-
670
680
  // src/core/primitives/opacity-dedup.ts
671
681
  var WriteSentinel = class {
672
682
  constructor() {
@@ -2596,6 +2606,7 @@ var BottomSheetCore = class {
2596
2606
  __publicField(this, "lifecycle");
2597
2607
  __publicField(this, "closeOnBack");
2598
2608
  __publicField(this, "routedTo");
2609
+ __publicField(this, "fitContentToSnap");
2599
2610
  __publicField(this, "persistent");
2600
2611
  __publicField(this, "disableCloseFlag");
2601
2612
  __publicField(this, "disableDragFlag");
@@ -2709,6 +2720,7 @@ var BottomSheetCore = class {
2709
2720
  );
2710
2721
  this.closeOnBack = resolved.closeOnBack;
2711
2722
  this.routedTo = opts.routedTo;
2723
+ this.fitContentToSnap = opts.fitContentToSnap === true;
2712
2724
  this.persistent = resolved.persistent;
2713
2725
  this.disableCloseFlag = resolved.disableClose;
2714
2726
  this.disableDragFlag = resolved.disableDrag;
@@ -2810,7 +2822,8 @@ var BottomSheetCore = class {
2810
2822
  closeOnBack: this.closeOnBack,
2811
2823
  closeOnRouteChange: this.closeOnRouteChange,
2812
2824
  persistKey: this.persistKey,
2813
- autoCollapseAfter
2825
+ autoCollapseAfter,
2826
+ fitContentToSnap: this.fitContentToSnap
2814
2827
  },
2815
2828
  isDestroyed: () => this.destroyed,
2816
2829
  isDragging: () => this.isDraggingAny(),
@@ -2862,6 +2875,11 @@ var BottomSheetCore = class {
2862
2875
  "[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
2863
2876
  );
2864
2877
  }
2878
+ if (this.fitContentToSnap && !names.has("content-fit")) {
2879
+ devWarn(
2880
+ "[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
2881
+ );
2882
+ }
2865
2883
  if (this.persistKey && !names.has("persist")) {
2866
2884
  devWarn(
2867
2885
  "[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
@@ -4219,6 +4237,68 @@ function visualViewportFeature() {
4219
4237
  };
4220
4238
  }
4221
4239
 
4240
+ // src/core/features/content-fit.ts
4241
+ var INSET_VAR = "--bs-content-inset";
4242
+ var FIT_ATTR = "data-bs-fit-content";
4243
+ function contentFitFeature() {
4244
+ return {
4245
+ name: "content-fit",
4246
+ install: (ctx) => {
4247
+ const scroller = ctx.scrollContainer;
4248
+ if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
4249
+ return;
4250
+ }
4251
+ const sheet = ctx.element;
4252
+ let inset = 0;
4253
+ let unpaddedMax = -1;
4254
+ let top = 0;
4255
+ const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
4256
+ const follow = (size) => {
4257
+ if (unpaddedMax < 0) {
4258
+ unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
4259
+ top = scroller.scrollTop;
4260
+ }
4261
+ const limit = Math.max(0, unpaddedMax + hiddenAt(size));
4262
+ if (top > limit) {
4263
+ if (scroller.scrollTop > limit) scroller.scrollTop = limit;
4264
+ top = limit;
4265
+ }
4266
+ };
4267
+ const settle = () => {
4268
+ if (ctx.isDestroyed()) return;
4269
+ const size = ctx.getSize();
4270
+ unpaddedMax = -1;
4271
+ follow(size);
4272
+ inset = hiddenAt(size);
4273
+ sheet.style.setProperty(INSET_VAR, `${inset}px`);
4274
+ unpaddedMax = -1;
4275
+ };
4276
+ const moving = () => ctx.isAnimating() || ctx.isDragging();
4277
+ const whenIdle = () => {
4278
+ if (!moving()) settle();
4279
+ };
4280
+ sheet.setAttribute(FIT_ATTR, "");
4281
+ settle();
4282
+ const offProgress = ctx.on(
4283
+ "progress",
4284
+ (p) => moving() ? follow(p.size) : settle()
4285
+ );
4286
+ const offSnap = ctx.on("snap", settle);
4287
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
4288
+ observer?.observe(document.documentElement);
4289
+ window.addEventListener("orientationchange", whenIdle);
4290
+ return () => {
4291
+ offProgress();
4292
+ offSnap();
4293
+ observer?.disconnect();
4294
+ window.removeEventListener("orientationchange", whenIdle);
4295
+ sheet.removeAttribute(FIT_ATTR);
4296
+ sheet.style.removeProperty(INSET_VAR);
4297
+ };
4298
+ }
4299
+ };
4300
+ }
4301
+
4222
4302
  // src/core/default-features.ts
4223
4303
  function defaultEngineFeatures() {
4224
4304
  return [
@@ -4226,7 +4306,8 @@ function defaultEngineFeatures() {
4226
4306
  visualViewportFeature(),
4227
4307
  persistFeature(),
4228
4308
  autoCollapseFeature(),
4229
- routeFeature()
4309
+ routeFeature(),
4310
+ contentFitFeature()
4230
4311
  ];
4231
4312
  }
4232
4313
 
@@ -4402,6 +4483,7 @@ function BottomSheet($$anchor, $$props) {
4402
4483
  disableDrag: disableDrag(),
4403
4484
  dragFrom: $$props.dragFrom,
4404
4485
  dragFromContent: $$props.dragFromContent,
4486
+ fitContentToSnap: $$props.fitContentToSnap,
4405
4487
  closeOnRouteChange: closeOnRouteChange(),
4406
4488
  stackEffect: stackEffect(),
4407
4489
  radius: $$props.radius,
package/dist/vue.cjs CHANGED
@@ -377,14 +377,26 @@ function notifyLinkedSheets(sheets, self) {
377
377
  }
378
378
  }
379
379
 
380
+ // src/core/primitives/hot-path-thresholds.ts
381
+ var SIZE_WRITE_EPSILON = 0.5;
382
+ var OPACITY_WRITE_EPSILON = 5e-3;
383
+ var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
384
+ var RANGE_DIVISION_EPSILON = 1e-4;
385
+
380
386
  // src/core/features/resize-observer.ts
381
387
  function installResizeObserver(deps) {
382
388
  if (typeof window === "undefined") {
383
389
  return () => {
384
390
  };
385
391
  }
392
+ const seatFor = () => {
393
+ const snap = deps.resolveActiveSnap();
394
+ const max = deps.getMaxAxisSize();
395
+ return { target: snap ? Math.min(snap.size, max) : null, max };
396
+ };
386
397
  const onResize = () => {
387
398
  if (deps.isDestroyed()) return;
399
+ const before = seatFor();
388
400
  deps.recomputeSnaps();
389
401
  const mode = deps.getMode();
390
402
  const isVerticalAxis = mode === "bottom" || mode === "top";
@@ -393,6 +405,10 @@ function installResizeObserver(deps) {
393
405
  if (viewportSize2 > 0 && viewportSize2 < max) {
394
406
  deps.setMaxAxisSize(viewportSize2);
395
407
  }
408
+ const after = seatFor();
409
+ if (before.target !== null && after.target !== null && Math.abs(after.target - before.target) < SIZE_WRITE_EPSILON && Math.abs(after.max - before.max) < SIZE_WRITE_EPSILON) {
410
+ return;
411
+ }
396
412
  const wasAnimating = deps.isAnimating?.() ?? false;
397
413
  deps.cancelInFlight();
398
414
  deps.newCycle();
@@ -661,12 +677,6 @@ var SCRIM_PRESETS = Object.freeze({
661
677
  }
662
678
  });
663
679
 
664
- // src/core/primitives/hot-path-thresholds.ts
665
- var SIZE_WRITE_EPSILON = 0.5;
666
- var OPACITY_WRITE_EPSILON = 5e-3;
667
- var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
668
- var RANGE_DIVISION_EPSILON = 1e-4;
669
-
670
680
  // src/core/primitives/opacity-dedup.ts
671
681
  var WriteSentinel = class {
672
682
  constructor() {
@@ -2596,6 +2606,7 @@ var BottomSheetCore = class {
2596
2606
  __publicField(this, "lifecycle");
2597
2607
  __publicField(this, "closeOnBack");
2598
2608
  __publicField(this, "routedTo");
2609
+ __publicField(this, "fitContentToSnap");
2599
2610
  __publicField(this, "persistent");
2600
2611
  __publicField(this, "disableCloseFlag");
2601
2612
  __publicField(this, "disableDragFlag");
@@ -2709,6 +2720,7 @@ var BottomSheetCore = class {
2709
2720
  );
2710
2721
  this.closeOnBack = resolved.closeOnBack;
2711
2722
  this.routedTo = opts.routedTo;
2723
+ this.fitContentToSnap = opts.fitContentToSnap === true;
2712
2724
  this.persistent = resolved.persistent;
2713
2725
  this.disableCloseFlag = resolved.disableClose;
2714
2726
  this.disableDragFlag = resolved.disableDrag;
@@ -2810,7 +2822,8 @@ var BottomSheetCore = class {
2810
2822
  closeOnBack: this.closeOnBack,
2811
2823
  closeOnRouteChange: this.closeOnRouteChange,
2812
2824
  persistKey: this.persistKey,
2813
- autoCollapseAfter
2825
+ autoCollapseAfter,
2826
+ fitContentToSnap: this.fitContentToSnap
2814
2827
  },
2815
2828
  isDestroyed: () => this.destroyed,
2816
2829
  isDragging: () => this.isDraggingAny(),
@@ -2862,6 +2875,11 @@ var BottomSheetCore = class {
2862
2875
  "[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
2863
2876
  );
2864
2877
  }
2878
+ if (this.fitContentToSnap && !names.has("content-fit")) {
2879
+ devWarn(
2880
+ "[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
2881
+ );
2882
+ }
2865
2883
  if (this.persistKey && !names.has("persist")) {
2866
2884
  devWarn(
2867
2885
  "[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
@@ -4219,6 +4237,68 @@ function visualViewportFeature() {
4219
4237
  };
4220
4238
  }
4221
4239
 
4240
+ // src/core/features/content-fit.ts
4241
+ var INSET_VAR = "--bs-content-inset";
4242
+ var FIT_ATTR = "data-bs-fit-content";
4243
+ function contentFitFeature() {
4244
+ return {
4245
+ name: "content-fit",
4246
+ install: (ctx) => {
4247
+ const scroller = ctx.scrollContainer;
4248
+ if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
4249
+ return;
4250
+ }
4251
+ const sheet = ctx.element;
4252
+ let inset = 0;
4253
+ let unpaddedMax = -1;
4254
+ let top = 0;
4255
+ const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
4256
+ const follow = (size) => {
4257
+ if (unpaddedMax < 0) {
4258
+ unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
4259
+ top = scroller.scrollTop;
4260
+ }
4261
+ const limit = Math.max(0, unpaddedMax + hiddenAt(size));
4262
+ if (top > limit) {
4263
+ if (scroller.scrollTop > limit) scroller.scrollTop = limit;
4264
+ top = limit;
4265
+ }
4266
+ };
4267
+ const settle = () => {
4268
+ if (ctx.isDestroyed()) return;
4269
+ const size = ctx.getSize();
4270
+ unpaddedMax = -1;
4271
+ follow(size);
4272
+ inset = hiddenAt(size);
4273
+ sheet.style.setProperty(INSET_VAR, `${inset}px`);
4274
+ unpaddedMax = -1;
4275
+ };
4276
+ const moving = () => ctx.isAnimating() || ctx.isDragging();
4277
+ const whenIdle = () => {
4278
+ if (!moving()) settle();
4279
+ };
4280
+ sheet.setAttribute(FIT_ATTR, "");
4281
+ settle();
4282
+ const offProgress = ctx.on(
4283
+ "progress",
4284
+ (p) => moving() ? follow(p.size) : settle()
4285
+ );
4286
+ const offSnap = ctx.on("snap", settle);
4287
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
4288
+ observer?.observe(document.documentElement);
4289
+ window.addEventListener("orientationchange", whenIdle);
4290
+ return () => {
4291
+ offProgress();
4292
+ offSnap();
4293
+ observer?.disconnect();
4294
+ window.removeEventListener("orientationchange", whenIdle);
4295
+ sheet.removeAttribute(FIT_ATTR);
4296
+ sheet.style.removeProperty(INSET_VAR);
4297
+ };
4298
+ }
4299
+ };
4300
+ }
4301
+
4222
4302
  // src/core/default-features.ts
4223
4303
  function defaultEngineFeatures() {
4224
4304
  return [
@@ -4226,7 +4306,8 @@ function defaultEngineFeatures() {
4226
4306
  visualViewportFeature(),
4227
4307
  persistFeature(),
4228
4308
  autoCollapseFeature(),
4229
- routeFeature()
4309
+ routeFeature(),
4310
+ contentFitFeature()
4230
4311
  ];
4231
4312
  }
4232
4313
 
@@ -4443,6 +4524,10 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
4443
4524
  type: Boolean,
4444
4525
  required: false
4445
4526
  },
4527
+ fitContentToSnap: {
4528
+ type: Boolean,
4529
+ required: false
4530
+ },
4446
4531
  rubberBand: {
4447
4532
  type: Boolean,
4448
4533
  required: false