@surdeddd/bottom-sheet 0.14.0 → 0.20.1

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 (56) hide show
  1. package/README.md +13 -0
  2. package/dist/{BottomSheetCore-DJYwWOqt.d.ts → BottomSheetCore-Cgn8b_6A.d.ts} +11 -2
  3. package/dist/{BottomSheetCore-Cp7dWy91.d.cts → BottomSheetCore-VPJZcKcg.d.cts} +11 -2
  4. package/dist/{BottomSheetEngine-Lm7HIVHv.d.cts → BottomSheetEngine-B8C2CwF9.d.cts} +1 -1
  5. package/dist/{BottomSheetEngine-O5PbeKfe.d.ts → BottomSheetEngine-DwYR_ygJ.d.ts} +1 -1
  6. package/dist/core.cjs +100 -9
  7. package/dist/core.d.cts +2 -2
  8. package/dist/core.d.ts +2 -2
  9. package/dist/core.js +100 -9
  10. package/dist/debug.d.cts +1 -1
  11. package/dist/debug.d.ts +1 -1
  12. package/dist/element.cjs +107 -9
  13. package/dist/element.d.cts +2 -2
  14. package/dist/element.d.ts +2 -2
  15. package/dist/element.iife.global.js +2 -2
  16. package/dist/element.js +107 -9
  17. package/dist/features.d.cts +4 -4
  18. package/dist/features.d.ts +4 -4
  19. package/dist/{index-Bb5TRmyg.d.cts → index-CnfbOKx0.d.cts} +1 -1
  20. package/dist/{index-Cl9ebCP2.d.ts → index-DcMkhXAy.d.ts} +1 -1
  21. package/dist/index.cjs +100 -9
  22. package/dist/index.d.cts +8 -8
  23. package/dist/index.d.ts +8 -8
  24. package/dist/index.js +100 -9
  25. package/dist/integrations/formik.d.cts +1 -1
  26. package/dist/integrations/formik.d.ts +1 -1
  27. package/dist/integrations/react-hook-form.d.cts +1 -1
  28. package/dist/integrations/react-hook-form.d.ts +1 -1
  29. package/dist/preact.d.cts +2 -2
  30. package/dist/preact.d.ts +2 -2
  31. package/dist/qwik-lib/index.qwik.cjs +98 -9
  32. package/dist/qwik-lib/index.qwik.mjs +98 -9
  33. package/dist/qwik.cjs +100 -9
  34. package/dist/qwik.d.cts +2 -2
  35. package/dist/qwik.d.ts +2 -2
  36. package/dist/qwik.js +100 -9
  37. package/dist/react.cjs +100 -9
  38. package/dist/react.d.cts +3 -3
  39. package/dist/react.d.ts +3 -3
  40. package/dist/react.js +100 -9
  41. package/dist/solid.cjs +100 -9
  42. package/dist/solid.d.cts +10 -1
  43. package/dist/solid.d.ts +10 -1
  44. package/dist/solid.js +100 -9
  45. package/dist/solid.source.jsx +100 -9
  46. package/dist/svelte-core.cjs +100 -9
  47. package/dist/svelte-core.js +100 -9
  48. package/dist/svelte.cjs +100 -9
  49. package/dist/svelte.js +100 -9
  50. package/dist/vue.cjs +101 -10
  51. package/dist/vue.js +101 -10
  52. package/dist/webgl.cjs +154 -34
  53. package/dist/webgl.d.cts +1 -1
  54. package/dist/webgl.d.ts +1 -1
  55. package/dist/webgl.js +154 -34
  56. package/package.json +39 -39
package/dist/svelte.cjs CHANGED
@@ -339,6 +339,11 @@ var SnapResolver = class {
339
339
  this.raw = raw;
340
340
  this.recompute();
341
341
  }
