@surdeddd/bottom-sheet 0.6.1 → 0.7.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.
- package/README.md +31 -3
- package/dist/element.cjs +28 -26
- package/dist/element.iife.global.js +2 -2
- package/dist/element.js +28 -26
- package/dist/index.cjs +27 -25
- package/dist/index.js +27 -25
- package/dist/qwik.cjs +27 -25
- package/dist/qwik.js +27 -25
- package/dist/react.cjs +27 -25
- package/dist/react.js +27 -25
- package/dist/solid.cjs +30 -26
- package/dist/solid.d.cts +2 -0
- package/dist/solid.d.ts +2 -0
- package/dist/solid.js +30 -26
- package/dist/solid.source.jsx +30 -26
- package/dist/styles.css +4 -4
- package/dist/svelte-core.cjs +27 -25
- package/dist/svelte-core.js +27 -25
- package/dist/svelte.cjs +27 -25
- package/dist/svelte.js +27 -25
- package/dist/vue.cjs +27 -25
- package/dist/vue.js +27 -25
- package/package.json +1 -1
package/dist/solid.js
CHANGED
|
@@ -2648,8 +2648,8 @@ var BottomSheetEngine = class {
|
|
|
2648
2648
|
this.updateAriaSlider();
|
|
2649
2649
|
this.emit("snap", {
|
|
2650
2650
|
id,
|
|
2651
|
-
size:
|
|
2652
|
-
progress: this.computeProgress(
|
|
2651
|
+
size: this.size,
|
|
2652
|
+
progress: this.computeProgress(this.size)
|
|
2653
2653
|
});
|
|
2654
2654
|
if (wasClosed && target.size > 0) {
|
|
2655
2655
|
this.emit("open", { id });
|
|
@@ -2728,12 +2728,12 @@ var BottomSheetEngine = class {
|
|
|
2728
2728
|
const value = typeof h === "number" ? `${h}px` : h;
|
|
2729
2729
|
const axis = layoutAxis(this.mode);
|
|
2730
2730
|
this.element.style.setProperty(
|
|
2731
|
-
axis === "height" ? "
|
|
2731
|
+
axis === "height" ? "max-height" : "max-width",
|
|
2732
2732
|
value
|
|
2733
2733
|
);
|
|
2734
2734
|
if (typeof h === "number") {
|
|
2735
2735
|
this.maxHeightCap = h;
|
|
2736
|
-
this.
|
|
2736
|
+
this.recompute();
|
|
2737
2737
|
} else if (typeof window !== "undefined") {
|
|
2738
2738
|
const probe2 = document.createElement("div");
|
|
2739
2739
|
probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
|
|
@@ -2741,7 +2741,7 @@ var BottomSheetEngine = class {
|
|
|
2741
2741
|
const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
|
|
2742
2742
|
probe2.remove();
|
|
2743
2743
|
this.maxHeightCap = measured > 0 ? measured : void 0;
|
|
2744
|
-
this.
|
|
2744
|
+
this.recompute();
|
|
2745
2745
|
}
|
|
2746
2746
|
}
|
|
2747
2747
|
clampToMaxHeight() {
|
|
@@ -2749,9 +2749,6 @@ var BottomSheetEngine = class {
|
|
|
2749
2749
|
if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
|
|
2750
2750
|
this.snaps.setMaxAxisSize(this.maxHeightCap);
|
|
2751
2751
|
}
|
|
2752
|
-
if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
|
|
2753
|
-
this.applySize(this.maxHeightCap);
|
|
2754
|
-
}
|
|
2755
2752
|
}
|
|
2756
2753
|
setAllowed(ids, snap) {
|
|
2757
2754
|
if (this.destroyed) return;
|
|
@@ -2889,6 +2886,7 @@ var BottomSheetEngine = class {
|
|
|
2889
2886
|
recompute() {
|
|
2890
2887
|
if (this.destroyed) return;
|
|
2891
2888
|
this.snaps.recompute();
|
|
2889
|
+
this.clampToMaxHeight();
|
|
2892
2890
|
this.scrim.invalidateOpacityCache();
|
|
2893
2891
|
if (this.gesture?.isDragging) return;
|
|
2894
2892
|
const current = this.snaps.findById(this.activeId);
|
|
@@ -2946,9 +2944,10 @@ var BottomSheetEngine = class {
|
|
|
2946
2944
|
const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
|
|
2947
2945
|
const content = this.scrollContainer;
|
|
2948
2946
|
const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
|
|
2949
|
-
|
|
2947
|
+
const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
|
|
2948
|
+
if (typeof window === "undefined") return capped;
|
|
2950
2949
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
2951
|
-
return viewport > 0 ? Math.min(
|
|
2950
|
+
return viewport > 0 ? Math.min(capped, viewport) : capped;
|
|
2952
2951
|
}
|
|
2953
2952
|
installFitObserver() {
|
|
2954
2953
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3319,8 +3318,8 @@ var BottomSheetEngine = class {
|
|
|
3319
3318
|
this.updateAriaSlider();
|
|
3320
3319
|
this.emit("snap", {
|
|
3321
3320
|
id: target.id,
|
|
3322
|
-
size:
|
|
3323
|
-
progress: this.computeProgress(
|
|
3321
|
+
size: this.size,
|
|
3322
|
+
progress: this.computeProgress(this.size)
|
|
3324
3323
|
});
|
|
3325
3324
|
this.haptic();
|
|
3326
3325
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
@@ -3345,23 +3344,25 @@ var BottomSheetEngine = class {
|
|
|
3345
3344
|
}
|
|
3346
3345
|
}
|
|
3347
3346
|
applySize(size) {
|
|
3348
|
-
|
|
3349
|
-
const
|
|
3347
|
+
const cap = this.snaps.getMaxAxisSize();
|
|
3348
|
+
const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
|
|
3349
|
+
this.size = clamped;
|
|
3350
|
+
const offset = cap - clamped;
|
|
3350
3351
|
const style = this.element.style;
|
|
3351
3352
|
style.transform = this.transformTemplate(offset);
|
|
3352
|
-
if (this.sizeWriteSentinel.shouldWrite(
|
|
3353
|
-
style.setProperty("--bs-size", `${
|
|
3353
|
+
if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
|
|
3354
|
+
style.setProperty("--bs-size", `${clamped}px`);
|
|
3354
3355
|
if (this.scrimParent) {
|
|
3355
|
-
this.scrimParent.style.setProperty("--bs-size", `${
|
|
3356
|
+
this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
|
|
3356
3357
|
}
|
|
3357
3358
|
if (this.anchorHost && this.anchorHost !== this.scrimParent) {
|
|
3358
|
-
this.anchorHost.style.setProperty("--bs-size", `${
|
|
3359
|
+
this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
|
|
3359
3360
|
}
|
|
3360
3361
|
if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
|
|
3361
|
-
this.rootEl.style.setProperty("--bs-size", `${
|
|
3362
|
+
this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
|
|
3362
3363
|
}
|
|
3363
3364
|
}
|
|
3364
|
-
const progress = this.computeProgress(
|
|
3365
|
+
const progress = this.computeProgress(clamped);
|
|
3365
3366
|
const progressChanged = this.progressWriteSentinel.shouldWrite(
|
|
3366
3367
|
progress,
|
|
3367
3368
|
OPACITY_WRITE_EPSILON
|
|
@@ -3378,14 +3379,15 @@ var BottomSheetEngine = class {
|
|
|
3378
3379
|
this.scrim.applyOpacity(progress, progressChanged);
|
|
3379
3380
|
if (progressChanged && this.bus.listenerCount("progress") > 0) {
|
|
3380
3381
|
this.progressPayload.value = progress;
|
|
3381
|
-
this.progressPayload.size =
|
|
3382
|
+
this.progressPayload.size = clamped;
|
|
3382
3383
|
this.emit("progress", this.progressPayload);
|
|
3383
3384
|
}
|
|
3384
3385
|
}
|
|
3385
3386
|
computeProgress(size) {
|
|
3386
3387
|
const { min, max } = this.getAllowedRange();
|
|
3387
|
-
|
|
3388
|
-
|
|
3388
|
+
const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
|
|
3389
|
+
if (reachableMax <= min) return 0;
|
|
3390
|
+
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
3389
3391
|
}
|
|
3390
3392
|
handleOpen() {
|
|
3391
3393
|
sheetStack.promote(this.id);
|
|
@@ -3409,8 +3411,8 @@ var BottomSheetEngine = class {
|
|
|
3409
3411
|
this.updateAriaSlider();
|
|
3410
3412
|
this.emit("snap", {
|
|
3411
3413
|
id: target.id,
|
|
3412
|
-
size:
|
|
3413
|
-
progress: this.computeProgress(
|
|
3414
|
+
size: this.size,
|
|
3415
|
+
progress: this.computeProgress(this.size)
|
|
3414
3416
|
});
|
|
3415
3417
|
if (target.size > 0 && !this.lifecycle.isInstalled) {
|
|
3416
3418
|
this.emit("open", { id: target.id });
|
|
@@ -3469,7 +3471,9 @@ var BottomSheet = (props) => {
|
|
|
3469
3471
|
closeOnBack: props.closeOnBack,
|
|
3470
3472
|
lockBodyScroll: props.lockBodyScroll,
|
|
3471
3473
|
rubberBand: props.rubberBand,
|
|
3472
|
-
backdropRange: props.backdropRange
|
|
3474
|
+
backdropRange: props.backdropRange,
|
|
3475
|
+
radius: props.radius,
|
|
3476
|
+
maxHeight: props.maxHeight
|
|
3473
3477
|
};
|
|
3474
3478
|
engine = new BottomSheetEngine(engineOpts);
|
|
3475
3479
|
props.engineRef?.(engine);
|
package/dist/solid.source.jsx
CHANGED
|
@@ -2650,8 +2650,8 @@ var BottomSheetEngine = class {
|
|
|
2650
2650
|
this.updateAriaSlider();
|
|
2651
2651
|
this.emit("snap", {
|
|
2652
2652
|
id,
|
|
2653
|
-
size:
|
|
2654
|
-
progress: this.computeProgress(
|
|
2653
|
+
size: this.size,
|
|
2654
|
+
progress: this.computeProgress(this.size)
|
|
2655
2655
|
});
|
|
2656
2656
|
if (wasClosed && target.size > 0) {
|
|
2657
2657
|
this.emit("open", { id });
|
|
@@ -2730,12 +2730,12 @@ var BottomSheetEngine = class {
|
|
|
2730
2730
|
const value = typeof h === "number" ? `${h}px` : h;
|
|
2731
2731
|
const axis = layoutAxis(this.mode);
|
|
2732
2732
|
this.element.style.setProperty(
|
|
2733
|
-
axis === "height" ? "
|
|
2733
|
+
axis === "height" ? "max-height" : "max-width",
|
|
2734
2734
|
value
|
|
2735
2735
|
);
|
|
2736
2736
|
if (typeof h === "number") {
|
|
2737
2737
|
this.maxHeightCap = h;
|
|
2738
|
-
this.
|
|
2738
|
+
this.recompute();
|
|
2739
2739
|
} else if (typeof window !== "undefined") {
|
|
2740
2740
|
const probe2 = document.createElement("div");
|
|
2741
2741
|
probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
|
|
@@ -2743,7 +2743,7 @@ var BottomSheetEngine = class {
|
|
|
2743
2743
|
const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
|
|
2744
2744
|
probe2.remove();
|
|
2745
2745
|
this.maxHeightCap = measured > 0 ? measured : void 0;
|
|
2746
|
-
this.
|
|
2746
|
+
this.recompute();
|
|
2747
2747
|
}
|
|
2748
2748
|
}
|
|
2749
2749
|
clampToMaxHeight() {
|
|
@@ -2751,9 +2751,6 @@ var BottomSheetEngine = class {
|
|
|
2751
2751
|
if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
|
|
2752
2752
|
this.snaps.setMaxAxisSize(this.maxHeightCap);
|
|
2753
2753
|
}
|
|
2754
|
-
if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
|
|
2755
|
-
this.applySize(this.maxHeightCap);
|
|
2756
|
-
}
|
|
2757
2754
|
}
|
|
2758
2755
|
setAllowed(ids, snap) {
|
|
2759
2756
|
if (this.destroyed) return;
|
|
@@ -2891,6 +2888,7 @@ var BottomSheetEngine = class {
|
|
|
2891
2888
|
recompute() {
|
|
2892
2889
|
if (this.destroyed) return;
|
|
2893
2890
|
this.snaps.recompute();
|
|
2891
|
+
this.clampToMaxHeight();
|
|
2894
2892
|
this.scrim.invalidateOpacityCache();
|
|
2895
2893
|
if (this.gesture?.isDragging) return;
|
|
2896
2894
|
const current = this.snaps.findById(this.activeId);
|
|
@@ -2948,9 +2946,10 @@ var BottomSheetEngine = class {
|
|
|
2948
2946
|
const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
|
|
2949
2947
|
const content = this.scrollContainer;
|
|
2950
2948
|
const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
|
|
2951
|
-
|
|
2949
|
+
const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
|
|
2950
|
+
if (typeof window === "undefined") return capped;
|
|
2952
2951
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
2953
|
-
return viewport > 0 ? Math.min(
|
|
2952
|
+
return viewport > 0 ? Math.min(capped, viewport) : capped;
|
|
2954
2953
|
}
|
|
2955
2954
|
installFitObserver() {
|
|
2956
2955
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3321,8 +3320,8 @@ var BottomSheetEngine = class {
|
|
|
3321
3320
|
this.updateAriaSlider();
|
|
3322
3321
|
this.emit("snap", {
|
|
3323
3322
|
id: target.id,
|
|
3324
|
-
size:
|
|
3325
|
-
progress: this.computeProgress(
|
|
3323
|
+
size: this.size,
|
|
3324
|
+
progress: this.computeProgress(this.size)
|
|
3326
3325
|
});
|
|
3327
3326
|
this.haptic();
|
|
3328
3327
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
@@ -3347,23 +3346,25 @@ var BottomSheetEngine = class {
|
|
|
3347
3346
|
}
|
|
3348
3347
|
}
|
|
3349
3348
|
applySize(size) {
|
|
3350
|
-
|
|
3351
|
-
const
|
|
3349
|
+
const cap = this.snaps.getMaxAxisSize();
|
|
3350
|
+
const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
|
|
3351
|
+
this.size = clamped;
|
|
3352
|
+
const offset = cap - clamped;
|
|
3352
3353
|
const style = this.element.style;
|
|
3353
3354
|
style.transform = this.transformTemplate(offset);
|
|
3354
|
-
if (this.sizeWriteSentinel.shouldWrite(
|
|
3355
|
-
style.setProperty("--bs-size", `${
|
|
3355
|
+
if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
|
|
3356
|
+
style.setProperty("--bs-size", `${clamped}px`);
|
|
3356
3357
|
if (this.scrimParent) {
|
|
3357
|
-
this.scrimParent.style.setProperty("--bs-size", `${
|
|
3358
|
+
this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
|
|
3358
3359
|
}
|
|
3359
3360
|
if (this.anchorHost && this.anchorHost !== this.scrimParent) {
|
|
3360
|
-
this.anchorHost.style.setProperty("--bs-size", `${
|
|
3361
|
+
this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
|
|
3361
3362
|
}
|
|
3362
3363
|
if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
|
|
3363
|
-
this.rootEl.style.setProperty("--bs-size", `${
|
|
3364
|
+
this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
|
|
3364
3365
|
}
|
|
3365
3366
|
}
|
|
3366
|
-
const progress = this.computeProgress(
|
|
3367
|
+
const progress = this.computeProgress(clamped);
|
|
3367
3368
|
const progressChanged = this.progressWriteSentinel.shouldWrite(
|
|
3368
3369
|
progress,
|
|
3369
3370
|
OPACITY_WRITE_EPSILON
|
|
@@ -3380,14 +3381,15 @@ var BottomSheetEngine = class {
|
|
|
3380
3381
|
this.scrim.applyOpacity(progress, progressChanged);
|
|
3381
3382
|
if (progressChanged && this.bus.listenerCount("progress") > 0) {
|
|
3382
3383
|
this.progressPayload.value = progress;
|
|
3383
|
-
this.progressPayload.size =
|
|
3384
|
+
this.progressPayload.size = clamped;
|
|
3384
3385
|
this.emit("progress", this.progressPayload);
|
|
3385
3386
|
}
|
|
3386
3387
|
}
|
|
3387
3388
|
computeProgress(size) {
|
|
3388
3389
|
const { min, max } = this.getAllowedRange();
|
|
3389
|
-
|
|
3390
|
-
|
|
3390
|
+
const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
|
|
3391
|
+
if (reachableMax <= min) return 0;
|
|
3392
|
+
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
3391
3393
|
}
|
|
3392
3394
|
handleOpen() {
|
|
3393
3395
|
sheetStack.promote(this.id);
|
|
@@ -3411,8 +3413,8 @@ var BottomSheetEngine = class {
|
|
|
3411
3413
|
this.updateAriaSlider();
|
|
3412
3414
|
this.emit("snap", {
|
|
3413
3415
|
id: target.id,
|
|
3414
|
-
size:
|
|
3415
|
-
progress: this.computeProgress(
|
|
3416
|
+
size: this.size,
|
|
3417
|
+
progress: this.computeProgress(this.size)
|
|
3416
3418
|
});
|
|
3417
3419
|
if (target.size > 0 && !this.lifecycle.isInstalled) {
|
|
3418
3420
|
this.emit("open", { id: target.id });
|
|
@@ -3467,7 +3469,9 @@ var BottomSheet = (props) => {
|
|
|
3467
3469
|
closeOnBack: props.closeOnBack,
|
|
3468
3470
|
lockBodyScroll: props.lockBodyScroll,
|
|
3469
3471
|
rubberBand: props.rubberBand,
|
|
3470
|
-
backdropRange: props.backdropRange
|
|
3472
|
+
backdropRange: props.backdropRange,
|
|
3473
|
+
radius: props.radius,
|
|
3474
|
+
maxHeight: props.maxHeight
|
|
3471
3475
|
};
|
|
3472
3476
|
engine = new BottomSheetEngine(engineOpts);
|
|
3473
3477
|
props.engineRef?.(engine);
|
package/dist/styles.css
CHANGED
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
display: flex;
|
|
119
119
|
flex-direction: column;
|
|
120
120
|
justify-content: center;
|
|
121
|
-
padding: 8px 16px 4px;
|
|
121
|
+
padding: var(--bs-handle-padding, 8px 16px 4px);
|
|
122
122
|
cursor: grab;
|
|
123
123
|
touch-action: none;
|
|
124
124
|
user-select: none;
|
|
@@ -246,7 +246,7 @@
|
|
|
246
246
|
|
|
247
247
|
.bs-header {
|
|
248
248
|
flex: 0 0 auto;
|
|
249
|
-
padding: 0 16px 8px;
|
|
249
|
+
padding: var(--bs-header-padding, 0 16px 8px);
|
|
250
250
|
background: var(--bs-surface, var(--bs-surface-d));
|
|
251
251
|
}
|
|
252
252
|
|
|
@@ -257,12 +257,12 @@
|
|
|
257
257
|
-webkit-overflow-scrolling: touch;
|
|
258
258
|
overscroll-behavior: contain;
|
|
259
259
|
user-select: text;
|
|
260
|
-
padding: 0 16px 16px;
|
|
260
|
+
padding: var(--bs-content-padding, 0 16px 16px);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
.bs-footer {
|
|
264
264
|
flex: 0 0 auto;
|
|
265
|
-
padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
|
|
265
|
+
padding: var(--bs-footer-padding, 12px 16px calc(12px + env(safe-area-inset-bottom)));
|
|
266
266
|
border-top: 1px solid var(--bs-surface-border, var(--bs-surface-border-d));
|
|
267
267
|
background: var(--bs-surface, var(--bs-surface-d));
|
|
268
268
|
}
|
package/dist/svelte-core.cjs
CHANGED
|
@@ -2649,8 +2649,8 @@ var BottomSheetEngine = class {
|
|
|
2649
2649
|
this.updateAriaSlider();
|
|
2650
2650
|
this.emit("snap", {
|
|
2651
2651
|
id,
|
|
2652
|
-
size:
|
|
2653
|
-
progress: this.computeProgress(
|
|
2652
|
+
size: this.size,
|
|
2653
|
+
progress: this.computeProgress(this.size)
|
|
2654
2654
|
});
|
|
2655
2655
|
if (wasClosed && target.size > 0) {
|
|
2656
2656
|
this.emit("open", { id });
|
|
@@ -2729,12 +2729,12 @@ var BottomSheetEngine = class {
|
|
|
2729
2729
|
const value = typeof h === "number" ? `${h}px` : h;
|
|
2730
2730
|
const axis = layoutAxis(this.mode);
|
|
2731
2731
|
this.element.style.setProperty(
|
|
2732
|
-
axis === "height" ? "
|
|
2732
|
+
axis === "height" ? "max-height" : "max-width",
|
|
2733
2733
|
value
|
|
2734
2734
|
);
|
|
2735
2735
|
if (typeof h === "number") {
|
|
2736
2736
|
this.maxHeightCap = h;
|
|
2737
|
-
this.
|
|
2737
|
+
this.recompute();
|
|
2738
2738
|
} else if (typeof window !== "undefined") {
|
|
2739
2739
|
const probe2 = document.createElement("div");
|
|
2740
2740
|
probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
|
|
@@ -2742,7 +2742,7 @@ var BottomSheetEngine = class {
|
|
|
2742
2742
|
const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
|
|
2743
2743
|
probe2.remove();
|
|
2744
2744
|
this.maxHeightCap = measured > 0 ? measured : void 0;
|
|
2745
|
-
this.
|
|
2745
|
+
this.recompute();
|
|
2746
2746
|
}
|
|
2747
2747
|
}
|
|
2748
2748
|
clampToMaxHeight() {
|
|
@@ -2750,9 +2750,6 @@ var BottomSheetEngine = class {
|
|
|
2750
2750
|
if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
|
|
2751
2751
|
this.snaps.setMaxAxisSize(this.maxHeightCap);
|
|
2752
2752
|
}
|
|
2753
|
-
if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
|
|
2754
|
-
this.applySize(this.maxHeightCap);
|
|
2755
|
-
}
|
|
2756
2753
|
}
|
|
2757
2754
|
setAllowed(ids, snap) {
|
|
2758
2755
|
if (this.destroyed) return;
|
|
@@ -2890,6 +2887,7 @@ var BottomSheetEngine = class {
|
|
|
2890
2887
|
recompute() {
|
|
2891
2888
|
if (this.destroyed) return;
|
|
2892
2889
|
this.snaps.recompute();
|
|
2890
|
+
this.clampToMaxHeight();
|
|
2893
2891
|
this.scrim.invalidateOpacityCache();
|
|
2894
2892
|
if (this.gesture?.isDragging) return;
|
|
2895
2893
|
const current = this.snaps.findById(this.activeId);
|
|
@@ -2947,9 +2945,10 @@ var BottomSheetEngine = class {
|
|
|
2947
2945
|
const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
|
|
2948
2946
|
const content = this.scrollContainer;
|
|
2949
2947
|
const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
|
|
2950
|
-
|
|
2948
|
+
const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
|
|
2949
|
+
if (typeof window === "undefined") return capped;
|
|
2951
2950
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
2952
|
-
return viewport > 0 ? Math.min(
|
|
2951
|
+
return viewport > 0 ? Math.min(capped, viewport) : capped;
|
|
2953
2952
|
}
|
|
2954
2953
|
installFitObserver() {
|
|
2955
2954
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3320,8 +3319,8 @@ var BottomSheetEngine = class {
|
|
|
3320
3319
|
this.updateAriaSlider();
|
|
3321
3320
|
this.emit("snap", {
|
|
3322
3321
|
id: target.id,
|
|
3323
|
-
size:
|
|
3324
|
-
progress: this.computeProgress(
|
|
3322
|
+
size: this.size,
|
|
3323
|
+
progress: this.computeProgress(this.size)
|
|
3325
3324
|
});
|
|
3326
3325
|
this.haptic();
|
|
3327
3326
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
@@ -3346,23 +3345,25 @@ var BottomSheetEngine = class {
|
|
|
3346
3345
|
}
|
|
3347
3346
|
}
|
|
3348
3347
|
applySize(size) {
|
|
3349
|
-
|
|
3350
|
-
const
|
|
3348
|
+
const cap = this.snaps.getMaxAxisSize();
|
|
3349
|
+
const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
|
|
3350
|
+
this.size = clamped;
|
|
3351
|
+
const offset = cap - clamped;
|
|
3351
3352
|
const style = this.element.style;
|
|
3352
3353
|
style.transform = this.transformTemplate(offset);
|
|
3353
|
-
if (this.sizeWriteSentinel.shouldWrite(
|
|
3354
|
-
style.setProperty("--bs-size", `${
|
|
3354
|
+
if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
|
|
3355
|
+
style.setProperty("--bs-size", `${clamped}px`);
|
|
3355
3356
|
if (this.scrimParent) {
|
|
3356
|
-
this.scrimParent.style.setProperty("--bs-size", `${
|
|
3357
|
+
this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
|
|
3357
3358
|
}
|
|
3358
3359
|
if (this.anchorHost && this.anchorHost !== this.scrimParent) {
|
|
3359
|
-
this.anchorHost.style.setProperty("--bs-size", `${
|
|
3360
|
+
this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
|
|
3360
3361
|
}
|
|
3361
3362
|
if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
|
|
3362
|
-
this.rootEl.style.setProperty("--bs-size", `${
|
|
3363
|
+
this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
|
|
3363
3364
|
}
|
|
3364
3365
|
}
|
|
3365
|
-
const progress = this.computeProgress(
|
|
3366
|
+
const progress = this.computeProgress(clamped);
|
|
3366
3367
|
const progressChanged = this.progressWriteSentinel.shouldWrite(
|
|
3367
3368
|
progress,
|
|
3368
3369
|
OPACITY_WRITE_EPSILON
|
|
@@ -3379,14 +3380,15 @@ var BottomSheetEngine = class {
|
|
|
3379
3380
|
this.scrim.applyOpacity(progress, progressChanged);
|
|
3380
3381
|
if (progressChanged && this.bus.listenerCount("progress") > 0) {
|
|
3381
3382
|
this.progressPayload.value = progress;
|
|
3382
|
-
this.progressPayload.size =
|
|
3383
|
+
this.progressPayload.size = clamped;
|
|
3383
3384
|
this.emit("progress", this.progressPayload);
|
|
3384
3385
|
}
|
|
3385
3386
|
}
|
|
3386
3387
|
computeProgress(size) {
|
|
3387
3388
|
const { min, max } = this.getAllowedRange();
|
|
3388
|
-
|
|
3389
|
-
|
|
3389
|
+
const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
|
|
3390
|
+
if (reachableMax <= min) return 0;
|
|
3391
|
+
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
3390
3392
|
}
|
|
3391
3393
|
handleOpen() {
|
|
3392
3394
|
sheetStack.promote(this.id);
|
|
@@ -3410,8 +3412,8 @@ var BottomSheetEngine = class {
|
|
|
3410
3412
|
this.updateAriaSlider();
|
|
3411
3413
|
this.emit("snap", {
|
|
3412
3414
|
id: target.id,
|
|
3413
|
-
size:
|
|
3414
|
-
progress: this.computeProgress(
|
|
3415
|
+
size: this.size,
|
|
3416
|
+
progress: this.computeProgress(this.size)
|
|
3415
3417
|
});
|
|
3416
3418
|
if (target.size > 0 && !this.lifecycle.isInstalled) {
|
|
3417
3419
|
this.emit("open", { id: target.id });
|
package/dist/svelte-core.js
CHANGED
|
@@ -2647,8 +2647,8 @@ var BottomSheetEngine = class {
|
|
|
2647
2647
|
this.updateAriaSlider();
|
|
2648
2648
|
this.emit("snap", {
|
|
2649
2649
|
id,
|
|
2650
|
-
size:
|
|
2651
|
-
progress: this.computeProgress(
|
|
2650
|
+
size: this.size,
|
|
2651
|
+
progress: this.computeProgress(this.size)
|
|
2652
2652
|
});
|
|
2653
2653
|
if (wasClosed && target.size > 0) {
|
|
2654
2654
|
this.emit("open", { id });
|
|
@@ -2727,12 +2727,12 @@ var BottomSheetEngine = class {
|
|
|
2727
2727
|
const value = typeof h === "number" ? `${h}px` : h;
|
|
2728
2728
|
const axis = layoutAxis(this.mode);
|
|
2729
2729
|
this.element.style.setProperty(
|
|
2730
|
-
axis === "height" ? "
|
|
2730
|
+
axis === "height" ? "max-height" : "max-width",
|
|
2731
2731
|
value
|
|
2732
2732
|
);
|
|
2733
2733
|
if (typeof h === "number") {
|
|
2734
2734
|
this.maxHeightCap = h;
|
|
2735
|
-
this.
|
|
2735
|
+
this.recompute();
|
|
2736
2736
|
} else if (typeof window !== "undefined") {
|
|
2737
2737
|
const probe2 = document.createElement("div");
|
|
2738
2738
|
probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
|
|
@@ -2740,7 +2740,7 @@ var BottomSheetEngine = class {
|
|
|
2740
2740
|
const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
|
|
2741
2741
|
probe2.remove();
|
|
2742
2742
|
this.maxHeightCap = measured > 0 ? measured : void 0;
|
|
2743
|
-
this.
|
|
2743
|
+
this.recompute();
|
|
2744
2744
|
}
|
|
2745
2745
|
}
|
|
2746
2746
|
clampToMaxHeight() {
|
|
@@ -2748,9 +2748,6 @@ var BottomSheetEngine = class {
|
|
|
2748
2748
|
if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
|
|
2749
2749
|
this.snaps.setMaxAxisSize(this.maxHeightCap);
|
|
2750
2750
|
}
|
|
2751
|
-
if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
|
|
2752
|
-
this.applySize(this.maxHeightCap);
|
|
2753
|
-
}
|
|
2754
2751
|
}
|
|
2755
2752
|
setAllowed(ids, snap) {
|
|
2756
2753
|
if (this.destroyed) return;
|
|
@@ -2888,6 +2885,7 @@ var BottomSheetEngine = class {
|
|
|
2888
2885
|
recompute() {
|
|
2889
2886
|
if (this.destroyed) return;
|
|
2890
2887
|
this.snaps.recompute();
|
|
2888
|
+
this.clampToMaxHeight();
|
|
2891
2889
|
this.scrim.invalidateOpacityCache();
|
|
2892
2890
|
if (this.gesture?.isDragging) return;
|
|
2893
2891
|
const current = this.snaps.findById(this.activeId);
|
|
@@ -2945,9 +2943,10 @@ var BottomSheetEngine = class {
|
|
|
2945
2943
|
const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
|
|
2946
2944
|
const content = this.scrollContainer;
|
|
2947
2945
|
const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
|
|
2948
|
-
|
|
2946
|
+
const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
|
|
2947
|
+
if (typeof window === "undefined") return capped;
|
|
2949
2948
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
2950
|
-
return viewport > 0 ? Math.min(
|
|
2949
|
+
return viewport > 0 ? Math.min(capped, viewport) : capped;
|
|
2951
2950
|
}
|
|
2952
2951
|
installFitObserver() {
|
|
2953
2952
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3318,8 +3317,8 @@ var BottomSheetEngine = class {
|
|
|
3318
3317
|
this.updateAriaSlider();
|
|
3319
3318
|
this.emit("snap", {
|
|
3320
3319
|
id: target.id,
|
|
3321
|
-
size:
|
|
3322
|
-
progress: this.computeProgress(
|
|
3320
|
+
size: this.size,
|
|
3321
|
+
progress: this.computeProgress(this.size)
|
|
3323
3322
|
});
|
|
3324
3323
|
this.haptic();
|
|
3325
3324
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
@@ -3344,23 +3343,25 @@ var BottomSheetEngine = class {
|
|
|
3344
3343
|
}
|
|
3345
3344
|
}
|
|
3346
3345
|
applySize(size) {
|
|
3347
|
-
|
|
3348
|
-
const
|
|
3346
|
+
const cap = this.snaps.getMaxAxisSize();
|
|
3347
|
+
const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
|
|
3348
|
+
this.size = clamped;
|
|
3349
|
+
const offset = cap - clamped;
|
|
3349
3350
|
const style = this.element.style;
|
|
3350
3351
|
style.transform = this.transformTemplate(offset);
|
|
3351
|
-
if (this.sizeWriteSentinel.shouldWrite(
|
|
3352
|
-
style.setProperty("--bs-size", `${
|
|
3352
|
+
if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
|
|
3353
|
+
style.setProperty("--bs-size", `${clamped}px`);
|
|
3353
3354
|
if (this.scrimParent) {
|
|
3354
|
-
this.scrimParent.style.setProperty("--bs-size", `${
|
|
3355
|
+
this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
|
|
3355
3356
|
}
|
|
3356
3357
|
if (this.anchorHost && this.anchorHost !== this.scrimParent) {
|
|
3357
|
-
this.anchorHost.style.setProperty("--bs-size", `${
|
|
3358
|
+
this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
|
|
3358
3359
|
}
|
|
3359
3360
|
if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
|
|
3360
|
-
this.rootEl.style.setProperty("--bs-size", `${
|
|
3361
|
+
this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
|
|
3361
3362
|
}
|
|
3362
3363
|
}
|
|
3363
|
-
const progress = this.computeProgress(
|
|
3364
|
+
const progress = this.computeProgress(clamped);
|
|
3364
3365
|
const progressChanged = this.progressWriteSentinel.shouldWrite(
|
|
3365
3366
|
progress,
|
|
3366
3367
|
OPACITY_WRITE_EPSILON
|
|
@@ -3377,14 +3378,15 @@ var BottomSheetEngine = class {
|
|
|
3377
3378
|
this.scrim.applyOpacity(progress, progressChanged);
|
|
3378
3379
|
if (progressChanged && this.bus.listenerCount("progress") > 0) {
|
|
3379
3380
|
this.progressPayload.value = progress;
|
|
3380
|
-
this.progressPayload.size =
|
|
3381
|
+
this.progressPayload.size = clamped;
|
|
3381
3382
|
this.emit("progress", this.progressPayload);
|
|
3382
3383
|
}
|
|
3383
3384
|
}
|
|
3384
3385
|
computeProgress(size) {
|
|
3385
3386
|
const { min, max } = this.getAllowedRange();
|
|
3386
|
-
|
|
3387
|
-
|
|
3387
|
+
const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
|
|
3388
|
+
if (reachableMax <= min) return 0;
|
|
3389
|
+
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
3388
3390
|
}
|
|
3389
3391
|
handleOpen() {
|
|
3390
3392
|
sheetStack.promote(this.id);
|
|
@@ -3408,8 +3410,8 @@ var BottomSheetEngine = class {
|
|
|
3408
3410
|
this.updateAriaSlider();
|
|
3409
3411
|
this.emit("snap", {
|
|
3410
3412
|
id: target.id,
|
|
3411
|
-
size:
|
|
3412
|
-
progress: this.computeProgress(
|
|
3413
|
+
size: this.size,
|
|
3414
|
+
progress: this.computeProgress(this.size)
|
|
3413
3415
|
});
|
|
3414
3416
|
if (target.size > 0 && !this.lifecycle.isInstalled) {
|
|
3415
3417
|
this.emit("open", { id: target.id });
|