@surdeddd/bottom-sheet 0.21.2 → 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 +9 -1
  7. package/dist/core.d.cts +2 -2
  8. package/dist/core.d.ts +2 -2
  9. package/dist/core.js +9 -1
  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 +84 -4
  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 +84 -4
  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 +73 -2
  26. package/dist/index.d.cts +5 -5
  27. package/dist/index.d.ts +5 -5
  28. package/dist/index.js +73 -2
  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 +67 -2
  36. package/dist/qwik-lib/index.qwik.mjs +67 -2
  37. package/dist/qwik.cjs +74 -2
  38. package/dist/qwik.d.cts +3 -2
  39. package/dist/qwik.d.ts +3 -2
  40. package/dist/qwik.js +74 -2
  41. package/dist/react.cjs +73 -2
  42. package/dist/react.d.cts +3 -3
  43. package/dist/react.d.ts +3 -3
  44. package/dist/react.js +73 -2
  45. package/dist/solid.cjs +74 -2
  46. package/dist/solid.d.cts +4 -0
  47. package/dist/solid.d.ts +4 -0
  48. package/dist/solid.js +74 -2
  49. package/dist/solid.source.jsx +74 -2
  50. package/dist/styles.css +11 -0
  51. package/dist/svelte-core.cjs +73 -2
  52. package/dist/svelte-core.js +73 -2
  53. package/dist/svelte-src/BottomSheet.svelte +3 -0
  54. package/dist/svelte.cjs +74 -2
  55. package/dist/svelte.d.cts +1 -0
  56. package/dist/svelte.d.ts +1 -0
  57. package/dist/svelte.js +74 -2
  58. package/dist/vue.cjs +77 -2
  59. package/dist/vue.js +77 -2
  60. package/dist/webgl.d.cts +1 -1
  61. package/dist/webgl.d.ts +1 -1
  62. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -2602,6 +2602,7 @@ var BottomSheetCore = class {
2602
2602
  __publicField(this, "lifecycle");
2603
2603
  __publicField(this, "closeOnBack");
2604
2604
  __publicField(this, "routedTo");
2605
+ __publicField(this, "fitContentToSnap");
2605
2606
  __publicField(this, "persistent");
2606
2607
  __publicField(this, "disableCloseFlag");
2607
2608
  __publicField(this, "disableDragFlag");
@@ -2715,6 +2716,7 @@ var BottomSheetCore = class {
2715
2716
  );
2716
2717
  this.closeOnBack = resolved.closeOnBack;
2717
2718
  this.routedTo = opts.routedTo;
2719
+ this.fitContentToSnap = opts.fitContentToSnap === true;
2718
2720
  this.persistent = resolved.persistent;
2719
2721
  this.disableCloseFlag = resolved.disableClose;
2720
2722
  this.disableDragFlag = resolved.disableDrag;
@@ -2816,7 +2818,8 @@ var BottomSheetCore = class {
2816
2818
  closeOnBack: this.closeOnBack,
2817
2819
  closeOnRouteChange: this.closeOnRouteChange,
2818
2820
  persistKey: this.persistKey,
2819
- autoCollapseAfter
2821
+ autoCollapseAfter,
2822
+ fitContentToSnap: this.fitContentToSnap
2820
2823
  },
2821
2824
  isDestroyed: () => this.destroyed,
2822
2825
  isDragging: () => this.isDraggingAny(),
@@ -2868,6 +2871,11 @@ var BottomSheetCore = class {
2868
2871
  "[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
2869
2872
  );
2870
2873
  }
