@surdeddd/bottom-sheet 0.4.0 → 0.5.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 (41) hide show
  1. package/dist/{BottomSheetEngine-L05jGZvU.d.ts → BottomSheetEngine-BHjKFtnM.d.ts} +2 -0
  2. package/dist/{BottomSheetEngine-BJrH7qY3.d.cts → BottomSheetEngine-CqiCz64W.d.cts} +2 -0
  3. package/dist/element.cjs +120 -13
  4. package/dist/element.d.cts +1 -1
  5. package/dist/element.d.ts +1 -1
  6. package/dist/element.iife.global.js +2 -2
  7. package/dist/element.js +120 -13
  8. package/dist/index.cjs +97 -8
  9. package/dist/index.d.cts +2 -2
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +97 -8
  12. package/dist/integrations/formik.d.cts +1 -1
  13. package/dist/integrations/formik.d.ts +1 -1
  14. package/dist/integrations/react-hook-form.d.cts +1 -1
  15. package/dist/integrations/react-hook-form.d.ts +1 -1
  16. package/dist/preact.d.cts +1 -1
  17. package/dist/preact.d.ts +1 -1
  18. package/dist/qwik.cjs +100 -10
  19. package/dist/qwik.d.cts +2 -2
  20. package/dist/qwik.d.ts +2 -2
  21. package/dist/qwik.js +100 -10
  22. package/dist/react.cjs +119 -12
  23. package/dist/react.d.cts +4 -2
  24. package/dist/react.d.ts +4 -2
  25. package/dist/react.js +119 -12
  26. package/dist/solid.cjs +128 -18
  27. package/dist/solid.d.cts +3 -0
  28. package/dist/solid.d.ts +3 -0
  29. package/dist/solid.js +130 -20
  30. package/dist/solid.source.jsx +106 -12
  31. package/dist/styles.css +34 -5
  32. package/dist/svelte-core.cjs +97 -8
  33. package/dist/svelte-core.js +97 -8
  34. package/dist/svelte-src/BottomSheet.svelte +15 -13
  35. package/dist/svelte.cjs +159 -53
  36. package/dist/svelte.d.cts +1 -0
  37. package/dist/svelte.d.ts +1 -0
  38. package/dist/svelte.js +159 -53
  39. package/dist/vue.cjs +126 -30
  40. package/dist/vue.js +126 -30
  41. package/package.json +3 -3
package/dist/svelte.cjs CHANGED
@@ -2919,11 +2919,54 @@ var BottomSheetEngine = class {
2919
2919
  this.updateAriaSlider();
2920
2920
  }
2921
2921
  }
