@surdeddd/bottom-sheet 0.14.0 → 0.20.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 (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 +100 -9
  51. package/dist/vue.js +100 -9
  52. package/dist/webgl.cjs +104 -14
  53. package/dist/webgl.d.cts +1 -1
  54. package/dist/webgl.d.ts +1 -1
  55. package/dist/webgl.js +104 -14
  56. package/package.json +39 -39
package/dist/solid.js CHANGED
@@ -316,6 +316,11 @@ var SnapResolver = class {
316
316
  this.raw = raw;
317
317
  this.recompute();
318
318
  }
319
+ setMode(mode) {
320
+ if (mode === this.mode) return;
321
+ this.mode = mode;
322
+ this.recompute();
323
+ }
319
324
  setAllowedIds(ids) {
320
325
  this.allowedIds = ids;
321
326
  this.rangeCache = null;
@@ -899,6 +904,11 @@ var ScrimController = class {
899
904
  if (this.isDestroyed()) return;
900
905
  this.applyScrimStyles({ interactive });
901
906
  }
907
+ setSheetMode(mode) {
908
+ if (this.isDestroyed() || mode === this.mode) return;
909
+ this.mode = mode;
910
+ this.invalidateOpacityCache();
911
+ }
902
912
  setScrimMode(mode, applySize) {
903
913
  if (this.isDestroyed()) return;
904
914
  if (mode === this.scrimMode) return;
@@ -1821,6 +1831,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1821
1831
  let activePointerId = null;
1822
1832
  let activePointerType = "touch";
1823
1833
  let startCoord = 0;
1834
+ let startCross = 0;
1824
1835
  let lastCoord = 0;
1825
1836
  let pendingStart = false;
1826
1837
  const VELOCITY_WINDOW_MS = (kind) => kind === "mouse" ? 160 : 120;
@@ -1829,6 +1840,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1829
1840
  const axis = isAxisVertical(mode) ? "Y" : "X";
1830
1841
  const sign = mode === "bottom" || mode === "right" ? -1 : 1;
1831
1842
  const coordOf = (e) => axis === "Y" ? e.clientY : e.clientX;
1843
+ const crossOf = (e) => axis === "Y" ? e.clientX : e.clientY;
1832
1844
  const capture = (pointerId) => {
1833
1845
  try {
1834
1846
  handle.setPointerCapture(pointerId);
@@ -1847,6 +1859,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1847
1859
  activePointerId = e.pointerId;
1848
1860
  activePointerType = e.pointerType || "touch";
1849
1861
  startCoord = coordOf(e);
1862
+ startCross = crossOf(e);
1850
1863
  lastCoord = startCoord;
1851
1864
  samples.reset();
1852
1865
  samples.push(e.timeStamp, startCoord);
@@ -1863,7 +1876,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1863
1876
  const rawDelta = coord - startCoord;
1864
1877
  const delta = rawDelta * sign;
1865
1878
  if (pendingStart) {
1866
- const verdict = options.deferStart(e, delta);
1879
+ const verdict = options.deferStart(e, delta, crossOf(e) - startCross);
1867
1880
  if (verdict === false) {
1868
1881
  releaseTracking();
1869
1882
  return;
@@ -2081,12 +2094,45 @@ function isDragAllowedFrom(target, mode) {
2081
2094
  var CONTENT_DRAG_SLOP = 6;
2082
2095
  function decideContentGesture(input) {
2083
2096
  const slop = input.slop ?? CONTENT_DRAG_SLOP;
2097
+ const cross = input.crossDelta ?? 0;
2098
+ const sharesScrollAxis = input.sharesScrollAxis ?? true;
2099
+ if (!sharesScrollAxis) {
2100
+ if (Math.abs(input.delta) < slop && Math.abs(cross) < slop) return "pending";
2101
+ if (Math.abs(input.delta) <= Math.abs(cross)) return "scroll";
2102
+ return "drag";
2103
+ }
2084
2104
  if (Math.abs(input.delta) < slop) return "pending";
2085
2105
  if (input.scrollTop > 0) return "scroll";
2086
2106
  if (input.delta > 0 && input.atMaxSnap) return "scroll";
2087
2107
  return "drag";
2088
2108
  }
2089
2109
 
2110
+ // src/core/primitives/logical-mode.ts
2111
+ var isLogicalMode = (mode) => mode === "start" || mode === "end";
2112
+ var readDirection = (el) => {
2113
+ if (!el) return "ltr";
2114
+ if (typeof getComputedStyle === "function") {
2115
+ try {
2116
+ if (getComputedStyle(el).direction === "rtl") return "rtl";
2117
+ } catch {
2118
+ }
2119
+ }
2120
+ try {
2121
+ const marked = el.closest?.("[dir]");
2122
+ if (marked) {
2123
+ return marked.getAttribute("dir")?.toLowerCase() === "rtl" ? "rtl" : "ltr";
2124
+ }
2125
+ } catch {
2126
+ }
2127
+ return "ltr";
2128
+ };
2129
+ var resolveMode = (mode, el) => {
2130
+ if (!isLogicalMode(mode)) return mode;
2131
+ const rtl = readDirection(el) === "rtl";
2132
+ if (mode === "start") return rtl ? "right" : "left";
2133
+ return rtl ? "left" : "right";
2134
+ };
2135
+
2090
2136
  // src/core/primitives/touch-scroll-guard.ts
2091
2137
  function installTouchScrollGuard(surface, isDragging) {
2092
2138
  const onTouchMove = (e) => {
@@ -2449,7 +2495,7 @@ function resolveEngineOptions(opts, extras) {
2449
2495
  }
2450
2496
  }
2451
2497
  return {
2452
- mode: opts.mode ?? "bottom",
2498
+ mode: resolveMode(opts.mode ?? "bottom", opts.element),
2453
2499
  flickVelocity: opts.flickVelocity ?? DEFAULT_FLICK_VELOCITY,
2454
2500
  dragThreshold: opts.dragThreshold ?? DEFAULT_DRAG_THRESHOLD,
2455
2501
  dragFrom: opts.dragFrom ?? (opts.handle ? "handle" : "sheet"),
@@ -2553,6 +2599,7 @@ var BottomSheetCore = class {
2553
2599
  __publicField(this, "disableDragFlag");
2554
2600
  __publicField(this, "closeOnRouteChange");
2555
2601
  __publicField(this, "maxHeight");
2602
+ __publicField(this, "maxHeightDeps");
2556
2603
  __publicField(this, "snapPointsRaw");
2557
2604
  __publicField(this, "snaps");
2558
2605
  __publicField(this, "activeId");
@@ -2560,6 +2607,7 @@ var BottomSheetCore = class {
2560
2607
  __publicField(this, "gesture");
2561
2608
  __publicField(this, "contentGesture");
2562
2609
  __publicField(this, "detachSheetGesture", null);
2610
+ __publicField(this, "detachSliderKeyboard", null);
2563
2611
  __publicField(this, "rootEl", null);
2564
2612
  __publicField(this, "destroyed", false);
2565
2613
  __publicField(this, "restClosed", false);
@@ -2611,6 +2659,7 @@ var BottomSheetCore = class {
2611
2659
  this.screenComponent = opts.scrim ?? opts.screenComponent;
2612
2660
  this.scrimParent = this.screenComponent?.parentElement ?? null;
2613
2661
  this.mode = resolved.mode;
2662
+ this.element.dataset.mode = this.mode;
2614
2663
  this.transformTemplate = buildTransformTemplate(this.mode);
2615
2664
  this.aria = new AriaSliderWriter(this.handle, this.mode);
2616
2665
  this.flickVelocity = resolved.flickVelocity;
@@ -2677,7 +2726,7 @@ var BottomSheetCore = class {
2677
2726
  auditVhUsage(this.snapPointsRaw);
2678
2727
  this.auditDuplicateSnapIds(this.snapPointsRaw);
2679
2728
  this.rootEl = this.element.closest(".bs-root");
2680
- this.maxHeight = createMaxHeightController({
2729
+ this.maxHeightDeps = {
2681
2730
  element: this.element,
2682
2731
  mode: this.mode,
2683
2732
  getMaxAxisSize: () => this.snaps.getMaxAxisSize(),
@@ -2685,7 +2734,8 @@ var BottomSheetCore = class {
2685
2734
  this.snaps.setMaxAxisSize(size);
2686
2735
  },
2687
2736
  recompute: () => this.recompute()
2688
- });
2737
+ };
2738
+ this.maxHeight = createMaxHeightController(this.maxHeightDeps);
2689
2739
  this.fitDeps = {
2690
2740
  element: this.element,
2691
2741
  scrollContainer: this.scrollContainer,
@@ -3019,6 +3069,37 @@ var BottomSheetCore = class {
3019
3069
  getDragFrom() {
3020
3070
  return this.dragFromMode;
3021
3071
  }
3072
+ setMode(mode) {
3073
+ if (this.destroyed) return;
3074
+ const next = resolveMode(mode, this.element);
3075
+ if (next === this.mode) return;
3076
+ const wasVertical = this.mode === "bottom" || this.mode === "top";
3077
+ const nowVertical = next === "bottom" || next === "top";
3078
+ this.gesture?.forceClearDragState();
3079
+ this.detachSheetGesture?.();
3080
+ this.animation.cancel();
3081
+ this.element.style.removeProperty(layoutAxis(this.mode));
3082
+ this.mode = next;
3083
+ this.element.dataset.mode = next;
3084
+ this.transformTemplate = buildTransformTemplate(next);
3085
+ this.maxHeightDeps.mode = next;
3086
+ this.fitDeps.mode = next;
3087
+ this.snaps.setMode(next);
3088
+ this.scrim.setSheetMode(next);
3089
+ if (wasVertical !== nowVertical) {
3090
+ this.aria = new AriaSliderWriter(this.handle, next);
3091
+ }
3092
+ this.detachSliderKeyboard?.();
3093
+ this.mountSliderKeyboard();
3094
+ this.mountSheetGesture();
3095
+ this.recompute();
3096
+ const active = this.snaps.findById(this.activeId);
3097
+ if (active) this.applySize(active.size);
3098
+ this.updateAriaSlider();
3099
+ }
3100
+ getMode() {
3101
+ return this.mode;
3102
+ }
3022
3103
  isTop() {
3023
3104
  return this.isTopSheet;
3024
3105
  }
@@ -3367,7 +3448,7 @@ var BottomSheetCore = class {
3367
3448
  const point = this.snapPointsRaw.find((p) => p.id === this.activeId);
3368
3449
  return point?.dragFromContent ?? this.dragFromContentDefault;
3369
3450
  }
3370
- decideContentDrag(surface, e, delta) {
3451
+ decideContentDrag(surface, e, delta, crossDelta) {
3371
3452
  if (this.destroyed) return false;
3372
3453
  if (e.pointerType === "mouse") return false;
3373
3454
  if (this.gesture?.isDragging) return false;
@@ -3375,6 +3456,8 @@ var BottomSheetCore = class {
3375
3456
  if (!isDragAllowedFrom(e.target, "sheet")) return false;
3376
3457
  const decision = decideContentGesture({
3377
3458
  delta,
3459
+ crossDelta,
3460
+ sharesScrollAxis: this.mode === "bottom" || this.mode === "top",
3378
3461
  scrollTop: surface.scrollTop,
3379
3462
  atMaxSnap: this.size >= this.getAllowedRange().max - 0.5
3380
3463
  });
@@ -3387,7 +3470,7 @@ var BottomSheetCore = class {
3387
3470
  const controller = new GestureController(
3388
3471
  this.buildGestureDeps(surface, {
3389
3472
  manageTouchAction: false,
3390
- deferStart: (e, delta) => this.decideContentDrag(surface, e, delta)
3473
+ deferStart: (e, delta, crossDelta) => this.decideContentDrag(surface, e, delta, crossDelta)
3391
3474
  })
3392
3475
  );
3393
3476
  this.contentGesture = controller;
@@ -3513,7 +3596,11 @@ var BottomSheetCore = class {
3513
3596
  );
3514
3597
  }
3515
3598
  }
3516
- this.teardowns.add(installSliderKeyboard({
3599
+ this.mountSliderKeyboard();
3600
+ this.scrim.attach();
3601
+ }
3602
+ mountSliderKeyboard() {
3603
+ const detach = installSliderKeyboard({
3517
3604
  handle: this.handle,
3518
3605
  mode: this.mode,
3519
3606
  isDestroyed: () => this.destroyed,
@@ -3522,8 +3609,12 @@ var BottomSheetCore = class {
3522
3609
  snapTo: (id) => {
3523
3610
  void this.snapTo(id);
3524
3611
  }
3525
- }));
3526
- this.scrim.attach();
3612
+ });
3613
+ this.detachSliderKeyboard = detach;
3614
+ this.teardowns.add(() => {
3615
+ this.detachSliderKeyboard?.();
3616
+ this.detachSliderKeyboard = null;
3617
+ });
3527
3618
  }
3528
3619
  settleAfterDrag(delta, velocity, kind = "touch") {
3529
3620
  const signal = this.newCycle();
@@ -321,6 +321,11 @@ var SnapResolver = class {
321
321
  this.raw = raw;
322
322
  this.recompute();
323
323
  }
324
+ setMode(mode) {
325
+ if (mode === this.mode) return;
326
+ this.mode = mode;
327
+ this.recompute();
328
+ }
324
329
  setAllowedIds(ids) {
325
330
  this.allowedIds = ids;
326
331
  this.rangeCache = null;
@@ -902,6 +907,11 @@ var ScrimController = class {
902
907
  if (this.isDestroyed()) return;
903
908
  this.applyScrimStyles({ interactive });
904
909
  }
910
+ setSheetMode(mode) {
911
+ if (this.isDestroyed() || mode === this.mode) return;
912
+ this.mode = mode;
913
+ this.invalidateOpacityCache();
914
+ }
905
915
  setScrimMode(mode, applySize) {
906
916
  if (this.isDestroyed()) return;
907
917
  if (mode === this.scrimMode) return;
@@ -1824,6 +1834,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1824
1834
  let activePointerId = null;
1825
1835
  let activePointerType = "touch";
1826
1836
  let startCoord = 0;
1837
+ let startCross = 0;
1827
1838
  let lastCoord = 0;
1828
1839
  let pendingStart = false;
1829
1840
  const VELOCITY_WINDOW_MS = (kind) => kind === "mouse" ? 160 : 120;
@@ -1832,6 +1843,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1832
1843
  const axis = isAxisVertical(mode) ? "Y" : "X";
1833
1844
  const sign = mode === "bottom" || mode === "right" ? -1 : 1;
1834
1845
  const coordOf = (e) => axis === "Y" ? e.clientY : e.clientX;
1846
+ const crossOf = (e) => axis === "Y" ? e.clientX : e.clientY;
1835
1847
  const capture = (pointerId) => {
1836
1848
  try {
1837
1849
  handle.setPointerCapture(pointerId);
@@ -1850,6 +1862,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1850
1862
  activePointerId = e.pointerId;
1851
1863
  activePointerType = e.pointerType || "touch";
1852
1864
  startCoord = coordOf(e);
1865
+ startCross = crossOf(e);
1853
1866
  lastCoord = startCoord;
1854
1867
  samples.reset();
1855
1868
  samples.push(e.timeStamp, startCoord);
@@ -1866,7 +1879,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1866
1879
  const rawDelta = coord - startCoord;
1867
1880
  const delta = rawDelta * sign;
1868
1881
  if (pendingStart) {
1869
- const verdict = options.deferStart(e, delta);
1882
+ const verdict = options.deferStart(e, delta, crossOf(e) - startCross);
1870
1883
  if (verdict === false) {
1871
1884
  releaseTracking();
1872
1885
  return;
@@ -2084,12 +2097,45 @@ function isDragAllowedFrom(target, mode) {
2084
2097
  var CONTENT_DRAG_SLOP = 6;
2085
2098
  function decideContentGesture(input) {
2086
2099
  const slop = input.slop ?? CONTENT_DRAG_SLOP;
2100
+ const cross = input.crossDelta ?? 0;
2101
+ const sharesScrollAxis = input.sharesScrollAxis ?? true;
2102
+ if (!sharesScrollAxis) {
2103
+ if (Math.abs(input.delta) < slop && Math.abs(cross) < slop) return "pending";
2104
+ if (Math.abs(input.delta) <= Math.abs(cross)) return "scroll";
2105
+ return "drag";
2106
+ }
2087
2107
  if (Math.abs(input.delta) < slop) return "pending";
2088
2108
  if (input.scrollTop > 0) return "scroll";
2089
2109
  if (input.delta > 0 && input.atMaxSnap) return "scroll";
2090
2110
  return "drag";
2091
2111
  }
2092
2112
 
2113
+ // src/core/primitives/logical-mode.ts
2114
+ var isLogicalMode = (mode) => mode === "start" || mode === "end";
2115
+ var readDirection = (el) => {
2116
+ if (!el) return "ltr";
2117
+ if (typeof getComputedStyle === "function") {
2118
+ try {
2119
+ if (getComputedStyle(el).direction === "rtl") return "rtl";
2120
+ } catch {
2121
+ }
2122
+ }
2123
+ try {
2124
+ const marked = el.closest?.("[dir]");
2125
+ if (marked) {
2126
+ return marked.getAttribute("dir")?.toLowerCase() === "rtl" ? "rtl" : "ltr";
2127
+ }
2128
+ } catch {
2129
+ }
2130
+ return "ltr";
2131
+ };
2132
+ var resolveMode = (mode, el) => {
2133
+ if (!isLogicalMode(mode)) return mode;
2134
+ const rtl = readDirection(el) === "rtl";
2135
+ if (mode === "start") return rtl ? "right" : "left";
2136
+ return rtl ? "left" : "right";
2137
+ };
2138
+
2093
2139
  // src/core/primitives/touch-scroll-guard.ts
2094
2140
  function installTouchScrollGuard(surface, isDragging) {
2095
2141
  const onTouchMove = (e) => {
@@ -2453,7 +2499,7 @@ function resolveEngineOptions(opts, extras) {
2453
2499
  }
2454
2500
  }
2455
2501
  return {
2456
- mode: opts.mode ?? "bottom",
2502
+ mode: resolveMode(opts.mode ?? "bottom", opts.element),
2457
2503
  flickVelocity: opts.flickVelocity ?? DEFAULT_FLICK_VELOCITY,
2458
2504
  dragThreshold: opts.dragThreshold ?? DEFAULT_DRAG_THRESHOLD,
2459
2505
  dragFrom: opts.dragFrom ?? (opts.handle ? "handle" : "sheet"),
@@ -2554,6 +2600,7 @@ var BottomSheetCore = class {
2554
2600
  disableDragFlag;
2555
2601
  closeOnRouteChange;
2556
2602
  maxHeight;
2603
+ maxHeightDeps;
2557
2604
  snapPointsRaw;
2558
2605
  snaps;
2559
2606
  activeId;
@@ -2561,6 +2608,7 @@ var BottomSheetCore = class {
2561
2608
  gesture;
2562
2609
  contentGesture;
2563
2610
  detachSheetGesture = null;
2611
+ detachSliderKeyboard = null;
2564
2612
  rootEl = null;
2565
2613
  destroyed = false;
2566
2614
  restClosed = false;
@@ -2613,6 +2661,7 @@ var BottomSheetCore = class {
2613
2661
  this.screenComponent = opts.scrim ?? opts.screenComponent;
2614
2662
  this.scrimParent = this.screenComponent?.parentElement ?? null;
2615
2663
  this.mode = resolved.mode;
2664
+ this.element.dataset.mode = this.mode;
2616
2665
  this.transformTemplate = buildTransformTemplate(this.mode);
2617
2666
  this.aria = new AriaSliderWriter(this.handle, this.mode);
2618
2667
  this.flickVelocity = resolved.flickVelocity;
@@ -2679,7 +2728,7 @@ var BottomSheetCore = class {
2679
2728
  auditVhUsage(this.snapPointsRaw);
2680
2729
  this.auditDuplicateSnapIds(this.snapPointsRaw);
2681
2730
  this.rootEl = this.element.closest(".bs-root");
2682
- this.maxHeight = createMaxHeightController({
2731
+ this.maxHeightDeps = {
2683
2732
  element: this.element,
2684
2733
  mode: this.mode,
2685
2734
  getMaxAxisSize: () => this.snaps.getMaxAxisSize(),
@@ -2687,7 +2736,8 @@ var BottomSheetCore = class {
2687
2736
  this.snaps.setMaxAxisSize(size);
2688
2737
  },
2689
2738
  recompute: () => this.recompute()
2690
- });
2739
+ };
2740
+ this.maxHeight = createMaxHeightController(this.maxHeightDeps);
2691
2741
  this.fitDeps = {
2692
2742
  element: this.element,
2693
2743
  scrollContainer: this.scrollContainer,
@@ -3021,6 +3071,37 @@ var BottomSheetCore = class {
3021
3071
  getDragFrom() {
3022
3072
  return this.dragFromMode;
3023
3073
  }
3074
+ setMode(mode) {
3075
+ if (this.destroyed) return;
3076
+ const next = resolveMode(mode, this.element);
3077
+ if (next === this.mode) return;
3078
+ const wasVertical = this.mode === "bottom" || this.mode === "top";
3079
+ const nowVertical = next === "bottom" || next === "top";
3080
+ this.gesture?.forceClearDragState();
3081
+ this.detachSheetGesture?.();
3082
+ this.animation.cancel();
3083
+ this.element.style.removeProperty(layoutAxis(this.mode));
3084
+ this.mode = next;
3085
+ this.element.dataset.mode = next;
3086
+ this.transformTemplate = buildTransformTemplate(next);
3087
+ this.maxHeightDeps.mode = next;
3088
+ this.fitDeps.mode = next;
3089
+ this.snaps.setMode(next);
3090
+ this.scrim.setSheetMode(next);
3091
+ if (wasVertical !== nowVertical) {
3092
+ this.aria = new AriaSliderWriter(this.handle, next);
3093
+ }
3094
+ this.detachSliderKeyboard?.();
3095
+ this.mountSliderKeyboard();
3096
+ this.mountSheetGesture();
3097
+ this.recompute();
3098
+ const active = this.snaps.findById(this.activeId);
3099
+ if (active) this.applySize(active.size);
3100
+ this.updateAriaSlider();
3101
+ }
3102
+ getMode() {
3103
+ return this.mode;
3104
+ }
3024
3105
  isTop() {
3025
3106
  return this.isTopSheet;
3026
3107
  }
@@ -3369,7 +3450,7 @@ var BottomSheetCore = class {
3369
3450
  const point = this.snapPointsRaw.find((p) => p.id === this.activeId);
3370
3451
  return point?.dragFromContent ?? this.dragFromContentDefault;
3371
3452
  }
3372
- decideContentDrag(surface, e, delta) {
3453
+ decideContentDrag(surface, e, delta, crossDelta) {
3373
3454
  if (this.destroyed) return false;
3374
3455
  if (e.pointerType === "mouse") return false;
3375
3456
  if (this.gesture?.isDragging) return false;
@@ -3377,6 +3458,8 @@ var BottomSheetCore = class {
3377
3458
  if (!isDragAllowedFrom(e.target, "sheet")) return false;
3378
3459
  const decision = decideContentGesture({
3379
3460
  delta,
3461
+ crossDelta,
3462
+ sharesScrollAxis: this.mode === "bottom" || this.mode === "top",
3380
3463
  scrollTop: surface.scrollTop,
3381
3464
  atMaxSnap: this.size >= this.getAllowedRange().max - 0.5
3382
3465
  });
@@ -3389,7 +3472,7 @@ var BottomSheetCore = class {
3389
3472
  const controller = new GestureController(
3390
3473
  this.buildGestureDeps(surface, {
3391
3474
  manageTouchAction: false,
3392
- deferStart: (e, delta) => this.decideContentDrag(surface, e, delta)
3475
+ deferStart: (e, delta, crossDelta) => this.decideContentDrag(surface, e, delta, crossDelta)
3393
3476
  })
3394
3477
  );
3395
3478
  this.contentGesture = controller;
@@ -3515,7 +3598,11 @@ var BottomSheetCore = class {
3515
3598
  );
3516
3599
  }
3517
3600
  }
3518
- this.teardowns.add(installSliderKeyboard({
3601
+ this.mountSliderKeyboard();
3602
+ this.scrim.attach();
3603
+ }
3604
+ mountSliderKeyboard() {
3605
+ const detach = installSliderKeyboard({
3519
3606
  handle: this.handle,
3520
3607
  mode: this.mode,
3521
3608
  isDestroyed: () => this.destroyed,
@@ -3524,8 +3611,12 @@ var BottomSheetCore = class {
3524
3611
  snapTo: (id) => {
3525
3612
  void this.snapTo(id);
3526
3613
  }
3527
- }));
3528
- this.scrim.attach();
3614
+ });
3615
+ this.detachSliderKeyboard = detach;
3616
+ this.teardowns.add(() => {
3617
+ this.detachSliderKeyboard?.();
3618
+ this.detachSliderKeyboard = null;
3619
+ });
3529
3620
  }
3530
3621
  settleAfterDrag(delta, velocity, kind = "touch") {
3531
3622
  const signal = this.newCycle();