2874
+ if (this.fitContentToSnap && !names.has("content-fit")) {
2875
+ devWarn(
2876
+ "[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
2877
+ );
2878
+ }
2871
2879
  if (this.persistKey && !names.has("persist")) {
2872
2880
  devWarn(
2873
2881
  "[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
@@ -4225,6 +4233,68 @@ function visualViewportFeature() {
4225
4233
  };
4226
4234
  }
4227
4235
 
4236
+ // src/core/features/content-fit.ts
4237
+ var INSET_VAR = "--bs-content-inset";
4238
+ var FIT_ATTR = "data-bs-fit-content";
4239
+ function contentFitFeature() {
4240
+ return {
4241
+ name: "content-fit",
4242
+ install: (ctx) => {
4243
+ const scroller = ctx.scrollContainer;
4244
+ if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
4245
+ return;
4246
+ }
4247
+ const sheet = ctx.element;
4248
+ let inset = 0;
4249
+ let unpaddedMax = -1;
4250
+ let top = 0;
4251
+ const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
4252
+ const follow = (size) => {
4253
+ if (unpaddedMax < 0) {
4254
+ unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
4255
+ top = scroller.scrollTop;
4256
+ }
4257
+ const limit = Math.max(0, unpaddedMax + hiddenAt(size));
4258
+ if (top > limit) {
4259
+ if (scroller.scrollTop > limit) scroller.scrollTop = limit;
4260
+ top = limit;
4261
+ }
4262
+ };
4263
+ const settle = () => {
4264
+ if (ctx.isDestroyed()) return;
4265
+ const size = ctx.getSize();
4266
+ unpaddedMax = -1;
4267
+ follow(size);
4268
+ inset = hiddenAt(size);
4269
+ sheet.style.setProperty(INSET_VAR, `${inset}px`);
4270
+ unpaddedMax = -1;
4271
+ };
4272
+ const moving = () => ctx.isAnimating() || ctx.isDragging();
4273
+ const whenIdle = () => {
4274
+ if (!moving()) settle();
4275
+ };
4276
+ sheet.setAttribute(FIT_ATTR, "");
4277
+ settle();
4278
+ const offProgress = ctx.on(
4279
+ "progress",
4280
+ (p) => moving() ? follow(p.size) : settle()
4281
+ );
4282
+ const offSnap = ctx.on("snap", settle);
4283
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
4284
+ observer?.observe(document.documentElement);
4285
+ window.addEventListener("orientationchange", whenIdle);
4286
+ return () => {
4287
+ offProgress();
4288
+ offSnap();
4289
+ observer?.disconnect();
4290
+ window.removeEventListener("orientationchange", whenIdle);
4291
+ sheet.removeAttribute(FIT_ATTR);
4292
+ sheet.style.removeProperty(INSET_VAR);
4293
+ };
4294
+ }
4295
+ };
4296
+ }
4297
+
4228
4298
  // src/core/default-features.ts
