@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.
- package/README.md +13 -0
- package/dist/{BottomSheetCore-DJYwWOqt.d.ts → BottomSheetCore-Cgn8b_6A.d.ts} +11 -2
- package/dist/{BottomSheetCore-Cp7dWy91.d.cts → BottomSheetCore-VPJZcKcg.d.cts} +11 -2
- package/dist/{BottomSheetEngine-Lm7HIVHv.d.cts → BottomSheetEngine-B8C2CwF9.d.cts} +1 -1
- package/dist/{BottomSheetEngine-O5PbeKfe.d.ts → BottomSheetEngine-DwYR_ygJ.d.ts} +1 -1
- package/dist/core.cjs +100 -9
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +100 -9
- package/dist/debug.d.cts +1 -1
- package/dist/debug.d.ts +1 -1
- package/dist/element.cjs +107 -9
- package/dist/element.d.cts +2 -2
- package/dist/element.d.ts +2 -2
- package/dist/element.iife.global.js +2 -2
- package/dist/element.js +107 -9
- package/dist/features.d.cts +4 -4
- package/dist/features.d.ts +4 -4
- package/dist/{index-Bb5TRmyg.d.cts → index-CnfbOKx0.d.cts} +1 -1
- package/dist/{index-Cl9ebCP2.d.ts → index-DcMkhXAy.d.ts} +1 -1
- package/dist/index.cjs +100 -9
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +100 -9
- package/dist/integrations/formik.d.cts +1 -1
- package/dist/integrations/formik.d.ts +1 -1
- package/dist/integrations/react-hook-form.d.cts +1 -1
- package/dist/integrations/react-hook-form.d.ts +1 -1
- package/dist/preact.d.cts +2 -2
- package/dist/preact.d.ts +2 -2
- package/dist/qwik-lib/index.qwik.cjs +98 -9
- package/dist/qwik-lib/index.qwik.mjs +98 -9
- package/dist/qwik.cjs +100 -9
- package/dist/qwik.d.cts +2 -2
- package/dist/qwik.d.ts +2 -2
- package/dist/qwik.js +100 -9
- package/dist/react.cjs +100 -9
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +100 -9
- package/dist/solid.cjs +100 -9
- package/dist/solid.d.cts +10 -1
- package/dist/solid.d.ts +10 -1
- package/dist/solid.js +100 -9
- package/dist/solid.source.jsx +100 -9
- package/dist/svelte-core.cjs +100 -9
- package/dist/svelte-core.js +100 -9
- package/dist/svelte.cjs +100 -9
- package/dist/svelte.js +100 -9
- package/dist/vue.cjs +101 -10
- package/dist/vue.js +101 -10
- package/dist/webgl.cjs +154 -34
- package/dist/webgl.d.cts +1 -1
- package/dist/webgl.d.ts +1 -1
- package/dist/webgl.js +154 -34
- package/package.json +39 -39
package/dist/qwik.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.
|
|
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.
|
|
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.
|
|
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();
|
package/dist/react.cjs
CHANGED
|
@@ -325,6 +325,11 @@ var SnapResolver = class {
|
|
|
325
325
|
this.raw = raw;
|
|
326
326
|
this.recompute();
|
|
327
327
|
}
|
|
328
|
+
setMode(mode) {
|
|
329
|
+
if (mode === this.mode) return;
|
|
330
|
+
this.mode = mode;
|
|
331
|
+
this.recompute();
|
|
332
|
+
}
|
|
328
333
|
setAllowedIds(ids) {
|
|
329
334
|
this.allowedIds = ids;
|
|
330
335
|
this.rangeCache = null;
|
|
@@ -908,6 +913,11 @@ var ScrimController = class {
|
|
|
908
913
|
if (this.isDestroyed()) return;
|
|
909
914
|
this.applyScrimStyles({ interactive });
|
|
910
915
|
}
|
|
916
|
+
setSheetMode(mode) {
|
|
917
|
+
if (this.isDestroyed() || mode === this.mode) return;
|
|
918
|
+
this.mode = mode;
|
|
919
|
+
this.invalidateOpacityCache();
|
|
920
|
+
}
|
|
911
921
|
setScrimMode(mode, applySize) {
|
|
912
922
|
if (this.isDestroyed()) return;
|
|
913
923
|
if (mode === this.scrimMode) return;
|
|
@@ -1830,6 +1840,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
|
|
|
1830
1840
|
let activePointerId = null;
|
|
1831
1841
|
let activePointerType = "touch";
|
|
1832
1842
|
let startCoord = 0;
|
|
1843
|
+
let startCross = 0;
|
|
1833
1844
|
let lastCoord = 0;
|
|
1834
1845
|
let pendingStart = false;
|
|
1835
1846
|
const VELOCITY_WINDOW_MS = (kind) => kind === "mouse" ? 160 : 120;
|
|
@@ -1838,6 +1849,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
|
|
|
1838
1849
|
const axis = isAxisVertical(mode) ? "Y" : "X";
|
|
1839
1850
|
const sign = mode === "bottom" || mode === "right" ? -1 : 1;
|
|
1840
1851
|
const coordOf = (e) => axis === "Y" ? e.clientY : e.clientX;
|
|
1852
|
+
const crossOf = (e) => axis === "Y" ? e.clientX : e.clientY;
|
|
1841
1853
|
const capture = (pointerId) => {
|
|
1842
1854
|
try {
|
|
1843
1855
|
handle.setPointerCapture(pointerId);
|
|
@@ -1856,6 +1868,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
|
|
|
1856
1868
|
activePointerId = e.pointerId;
|
|
1857
1869
|
activePointerType = e.pointerType || "touch";
|
|
1858
1870
|
startCoord = coordOf(e);
|
|
1871
|
+
startCross = crossOf(e);
|
|
1859
1872
|
lastCoord = startCoord;
|
|
1860
1873
|
samples.reset();
|
|
1861
1874
|
samples.push(e.timeStamp, startCoord);
|
|
@@ -1872,7 +1885,7 @@ var installGestures = (handle, mode, callbacks, options = {}) => {
|
|
|
1872
1885
|
const rawDelta = coord - startCoord;
|
|
1873
1886
|
const delta = rawDelta * sign;
|
|
1874
1887
|
if (pendingStart) {
|
|
1875
|
-
const verdict = options.deferStart(e, delta);
|
|
1888
|
+
const verdict = options.deferStart(e, delta, crossOf(e) - startCross);
|
|
1876
1889
|
if (verdict === false) {
|
|
1877
1890
|
releaseTracking();
|
|
1878
1891
|
return;
|
|
@@ -2090,12 +2103,45 @@ function isDragAllowedFrom(target, mode) {
|
|
|
2090
2103
|
var CONTENT_DRAG_SLOP = 6;
|
|
2091
2104
|
function decideContentGesture(input) {
|
|
2092
2105
|
const slop = input.slop ?? CONTENT_DRAG_SLOP;
|
|
2106
|
+
const cross = input.crossDelta ?? 0;
|
|
2107
|
+
const sharesScrollAxis = input.sharesScrollAxis ?? true;
|
|
2108
|
+
if (!sharesScrollAxis) {
|
|
2109
|
+
if (Math.abs(input.delta) < slop && Math.abs(cross) < slop) return "pending";
|
|
2110
|
+
if (Math.abs(input.delta) <= Math.abs(cross)) return "scroll";
|
|
2111
|
+
return "drag";
|
|
2112
|
+
}
|
|
2093
2113
|
if (Math.abs(input.delta) < slop) return "pending";
|
|
2094
2114
|
if (input.scrollTop > 0) return "scroll";
|
|
2095
2115
|
if (input.delta > 0 && input.atMaxSnap) return "scroll";
|
|
2096
2116
|
return "drag";
|
|
2097
2117
|
}
|
|
2098
2118
|
|
|
2119
|
+
// src/core/primitives/logical-mode.ts
|
|
2120
|
+
var isLogicalMode = (mode) => mode === "start" || mode === "end";
|
|
2121
|
+
var readDirection = (el) => {
|
|
2122
|
+
if (!el) return "ltr";
|
|
2123
|
+
if (typeof getComputedStyle === "function") {
|
|
2124
|
+
try {
|
|
2125
|
+
if (getComputedStyle(el).direction === "rtl") return "rtl";
|
|
2126
|
+
} catch {
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
try {
|
|
2130
|
+
const marked = el.closest?.("[dir]");
|
|
2131
|
+
if (marked) {
|
|
2132
|
+
return marked.getAttribute("dir")?.toLowerCase() === "rtl" ? "rtl" : "ltr";
|
|
2133
|
+
}
|
|
2134
|
+
} catch {
|
|
2135
|
+
}
|
|
2136
|
+
return "ltr";
|
|
2137
|
+
};
|
|
2138
|
+
var resolveMode = (mode, el) => {
|
|
2139
|
+
if (!isLogicalMode(mode)) return mode;
|
|
2140
|
+
const rtl = readDirection(el) === "rtl";
|
|
2141
|
+
if (mode === "start") return rtl ? "right" : "left";
|
|
2142
|
+
return rtl ? "left" : "right";
|
|
2143
|
+
};
|
|
2144
|
+
|
|
2099
2145
|
// src/core/primitives/touch-scroll-guard.ts
|
|
2100
2146
|
function installTouchScrollGuard(surface, isDragging) {
|
|
2101
2147
|
const onTouchMove = (e) => {
|
|
@@ -2458,7 +2504,7 @@ function resolveEngineOptions(opts, extras) {
|
|
|
2458
2504
|
}
|
|
2459
2505
|
}
|
|
2460
2506
|
return {
|
|
2461
|
-
mode: opts.mode ?? "bottom",
|
|
2507
|
+
mode: resolveMode(opts.mode ?? "bottom", opts.element),
|
|
2462
2508
|
flickVelocity: opts.flickVelocity ?? DEFAULT_FLICK_VELOCITY,
|
|
2463
2509
|
dragThreshold: opts.dragThreshold ?? DEFAULT_DRAG_THRESHOLD,
|
|
2464
2510
|
dragFrom: opts.dragFrom ?? (opts.handle ? "handle" : "sheet"),
|
|
@@ -2562,6 +2608,7 @@ var BottomSheetCore = class {
|
|
|
2562
2608
|
__publicField(this, "disableDragFlag");
|
|
2563
2609
|
__publicField(this, "closeOnRouteChange");
|
|
2564
2610
|
__publicField(this, "maxHeight");
|
|
2611
|
+
__publicField(this, "maxHeightDeps");
|
|
2565
2612
|
__publicField(this, "snapPointsRaw");
|
|
2566
2613
|
__publicField(this, "snaps");
|
|
2567
2614
|
__publicField(this, "activeId");
|
|
@@ -2569,6 +2616,7 @@ var BottomSheetCore = class {
|
|
|
2569
2616
|
__publicField(this, "gesture");
|
|
2570
2617
|
__publicField(this, "contentGesture");
|
|
2571
2618
|
__publicField(this, "detachSheetGesture", null);
|
|
2619
|
+
__publicField(this, "detachSliderKeyboard", null);
|
|
2572
2620
|
__publicField(this, "rootEl", null);
|
|
2573
2621
|
__publicField(this, "destroyed", false);
|
|
2574
2622
|
__publicField(this, "restClosed", false);
|
|
@@ -2620,6 +2668,7 @@ var BottomSheetCore = class {
|
|
|
2620
2668
|
this.screenComponent = opts.scrim ?? opts.screenComponent;
|
|
2621
2669
|
this.scrimParent = this.screenComponent?.parentElement ?? null;
|
|
2622
2670
|
this.mode = resolved.mode;
|
|
2671
|
+
this.element.dataset.mode = this.mode;
|
|
2623
2672
|
this.transformTemplate = buildTransformTemplate(this.mode);
|
|
2624
2673
|
this.aria = new AriaSliderWriter(this.handle, this.mode);
|
|
2625
2674
|
this.flickVelocity = resolved.flickVelocity;
|
|
@@ -2686,7 +2735,7 @@ var BottomSheetCore = class {
|
|
|
2686
2735
|
auditVhUsage(this.snapPointsRaw);
|
|
2687
2736
|
this.auditDuplicateSnapIds(this.snapPointsRaw);
|
|
2688
2737
|
this.rootEl = this.element.closest(".bs-root");
|
|
2689
|
-
this.
|
|
2738
|
+
this.maxHeightDeps = {
|
|
2690
2739
|
element: this.element,
|
|
2691
2740
|
mode: this.mode,
|
|
2692
2741
|
getMaxAxisSize: () => this.snaps.getMaxAxisSize(),
|
|
@@ -2694,7 +2743,8 @@ var BottomSheetCore = class {
|
|
|
2694
2743
|
this.snaps.setMaxAxisSize(size);
|
|
2695
2744
|
},
|
|
2696
2745
|
recompute: () => this.recompute()
|
|
2697
|
-
}
|
|
2746
|
+
};
|
|
2747
|
+
this.maxHeight = createMaxHeightController(this.maxHeightDeps);
|
|
2698
2748
|
this.fitDeps = {
|
|
2699
2749
|
element: this.element,
|
|
2700
2750
|
scrollContainer: this.scrollContainer,
|
|
@@ -3028,6 +3078,37 @@ var BottomSheetCore = class {
|
|
|
3028
3078
|
getDragFrom() {
|
|
3029
3079
|
return this.dragFromMode;
|
|
3030
3080
|
}
|
|
3081
|
+
setMode(mode) {
|
|
3082
|
+
if (this.destroyed) return;
|
|
3083
|
+
const next = resolveMode(mode, this.element);
|
|
3084
|
+
if (next === this.mode) return;
|
|
3085
|
+
const wasVertical = this.mode === "bottom" || this.mode === "top";
|
|
3086
|
+
const nowVertical = next === "bottom" || next === "top";
|
|
3087
|
+
this.gesture?.forceClearDragState();
|
|
3088
|
+
this.detachSheetGesture?.();
|
|
3089
|
+
this.animation.cancel();
|
|
3090
|
+
this.element.style.removeProperty(layoutAxis(this.mode));
|
|
3091
|
+
this.mode = next;
|
|
3092
|
+
this.element.dataset.mode = next;
|
|
3093
|
+
this.transformTemplate = buildTransformTemplate(next);
|
|
3094
|
+
this.maxHeightDeps.mode = next;
|
|
3095
|
+
this.fitDeps.mode = next;
|
|
3096
|
+
this.snaps.setMode(next);
|
|
3097
|
+
this.scrim.setSheetMode(next);
|
|
3098
|
+
if (wasVertical !== nowVertical) {
|
|
3099
|
+
this.aria = new AriaSliderWriter(this.handle, next);
|
|
3100
|
+
}
|
|
3101
|
+
this.detachSliderKeyboard?.();
|
|
3102
|
+
this.mountSliderKeyboard();
|
|
3103
|
+
this.mountSheetGesture();
|
|
3104
|
+
this.recompute();
|
|
3105
|
+
const active = this.snaps.findById(this.activeId);
|
|
3106
|
+
if (active) this.applySize(active.size);
|
|
3107
|
+
this.updateAriaSlider();
|
|
3108
|
+
}
|
|
3109
|
+
getMode() {
|
|
3110
|
+
return this.mode;
|
|
3111
|
+
}
|
|
3031
3112
|
isTop() {
|
|
3032
3113
|
return this.isTopSheet;
|
|
3033
3114
|
}
|
|
@@ -3376,7 +3457,7 @@ var BottomSheetCore = class {
|
|
|
3376
3457
|
const point = this.snapPointsRaw.find((p) => p.id === this.activeId);
|
|
3377
3458
|
return point?.dragFromContent ?? this.dragFromContentDefault;
|
|
3378
3459
|
}
|
|
3379
|
-
decideContentDrag(surface, e, delta) {
|
|
3460
|
+
decideContentDrag(surface, e, delta, crossDelta) {
|
|
3380
3461
|
if (this.destroyed) return false;
|
|
3381
3462
|
if (e.pointerType === "mouse") return false;
|
|
3382
3463
|
if (this.gesture?.isDragging) return false;
|
|
@@ -3384,6 +3465,8 @@ var BottomSheetCore = class {
|
|
|
3384
3465
|
if (!isDragAllowedFrom(e.target, "sheet")) return false;
|
|
3385
3466
|
const decision = decideContentGesture({
|
|
3386
3467
|
delta,
|
|
3468
|
+
crossDelta,
|
|
3469
|
+
sharesScrollAxis: this.mode === "bottom" || this.mode === "top",
|
|
3387
3470
|
scrollTop: surface.scrollTop,
|
|
3388
3471
|
atMaxSnap: this.size >= this.getAllowedRange().max - 0.5
|
|
3389
3472
|
});
|
|
@@ -3396,7 +3479,7 @@ var BottomSheetCore = class {
|
|
|
3396
3479
|
const controller = new GestureController(
|
|
3397
3480
|
this.buildGestureDeps(surface, {
|
|
3398
3481
|
manageTouchAction: false,
|
|
3399
|
-
deferStart: (e, delta) => this.decideContentDrag(surface, e, delta)
|
|
3482
|
+
deferStart: (e, delta, crossDelta) => this.decideContentDrag(surface, e, delta, crossDelta)
|
|
3400
3483
|
})
|
|
3401
3484
|
);
|
|
3402
3485
|
this.contentGesture = controller;
|
|
@@ -3522,7 +3605,11 @@ var BottomSheetCore = class {
|
|
|
3522
3605
|
);
|
|
3523
3606
|
}
|
|
3524
3607
|
}
|
|
3525
|
-
this.
|
|
3608
|
+
this.mountSliderKeyboard();
|
|
3609
|
+
this.scrim.attach();
|
|
3610
|
+
}
|
|
3611
|
+
mountSliderKeyboard() {
|
|
3612
|
+
const detach = installSliderKeyboard({
|
|
3526
3613
|
handle: this.handle,
|
|
3527
3614
|
mode: this.mode,
|
|
3528
3615
|
isDestroyed: () => this.destroyed,
|
|
@@ -3531,8 +3618,12 @@ var BottomSheetCore = class {
|
|
|
3531
3618
|
snapTo: (id) => {
|
|
3532
3619
|
void this.snapTo(id);
|
|
3533
3620
|
}
|
|
3534
|
-
})
|
|
3535
|
-
this.
|
|
3621
|
+
});
|
|
3622
|
+
this.detachSliderKeyboard = detach;
|
|
3623
|
+
this.teardowns.add(() => {
|
|
3624
|
+
this.detachSliderKeyboard?.();
|
|
3625
|
+
this.detachSliderKeyboard = null;
|
|
3626
|
+
});
|
|
3536
3627
|
}
|
|
3537
3628
|
settleAfterDrag(delta, velocity, kind = "touch") {
|
|
3538
3629
|
const signal = this.newCycle();
|
package/dist/react.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { c as EngineOptions, E as EngineState, A as AnchorOptions, e as ScrimStagesOptions, u as ScrimStageDef, S as SheetEventMap, C as CloseReason, v as ScrimUpdate, r as ScrimOverlayOptions, a as SnapPointDef, b as SheetMode } from './BottomSheetCore-VPJZcKcg.cjs';
|
|
2
|
+
export { d as SnapPoint } from './BottomSheetCore-VPJZcKcg.cjs';
|
|
3
3
|
import { OverlayOptions, OverlayState, Overlay as OverlayEngine } from './overlay.cjs';
|
|
4
4
|
export { OverlayEdge } from './overlay.cjs';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { CSSProperties, ReactNode } from 'react';
|
|
7
|
-
import { B as BottomSheetEngine } from './BottomSheetEngine-
|
|
7
|
+
import { B as BottomSheetEngine } from './BottomSheetEngine-B8C2CwF9.cjs';
|
|
8
8
|
import { T as TeleportTarget } from './teleport-7uYNiEAT.cjs';
|
|
9
9
|
import './transform-jVfAikE9.cjs';
|
|
10
10
|
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { c as EngineOptions, E as EngineState, A as AnchorOptions, e as ScrimStagesOptions, u as ScrimStageDef, S as SheetEventMap, C as CloseReason, v as ScrimUpdate, r as ScrimOverlayOptions, a as SnapPointDef, b as SheetMode } from './BottomSheetCore-Cgn8b_6A.js';
|
|
2
|
+
export { d as SnapPoint } from './BottomSheetCore-Cgn8b_6A.js';
|
|
3
3
|
import { OverlayOptions, OverlayState, Overlay as OverlayEngine } from './overlay.js';
|
|
4
4
|
export { OverlayEdge } from './overlay.js';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { CSSProperties, ReactNode } from 'react';
|
|
7
|
-
import { B as BottomSheetEngine } from './BottomSheetEngine-
|
|
7
|
+
import { B as BottomSheetEngine } from './BottomSheetEngine-DwYR_ygJ.js';
|
|
8
8
|
import { T as TeleportTarget } from './teleport-7uYNiEAT.js';
|
|
9
9
|
import './transform-jVfAikE9.js';
|
|
10
10
|
|