2922
+ contentTargets() {
2923
+ const scroller = this.scrollContainer;
2924
+ if (!scroller) return [];
2925
+ const hasSlot = typeof HTMLSlotElement !== "undefined";
2926
+ const out = [];
2927
+ for (const child2 of Array.from(scroller.children)) {
2928
+ if (hasSlot && child2 instanceof HTMLSlotElement) {
2929
+ for (const el of child2.assignedElements()) out.push(el);
2930
+ } else {
2931
+ out.push(child2);
2932
+ }
2933
+ }
2934
+ return out;
2935
+ }
2936
+ measureContentExtent(vertical) {
2937
+ const content = this.scrollContainer;
2938
+ if (!content) return 0;
2939
+ const targets = this.contentTargets();
2940
+ if (targets.length === 0) {
2941
+ return vertical ? content.scrollHeight : content.scrollWidth;
2942
+ }
2943
+ let min = Infinity;
2944
+ let max = -Infinity;
2945
+ for (const el of targets) {
2946
+ const r = el.getBoundingClientRect();
2947
+ if (vertical) {
2948
+ if (r.top < min) min = r.top;
2949
+ if (r.bottom > max) max = r.bottom;
2950
+ } else {
2951
+ if (r.left < min) min = r.left;
2952
+ if (r.right > max) max = r.right;
2953
+ }
2954
+ }
2955
+ if (!isFinite(min) || !isFinite(max) || max <= min) {
2956
+ return vertical ? content.scrollHeight : content.scrollWidth;
2957
+ }
2958
+ let pad = 0;
2959
+ if (typeof getComputedStyle !== "undefined") {
2960
+ const cs = getComputedStyle(content);
2961
+ pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
2962
+ }
2963
+ return max - min + pad;
2964
+ }
2922
2965
  measureFitSize() {
2923
2966
  const vertical = layoutAxis(this.mode) === "height";
2924
2967
  const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2925
2968
  const content = this.scrollContainer;
2926
- const natural = content ? handleSize + (vertical ? content.scrollHeight : content.scrollWidth) : handleSize;
2969
+ const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2927
2970
  if (typeof window === "undefined") return natural;
2928
2971
  const viewport = vertical ? window.innerHeight : window.innerWidth;
2929
2972
  return viewport > 0 ? Math.min(natural, viewport) : natural;
@@ -2932,22 +2975,62 @@ var BottomSheetEngine = class {
2932
2975
  if (typeof ResizeObserver === "undefined") return;
2933
2976
  if (!this.snapPointsRaw.some((p) => p.size === "fit" || p.size === "content"))
2934
2977
  return;
2935
- const targets = [this.handle];
2936
- if (this.scrollContainer && this.scrollContainer !== this.handle) {
2937
- targets.push(this.scrollContainer);
2938
- }
2939
2978
  let raf = 0;
2940
- const ro = new ResizeObserver(() => {
2979
+ const schedule = () => {
2941
2980
  if (raf) return;
2942
2981
  raf = requestAnimationFrame(() => {
2943
2982
  raf = 0;
2944
2983
  if (this.destroyed || this.gesture?.isDragging) return;
2945
2984
  this.recompute();
2946
2985
  });
2947
- });
2948
- for (const t of targets) ro.observe(t);
2986
+ };
2987
+ const ro = new ResizeObserver(schedule);
2988
+ ro.observe(this.handle);
2989
+ const scroller = this.scrollContainer;
2990
+ const observed = /* @__PURE__ */ new Set();
2991
+ const slots = /* @__PURE__ */ new Set();
2992
+ const hasSlot = typeof HTMLSlotElement !== "undefined";
2993
+ const onSlotChange = () => resync();
2994
+ const trackSlots = () => {
2995
+ if (!scroller || !hasSlot) return;
2996
+ for (const child2 of Array.from(scroller.children)) {
2997
+ if (child2 instanceof HTMLSlotElement && !slots.has(child2)) {
2998
+ child2.addEventListener("slotchange", onSlotChange);
2999
+ slots.add(child2);
3000
+ }
3001
+ }
3002
+ };
3003
+ const resync = () => {
3004
+ trackSlots();
3005
+ const targets = this.contentTargets();
3006
+ for (const el of observed) {
3007
+ if (!targets.includes(el)) {
3008
+ ro.unobserve(el);
3009
+ observed.delete(el);
3010
+ }
3011
+ }
3012
+ for (const el of targets) {
3013
+ if (!observed.has(el)) {
3014
+ ro.observe(el);
3015
+ observed.add(el);
3016
+ }
3017
+ }
3018
+ schedule();
3019
+ };
3020
+ let mo;
3021
+ if (scroller) {
3022
+ resync();
3023
+ if (typeof MutationObserver !== "undefined") {
3024
+ mo = new MutationObserver(resync);
3025
+ mo.observe(scroller, { childList: true });
3026
+ }
3027
+ }
2949
3028
  this.teardowns.add(() => {
2950
3029
  ro.disconnect();
3030
+ mo?.disconnect();
3031
+ for (const slot of slots) {
3032
+ slot.removeEventListener("slotchange", onSlotChange);
3033
+ }
2951
3034
  if (raf) cancelAnimationFrame(raf);
2952
3035
  });
2953
3036
  }
@@ -3295,6 +3378,9 @@ var BottomSheetEngine = class {
3295
3378
  if (this.anchorHost && this.anchorHost !== this.scrimParent) {
3296
3379
  this.anchorHost.style.setProperty("--bs-size", `${size}px`);
3297
3380
  }
3381
+ if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
3382
+ this.rootEl.style.setProperty("--bs-size", `${size}px`);
3383
+ }
3298
3384
  }
3299
3385
  const progress = this.computeProgress(size);