4229
4299
  function defaultEngineFeatures() {
4230
4300
  return [
@@ -4232,7 +4302,8 @@ function defaultEngineFeatures() {
4232
4302
  visualViewportFeature(),
4233
4303
  persistFeature(),
4234
4304
  autoCollapseFeature(),
4235
- routeFeature()
4305
+ routeFeature(),
4306
+ contentFitFeature()
4236
4307
  ];
4237
4308
  }
4238
4309
 
@@ -1,4 +1,4 @@
1
- import { S as SheetEventMap } from '../BottomSheetCore-BHv6LPmS.cjs';
1
+ import { S as SheetEventMap } from '../BottomSheetCore-CQStdVy2.cjs';
2
2
  import '../transform-jVfAikE9.cjs';
3
3
 
4
4
  type FormikStateLike = {
@@ -1,4 +1,4 @@
1
- import { S as SheetEventMap } from '../BottomSheetCore-CK_mq14p.js';
1
+ import { S as SheetEventMap } from '../BottomSheetCore-9i-Uh6T3.js';
2
2
  import '../transform-jVfAikE9.js';
3
3
 
4
4
  type FormikStateLike = {
@@ -1,4 +1,4 @@
1
- import { S as SheetEventMap } from '../BottomSheetCore-BHv6LPmS.cjs';
1
+ import { S as SheetEventMap } from '../BottomSheetCore-CQStdVy2.cjs';
2
2
  import '../transform-jVfAikE9.cjs';
3
3
 
4
4
  type RhfFormStateLike = {
@@ -1,4 +1,4 @@
1
- import { S as SheetEventMap } from '../BottomSheetCore-CK_mq14p.js';
1
+ import { S as SheetEventMap } from '../BottomSheetCore-9i-Uh6T3.js';
2
2
  import '../transform-jVfAikE9.js';
3
3
 
4
4
  type RhfFormStateLike = {
package/dist/preact.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { BottomSheet, BottomSheetFromConfig, BottomSheetFromConfigProps, BottomSheetHandle, BottomSheetProps, HeaderProp, Overlay, OverlayHandle, OverlayProps, SheetConfig, UseBottomSheetRefs, UseBottomSheetReturn, UseOverlayReturn, useBottomSheet, useOverlay } from './react.cjs';
2
- export { E as EngineState, b as SheetMode, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-BHv6LPmS.cjs';
2
+ export { d as EngineState, f as SheetMode, h as SnapPoint, e as SnapPointDef } from './BottomSheetCore-CQStdVy2.cjs';
3
3
  export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.cjs';
4
4
  import 'react';
5
- import './BottomSheetEngine-mmFzIK1Z.cjs';
5
+ import './BottomSheetEngine-CsQWHLNb.cjs';
6
6
  import './teleport-7uYNiEAT.cjs';
7
7
  import './transform-jVfAikE9.cjs';
package/dist/preact.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { BottomSheet, BottomSheetFromConfig, BottomSheetFromConfigProps, BottomSheetHandle, BottomSheetProps, HeaderProp, Overlay, OverlayHandle, OverlayProps, SheetConfig, UseBottomSheetRefs, UseBottomSheetReturn, UseOverlayReturn, useBottomSheet, useOverlay } from './react.js';
2
- export { E as EngineState, b as SheetMode, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-CK_mq14p.js';
2
+ export { d as EngineState, f as SheetMode, h as SnapPoint, e as SnapPointDef } from './BottomSheetCore-9i-Uh6T3.js';
3
3
  export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.js';
4
4
  import 'react';
5
- import './BottomSheetEngine-wLn6Q2kA.js';
5
+ import './BottomSheetEngine-Dn6h-7gF.js';
6
6
  import './teleport-7uYNiEAT.js';
7
7
  import './transform-jVfAikE9.js';
@@ -2651,6 +2651,7 @@ class BottomSheetCore {
2651
2651
  __publicField(this, "lifecycle");
2652
2652
  __publicField(this, "closeOnBack");
2653
2653
  __publicField(this, "routedTo");
2654
+ __publicField(this, "fitContentToSnap");
2654
2655
  __publicField(this, "persistent");
2655
2656
  __publicField(this, "disableCloseFlag");
2656
2657
  __publicField(this, "disableDragFlag");
@@ -2756,6 +2757,7 @@ class BottomSheetCore {
2756
2757
  }, resolved.lifecycle);
2757
2758
  this.closeOnBack = resolved.closeOnBack;
2758
2759
  this.routedTo = opts.routedTo;
2760
+ this.fitContentToSnap = opts.fitContentToSnap === true;
2759
2761
  this.persistent = resolved.persistent;
2760
2762
  this.disableCloseFlag = resolved.disableClose;
2761
2763
  this.disableDragFlag = resolved.disableDrag;
@@ -2847,7 +2849,8 @@ class BottomSheetCore {
2847
2849
  closeOnBack: this.closeOnBack,
2848
2850
  closeOnRouteChange: this.closeOnRouteChange,
2849
2851
  persistKey: this.persistKey,
2850
- autoCollapseAfter
2852
+ autoCollapseAfter,
2853
+ fitContentToSnap: this.fitContentToSnap
2851
2854
  },
2852
2855
  isDestroyed: () => this.destroyed,
2853
2856
  isDragging: () => this.isDraggingAny(),
@@ -2897,6 +2900,9 @@ class BottomSheetCore {
2897
2900
  if ((this.closeOnBack || this.routedTo !== void 0 || this.closeOnRouteChange) && !names.has("route")) {
2898
2901
  devWarn("[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() — option ignored");
2899
2902
  }
2903
+ if (this.fitContentToSnap && !names.has("content-fit")) {
2904
+ devWarn("[BottomSheet] fitContentToSnap needs contentFitFeature() — option ignored");
2905
+ }
2900
2906
  if (this.persistKey && !names.has("persist")) {
2901
2907
  devWarn("[BottomSheet] persistKey needs persistFeature() — snaps will not be saved");
2902
2908
  }
@@ -4221,13 +4227,71 @@ function visualViewportFeature() {
4221
4227
  }
4222
4228
  };
4223
4229
  }
4230
+ const INSET_VAR = "--bs-content-inset";
4231
+ const FIT_ATTR = "data-bs-fit-content";
4232
+ function contentFitFeature() {
4233
+ return {
4234
+ name: "content-fit",
4235
+ install: (ctx) => {
4236
+ const scroller = ctx.scrollContainer;
4237
+ if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
4238
+ return;
4239
+ }
4240
+ const sheet = ctx.element;
4241
+ let inset = 0;
4242
+ let unpaddedMax = -1;
4243
+ let top = 0;
4244
+ const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
4245
+ const follow = (size) => {
4246
+ if (unpaddedMax < 0) {
4247
+ unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
4248
+ top = scroller.scrollTop;
4249
+ }
4250
+ const limit = Math.max(0, unpaddedMax + hiddenAt(size));
4251
+ if (top > limit) {
4252
+ if (scroller.scrollTop > limit) scroller.scrollTop = limit;
4253
+ top = limit;
4254
+ }
4255
+ };
4256
+ const settle = () => {
4257
+ if (ctx.isDestroyed()) return;
4258
+ const size = ctx.getSize();
4259
+ unpaddedMax = -1;
4260
+ follow(size);
4261
+ inset = hiddenAt(size);
4262
+ sheet.style.setProperty(INSET_VAR, `${inset}px`);
4263
+ unpaddedMax = -1;
4264
+ };
4265
+ const moving = () => ctx.isAnimating() || ctx.isDragging();
4266
+ const whenIdle = () => {
4267
+ if (!moving()) settle();
4268
+ };
4269
+ sheet.setAttribute(FIT_ATTR, "");
4270
+ settle();
4271
+ const offProgress = ctx.on("progress", (p) => moving() ? follow(p.size) : settle());
4272
+ const offSnap = ctx.on("snap", settle);
4273
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
4274
+ observer?.observe(document.documentElement);
4275
+ window.addEventListener("orientationchange", whenIdle);
4276
+ return () => {
4277
+ offProgress();
4278
+ offSnap();
4279
+ observer?.disconnect();
4280
+ window.removeEventListener("orientationchange", whenIdle);
4281
+ sheet.removeAttribute(FIT_ATTR);
4282
+ sheet.style.removeProperty(INSET_VAR);
4283
+ };
4284
+ }
4285
+ };
4286
+ }
4224
4287
  function defaultEngineFeatures() {
4225
4288
  return [
4226
4289
  contentSwipeFeature(),
4227
4290
  visualViewportFeature(),
4228
4291
  persistFeature(),
4229
4292
  autoCollapseFeature(),
4230
- routeFeature()
4293
+ routeFeature(),
4294
+ contentFitFeature()
4231
4295
  ];
4232
4296
  }
4233
4297
  class BottomSheetEngine extends BottomSheetCore {
@@ -4324,6 +4388,7 @@ const BottomSheet = qwik.component$((props) => {
4324
4388
  disableDrag: props.disableDrag,
4325
4389
  dragFrom: props.dragFrom,
4326
4390
  dragFromContent: props.dragFromContent,
4391
+ fitContentToSnap: props.fitContentToSnap,
4327
4392
  closeOnRouteChange: props.closeOnRouteChange,
4328
4393
  stackEffect: props.stackEffect,
4329
4394
  returnFocusTo: props.returnFocusTo,
@@ -2649,6 +2649,7 @@ class BottomSheetCore {
2649
2649
  __publicField(this, "lifecycle");
2650
2650
  __publicField(this, "closeOnBack");
2651
2651
  __publicField(this, "routedTo");
2652
+ __publicField(this, "fitContentToSnap");
2652
2653
  __publicField(this, "persistent");
2653
2654
  __publicField(this, "disableCloseFlag");
2654
2655
  __publicField(this, "disableDragFlag");
@@ -2754,6 +2755,7 @@ class BottomSheetCore {
2754
2755
  }, resolved.lifecycle);
2755
2756
  this.closeOnBack = resolved.closeOnBack;
2756
2757
  this.routedTo = opts.routedTo;
2758
+ this.fitContentToSnap = opts.fitContentToSnap === true;
2757
2759
  this.persistent = resolved.persistent;
2758
2760
  this.disableCloseFlag = resolved.disableClose;
2759
2761
  this.disableDragFlag = resolved.disableDrag;
@@ -2845,7 +2847,8 @@ class BottomSheetCore {
2845
2847
  closeOnBack: this.closeOnBack,
2846
2848
  closeOnRouteChange: this.closeOnRouteChange,
2847
2849
  persistKey: this.persistKey,
2848
- autoCollapseAfter
2850
+ autoCollapseAfter,
2851
+ fitContentToSnap: this.fitContentToSnap
2849
2852
  },
2850
2853
  isDestroyed: () => this.destroyed,
2851
2854
  isDragging: () => this.isDraggingAny(),
@@ -2895,6 +2898,9 @@ class BottomSheetCore {
2895
2898
  if ((this.closeOnBack || this.routedTo !== void 0 || this.closeOnRouteChange) && !names.has("route")) {
2896
2899
  devWarn("[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() — option ignored");
2897
2900
  }
2901
+ if (this.fitContentToSnap && !names.has("content-fit")) {
2902
+ devWarn("[BottomSheet] fitContentToSnap needs contentFitFeature() — option ignored");
2903
+ }
2898
2904
  if (this.persistKey && !names.has("persist")) {
2899
2905
  devWarn("[BottomSheet] persistKey needs persistFeature() — snaps will not be saved");
2900
2906
  }
@@ -4219,13 +4225,71 @@ function visualViewportFeature() {
4219
4225
  }
4220
4226
  };
4221
4227
  }
4228
+ const INSET_VAR = "--bs-content-inset";
4229
+ const FIT_ATTR = "data-bs-fit-content";
4230
+ function contentFitFeature() {
4231
+ return {
4232
+ name: "content-fit",
4233
+ install: (ctx) => {
4234
+ const scroller = ctx.scrollContainer;
4235
+ if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
4236
+ return;
4237
+ }
4238
+ const sheet = ctx.element;
4239
+ let inset = 0;
4240
+ let unpaddedMax = -1;
4241
+ let top = 0;
4242
+ const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
4243
+ const follow = (size) => {
4244
+ if (unpaddedMax < 0) {
4245
+ unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
4246
+ top = scroller.scrollTop;
4247
+ }
4248
+ const limit = Math.max(0, unpaddedMax + hiddenAt(size));
4249
+ if (top > limit) {
4250
+ if (scroller.scrollTop > limit) scroller.scrollTop = limit;
4251
+ top = limit;
4252
+ }
4253
+ };
4254
+ const settle = () => {
4255
+ if (ctx.isDestroyed()) return;
4256
+ const size = ctx.getSize();
4257
+ unpaddedMax = -1;
4258
+ follow(size);
4259
+ inset = hiddenAt(size);
4260
+ sheet.style.setProperty(INSET_VAR, `${inset}px`);
4261
+ unpaddedMax = -1;
4262
+ };
4263
+ const moving = () => ctx.isAnimating() || ctx.isDragging();
4264
+ const whenIdle = () => {
4265
+ if (!moving()) settle();
4266
+ };
4267
+ sheet.setAttribute(FIT_ATTR, "");
4268
+ settle();
4269
+ const offProgress = ctx.on("progress", (p) => moving() ? follow(p.size) : settle());
4270
+ const offSnap = ctx.on("snap", settle);
4271
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
4272
+ observer?.observe(document.documentElement);
4273
+ window.addEventListener("orientationchange", whenIdle);
4274
+ return () => {
4275
+ offProgress();
4276
+ offSnap();
4277
+ observer?.disconnect();
4278
+ window.removeEventListener("orientationchange", whenIdle);
4279
+ sheet.removeAttribute(FIT_ATTR);
4280
+ sheet.style.removeProperty(INSET_VAR);
4281
+ };
4282
+ }
4283
+ };
4284
+ }
4222
4285
  function defaultEngineFeatures() {
4223
4286
  return [
4224
4287
  contentSwipeFeature(),
4225
4288
  visualViewportFeature(),
4226
4289
  persistFeature(),
4227
4290
  autoCollapseFeature(),
4228
- routeFeature()
4291
+ routeFeature(),
4292
+ contentFitFeature()
4229
4293
  ];
4230
4294
  }
4231
4295
  class BottomSheetEngine extends BottomSheetCore {
@@ -4322,6 +4386,7 @@ const BottomSheet = component$((props) => {
4322
4386
  disableDrag: props.disableDrag,
4323
4387
  dragFrom: props.dragFrom,
4324
4388
  dragFromContent: props.dragFromContent,
4389
+ fitContentToSnap: props.fitContentToSnap,
4325
4390
  closeOnRouteChange: props.closeOnRouteChange,
4326
4391
  stackEffect: props.stackEffect,
4327
4392
  returnFocusTo: props.returnFocusTo,
package/dist/qwik.cjs CHANGED
@@ -2607,6 +2607,7 @@ var BottomSheetCore = class {
2607
2607
  __publicField(this, "lifecycle");
2608
2608
  __publicField(this, "closeOnBack");
2609
2609
  __publicField(this, "routedTo");
2610
+ __publicField(this, "fitContentToSnap");
2610
2611
  __publicField(this, "persistent");
2611
2612
  __publicField(this, "disableCloseFlag");
2612
2613
  __publicField(this, "disableDragFlag");
@@ -2720,6 +2721,7 @@ var BottomSheetCore = class {
2720
2721
  );
2721
2722
  this.closeOnBack = resolved.closeOnBack;
2722
2723
  this.routedTo = opts.routedTo;
2724
+ this.fitContentToSnap = opts.fitContentToSnap === true;
2723
2725
  this.persistent = resolved.persistent;
2724
2726
  this.disableCloseFlag = resolved.disableClose;
2725
2727
  this.disableDragFlag = resolved.disableDrag;
@@ -2821,7 +2823,8 @@ var BottomSheetCore = class {
2821
2823
  closeOnBack: this.closeOnBack,
2822
2824
  closeOnRouteChange: this.closeOnRouteChange,
2823
2825
  persistKey: this.persistKey,
2824
- autoCollapseAfter
2826
+ autoCollapseAfter,
2827
+ fitContentToSnap: this.fitContentToSnap
2825
2828
  },
2826
2829
  isDestroyed: () => this.destroyed,
2827
2830
  isDragging: () => this.isDraggingAny(),
@@ -2873,6 +2876,11 @@ var BottomSheetCore = class {
2873
2876
  "[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
2874
2877
  );
2875
2878
  }
2879
+ if (this.fitContentToSnap && !names.has("content-fit")) {
2880
+ devWarn(
2881
+ "[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
2882
+ );
2883
+ }
2876
2884
  if (this.persistKey && !names.has("persist")) {
2877
2885
  devWarn(
2878
2886
  "[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
@@ -4230,6 +4238,68 @@ function visualViewportFeature() {
4230
4238
  };
4231
4239
  }
4232
4240
 
4241
+ // src/core/features/content-fit.ts
4242
+ var INSET_VAR = "--bs-content-inset";
4243
+ var FIT_ATTR = "data-bs-fit-content";
4244
+ function contentFitFeature() {
4245
+ return {
4246
+ name: "content-fit",
4247
+ install: (ctx) => {
4248
+ const scroller = ctx.scrollContainer;
4249
+ if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
4250
+ return;
4251
+ }
4252
+ const sheet = ctx.element;
4253
+ let inset = 0;
4254
+ let unpaddedMax = -1;
4255
+ let top = 0;
4256
+ const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
4257
+ const follow = (size) => {
4258
+ if (unpaddedMax < 0) {
4259
+ unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
4260
+ top = scroller.scrollTop;
4261
+ }
4262
+ const limit = Math.max(0, unpaddedMax + hiddenAt(size));
4263
+ if (top > limit) {
4264
+ if (scroller.scrollTop > limit) scroller.scrollTop = limit;
4265
+ top = limit;
4266
+ }
4267
+ };
4268
+ const settle = () => {
4269
+ if (ctx.isDestroyed()) return;
4270
+ const size = ctx.getSize();
4271
+ unpaddedMax = -1;
4272
+ follow(size);
4273
+ inset = hiddenAt(size);
4274
+ sheet.style.setProperty(INSET_VAR, `${inset}px`);
4275
+ unpaddedMax = -1;
4276
+ };
4277
+ const moving = () => ctx.isAnimating() || ctx.isDragging();
4278
+ const whenIdle = () => {
4279
+ if (!moving()) settle();
4280
+ };
4281
+ sheet.setAttribute(FIT_ATTR, "");
4282
+ settle();
4283
+ const offProgress = ctx.on(
4284
+ "progress",
4285
+ (p) => moving() ? follow(p.size) : settle()
4286
+ );
4287
+ const offSnap = ctx.on("snap", settle);
4288
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
4289
+ observer?.observe(document.documentElement);
4290
+ window.addEventListener("orientationchange", whenIdle);
4291
+ return () => {
4292
+ offProgress();
4293
+ offSnap();
4294
+ observer?.disconnect();
4295
+ window.removeEventListener("orientationchange", whenIdle);
4296
+ sheet.removeAttribute(FIT_ATTR);
4297
+ sheet.style.removeProperty(INSET_VAR);
4298
+ };
4299
+ }
4300
+ };
4301
+ }
4302
+
4233
4303
  // src/core/default-features.ts
4234
4304
  function defaultEngineFeatures() {
4235
4305
  return [
@@ -4237,7 +4307,8 @@ function defaultEngineFeatures() {
4237
4307
  visualViewportFeature(),
4238
4308
  persistFeature(),
4239
4309
  autoCollapseFeature(),
4240
- routeFeature()
4310
+ routeFeature(),
4311
+ contentFitFeature()
4241
4312
  ];
4242
4313
  }
4243
4314
 
@@ -4331,6 +4402,7 @@ var BottomSheet = qwik.component$((props) => {
4331
4402
  disableDrag: props.disableDrag,
4332
4403
  dragFrom: props.dragFrom,
4333
4404
  dragFromContent: props.dragFromContent,
4405
+ fitContentToSnap: props.fitContentToSnap,
4334
4406
  closeOnRouteChange: props.closeOnRouteChange,
4335
4407
  stackEffect: props.stackEffect,
4336
4408
  returnFocusTo: props.returnFocusTo,
package/dist/qwik.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _builder_io_qwik from '@builder.io/qwik';
2
2
  import { QRL } from '@builder.io/qwik';
3
3
  import { T as TeleportTarget } from './teleport-7uYNiEAT.cjs';
4
- import { a as SnapPointDef, b as SheetMode, c as EngineOptions, S as SheetEventMap, E as EngineState } from './BottomSheetCore-BHv6LPmS.cjs';
5
- export { d as SnapPoint } from './BottomSheetCore-BHv6LPmS.cjs';
4
+ import { e as SnapPointDef, f as SheetMode, g as EngineOptions, S as SheetEventMap, d as EngineState } from './BottomSheetCore-CQStdVy2.cjs';
5
+ export { h as SnapPoint } from './BottomSheetCore-CQStdVy2.cjs';
6
6
  import './transform-jVfAikE9.cjs';
7
7
 
8
8
  type BottomSheetProps<TId extends string = string> = {
@@ -29,6 +29,7 @@ type BottomSheetProps<TId extends string = string> = {
29
29
  disableDrag?: boolean;
30
30
  dragFrom?: EngineOptions["dragFrom"];
31
31
  dragFromContent?: boolean;
32
+ fitContentToSnap?: boolean;
32
33
  closeOnRouteChange?: boolean;
33
34
  stackEffect?: boolean;
34
35
  teleport?: boolean;
package/dist/qwik.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _builder_io_qwik from '@builder.io/qwik';
2
2
  import { QRL } from '@builder.io/qwik';
3
3
  import { T as TeleportTarget } from './teleport-7uYNiEAT.js';
4
- import { a as SnapPointDef, b as SheetMode, c as EngineOptions, S as SheetEventMap, E as EngineState } from './BottomSheetCore-CK_mq14p.js';
5
- export { d as SnapPoint } from './BottomSheetCore-CK_mq14p.js';
4
+ import { e as SnapPointDef, f as SheetMode, g as EngineOptions, S as SheetEventMap, d as EngineState } from './BottomSheetCore-9i-Uh6T3.js';
5
+ export { h as SnapPoint } from './BottomSheetCore-9i-Uh6T3.js';
6
6
  import './transform-jVfAikE9.js';
7
7
 
8
8
  type BottomSheetProps<TId extends string = string> = {
@@ -29,6 +29,7 @@ type BottomSheetProps<TId extends string = string> = {
29
29
  disableDrag?: boolean;
30
30
  dragFrom?: EngineOptions["dragFrom"];
31
31
  dragFromContent?: boolean;
32
+ fitContentToSnap?: boolean;
32
33
  closeOnRouteChange?: boolean;
33
34
  stackEffect?: boolean;
34
35
  teleport?: boolean;
package/dist/qwik.js CHANGED
@@ -2605,6 +2605,7 @@ var BottomSheetCore = class {
2605
2605
  __publicField(this, "lifecycle");
2606
2606
  __publicField(this, "closeOnBack");
2607
2607
  __publicField(this, "routedTo");
2608
+ __publicField(this, "fitContentToSnap");
2608
2609
  __publicField(this, "persistent");
2609
2610
  __publicField(this, "disableCloseFlag");
2610
2611
  __publicField(this, "disableDragFlag");
@@ -2718,6 +2719,7 @@ var BottomSheetCore = class {
2718
2719
  );
2719
2720
  this.closeOnBack = resolved.closeOnBack;
2720
2721
  this.routedTo = opts.routedTo;
2722
+ this.fitContentToSnap = opts.fitContentToSnap === true;
2721
2723
  this.persistent = resolved.persistent;
2722
2724
  this.disableCloseFlag = resolved.disableClose;
2723
2725
  this.disableDragFlag = resolved.disableDrag;
@@ -2819,7 +2821,8 @@ var BottomSheetCore = class {
2819
2821
  closeOnBack: this.closeOnBack,
2820
2822
  closeOnRouteChange: this.closeOnRouteChange,
2821
2823
  persistKey: this.persistKey,
2822
- autoCollapseAfter
2824
+ autoCollapseAfter,
2825
+ fitContentToSnap: this.fitContentToSnap
2823
2826
  },
2824
2827
  isDestroyed: () => this.destroyed,
2825
2828
  isDragging: () => this.isDraggingAny(),
@@ -2871,6 +2874,11 @@ var BottomSheetCore = class {
2871
2874
  "[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
2872
2875
  );
2873
2876
  }
2877
+ if (this.fitContentToSnap && !names.has("content-fit")) {
2878
+ devWarn(
2879
+ "[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
2880
+ );
2881
+ }
2874
2882
  if (this.persistKey && !names.has("persist")) {
2875
2883
  devWarn(
2876
2884
  "[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
@@ -4228,6 +4236,68 @@ function visualViewportFeature() {
4228
4236
  };
4229
4237
  }
4230
4238
 
4239
+ // src/core/features/content-fit.ts
4240
+ var INSET_VAR = "--bs-content-inset";
4241
+ var FIT_ATTR = "data-bs-fit-content";
4242
+ function contentFitFeature() {
4243
+ return {
4244
+ name: "content-fit",
4245
+ install: (ctx) => {
4246
+ const scroller = ctx.scrollContainer;
4247
+ if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
4248
+ return;
4249
+ }
4250
+ const sheet = ctx.element;
4251
+ let inset = 0;
4252
+ let unpaddedMax = -1;
4253
+ let top = 0;
4254
+ const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
4255
+ const follow = (size) => {
4256
+ if (unpaddedMax < 0) {
4257
+ unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
4258
+ top = scroller.scrollTop;
4259
+ }
4260
+ const limit = Math.max(0, unpaddedMax + hiddenAt(size));
4261
+ if (top > limit) {
4262
+ if (scroller.scrollTop > limit) scroller.scrollTop = limit;
4263
+ top = limit;
4264
+ }
4265
+ };
4266
+ const settle = () => {
4267
+ if (ctx.isDestroyed()) return;
4268
+ const size = ctx.getSize();
4269
+ unpaddedMax = -1;
4270
+ follow(size);
4271
+ inset = hiddenAt(size);
4272
+ sheet.style.setProperty(INSET_VAR, `${inset}px`);
4273
+ unpaddedMax = -1;
4274
+ };
4275
+ const moving = () => ctx.isAnimating() || ctx.isDragging();
4276
+ const whenIdle = () => {
4277
+ if (!moving()) settle();
4278
+ };
4279
+ sheet.setAttribute(FIT_ATTR, "");
4280
+ settle();
4281
+ const offProgress = ctx.on(
4282
+ "progress",
4283
+ (p) => moving() ? follow(p.size) : settle()
4284
+ );
4285
+ const offSnap = ctx.on("snap", settle);
4286
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
4287
+ observer?.observe(document.documentElement);
4288
+ window.addEventListener("orientationchange", whenIdle);
4289
+ return () => {
4290
+ offProgress();
4291
+ offSnap();
4292
+ observer?.disconnect();
4293
+ window.removeEventListener("orientationchange", whenIdle);
4294
+ sheet.removeAttribute(FIT_ATTR);
4295
+ sheet.style.removeProperty(INSET_VAR);
4296
+ };
4297
+ }
4298
+ };
4299
+ }
4300
+
4231
4301
  // src/core/default-features.ts
4232
4302
  function defaultEngineFeatures() {
4233
4303
  return [
@@ -4235,7 +4305,8 @@ function defaultEngineFeatures() {
4235
4305
  visualViewportFeature(),
4236
4306
  persistFeature(),
4237
4307
  autoCollapseFeature(),
4238
- routeFeature()
4308
+ routeFeature(),
4309
+ contentFitFeature()
4239
4310
  ];
4240
4311
  }
4241
4312
 
@@ -4329,6 +4400,7 @@ var BottomSheet = component$((props) => {
4329
4400
  disableDrag: props.disableDrag,
4330
4401
  dragFrom: props.dragFrom,
4331
4402
  dragFromContent: props.dragFromContent,
4403
+ fitContentToSnap: props.fitContentToSnap,
4332
4404
  closeOnRouteChange: props.closeOnRouteChange,
4333
4405
  stackEffect: props.stackEffect,
4334
4406
  returnFocusTo: props.returnFocusTo,