342
+ setMode(mode) {
343
+ if (mode === this.mode) return;
344
+ this.mode = mode;
345
+ this.recompute();
346
+ }
342
347
  setAllowedIds(ids) {
343
348
  this.allowedIds = ids;
344
349
  this.rangeCache = null;
@@ -922,6 +927,11 @@ var ScrimController = class {
922
927
  if (this.isDestroyed()) return;
923
928
  this.applyScrimStyles({ interactive });
924
929
  }
930
+ setSheetMode(mode) {
931
+ if (this.isDestroyed() || mode === this.mode) return;
932
+ this.mode = mode;
933
+ this.invalidateOpacityCache();
934
+ }
925
935
  setScrimMode(mode, applySize) {
926
936
  if (this.isDestroyed()) return;
927
937
  if (mode === this.scrimMode) return;
@@ -1844,6 +1854,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1844
1854
  let activePointerId = null;
1845
1855
  let activePointerType = "touch";
1846
1856
  let startCoord = 0;
1857
+ let startCross = 0;
1847
1858
  let lastCoord = 0;
1848
1859
  let pendingStart = false;
1849
1860
  const VELOCITY_WINDOW_MS = (kind) => kind === "mouse" ? 160 : 120;
@@ -1852,6 +1863,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1852
1863
  const axis = isAxisVertical(mode) ? "Y" : "X";
1853
1864
  const sign = mode === "bottom" || mode === "right" ? -1 : 1;
1854
1865
  const coordOf = (e) => axis === "Y" ? e.clientY : e.clientX;
1866
+ const crossOf = (e) => axis === "Y" ? e.clientX : e.clientY;
1855
1867
  const capture = (pointerId) => {
1856
1868
  try {
1857
1869
  handle.setPointerCapture(pointerId);
@@ -1870,6 +1882,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1870
1882
  activePointerId = e.pointerId;
1871
1883
  activePointerType = e.pointerType || "touch";
1872
1884
  startCoord = coordOf(e);
1885
+ startCross = crossOf(e);
1873
1886
  lastCoord = startCoord;
1874
1887
  samples.reset();
1875
1888
  samples.push(e.timeStamp, startCoord);
@@ -1886,7 +1899,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1886
1899
  const rawDelta = coord - startCoord;
1887
1900
  const delta = rawDelta * sign;
1888
1901
  if (pendingStart) {
1889
- const verdict = options.deferStart(e, delta);
1902
+ const verdict = options.deferStart(e, delta, crossOf(e) - startCross);
1890
1903
  if (verdict === false) {
1891
1904
  releaseTracking();
1892
1905
  return;
@@ -2104,12 +2117,45 @@ function isDragAllowedFrom(target, mode) {
2104
2117
  var CONTENT_DRAG_SLOP = 6;
2105
2118
  function decideContentGesture(input) {
2106
2119
  const slop = input.slop ?? CONTENT_DRAG_SLOP;
2120
+ const cross = input.crossDelta ?? 0;
2121
+ const sharesScrollAxis = input.sharesScrollAxis ?? true;
2122
+ if (!sharesScrollAxis) {
2123
+ if (Math.abs(input.delta) < slop && Math.abs(cross) < slop) return "pending";
2124
+ if (Math.abs(input.delta) <= Math.abs(cross)) return "scroll";
2125
+ return "drag";
2126
+ }
2107
2127
  if (Math.abs(input.delta) < slop) return "pending";
2108
2128
  if (input.scrollTop > 0) return "scroll";
2109
2129
  if (input.delta > 0 && input.atMaxSnap) return "scroll";
2110
2130
  return "drag";
2111
2131
  }
2112
2132
 
2133
+ // src/core/primitives/logical-mode.ts
2134
+ var isLogicalMode = (mode) => mode === "start" || mode === "end";
2135
+ var readDirection = (el) => {
2136
+ if (!el) return "ltr";
2137
+ if (typeof getComputedStyle === "function") {
2138
+ try {
2139
+ if (getComputedStyle(el).direction === "rtl") return "rtl";
2140
+ } catch {
2141
+ }
2142
+ }
2143
+ try {
2144
+ const marked = el.closest?.("[dir]");
2145
+ if (marked) {
2146
+ return marked.getAttribute("dir")?.toLowerCase() === "rtl" ? "rtl" : "ltr";
2147
+ }
2148
+ } catch {
2149
+ }
2150
+ return "ltr";
2151
+ };
2152
+ var resolveMode = (mode, el) => {
2153
+ if (!isLogicalMode(mode)) return mode;
2154
+ const rtl = readDirection(el) === "rtl";
2155
+ if (mode === "start") return rtl ? "right" : "left";
2156
+ return rtl ? "left" : "right";
2157
+ };
2158
+
2113
2159
  // src/core/primitives/touch-scroll-guard.ts
2114
2160
  function installTouchScrollGuard(surface, isDragging) {
2115
2161
  const onTouchMove = (e) => {
@@ -2472,7 +2518,7 @@ function resolveEngineOptions(opts, extras) {
2472
2518
  }
2473
2519
  }
2474
2520
  return {
2475
- mode: opts.mode ?? "bottom",
2521
+ mode: resolveMode(opts.mode ?? "bottom", opts.element),
2476
2522
  flickVelocity: opts.flickVelocity ?? DEFAULT_FLICK_VELOCITY,
2477
2523
  dragThreshold: opts.dragThreshold ?? DEFAULT_DRAG_THRESHOLD,
2478
2524
  dragFrom: opts.dragFrom ?? (opts.handle ? "handle" : "sheet"),
@@ -2576,6 +2622,7 @@ var BottomSheetCore = class {
2576
2622
  __publicField(this, "disableDragFlag");
2577
2623
  __publicField(this, "closeOnRouteChange");
2578
2624
  __publicField(this, "maxHeight");
2625
+ __publicField(this, "maxHeightDeps");
2579
2626
  __publicField(this, "snapPointsRaw");
2580
2627
  __publicField(this, "snaps");
2581
2628
  __publicField(this, "activeId");
@@ -2583,6 +2630,7 @@ var BottomSheetCore = class {
2583
2630
  __publicField(this, "gesture");
2584
2631
  __publicField(this, "contentGesture");
2585
2632
  __publicField(this, "detachSheetGesture", null);
2633
+ __publicField(this, "detachSliderKeyboard", null);
2586
2634
  __publicField(this, "rootEl", null);
2587
2635
  __publicField(this, "destroyed", false);
2588
2636
  __publicField(this, "restClosed", false);
@@ -2634,6 +2682,7 @@ var BottomSheetCore = class {
2634
2682
  this.screenComponent = opts.scrim ?? opts.screenComponent;
2635
2683
  this.scrimParent = this.screenComponent?.parentElement ?? null;
2636
2684
  this.mode = resolved.mode;
2685
+ this.element.dataset.mode = this.mode;
2637
2686
  this.transformTemplate = buildTransformTemplate(this.mode);
2638
2687
  this.aria = new AriaSliderWriter(this.handle, this.mode);
2639
2688
  this.flickVelocity = resolved.flickVelocity;
@@ -2700,7 +2749,7 @@ var BottomSheetCore = class {
2700
2749
  auditVhUsage(this.snapPointsRaw);
2701
2750
  this.auditDuplicateSnapIds(this.snapPointsRaw);
2702
2751
  this.rootEl = this.element.closest(".bs-root");
2703
- this.maxHeight = createMaxHeightController({
2752
+ this.maxHeightDeps = {
2704
2753
  element: this.element,
2705
2754
  mode: this.mode,
2706
2755
  getMaxAxisSize: () => this.snaps.getMaxAxisSize(),
@@ -2708,7 +2757,8 @@ var BottomSheetCore = class {
2708
2757
  this.snaps.setMaxAxisSize(size);
2709
2758
  },
2710
2759
  recompute: () => this.recompute()
2711
- });
2760
+ };
2761
+ this.maxHeight = createMaxHeightController(this.maxHeightDeps);
2712
2762
  this.fitDeps = {
2713
2763
  element: this.element,
2714
2764
  scrollContainer: this.scrollContainer,
@@ -3042,6 +3092,37 @@ var BottomSheetCore = class {
3042
3092
  getDragFrom() {
3043
3093
  return this.dragFromMode;
3044
3094
  }
3095
+ setMode(mode) {
3096
+ if (this.destroyed) return;
3097
+ const next = resolveMode(mode, this.element);
3098
+ if (next === this.mode) return;
3099
+ const wasVertical = this.mode === "bottom" || this.mode === "top";
3100
+ const nowVertical = next === "bottom" || next === "top";
3101
+ this.gesture?.forceClearDragState();
3102
+ this.detachSheetGesture?.();
3103
+ this.animation.cancel();
3104
+ this.element.style.removeProperty(layoutAxis(this.mode));
3105
+ this.mode = next;
3106
+ this.element.dataset.mode = next;
3107
+ this.transformTemplate = buildTransformTemplate(next);
3108
+ this.maxHeightDeps.mode = next;
3109
+ this.fitDeps.mode = next;
3110
+ this.snaps.setMode(next);
3111
+ this.scrim.setSheetMode(next);
3112
+ if (wasVertical !== nowVertical) {
3113
+ this.aria = new AriaSliderWriter(this.handle, next);
3114
+ }
3115
+ this.detachSliderKeyboard?.();
3116
+ this.mountSliderKeyboard();
3117
+ this.mountSheetGesture();
3118
+ this.recompute();
3119
+ const active = this.snaps.findById(this.activeId);
3120
+ if (active) this.applySize(active.size);
3121
+ this.updateAriaSlider();
3122
+ }
3123
+ getMode() {
3124
+ return this.mode;
3125
+ }
3045
3126
  isTop() {
3046
3127
  return this.isTopSheet;
3047
3128
  }
@@ -3390,7 +3471,7 @@ var BottomSheetCore = class {
3390
3471
  const point = this.snapPointsRaw.find((p) => p.id === this.activeId);
3391
3472
  return point?.dragFromContent ?? this.dragFromContentDefault;
3392
3473
  }
3393
- decideContentDrag(surface, e, delta) {
3474
+ decideContentDrag(surface, e, delta, crossDelta) {
3394
3475
  if (this.destroyed) return false;
3395
3476
  if (e.pointerType === "mouse") return false;
3396
3477
  if (this.gesture?.isDragging) return false;
@@ -3398,6 +3479,8 @@ var BottomSheetCore = class {
3398
3479
  if (!isDragAllowedFrom(e.target, "sheet")) return false;
3399
3480
  const decision = decideContentGesture({
3400
3481
  delta,
3482
+ crossDelta,
3483
+ sharesScrollAxis: this.mode === "bottom" || this.mode === "top",
3401
3484
  scrollTop: surface.scrollTop,
3402
3485
  atMaxSnap: this.size >= this.getAllowedRange().max - 0.5
3403
3486
  });
@@ -3410,7 +3493,7 @@ var BottomSheetCore = class {
3410
3493
  const controller = new GestureController(
3411
3494
  this.buildGestureDeps(surface, {
3412
3495
  manageTouchAction: false,
3413
- deferStart: (e, delta) => this.decideContentDrag(surface, e, delta)
3496
+ deferStart: (e, delta, crossDelta) => this.decideContentDrag(surface, e, delta, crossDelta)
3414
3497
  })
3415
3498
  );
3416
3499
  this.contentGesture = controller;
@@ -3536,7 +3619,11 @@ var BottomSheetCore = class {
3536
3619
  );
3537
3620
  }
3538
3621
  }
3539
- this.teardowns.add(installSliderKeyboard({
3622
+ this.mountSliderKeyboard();
3623
+ this.scrim.attach();
3624
+ }
3625
+ mountSliderKeyboard() {
3626
+ const detach = installSliderKeyboard({
3540
3627
  handle: this.handle,
3541
3628
  mode: this.mode,
3542
3629
  isDestroyed: () => this.destroyed,
@@ -3545,8 +3632,12 @@ var BottomSheetCore = class {
3545
3632
  snapTo: (id) => {
3546
3633
  void this.snapTo(id);
3547
3634
  }
3548
- }));
3549
- this.scrim.attach();
3635
+ });
3636
+ this.detachSliderKeyboard = detach;
3637
+ this.teardowns.add(() => {
3638
+ this.detachSliderKeyboard?.();
3639
+ this.detachSliderKeyboard = null;
3640
+ });
3550
3641
  }
3551
3642
  settleAfterDrag(delta, velocity, kind = "touch") {
3552
3643
  const signal = this.newCycle();
package/dist/svelte.js CHANGED
@@ -317,6 +317,11 @@ var SnapResolver = class {
317
317
  this.raw = raw;
318
318
  this.recompute();
319
319
  }
320
+ setMode(mode) {
321
+ if (mode === this.mode) return;
322
+ this.mode = mode;
323
+ this.recompute();
324
+ }
320
325
  setAllowedIds(ids) {
321
326
  this.allowedIds = ids;
322
327
  this.rangeCache = null;
@@ -900,6 +905,11 @@ var ScrimController = class {
900
905
  if (this.isDestroyed()) return;
901
906
  this.applyScrimStyles({ interactive });
902
907
  }
908
+ setSheetMode(mode) {
909
+ if (this.isDestroyed() || mode === this.mode) return;
910
+ this.mode = mode;
911
+ this.invalidateOpacityCache();
912
+ }
903
913
  setScrimMode(mode, applySize) {
904
914
  if (this.isDestroyed()) return;
905
915
  if (mode === this.scrimMode) return;
@@ -1822,6 +1832,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1822
1832
  let activePointerId = null;
1823
1833
  let activePointerType = "touch";
1824
1834
  let startCoord = 0;
1835
+ let startCross = 0;
1825
1836
  let lastCoord = 0;
1826
1837
  let pendingStart = false;
1827
1838
  const VELOCITY_WINDOW_MS = (kind) => kind === "mouse" ? 160 : 120;
@@ -1830,6 +1841,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1830
1841
  const axis = isAxisVertical(mode) ? "Y" : "X";
1831
1842
  const sign = mode === "bottom" || mode === "right" ? -1 : 1;
1832
1843
  const coordOf = (e) => axis === "Y" ? e.clientY : e.clientX;
1844
+ const crossOf = (e) => axis === "Y" ? e.clientX : e.clientY;
1833
1845
  const capture = (pointerId) => {
1834
1846
  try {
1835
1847
  handle.setPointerCapture(pointerId);
@@ -1848,6 +1860,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1848
1860
  activePointerId = e.pointerId;
1849
1861
  activePointerType = e.pointerType || "touch";
1850
1862
  startCoord = coordOf(e);
1863
+ startCross = crossOf(e);
1851
1864
  lastCoord = startCoord;
1852
1865
  samples.reset();
1853
1866
  samples.push(e.timeStamp, startCoord);
@@ -1864,7 +1877,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1864
1877
  const rawDelta = coord - startCoord;
1865
1878
  const delta = rawDelta * sign;
1866
1879
  if (pendingStart) {
1867
- const verdict = options.deferStart(e, delta);
1880
+ const verdict = options.deferStart(e, delta, crossOf(e) - startCross);
1868
1881
  if (verdict === false) {
1869
1882
  releaseTracking();
1870
1883
  return;
@@ -2082,12 +2095,45 @@ function isDragAllowedFrom(target, mode) {
2082
2095
  var CONTENT_DRAG_SLOP = 6;
2083
2096
  function decideContentGesture(input) {
2084
2097
  const slop = input.slop ?? CONTENT_DRAG_SLOP;
2098
+ const cross = input.crossDelta ?? 0;
2099
+ const sharesScrollAxis = input.sharesScrollAxis ?? true;
2100
+ if (!sharesScrollAxis) {
2101
+ if (Math.abs(input.delta) < slop && Math.abs(cross) < slop) return "pending";
2102
+ if (Math.abs(input.delta) <= Math.abs(cross)) return "scroll";
2103
+ return "drag";
2104
+ }
2085
2105
  if (Math.abs(input.delta) < slop) return "pending";
2086
2106
  if (input.scrollTop > 0) return "scroll";
2087
2107
  if (input.delta > 0 && input.atMaxSnap) return "scroll";
2088
2108
  return "drag";
2089
2109
  }
2090
2110
 
2111
+ // src/core/primitives/logical-mode.ts
2112
+ var isLogicalMode = (mode) => mode === "start" || mode === "end";
2113
+ var readDirection = (el) => {
2114
+ if (!el) return "ltr";
2115
+ if (typeof getComputedStyle === "function") {
2116
+ try {
2117
+ if (getComputedStyle(el).direction === "rtl") return "rtl";
2118
+ } catch {
2119
+ }
2120
+ }
2121
+ try {
2122
+ const marked = el.closest?.("[dir]");
2123
+ if (marked) {
2124
+ return marked.getAttribute("dir")?.toLowerCase() === "rtl" ? "rtl" : "ltr";
2125
+ }
2126
+ } catch {
2127
+ }
2128
+ return "ltr";
2129
+ };
2130
+ var resolveMode = (mode, el) => {
2131
+ if (!isLogicalMode(mode)) return mode;
2132
+ const rtl = readDirection(el) === "rtl";
2133
+ if (mode === "start") return rtl ? "right" : "left";
2134
+ return rtl ? "left" : "right";
2135
+ };
2136
+
2091
2137
  // src/core/primitives/touch-scroll-guard.ts
2092
2138
  function installTouchScrollGuard(surface, isDragging) {
2093
2139
  const onTouchMove = (e) => {
@@ -2450,7 +2496,7 @@ function resolveEngineOptions(opts, extras) {
2450
2496
  }
2451
2497
  }
2452
2498
  return {
2453
- mode: opts.mode ?? "bottom",
2499
+ mode: resolveMode(opts.mode ?? "bottom", opts.element),
2454
2500
  flickVelocity: opts.flickVelocity ?? DEFAULT_FLICK_VELOCITY,
2455
2501
  dragThreshold: opts.dragThreshold ?? DEFAULT_DRAG_THRESHOLD,
2456
2502
  dragFrom: opts.dragFrom ?? (opts.handle ? "handle" : "sheet"),
@@ -2554,6 +2600,7 @@ var BottomSheetCore = class {
2554
2600
  __publicField(this, "disableDragFlag");
2555
2601
  __publicField(this, "closeOnRouteChange");
2556
2602
  __publicField(this, "maxHeight");
2603
+ __publicField(this, "maxHeightDeps");
2557
2604
  __publicField(this, "snapPointsRaw");
2558
2605
  __publicField(this, "snaps");
2559
2606
  __publicField(this, "activeId");
@@ -2561,6 +2608,7 @@ var BottomSheetCore = class {
2561
2608
  __publicField(this, "gesture");
2562
2609
  __publicField(this, "contentGesture");
2563
2610
  __publicField(this, "detachSheetGesture", null);
2611
+ __publicField(this, "detachSliderKeyboard", null);
2564
2612
  __publicField(this, "rootEl", null);
2565
2613
  __publicField(this, "destroyed", false);
2566
2614
  __publicField(this, "restClosed", false);
@@ -2612,6 +2660,7 @@ var BottomSheetCore = class {
2612
2660
  this.screenComponent = opts.scrim ?? opts.screenComponent;
2613
2661
  this.scrimParent = this.screenComponent?.parentElement ?? null;
2614
2662
  this.mode = resolved.mode;
2663
+ this.element.dataset.mode = this.mode;
2615
2664
  this.transformTemplate = buildTransformTemplate(this.mode);
2616
2665
  this.aria = new AriaSliderWriter(this.handle, this.mode);
2617
2666
  this.flickVelocity = resolved.flickVelocity;
@@ -2678,7 +2727,7 @@ var BottomSheetCore = class {
2678
2727
  auditVhUsage(this.snapPointsRaw);
2679
2728
  this.auditDuplicateSnapIds(this.snapPointsRaw);
2680
2729
  this.rootEl = this.element.closest(".bs-root");
2681
- this.maxHeight = createMaxHeightController({
2730
+ this.maxHeightDeps = {
2682
2731
  element: this.element,
2683
2732
  mode: this.mode,
2684
2733
  getMaxAxisSize: () => this.snaps.getMaxAxisSize(),
@@ -2686,7 +2735,8 @@ var BottomSheetCore = class {
2686
2735
  this.snaps.setMaxAxisSize(size);
2687
2736
  },
2688
2737
  recompute: () => this.recompute()
2689
- });
2738
+ };
2739
+ this.maxHeight = createMaxHeightController(this.maxHeightDeps);
2690
2740
  this.fitDeps = {
2691
2741
  element: this.element,
2692
2742
  scrollContainer: this.scrollContainer,
@@ -3020,6 +3070,37 @@ var BottomSheetCore = class {
3020
3070
  getDragFrom() {
3021
3071
  return this.dragFromMode;
3022
3072
  }
3073
+ setMode(mode) {
3074
+ if (this.destroyed) return;
3075
+ const next = resolveMode(mode, this.element);
3076
+ if (next === this.mode) return;
3077
+ const wasVertical = this.mode === "bottom" || this.mode === "top";
3078
+ const nowVertical = next === "bottom" || next === "top";
3079
+ this.gesture?.forceClearDragState();
3080
+ this.detachSheetGesture?.();
3081
+ this.animation.cancel();
3082
+ this.element.style.removeProperty(layoutAxis(this.mode));
3083
+ this.mode = next;
3084
+ this.element.dataset.mode = next;
3085
+ this.transformTemplate = buildTransformTemplate(next);
3086
+ this.maxHeightDeps.mode = next;
3087
+ this.fitDeps.mode = next;
3088
+ this.snaps.setMode(next);
3089
+ this.scrim.setSheetMode(next);
3090
+ if (wasVertical !== nowVertical) {
3091
+ this.aria = new AriaSliderWriter(this.handle, next);
3092
+ }
3093
+ this.detachSliderKeyboard?.();
3094
+ this.mountSliderKeyboard();
3095
+ this.mountSheetGesture();
3096
+ this.recompute();
3097
+ const active = this.snaps.findById(this.activeId);
3098
+ if (active) this.applySize(active.size);
3099
+ this.updateAriaSlider();
3100
+ }
3101
+ getMode() {
3102
+ return this.mode;
3103
+ }
3023
3104
  isTop() {
3024
3105
  return this.isTopSheet;
3025
3106
  }
@@ -3368,7 +3449,7 @@ var BottomSheetCore = class {
3368
3449
  const point = this.snapPointsRaw.find((p) => p.id === this.activeId);
3369
3450
  return point?.dragFromContent ?? this.dragFromContentDefault;
3370
3451
  }
3371
- decideContentDrag(surface, e, delta) {
3452
+ decideContentDrag(surface, e, delta, crossDelta) {
3372
3453
  if (this.destroyed) return false;
3373
3454
  if (e.pointerType === "mouse") return false;
3374
3455
  if (this.gesture?.isDragging) return false;
@@ -3376,6 +3457,8 @@ var BottomSheetCore = class {
3376
3457
  if (!isDragAllowedFrom(e.target, "sheet")) return false;
3377
3458
  const decision = decideContentGesture({
3378
3459
  delta,
3460
+ crossDelta,
3461
+ sharesScrollAxis: this.mode === "bottom" || this.mode === "top",
3379
3462
  scrollTop: surface.scrollTop,
3380
3463
  atMaxSnap: this.size >= this.getAllowedRange().max - 0.5
3381
3464
  });
@@ -3388,7 +3471,7 @@ var BottomSheetCore = class {
3388
3471
  const controller = new GestureController(
3389
3472
  this.buildGestureDeps(surface, {
3390
3473
  manageTouchAction: false,
3391
- deferStart: (e, delta) => this.decideContentDrag(surface, e, delta)
3474
+ deferStart: (e, delta, crossDelta) => this.decideContentDrag(surface, e, delta, crossDelta)
3392
3475
  })
3393
3476
  );
3394
3477
  this.contentGesture = controller;
@@ -3514,7 +3597,11 @@ var BottomSheetCore = class {
3514
3597
  );
3515
3598
  }
3516
3599
  }
3517
- this.teardowns.add(installSliderKeyboard({
3600
+ this.mountSliderKeyboard();
3601
+ this.scrim.attach();
3602
+ }
3603
+ mountSliderKeyboard() {
3604
+ const detach = installSliderKeyboard({
3518
3605
  handle: this.handle,
3519
3606
  mode: this.mode,
3520
3607
  isDestroyed: () => this.destroyed,
@@ -3523,8 +3610,12 @@ var BottomSheetCore = class {
3523
3610
  snapTo: (id) => {
3524
3611
  void this.snapTo(id);
3525
3612
  }
3526
- }));
3527
- this.scrim.attach();
3613
+ });
3614
+ this.detachSliderKeyboard = detach;
3615
+ this.teardowns.add(() => {
3616
+ this.detachSliderKeyboard?.();
3617
+ this.detachSliderKeyboard = null;
3618
+ });
3528
3619
  }
3529
3620
  settleAfterDrag(delta, velocity, kind = "touch") {
3530
3621
  const signal = this.newCycle();