3300
3386
  const progressChanged = this.progressWriteSentinel.shouldWrite(
@@ -3306,6 +3392,9 @@ var BottomSheetEngine = class {
3306
3392
  if (this.anchorHost) {
3307
3393
  this.anchorHost.style.setProperty("--bs-progress", String(progress));
3308
3394
  }
3395
+ if (this.rootEl && this.rootEl !== this.anchorHost) {
3396
+ this.rootEl.style.setProperty("--bs-progress", String(progress));
3397
+ }
3309
3398
  }
3310
3399
  this.scrim.applyOpacity(progress, progressChanged);
3311
3400
  if (progressChanged && this.bus.listenerCount("progress") > 0) {
@@ -3432,9 +3521,11 @@ function createBottomSheet(opts) {
3432
3521
  };
3433
3522
  }
3434
3523
  var root_1 = $2__namespace.from_html(`<div class="bs-backdrop" aria-hidden="true"></div>`);
3435
- var root_3 = $2__namespace.from_html(`<div class="bs-button-slot" data-side="left"><!></div>`);
3436
- var root_4 = $2__namespace.from_html(`<div class="bs-button-slot" data-side="right"><!></div>`);
3437
- var root = $2__namespace.from_html(`<div class="bs-root"><!> <div class="bs-screen"><!></div> <section class="bs-sheet" role="dialog"><!> <!> <div class="bs-handle" role="slider" tabindex="0" aria-label="Resize sheet"><!></div> <div class="bs-content" tabindex="0" role="region" aria-label="Sheet content"><!></div> <span class="bs-sr-only" role="status" aria-live="polite"> </span></section></div>`);
3524
+ var root_3 = $2__namespace.from_html(`<div class="bs-header"><!></div>`);
3525
+ var root_5 = $2__namespace.from_html(`<div class="bs-footer"><!></div>`);
3526
+ var root_6 = $2__namespace.from_html(`<div class="bs-button-slot" data-side="left"><!></div>`);
3527
+ var root_7 = $2__namespace.from_html(`<div class="bs-button-slot" data-side="right"><!></div>`);
3528
+ var root = $2__namespace.from_html(`<div class="bs-root"><!> <div class="bs-screen"><!></div> <section class="bs-sheet" role="dialog"><div class="bs-handle" role="slider" tabindex="0" aria-label="Resize sheet"></div> <!> <div class="bs-content" tabindex="0" role="region" aria-label="Sheet content"><!></div> <!> <span class="bs-sr-only" role="status" aria-live="polite"> </span></section> <!> <!></div>`);
3438
3529
  function BottomSheet($$anchor, $$props) {
3439
3530
  $2__namespace.push($$props, true);
3440
3531
  let mode = $2__namespace.prop($$props, "mode", 3, "bottom"), animation = $2__namespace.prop($$props, "animation", 3, "spring"), focusTrap = $2__namespace.prop($$props, "focusTrap", 3, false), closeOnEscape = $2__namespace.prop($$props, "closeOnEscape", 3, true), closeOnBack = $2__namespace.prop($$props, "closeOnBack", 3, false), lockBodyScroll2 = $2__namespace.prop($$props, "lockBodyScroll", 3, true), rubberBand2 = $2__namespace.prop($$props, "rubberBand", 3, true), backdrop = $2__namespace.prop($$props, "backdrop", 3, true), closeOnBackdrop = $2__namespace.prop($$props, "closeOnBackdrop", 3, true), persistent = $2__namespace.prop($$props, "persistent", 3, false), disableClose = $2__namespace.prop($$props, "disableClose", 3, false), disableDrag = $2__namespace.prop($$props, "disableDrag", 3, false), closeOnRouteChange = $2__namespace.prop($$props, "closeOnRouteChange", 3, false), openProp = $2__namespace.prop($$props, "open", 15), snap = $2__namespace.prop($$props, "snap", 15), ariaLabel = $2__namespace.prop($$props, "ariaLabel", 3, "Bottom sheet");
@@ -3613,68 +3704,83 @@ function BottomSheet($$anchor, $$props) {
3613
3704
  $2__namespace.reset(div_2);
3614
3705
  $2__namespace.bind_this(div_2, ($$value) => $2__namespace.set(screenEl, $$value), () => $2__namespace.get(screenEl));
3615
3706
  var section = $2__namespace.sibling(div_2, 2);
3616
- var node_3 = $2__namespace.child(section);
3707
+ var div_3 = $2__namespace.child(section);
3708
+ $2__namespace.set_attribute(div_3, "aria-valuemin", 0);
3709
+ $2__namespace.bind_this(div_3, ($$value) => $2__namespace.set(handleEl, $$value), () => $2__namespace.get(handleEl));
3710
+ var node_3 = $2__namespace.sibling(div_3, 2);
3617
3711
  {
3618
3712
  var consequent_2 = ($$anchor2) => {
3619
- var div_3 = root_3();
3620
- var node_4 = $2__namespace.child(div_3);
3621
- $2__namespace.snippet(node_4, () => $$props.leftButton);
3622
- $2__namespace.reset(div_3);
3623
- $2__namespace.append($$anchor2, div_3);
3713
+ var div_4 = root_3();
3714
+ var node_4 = $2__namespace.child(div_4);
3715
+ $2__namespace.snippet(node_4, () => $$props.header, () => $2__namespace.get(viewState));
3716
+ $2__namespace.reset(div_4);
3717
+ $2__namespace.append($$anchor2, div_4);
3624
3718
  };
3625
3719
  $2__namespace.if(node_3, ($$render) => {
3626
- if ($$props.leftButton) $$render(consequent_2);
3720
+ if ($$props.header) $$render(consequent_2);
3627
3721
  });
3628
3722
  }
3629
- var node_5 = $2__namespace.sibling(node_3, 2);
3723
+ var div_5 = $2__namespace.sibling(node_3, 2);
3724
+ var node_5 = $2__namespace.child(div_5);
3630
3725
  {
3631
3726
  var consequent_3 = ($$anchor2) => {
3632
- var div_4 = root_4();
3633
- var node_6 = $2__namespace.child(div_4);
3634
- $2__namespace.snippet(node_6, () => $$props.rightButton);
3635
- $2__namespace.reset(div_4);
3636
- $2__namespace.append($$anchor2, div_4);
3727
+ var fragment_1 = $2__namespace.comment();
3728
+ var node_6 = $2__namespace.first_child(fragment_1);
3729
+ $2__namespace.snippet(node_6, () => $$props.children);
3730
+ $2__namespace.append($$anchor2, fragment_1);
3637
3731
  };
3638
3732
  $2__namespace.if(node_5, ($$render) => {
3639
- if ($$props.rightButton) $$render(consequent_3);
3733
+ if ($$props.children) $$render(consequent_3);
3640
3734
  });
3641
3735
  }
3642
- var div_5 = $2__namespace.sibling(node_5, 2);
3643
- $2__namespace.set_attribute(div_5, "aria-valuemin", 0);
3644
- var node_7 = $2__namespace.child(div_5);
3736
+ $2__namespace.reset(div_5);
3737
+ $2__namespace.bind_this(div_5, ($$value) => $2__namespace.set(contentEl, $$value), () => $2__namespace.get(contentEl));
3738
+ var node_7 = $2__namespace.sibling(div_5, 2);
3645
3739
  {
3646
3740
  var consequent_4 = ($$anchor2) => {
3647
- var fragment_1 = $2__namespace.comment();
3648
- var node_8 = $2__namespace.first_child(fragment_1);
3649
- $2__namespace.snippet(node_8, () => $$props.header, () => $2__namespace.get(viewState));
3650
- $2__namespace.append($$anchor2, fragment_1);
3741
+ var div_6 = root_5();
3742
+ var node_8 = $2__namespace.child(div_6);
3743
+ $2__namespace.snippet(node_8, () => $$props.footer, () => $2__namespace.get(viewState));
3744
+ $2__namespace.reset(div_6);
3745
+ $2__namespace.append($$anchor2, div_6);
3651
3746
  };
3652
3747
  $2__namespace.if(node_7, ($$render) => {
3653
- if ($$props.header) $$render(consequent_4);
3748
+ if ($$props.footer) $$render(consequent_4);
3654
3749
  });
3655
3750
  }
3656
- $2__namespace.reset(div_5);
3657
- $2__namespace.bind_this(div_5, ($$value) => $2__namespace.set(handleEl, $$value), () => $2__namespace.get(handleEl));
3658
- var div_6 = $2__namespace.sibling(div_5, 2);
3659
- var node_9 = $2__namespace.child(div_6);
3751
+ var span = $2__namespace.sibling(node_7, 2);
3752
+ var text = $2__namespace.child(span, true);
3753
+ $2__namespace.reset(span);
3754
+ $2__namespace.reset(section);
3755
+ $2__namespace.bind_this(section, ($$value) => $2__namespace.set(sheetEl, $$value), () => $2__namespace.get(sheetEl));
3756
+ var node_9 = $2__namespace.sibling(section, 2);
3660
3757
  {
3661
3758
  var consequent_5 = ($$anchor2) => {
3662
- var fragment_2 = $2__namespace.comment();
3663
- var node_10 = $2__namespace.first_child(fragment_2);
3664
- $2__namespace.snippet(node_10, () => $$props.children);
3665
- $2__namespace.append($$anchor2, fragment_2);
3759
+ var div_7 = root_6();
3760
+ var node_10 = $2__namespace.child(div_7);
3761
+ $2__namespace.snippet(node_10, () => $$props.leftButton);
3762
+ $2__namespace.reset(div_7);
3763
+ $2__namespace.template_effect(() => $2__namespace.set_attribute(div_7, "data-mode", mode()));
3764
+ $2__namespace.append($$anchor2, div_7);
3666
3765
  };
3667
3766
  $2__namespace.if(node_9, ($$render) => {
3668
- if ($$props.children) $$render(consequent_5);
3767
+ if ($$props.leftButton) $$render(consequent_5);
3768
+ });
3769
+ }
3770
+ var node_11 = $2__namespace.sibling(node_9, 2);
3771
+ {
3772
+ var consequent_6 = ($$anchor2) => {
3773
+ var div_8 = root_7();
3774
+ var node_12 = $2__namespace.child(div_8);
3775
+ $2__namespace.snippet(node_12, () => $$props.rightButton);
3776
+ $2__namespace.reset(div_8);
3777
+ $2__namespace.template_effect(() => $2__namespace.set_attribute(div_8, "data-mode", mode()));
3778
+ $2__namespace.append($$anchor2, div_8);
3779
+ };
3780
+ $2__namespace.if(node_11, ($$render) => {
3781
+ if ($$props.rightButton) $$render(consequent_6);
3669
3782
  });
3670
3783
  }
3671
- $2__namespace.reset(div_6);
3672
- $2__namespace.bind_this(div_6, ($$value) => $2__namespace.set(contentEl, $$value), () => $2__namespace.get(contentEl));
3673
- var span = $2__namespace.sibling(div_6, 2);
3674
- var text = $2__namespace.child(span, true);
3675
- $2__namespace.reset(span);
3676
- $2__namespace.reset(section);
3677
- $2__namespace.bind_this(section, ($$value) => $2__namespace.set(sheetEl, $$value), () => $2__namespace.get(sheetEl));
3678
3784
  $2__namespace.reset(div);
3679
3785
  $2__namespace.template_effect(
3680
3786
  ($0, $1) => {
@@ -3682,10 +3788,10 @@ function BottomSheet($$anchor, $$props) {
3682
3788
  $2__namespace.set_attribute(section, "data-active", $2__namespace.get(viewState).activeId);
3683
3789
  $2__namespace.set_attribute(section, "aria-modal", focusTrap() ? "true" : void 0);
3684
3790
  $2__namespace.set_attribute(section, "aria-label", ariaLabel());
3685
- $2__namespace.set_attribute(div_5, "aria-orientation", $2__namespace.get(isVerticalAxis) ? "vertical" : "horizontal");
3686
- $2__namespace.set_attribute(div_5, "aria-valuemax", $0);
3687
- $2__namespace.set_attribute(div_5, "aria-valuenow", $1);
3688
- $2__namespace.set_attribute(div_5, "aria-valuetext", $2__namespace.get(viewState).activeId);
3791
+ $2__namespace.set_attribute(div_3, "aria-orientation", $2__namespace.get(isVerticalAxis) ? "vertical" : "horizontal");
3792
+ $2__namespace.set_attribute(div_3, "aria-valuemax", $0);
3793
+ $2__namespace.set_attribute(div_3, "aria-valuenow", $1);
3794
+ $2__namespace.set_attribute(div_3, "aria-valuetext", $2__namespace.get(viewState).activeId);
3689
3795
  $2__namespace.set_text(text, $2__namespace.get(viewState).activeId);
3690
3796
  },
3691
3797
  [
package/dist/svelte.d.cts CHANGED
@@ -95,6 +95,7 @@ export type BottomSheetProps<TId extends string = string> = {
95
95
  returnFocusTo?: HTMLElement | string | (() => HTMLElement | null);
96
96
  ariaLabel?: string;
97
97
  header?: Snippet<[EngineState & { activeId: TId }]>;
98
+ footer?: Snippet<[EngineState & { activeId: TId }]>;
98
99
  leftButton?: Snippet;
99
100
  rightButton?: Snippet;
100
101
  screen?: Snippet;
package/dist/svelte.d.ts CHANGED
@@ -95,6 +95,7 @@ export type BottomSheetProps<TId extends string = string> = {
95
95
  returnFocusTo?: HTMLElement | string | (() => HTMLElement | null);
96
96
  ariaLabel?: string;
97
97
  header?: Snippet<[EngineState & { activeId: TId }]>;
98
+ footer?: Snippet<[EngineState & { activeId: TId }]>;
98
99
  leftButton?: Snippet;
99
100
  rightButton?: Snippet;
100
101
  screen?: Snippet;
package/dist/svelte.js CHANGED
@@ -2897,11 +2897,54 @@ var BottomSheetEngine = class {
2897
2897
  this.updateAriaSlider();
2898
2898
  }
2899
2899
  }
2900
+ contentTargets() {
2901
+ const scroller = this.scrollContainer;
2902
+ if (!scroller) return [];
2903
+ const hasSlot = typeof HTMLSlotElement !== "undefined";
2904
+ const out = [];
2905
+ for (const child2 of Array.from(scroller.children)) {
2906
+ if (hasSlot && child2 instanceof HTMLSlotElement) {
2907
+ for (const el of child2.assignedElements()) out.push(el);
2908
+ } else {
2909
+ out.push(child2);
2910
+ }
2911
+ }
2912
+ return out;
2913
+ }
2914
+ measureContentExtent(vertical) {
2915
+ 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;
2942
+ }
2900
2943
  measureFitSize() {
2901
2944
  const vertical = layoutAxis(this.mode) === "height";
2902
2945
  const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2903
2946
  const content = this.scrollContainer;
2904
- const natural = content ? handleSize + (vertical ? content.scrollHeight : content.scrollWidth) : handleSize;
2947
+ const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2905
2948
  if (typeof window === "undefined") return natural;
2906
2949
  const viewport = vertical ? window.innerHeight : window.innerWidth;
2907
2950
  return viewport > 0 ? Math.min(natural, viewport) : natural;
@@ -2910,22 +2953,62 @@ var BottomSheetEngine = class {
2910
2953
  if (typeof ResizeObserver === "undefined") return;
2911
2954
  if (!this.snapPointsRaw.some((p) => p.size === "fit" || p.size === "content"))
2912
2955
  return;
2913
- const targets = [this.handle];
2914
- if (this.scrollContainer && this.scrollContainer !== this.handle) {
2915
- targets.push(this.scrollContainer);
2916
- }
2917
2956
  let raf = 0;
2918
- const ro = new ResizeObserver(() => {
2957
+ const schedule = () => {
2919
2958
  if (raf) return;
2920
2959
  raf = requestAnimationFrame(() => {
2921
2960
  raf = 0;
2922
2961
  if (this.destroyed || this.gesture?.isDragging) return;
2923
2962
  this.recompute();
2924
2963
  });
2925
- });
2926
- for (const t of targets) ro.observe(t);
2964
+ };
2965
+ const ro = new ResizeObserver(schedule);
2966
+ ro.observe(this.handle);
2967
+ const scroller = this.scrollContainer;
2968
+ const observed = /* @__PURE__ */ new Set();
2969
+ const slots = /* @__PURE__ */ new Set();
2970
+ const hasSlot = typeof HTMLSlotElement !== "undefined";
2971
+ const onSlotChange = () => resync();
2972
+ const trackSlots = () => {
2973
+ if (!scroller || !hasSlot) return;
2974
+ for (const child2 of Array.from(scroller.children)) {
2975
+ if (child2 instanceof HTMLSlotElement && !slots.has(child2)) {
2976
+ child2.addEventListener("slotchange", onSlotChange);
2977
+ slots.add(child2);
2978
+ }
2979
+ }
2980
+ };
2981
+ const resync = () => {
2982
+ trackSlots();
2983
+ const targets = this.contentTargets();
2984
+ for (const el of observed) {
2985
+ if (!targets.includes(el)) {
2986
+ ro.unobserve(el);
2987
+ observed.delete(el);
2988
+ }
2989
+ }
2990
+ for (const el of targets) {
2991
+ if (!observed.has(el)) {
2992
+ ro.observe(el);
2993
+ observed.add(el);
2994
+ }
2995
+ }
2996
+ schedule();
2997
+ };
2998
+ let mo;
2999
+ if (scroller) {
3000
+ resync();
3001
+ if (typeof MutationObserver !== "undefined") {
3002
+ mo = new MutationObserver(resync);
3003
+ mo.observe(scroller, { childList: true });
3004
+ }
3005
+ }
2927
3006
  this.teardowns.add(() => {
2928
3007
  ro.disconnect();
3008
+ mo?.disconnect();
3009
+ for (const slot of slots) {
3010
+ slot.removeEventListener("slotchange", onSlotChange);
3011
+ }
2929
3012
  if (raf) cancelAnimationFrame(raf);
2930
3013
  });
2931
3014
  }
@@ -3273,6 +3356,9 @@ var BottomSheetEngine = class {
3273
3356
  if (this.anchorHost && this.anchorHost !== this.scrimParent) {
3274
3357
  this.anchorHost.style.setProperty("--bs-size", `${size}px`);
3275
3358
  }
3359
+ if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
3360
+ this.rootEl.style.setProperty("--bs-size", `${size}px`);
3361
+ }
3276
3362
  }
3277
3363
  const progress = this.computeProgress(size);
3278
3364
  const progressChanged = this.progressWriteSentinel.shouldWrite(
@@ -3284,6 +3370,9 @@ var BottomSheetEngine = class {
3284
3370
  if (this.anchorHost) {
3285
3371
  this.anchorHost.style.setProperty("--bs-progress", String(progress));
3286
3372
  }
3373
+ if (this.rootEl && this.rootEl !== this.anchorHost) {
3374
+ this.rootEl.style.setProperty("--bs-progress", String(progress));
3375
+ }
3287
3376
  }
3288
3377
  this.scrim.applyOpacity(progress, progressChanged);
3289
3378
  if (progressChanged && this.bus.listenerCount("progress") > 0) {
@@ -3410,9 +3499,11 @@ function createBottomSheet(opts) {
3410
3499
  };
3411
3500
  }
3412
3501
  var root_1 = $2.from_html(`<div class="bs-backdrop" aria-hidden="true"></div>`);
3413
- var root_3 = $2.from_html(`<div class="bs-button-slot" data-side="left"><!></div>`);
3414
- var root_4 = $2.from_html(`<div class="bs-button-slot" data-side="right"><!></div>`);
3415
- var root = $2.from_html(`<div class="bs-root"><!> <div class="bs-screen"><!></div> <section class="bs-sheet" role="dialog"><!> <!> <div class="bs-handle" role="slider" tabindex="0" aria-label="Resize sheet"><!></div> <div class="bs-content" tabindex="0" role="region" aria-label="Sheet content"><!></div> <span class="bs-sr-only" role="status" aria-live="polite"> </span></section></div>`);
3502
+ var root_3 = $2.from_html(`<div class="bs-header"><!></div>`);
3503
+ var root_5 = $2.from_html(`<div class="bs-footer"><!></div>`);
3504
+ var root_6 = $2.from_html(`<div class="bs-button-slot" data-side="left"><!></div>`);
3505
+ var root_7 = $2.from_html(`<div class="bs-button-slot" data-side="right"><!></div>`);
3506
+ var root = $2.from_html(`<div class="bs-root"><!> <div class="bs-screen"><!></div> <section class="bs-sheet" role="dialog"><div class="bs-handle" role="slider" tabindex="0" aria-label="Resize sheet"></div> <!> <div class="bs-content" tabindex="0" role="region" aria-label="Sheet content"><!></div> <!> <span class="bs-sr-only" role="status" aria-live="polite"> </span></section> <!> <!></div>`);
3416
3507
  function BottomSheet($$anchor, $$props) {
3417
3508
  $2.push($$props, true);
3418
3509
  let mode = $2.prop($$props, "mode", 3, "bottom"), animation = $2.prop($$props, "animation", 3, "spring"), focusTrap = $2.prop($$props, "focusTrap", 3, false), closeOnEscape = $2.prop($$props, "closeOnEscape", 3, true), closeOnBack = $2.prop($$props, "closeOnBack", 3, false), lockBodyScroll2 = $2.prop($$props, "lockBodyScroll", 3, true), rubberBand2 = $2.prop($$props, "rubberBand", 3, true), backdrop = $2.prop($$props, "backdrop", 3, true), closeOnBackdrop = $2.prop($$props, "closeOnBackdrop", 3, true), persistent = $2.prop($$props, "persistent", 3, false), disableClose = $2.prop($$props, "disableClose", 3, false), disableDrag = $2.prop($$props, "disableDrag", 3, false), closeOnRouteChange = $2.prop($$props, "closeOnRouteChange", 3, false), openProp = $2.prop($$props, "open", 15), snap = $2.prop($$props, "snap", 15), ariaLabel = $2.prop($$props, "ariaLabel", 3, "Bottom sheet");
@@ -3591,68 +3682,83 @@ function BottomSheet($$anchor, $$props) {
3591
3682
  $2.reset(div_2);
3592
3683
  $2.bind_this(div_2, ($$value) => $2.set(screenEl, $$value), () => $2.get(screenEl));
3593
3684
  var section = $2.sibling(div_2, 2);
3594
- var node_3 = $2.child(section);
3685
+ var div_3 = $2.child(section);
3686
+ $2.set_attribute(div_3, "aria-valuemin", 0);
3687
+ $2.bind_this(div_3, ($$value) => $2.set(handleEl, $$value), () => $2.get(handleEl));
3688
+ var node_3 = $2.sibling(div_3, 2);
3595
3689
  {
3596
3690
  var consequent_2 = ($$anchor2) => {
3597
- var div_3 = root_3();
3598
- var node_4 = $2.child(div_3);
3599
- $2.snippet(node_4, () => $$props.leftButton);
3600
- $2.reset(div_3);
3601
- $2.append($$anchor2, div_3);
3691
+ var div_4 = root_3();
3692
+ var node_4 = $2.child(div_4);
3693
+ $2.snippet(node_4, () => $$props.header, () => $2.get(viewState));
3694
+ $2.reset(div_4);
3695
+ $2.append($$anchor2, div_4);
3602
3696
  };
3603
3697
  $2.if(node_3, ($$render) => {
3604
- if ($$props.leftButton) $$render(consequent_2);
3698
+ if ($$props.header) $$render(consequent_2);
3605
3699
  });
3606
3700
  }
3607
- var node_5 = $2.sibling(node_3, 2);
3701
+ var div_5 = $2.sibling(node_3, 2);
3702
+ var node_5 = $2.child(div_5);
3608
3703
  {
3609
3704
  var consequent_3 = ($$anchor2) => {
3610
- var div_4 = root_4();
3611
- var node_6 = $2.child(div_4);
3612
- $2.snippet(node_6, () => $$props.rightButton);
3613
- $2.reset(div_4);
3614
- $2.append($$anchor2, div_4);
3705
+ var fragment_1 = $2.comment();
3706
+ var node_6 = $2.first_child(fragment_1);
3707
+ $2.snippet(node_6, () => $$props.children);
3708
+ $2.append($$anchor2, fragment_1);
3615
3709
  };
3616
3710
  $2.if(node_5, ($$render) => {
3617
- if ($$props.rightButton) $$render(consequent_3);
3711
+ if ($$props.children) $$render(consequent_3);
3618
3712
  });
3619
3713
  }
3620
- var div_5 = $2.sibling(node_5, 2);
3621
- $2.set_attribute(div_5, "aria-valuemin", 0);
3622
- var node_7 = $2.child(div_5);
3714
+ $2.reset(div_5);
3715
+ $2.bind_this(div_5, ($$value) => $2.set(contentEl, $$value), () => $2.get(contentEl));
3716
+ var node_7 = $2.sibling(div_5, 2);
3623
3717
  {
3624
3718
  var consequent_4 = ($$anchor2) => {
3625
- var fragment_1 = $2.comment();
3626
- var node_8 = $2.first_child(fragment_1);
3627
- $2.snippet(node_8, () => $$props.header, () => $2.get(viewState));
3628
- $2.append($$anchor2, fragment_1);
3719
+ var div_6 = root_5();
3720
+ var node_8 = $2.child(div_6);
3721
+ $2.snippet(node_8, () => $$props.footer, () => $2.get(viewState));
3722
+ $2.reset(div_6);
3723
+ $2.append($$anchor2, div_6);
3629
3724
  };
3630
3725
  $2.if(node_7, ($$render) => {
3631
- if ($$props.header) $$render(consequent_4);
3726
+ if ($$props.footer) $$render(consequent_4);
3632
3727
  });
3633
3728
  }
3634
- $2.reset(div_5);
3635
- $2.bind_this(div_5, ($$value) => $2.set(handleEl, $$value), () => $2.get(handleEl));
3636
- var div_6 = $2.sibling(div_5, 2);
3637
- var node_9 = $2.child(div_6);
3729
+ var span = $2.sibling(node_7, 2);
3730
+ var text = $2.child(span, true);
3731
+ $2.reset(span);
3732
+ $2.reset(section);
3733
+ $2.bind_this(section, ($$value) => $2.set(sheetEl, $$value), () => $2.get(sheetEl));
3734
+ var node_9 = $2.sibling(section, 2);
3638
3735
  {
3639
3736
  var consequent_5 = ($$anchor2) => {
3640
- var fragment_2 = $2.comment();
3641
- var node_10 = $2.first_child(fragment_2);
3642
- $2.snippet(node_10, () => $$props.children);
3643
- $2.append($$anchor2, fragment_2);
3737
+ var div_7 = root_6();
3738
+ var node_10 = $2.child(div_7);
3739
+ $2.snippet(node_10, () => $$props.leftButton);
3740
+ $2.reset(div_7);
3741
+ $2.template_effect(() => $2.set_attribute(div_7, "data-mode", mode()));
3742
+ $2.append($$anchor2, div_7);
3644
3743
  };
3645
3744
  $2.if(node_9, ($$render) => {
3646
- if ($$props.children) $$render(consequent_5);
3745
+ if ($$props.leftButton) $$render(consequent_5);
3746
+ });
3747
+ }
3748
+ var node_11 = $2.sibling(node_9, 2);
3749
+ {
3750
+ var consequent_6 = ($$anchor2) => {
3751
+ var div_8 = root_7();
3752
+ var node_12 = $2.child(div_8);
3753
+ $2.snippet(node_12, () => $$props.rightButton);
3754
+ $2.reset(div_8);
3755
+ $2.template_effect(() => $2.set_attribute(div_8, "data-mode", mode()));
3756
+ $2.append($$anchor2, div_8);
3757
+ };
3758
+ $2.if(node_11, ($$render) => {
3759
+ if ($$props.rightButton) $$render(consequent_6);
3647
3760
  });
3648
3761
  }
3649
- $2.reset(div_6);
3650
- $2.bind_this(div_6, ($$value) => $2.set(contentEl, $$value), () => $2.get(contentEl));
3651
- var span = $2.sibling(div_6, 2);
3652
- var text = $2.child(span, true);
3653
- $2.reset(span);
3654
- $2.reset(section);
3655
- $2.bind_this(section, ($$value) => $2.set(sheetEl, $$value), () => $2.get(sheetEl));
3656
3762
  $2.reset(div);
3657
3763
  $2.template_effect(
3658
3764
  ($0, $1) => {
@@ -3660,10 +3766,10 @@ function BottomSheet($$anchor, $$props) {
3660
3766
  $2.set_attribute(section, "data-active", $2.get(viewState).activeId);
3661
3767
  $2.set_attribute(section, "aria-modal", focusTrap() ? "true" : void 0);
3662
3768
  $2.set_attribute(section, "aria-label", ariaLabel());
3663
- $2.set_attribute(div_5, "aria-orientation", $2.get(isVerticalAxis) ? "vertical" : "horizontal");
3664
- $2.set_attribute(div_5, "aria-valuemax", $0);
3665
- $2.set_attribute(div_5, "aria-valuenow", $1);
3666
- $2.set_attribute(div_5, "aria-valuetext", $2.get(viewState).activeId);
3769
+ $2.set_attribute(div_3, "aria-orientation", $2.get(isVerticalAxis) ? "vertical" : "horizontal");
3770
+ $2.set_attribute(div_3, "aria-valuemax", $0);
3771
+ $2.set_attribute(div_3, "aria-valuenow", $1);
3772
+ $2.set_attribute(div_3, "aria-valuetext", $2.get(viewState).activeId);
3667
3773
  $2.set_text(text, $2.get(viewState).activeId);
3668
3774
  },
3669
3775
  [