@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/react.js CHANGED
@@ -323,6 +323,11 @@ var SnapResolver = class {
323
323
  this.raw = raw;
324
324
  this.recompute();
325
325
  }
326
+ setMode(mode) {
327
+ if (mode === this.mode) return;
328
+ this.mode = mode;
329
+ this.recompute();
330
+ }
326
331
  setAllowedIds(ids) {
327
332
  this.allowedIds = ids;
328
333
  this.rangeCache = null;
@@ -906,6 +911,11 @@ var ScrimController = class {
906
911
  if (this.isDestroyed()) return;
907
912
  this.applyScrimStyles({ interactive });
908
913
  }
914
+ setSheetMode(mode) {
915
+ if (this.isDestroyed() || mode === this.mode) return;
916
+ this.mode = mode;
917
+ this.invalidateOpacityCache();
918
+ }
909
919
  setScrimMode(mode, applySize) {
910
920
  if (this.isDestroyed()) return;
911
921
  if (mode === this.scrimMode) return;
@@ -1828,6 +1838,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1828
1838
  let activePointerId = null;
1829
1839
  let activePointerType = "touch";
1830
1840
  let startCoord = 0;
1841
+ let startCross = 0;
1831
1842
  let lastCoord = 0;
1832
1843
  let pendingStart = false;
1833
1844
  const VELOCITY_WINDOW_MS = (kind) => kind === "mouse" ? 160 : 120;
@@ -1836,6 +1847,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1836
1847
  const axis = isAxisVertical(mode) ? "Y" : "X";
1837
1848
  const sign = mode === "bottom" || mode === "right" ? -1 : 1;
1838
1849
  const coordOf = (e) => axis === "Y" ? e.clientY : e.clientX;
1850
+ const crossOf = (e) => axis === "Y" ? e.clientX : e.clientY;
1839
1851
  const capture = (pointerId) => {
1840
1852
  try {
1841
1853
  handle.setPointerCapture(pointerId);
@@ -1854,6 +1866,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1854
1866
  activePointerId = e.pointerId;
1855
1867
  activePointerType = e.pointerType || "touch";
1856
1868
  startCoord = coordOf(e);
1869
+ startCross = crossOf(e);
1857
1870
  lastCoord = startCoord;
1858
1871
  samples.reset();
1859
1872
  samples.push(e.timeStamp, startCoord);
@@ -1870,7 +1883,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1870
1883
  const rawDelta = coord - startCoord;
1871
1884
  const delta = rawDelta * sign;
1872
1885
  if (pendingStart) {
1873
- const verdict = options.deferStart(e, delta);
1886
+ const verdict = options.deferStart(e, delta, crossOf(e) - startCross);
1874
1887
  if (verdict === false) {
1875
1888
  releaseTracking();
1876
1889
  return;
@@ -2088,12 +2101,45 @@ function isDragAllowedFrom(target, mode) {
2088
2101
  var CONTENT_DRAG_SLOP = 6;
2089
2102
  function decideContentGesture(input) {
2090
2103
  const slop = input.slop ?? CONTENT_DRAG_SLOP;
2104
+ const cross = input.crossDelta ?? 0;
2105
+ const sharesScrollAxis = input.sharesScrollAxis ?? true;
2106
+ if (!sharesScrollAxis) {
2107
+ if (Math.abs(input.delta) < slop && Math.abs(cross) < slop) return "pending";
2108
+ if (Math.abs(input.delta) <= Math.abs(cross)) return "scroll";
2109
+ return "drag";
2110
+ }
2091
2111
  if (Math.abs(input.delta) < slop) return "pending";
2092
2112
  if (input.scrollTop > 0) return "scroll";
2093
2113
  if (input.delta > 0 && input.atMaxSnap) return "scroll";
2094
2114
  return "drag";
2095
2115
  }
2096
2116
 
2117
+ // src/core/primitives/logical-mode.ts
2118
+ var isLogicalMode = (mode) => mode === "start" || mode === "end";
2119
+ var readDirection = (el) => {
2120
+ if (!el) return "ltr";
2121
+ if (typeof getComputedStyle === "function") {
2122
+ try {
2123
+ if (getComputedStyle(el).direction === "rtl") return "rtl";
2124
+ } catch {
2125
+ }
2126
+ }
2127
+ try {
2128
+ const marked = el.closest?.("[dir]");
2129
+ if (marked) {
2130
+ return marked.getAttribute("dir")?.toLowerCase() === "rtl" ? "rtl" : "ltr";
2131
+ }
2132
+ } catch {
2133
+ }
2134
+ return "ltr";
2135
+ };
2136
+ var resolveMode = (mode, el) => {
2137
+ if (!isLogicalMode(mode)) return mode;
2138
+ const rtl = readDirection(el) === "rtl";
2139
+ if (mode === "start") return rtl ? "right" : "left";
2140
+ return rtl ? "left" : "right";
2141
+ };
2142
+
2097
2143
  // src/core/primitives/touch-scroll-guard.ts
2098
2144
  function installTouchScrollGuard(surface, isDragging) {
2099
2145
  const onTouchMove = (e) => {
@@ -2456,7 +2502,7 @@ function resolveEngineOptions(opts, extras) {
2456
2502
  }
2457
2503
  }
2458
2504
  return {
2459
- mode: opts.mode ?? "bottom",
2505
+ mode: resolveMode(opts.mode ?? "bottom", opts.element),
2460
2506
  flickVelocity: opts.flickVelocity ?? DEFAULT_FLICK_VELOCITY,
2461
2507
  dragThreshold: opts.dragThreshold ?? DEFAULT_DRAG_THRESHOLD,
2462
2508
  dragFrom: opts.dragFrom ?? (opts.handle ? "handle" : "sheet"),
@@ -2560,6 +2606,7 @@ var BottomSheetCore = class {
2560
2606
  __publicField(this, "disableDragFlag");
2561
2607
  __publicField(this, "closeOnRouteChange");
2562
2608
  __publicField(this, "maxHeight");
2609
+ __publicField(this, "maxHeightDeps");
2563
2610
  __publicField(this, "snapPointsRaw");
2564
2611
  __publicField(this, "snaps");
2565
2612
  __publicField(this, "activeId");
@@ -2567,6 +2614,7 @@ var BottomSheetCore = class {
2567
2614
  __publicField(this, "gesture");
2568
2615
  __publicField(this, "contentGesture");
2569
2616
  __publicField(this, "detachSheetGesture", null);
2617
+ __publicField(this, "detachSliderKeyboard", null);
2570
2618
  __publicField(this, "rootEl", null);
2571
2619
  __publicField(this, "destroyed", false);
2572
2620
  __publicField(this, "restClosed", false);
@@ -2618,6 +2666,7 @@ var BottomSheetCore = class {
2618
2666
  this.screenComponent = opts.scrim ?? opts.screenComponent;
2619
2667
  this.scrimParent = this.screenComponent?.parentElement ?? null;
2620
2668
  this.mode = resolved.mode;
2669
+ this.element.dataset.mode = this.mode;
2621
2670
  this.transformTemplate = buildTransformTemplate(this.mode);
2622
2671
  this.aria = new AriaSliderWriter(this.handle, this.mode);
2623
2672
  this.flickVelocity = resolved.flickVelocity;
@@ -2684,7 +2733,7 @@ var BottomSheetCore = class {
2684
2733
  auditVhUsage(this.snapPointsRaw);
2685
2734
  this.auditDuplicateSnapIds(this.snapPointsRaw);
2686
2735
  this.rootEl = this.element.closest(".bs-root");
2687
- this.maxHeight = createMaxHeightController({
2736
+ this.maxHeightDeps = {
2688
2737
  element: this.element,
2689
2738
  mode: this.mode,
2690
2739
  getMaxAxisSize: () => this.snaps.getMaxAxisSize(),
@@ -2692,7 +2741,8 @@ var BottomSheetCore = class {
2692
2741
  this.snaps.setMaxAxisSize(size);
2693
2742
  },
2694
2743
  recompute: () => this.recompute()
2695
- });
2744
+ };
2745
+ this.maxHeight = createMaxHeightController(this.maxHeightDeps);
2696
2746
  this.fitDeps = {
2697
2747
  element: this.element,
2698
2748
  scrollContainer: this.scrollContainer,
@@ -3026,6 +3076,37 @@ var BottomSheetCore = class {
3026
3076
  getDragFrom() {
3027
3077
  return this.dragFromMode;
3028
3078
  }
3079
+ setMode(mode) {
3080
+ if (this.destroyed) return;
3081
+ const next = resolveMode(mode, this.element);
3082
+ if (next === this.mode) return;
3083
+ const wasVertical = this.mode === "bottom" || this.mode === "top";
3084
+ const nowVertical = next === "bottom" || next === "top";
3085
+ this.gesture?.forceClearDragState();
3086
+ this.detachSheetGesture?.();
3087
+ this.animation.cancel();
3088
+ this.element.style.removeProperty(layoutAxis(this.mode));
3089
+ this.mode = next;
3090
+ this.element.dataset.mode = next;
3091
+ this.transformTemplate = buildTransformTemplate(next);
3092
+ this.maxHeightDeps.mode = next;
3093
+ this.fitDeps.mode = next;
3094
+ this.snaps.setMode(next);
3095
+ this.scrim.setSheetMode(next);
3096
+ if (wasVertical !== nowVertical) {
3097
+ this.aria = new AriaSliderWriter(this.handle, next);
3098
+ }
3099
+ this.detachSliderKeyboard?.();
3100
+ this.mountSliderKeyboard();
3101
+ this.mountSheetGesture();
3102
+ this.recompute();
3103
+ const active = this.snaps.findById(this.activeId);
3104
+ if (active) this.applySize(active.size);
3105
+ this.updateAriaSlider();
3106
+ }
3107
+ getMode() {
3108
+ return this.mode;
3109
+ }
3029
3110
  isTop() {
3030
3111
  return this.isTopSheet;
3031
3112
  }
@@ -3374,7 +3455,7 @@ var BottomSheetCore = class {
3374
3455
  const point = this.snapPointsRaw.find((p) => p.id === this.activeId);
3375
3456
  return point?.dragFromContent ?? this.dragFromContentDefault;
3376
3457
  }
3377
- decideContentDrag(surface, e, delta) {
3458
+ decideContentDrag(surface, e, delta, crossDelta) {
3378
3459
  if (this.destroyed) return false;
3379
3460
  if (e.pointerType === "mouse") return false;
3380
3461
  if (this.gesture?.isDragging) return false;
@@ -3382,6 +3463,8 @@ var BottomSheetCore = class {
3382
3463
  if (!isDragAllowedFrom(e.target, "sheet")) return false;
3383
3464
  const decision = decideContentGesture({
3384
3465
  delta,
3466
+ crossDelta,
3467
+ sharesScrollAxis: this.mode === "bottom" || this.mode === "top",
3385
3468
  scrollTop: surface.scrollTop,
3386
3469
  atMaxSnap: this.size >= this.getAllowedRange().max - 0.5
3387
3470
  });
@@ -3394,7 +3477,7 @@ var BottomSheetCore = class {
3394
3477
  const controller = new GestureController(
3395
3478
  this.buildGestureDeps(surface, {
3396
3479
  manageTouchAction: false,
3397
- deferStart: (e, delta) => this.decideContentDrag(surface, e, delta)
3480
+ deferStart: (e, delta, crossDelta) => this.decideContentDrag(surface, e, delta, crossDelta)
3398
3481
  })
3399
3482
  );
3400
3483
  this.contentGesture = controller;
@@ -3520,7 +3603,11 @@ var BottomSheetCore = class {
3520
3603
  );
3521
3604
  }
3522
3605
  }
3523
- this.teardowns.add(installSliderKeyboard({
3606
+ this.mountSliderKeyboard();
3607
+ this.scrim.attach();
3608
+ }
3609
+ mountSliderKeyboard() {
3610
+ const detach = installSliderKeyboard({
3524
3611
  handle: this.handle,
3525
3612
  mode: this.mode,
3526
3613
  isDestroyed: () => this.destroyed,
@@ -3529,8 +3616,12 @@ var BottomSheetCore = class {
3529
3616
  snapTo: (id) => {
3530
3617
  void this.snapTo(id);
3531
3618
  }
3532
- }));
3533
- this.scrim.attach();
3619
+ });
3620
+ this.detachSliderKeyboard = detach;
3621
+ this.teardowns.add(() => {
3622
+ this.detachSliderKeyboard?.();
3623
+ this.detachSliderKeyboard = null;
3624
+ });
3534
3625
  }
3535
3626
  settleAfterDrag(delta, velocity, kind = "touch") {
3536
3627
  const signal = this.newCycle();
package/dist/solid.cjs CHANGED
@@ -318,6 +318,11 @@ var SnapResolver = class {
318
318
  this.raw = raw;
319
319
  this.recompute();
320
320
  }
321
+ setMode(mode) {
322
+ if (mode === this.mode) return;
323
+ this.mode = mode;
324
+ this.recompute();
325
+ }
321
326
  setAllowedIds(ids) {
322
327
  this.allowedIds = ids;
323
328
  this.rangeCache = null;
@@ -901,6 +906,11 @@ var ScrimController = class {
901
906
  if (this.isDestroyed()) return;
902
907
  this.applyScrimStyles({ interactive });
903
908
  }
909
+ setSheetMode(mode) {
910
+ if (this.isDestroyed() || mode === this.mode) return;
911
+ this.mode = mode;
912
+ this.invalidateOpacityCache();
913
+ }
904
914
  setScrimMode(mode, applySize) {
905
915
  if (this.isDestroyed()) return;
906
916
  if (mode === this.scrimMode) return;
@@ -1823,6 +1833,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1823
1833
  let activePointerId = null;
1824
1834
  let activePointerType = "touch";
1825
1835
  let startCoord = 0;
1836
+ let startCross = 0;
1826
1837
  let lastCoord = 0;
1827
1838
  let pendingStart = false;
1828
1839
  const VELOCITY_WINDOW_MS = (kind) => kind === "mouse" ? 160 : 120;
@@ -1831,6 +1842,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1831
1842
  const axis = isAxisVertical(mode) ? "Y" : "X";
1832
1843
  const sign = mode === "bottom" || mode === "right" ? -1 : 1;
1833
1844
  const coordOf = (e) => axis === "Y" ? e.clientY : e.clientX;
1845
+ const crossOf = (e) => axis === "Y" ? e.clientX : e.clientY;
1834
1846
  const capture = (pointerId) => {
1835
1847
  try {
1836
1848
  handle.setPointerCapture(pointerId);
@@ -1849,6 +1861,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1849
1861
  activePointerId = e.pointerId;
1850
1862
  activePointerType = e.pointerType || "touch";
1851
1863
  startCoord = coordOf(e);
1864
+ startCross = crossOf(e);
1852
1865
  lastCoord = startCoord;
1853
1866
  samples.reset();
1854
1867
  samples.push(e.timeStamp, startCoord);
@@ -1865,7 +1878,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
1865
1878
  const rawDelta = coord - startCoord;
1866
1879
  const delta = rawDelta * sign;
1867
1880
  if (pendingStart) {
1868
- const verdict = options.deferStart(e, delta);
1881
+ const verdict = options.deferStart(e, delta, crossOf(e) - startCross);
1869
1882
  if (verdict === false) {
1870
1883
  releaseTracking();
1871
1884
  return;
@@ -2083,12 +2096,45 @@ function isDragAllowedFrom(target, mode) {
2083
2096
  var CONTENT_DRAG_SLOP = 6;
2084
2097
  function decideContentGesture(input) {
2085
2098
  const slop = input.slop ?? CONTENT_DRAG_SLOP;
2099
+ const cross = input.crossDelta ?? 0;
2100
+ const sharesScrollAxis = input.sharesScrollAxis ?? true;
2101
+ if (!sharesScrollAxis) {
2102
+ if (Math.abs(input.delta) < slop && Math.abs(cross) < slop) return "pending";
2103
+ if (Math.abs(input.delta) <= Math.abs(cross)) return "scroll";
2104
+ return "drag";
2105
+ }
2086
2106
  if (Math.abs(input.delta) < slop) return "pending";
2087
2107
  if (input.scrollTop > 0) return "scroll";
2088
2108
  if (input.delta > 0 && input.atMaxSnap) return "scroll";
2089
2109
  return "drag";
2090
2110
  }
2091
2111
 
2112
+ // src/core/primitives/logical-mode.ts
2113
+ var isLogicalMode = (mode) => mode === "start" || mode === "end";
2114
+ var readDirection = (el) => {
2115
+ if (!el) return "ltr";
2116
+ if (typeof getComputedStyle === "function") {
2117
+ try {
2118
+ if (getComputedStyle(el).direction === "rtl") return "rtl";
2119
+ } catch {
2120
+ }
2121
+ }
2122
+ try {
2123
+ const marked = el.closest?.("[dir]");
2124
+ if (marked) {
2125
+ return marked.getAttribute("dir")?.toLowerCase() === "rtl" ? "rtl" : "ltr";
2126
+ }
2127
+ } catch {
2128
+ }
2129
+ return "ltr";
2130
+ };
2131
+ var resolveMode = (mode, el) => {
2132
+ if (!isLogicalMode(mode)) return mode;
2133
+ const rtl = readDirection(el) === "rtl";
2134
+ if (mode === "start") return rtl ? "right" : "left";
2135
+ return rtl ? "left" : "right";
2136
+ };
2137
+
2092
2138
  // src/core/primitives/touch-scroll-guard.ts
2093
2139
  function installTouchScrollGuard(surface, isDragging) {
2094
2140
  const onTouchMove = (e) => {
@@ -2451,7 +2497,7 @@ function resolveEngineOptions(opts, extras) {
2451
2497
  }
2452
2498
  }
2453
2499
  return {
2454
- mode: opts.mode ?? "bottom",
2500
+ mode: resolveMode(opts.mode ?? "bottom", opts.element),
2455
2501
  flickVelocity: opts.flickVelocity ?? DEFAULT_FLICK_VELOCITY,
2456
2502
  dragThreshold: opts.dragThreshold ?? DEFAULT_DRAG_THRESHOLD,
2457
2503
  dragFrom: opts.dragFrom ?? (opts.handle ? "handle" : "sheet"),
@@ -2555,6 +2601,7 @@ var BottomSheetCore = class {
2555
2601
  __publicField(this, "disableDragFlag");
2556
2602
  __publicField(this, "closeOnRouteChange");
2557
2603
  __publicField(this, "maxHeight");
2604
+ __publicField(this, "maxHeightDeps");
2558
2605
  __publicField(this, "snapPointsRaw");
2559
2606
  __publicField(this, "snaps");
2560
2607
  __publicField(this, "activeId");
@@ -2562,6 +2609,7 @@ var BottomSheetCore = class {
2562
2609
  __publicField(this, "gesture");
2563
2610
  __publicField(this, "contentGesture");
2564
2611
  __publicField(this, "detachSheetGesture", null);
2612
+ __publicField(this, "detachSliderKeyboard", null);
2565
2613
  __publicField(this, "rootEl", null);
2566
2614
  __publicField(this, "destroyed", false);
2567
2615
  __publicField(this, "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();
package/dist/solid.d.cts CHANGED
@@ -4,13 +4,17 @@ type DragFrom$1 = "handle" | "sheet" | "zones";
4
4
 
5
5
  type TransformAxis = "bottom" | "top" | "left" | "right";
6
6
 
7
+ type LogicalAxis = "start" | "end";
8
+
7
9
  type SnapPoint = number | `${number}%` | "fit" | "content" | "full" | (string & {});
8
10
  type SnapPointDef<Id extends string = string> = {
9
11
  id: Id;
10
12
  size: SnapPoint;
11
13
  dragFromContent?: boolean;
12
14
  };
13
- type SheetMode = TransformAxis;
15
+ type PhysicalSheetMode = TransformAxis;
16
+ type LogicalSheetMode = LogicalAxis;
17
+ type SheetMode = PhysicalSheetMode | LogicalSheetMode;
14
18
  type DragFrom = DragFrom$1;
15
19
  type DragSurfaceKind = "content";
16
20
  type ScrimPreset = "subtle" | "standard" | "monitoring" | "cinematic";
@@ -263,6 +267,7 @@ declare class BottomSheetCore {
263
267
  private disableDragFlag;
264
268
  private closeOnRouteChange;
265
269
  private maxHeight;
270
+ private maxHeightDeps;
266
271
  private snapPointsRaw;
267
272
  private snaps;
268
273
  private activeId;
@@ -270,6 +275,7 @@ declare class BottomSheetCore {
270
275
  private gesture;
271
276
  private contentGesture;
272
277
  private detachSheetGesture;
278
+ private detachSliderKeyboard;
273
279
  private rootEl;
274
280
  private destroyed;
275
281
  private restClosed;
@@ -331,6 +337,8 @@ declare class BottomSheetCore {
331
337
  setDragFromContent(value: boolean): void;
332
338
  setDragFrom(mode: DragFrom$1): void;
333
339
  getDragFrom(): DragFrom$1;
340
+ setMode(mode: SheetMode): void;
341
+ getMode(): PhysicalSheetMode;
334
342
  isTop(): boolean;
335
343
  depth(): number;
336
344
  expand(): Promise<void>;
@@ -379,6 +387,7 @@ declare class BottomSheetCore {
379
387
  private mountSheetGesture;
380
388
  private attach;
381
389
  private attachFeatures;
390
+ private mountSliderKeyboard;
382
391
  private settleAfterDrag;
383
392
  private isDraggingAny;
384
393
  private clearWillChangeIfIdle;
package/dist/solid.d.ts CHANGED
@@ -4,13 +4,17 @@ type DragFrom$1 = "handle" | "sheet" | "zones";
4
4
 
5
5
  type TransformAxis = "bottom" | "top" | "left" | "right";
6
6
 
7
+ type LogicalAxis = "start" | "end";
8
+
7
9
  type SnapPoint = number | `${number}%` | "fit" | "content" | "full" | (string & {});
8
10
  type SnapPointDef<Id extends string = string> = {
9
11
  id: Id;
10
12
  size: SnapPoint;
11
13
  dragFromContent?: boolean;
12
14
  };
13
- type SheetMode = TransformAxis;
15
+ type PhysicalSheetMode = TransformAxis;
16
+ type LogicalSheetMode = LogicalAxis;
17
+ type SheetMode = PhysicalSheetMode | LogicalSheetMode;
14
18
  type DragFrom = DragFrom$1;
15
19
  type DragSurfaceKind = "content";
16
20
  type ScrimPreset = "subtle" | "standard" | "monitoring" | "cinematic";
@@ -263,6 +267,7 @@ declare class BottomSheetCore {
263
267
  private disableDragFlag;
264
268
  private closeOnRouteChange;
265
269
  private maxHeight;
270
+ private maxHeightDeps;
266
271
  private snapPointsRaw;
267
272
  private snaps;
268
273
  private activeId;
@@ -270,6 +275,7 @@ declare class BottomSheetCore {
270
275
  private gesture;
271
276
  private contentGesture;
272
277
  private detachSheetGesture;
278
+ private detachSliderKeyboard;
273
279
  private rootEl;
274
280
  private destroyed;
275
281
  private restClosed;
@@ -331,6 +337,8 @@ declare class BottomSheetCore {
331
337
  setDragFromContent(value: boolean): void;
332
338
  setDragFrom(mode: DragFrom$1): void;
333
339
  getDragFrom(): DragFrom$1;
340
+ setMode(mode: SheetMode): void;
341
+ getMode(): PhysicalSheetMode;
334
342
  isTop(): boolean;
335
343
  depth(): number;
336
344
  expand(): Promise<void>;
@@ -379,6 +387,7 @@ declare class BottomSheetCore {
379
387
  private mountSheetGesture;
380
388
  private attach;
381
389
  private attachFeatures;
390
+ private mountSliderKeyboard;
382
391
  private settleAfterDrag;
383
392
  private isDraggingAny;
384
393
  private clearWillChangeIfIdle;