@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/element.js
CHANGED
|
@@ -2887,8 +2887,8 @@ var init_BottomSheetEngine = __esm({
|
|
|
2887
2887
|
this.updateAriaSlider();
|
|
2888
2888
|
this.emit("snap", {
|
|
2889
2889
|
id,
|
|
2890
|
-
size:
|
|
2891
|
-
progress: this.computeProgress(
|
|
2890
|
+
size: this.size,
|
|
2891
|
+
progress: this.computeProgress(this.size)
|
|
2892
2892
|
});
|
|
2893
2893
|
if (wasClosed && target.size > 0) {
|
|
2894
2894
|
this.emit("open", { id });
|
|
@@ -2967,12 +2967,12 @@ var init_BottomSheetEngine = __esm({
|
|
|
2967
2967
|
const value = typeof h === "number" ? `${h}px` : h;
|
|
2968
2968
|
const axis = layoutAxis(this.mode);
|
|
2969
2969
|
this.element.style.setProperty(
|
|
2970
|
-
axis === "height" ? "
|
|
2970
|
+
axis === "height" ? "max-height" : "max-width",
|
|
2971
2971
|
value
|
|
2972
2972
|
);
|
|
2973
2973
|
if (typeof h === "number") {
|
|
2974
2974
|
this.maxHeightCap = h;
|
|
2975
|
-
this.
|
|
2975
|
+
this.recompute();
|
|
2976
2976
|
} else if (typeof window !== "undefined") {
|
|
2977
2977
|
const probe2 = document.createElement("div");
|
|
2978
2978
|
probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
|
|
@@ -2980,7 +2980,7 @@ var init_BottomSheetEngine = __esm({
|
|
|
2980
2980
|
const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
|
|
2981
2981
|
probe2.remove();
|
|
2982
2982
|
this.maxHeightCap = measured > 0 ? measured : void 0;
|
|
2983
|
-
this.
|
|
2983
|
+
this.recompute();
|
|
2984
2984
|
}
|
|
2985
2985
|
}
|
|
2986
2986
|
clampToMaxHeight() {
|
|
@@ -2988,9 +2988,6 @@ var init_BottomSheetEngine = __esm({
|
|
|
2988
2988
|
if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
|
|
2989
2989
|
this.snaps.setMaxAxisSize(this.maxHeightCap);
|
|
2990
2990
|
}
|
|
2991
|
-
if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
|
|
2992
|
-
this.applySize(this.maxHeightCap);
|
|
2993
|
-
}
|
|
2994
2991
|
}
|
|
2995
2992
|
setAllowed(ids, snap) {
|
|
2996
2993
|
if (this.destroyed) return;
|
|
@@ -3128,6 +3125,7 @@ var init_BottomSheetEngine = __esm({
|
|
|
3128
3125
|
recompute() {
|
|
3129
3126
|
if (this.destroyed) return;
|
|
3130
3127
|
this.snaps.recompute();
|
|
3128
|
+
this.clampToMaxHeight();
|
|
3131
3129
|
this.scrim.invalidateOpacityCache();
|
|
3132
3130
|
if (this.gesture?.isDragging) return;
|
|
3133
3131
|
const current = this.snaps.findById(this.activeId);
|
|
@@ -3185,9 +3183,10 @@ var init_BottomSheetEngine = __esm({
|
|
|
3185
3183
|
const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
|
|
3186
3184
|
const content = this.scrollContainer;
|
|
3187
3185
|
const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
|
|
3188
|
-
|
|
3186
|
+
const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
|
|
3187
|
+
if (typeof window === "undefined") return capped;
|
|
3189
3188
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
3190
|
-
return viewport > 0 ? Math.min(
|
|
3189
|
+
return viewport > 0 ? Math.min(capped, viewport) : capped;
|
|
3191
3190
|
}
|
|
3192
3191
|
installFitObserver() {
|
|
3193
3192
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3558,8 +3557,8 @@ var init_BottomSheetEngine = __esm({
|
|
|
3558
3557
|
this.updateAriaSlider();
|
|
3559
3558
|
this.emit("snap", {
|
|
3560
3559
|
id: target.id,
|
|
3561
|
-
size:
|
|
3562
|
-
progress: this.computeProgress(
|
|
3560
|
+
size: this.size,
|
|
3561
|
+
progress: this.computeProgress(this.size)
|
|
3563
3562
|
});
|
|
3564
3563
|
this.haptic();
|
|
3565
3564
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
@@ -3584,23 +3583,25 @@ var init_BottomSheetEngine = __esm({
|
|
|
3584
3583
|
}
|
|
3585
3584
|
}
|
|
3586
3585
|
applySize(size) {
|
|
3587
|
-
|
|
3588
|
-
const
|
|
3586
|
+
const cap = this.snaps.getMaxAxisSize();
|
|
3587
|
+
const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
|
|
3588
|
+
this.size = clamped;
|
|
3589
|
+
const offset = cap - clamped;
|
|
3589
3590
|
const style = this.element.style;
|
|
3590
3591
|
style.transform = this.transformTemplate(offset);
|
|
3591
|
-
if (this.sizeWriteSentinel.shouldWrite(
|
|
3592
|
-
style.setProperty("--bs-size", `${
|
|
3592
|
+
if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
|
|
3593
|
+
style.setProperty("--bs-size", `${clamped}px`);
|
|
3593
3594
|
if (this.scrimParent) {
|
|
3594
|
-
this.scrimParent.style.setProperty("--bs-size", `${
|
|
3595
|
+
this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
|
|
3595
3596
|
}
|
|
3596
3597
|
if (this.anchorHost && this.anchorHost !== this.scrimParent) {
|
|
3597
|
-
this.anchorHost.style.setProperty("--bs-size", `${
|
|
3598
|
+
this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
|
|
3598
3599
|
}
|
|
3599
3600
|
if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
|
|
3600
|
-
this.rootEl.style.setProperty("--bs-size", `${
|
|
3601
|
+
this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
|
|
3601
3602
|
}
|
|
3602
3603
|
}
|
|
3603
|
-
const progress = this.computeProgress(
|
|
3604
|
+
const progress = this.computeProgress(clamped);
|
|
3604
3605
|
const progressChanged = this.progressWriteSentinel.shouldWrite(
|
|
3605
3606
|
progress,
|
|
3606
3607
|
OPACITY_WRITE_EPSILON
|
|
@@ -3617,14 +3618,15 @@ var init_BottomSheetEngine = __esm({
|
|
|
3617
3618
|
this.scrim.applyOpacity(progress, progressChanged);
|
|
3618
3619
|
if (progressChanged && this.bus.listenerCount("progress") > 0) {
|
|
3619
3620
|
this.progressPayload.value = progress;
|
|
3620
|
-
this.progressPayload.size =
|
|
3621
|
+
this.progressPayload.size = clamped;
|
|
3621
3622
|
this.emit("progress", this.progressPayload);
|
|
3622
3623
|
}
|
|
3623
3624
|
}
|
|
3624
3625
|
computeProgress(size) {
|
|
3625
3626
|
const { min, max } = this.getAllowedRange();
|
|
3626
|
-
|
|
3627
|
-
|
|
3627
|
+
const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
|
|
3628
|
+
if (reachableMax <= min) return 0;
|
|
3629
|
+
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
3628
3630
|
}
|
|
3629
3631
|
handleOpen() {
|
|
3630
3632
|
sheetStack.promote(this.id);
|
|
@@ -3648,8 +3650,8 @@ var init_BottomSheetEngine = __esm({
|
|
|
3648
3650
|
this.updateAriaSlider();
|
|
3649
3651
|
this.emit("snap", {
|
|
3650
3652
|
id: target.id,
|
|
3651
|
-
size:
|
|
3652
|
-
progress: this.computeProgress(
|
|
3653
|
+
size: this.size,
|
|
3654
|
+
progress: this.computeProgress(this.size)
|
|
3653
3655
|
});
|
|
3654
3656
|
if (target.size > 0 && !this.lifecycle.isInstalled) {
|
|
3655
3657
|
this.emit("open", { id: target.id });
|
|
@@ -3675,7 +3677,7 @@ var init_BottomSheetEngine = __esm({
|
|
|
3675
3677
|
var baseStyles;
|
|
3676
3678
|
var init_baseStyles = __esm({
|
|
3677
3679
|
"src/web-component/baseStyles.ts"() {
|
|
3678
|
-
baseStyles = `:where(.bs-root){--bs-surface-d:#ffffff;--bs-surface-border-d:rgba(225,227,237,1);--bs-radius-d:20px;--bs-handle-color-d:rgba(26,22,20,0.3);--bs-handle-width:40px;--bs-handle-height:5px;--bs-z-backdrop:90;--bs-z-sheet:100;--bs-header-min-height:80px;--bs-backdrop-color-d:rgba(0,0,0,0.5);--bs-scrim-color-d:transparent;--bs-scrim-blur:0px;--bs-z-scrim:calc(var(--bs-z-sheet) - 1);--bs-size:0px;--bs-progress:0}.bs-backdrop{position:fixed;inset:0;background:var(--bs-backdrop-color,var(--bs-backdrop-color-d));opacity:0;pointer-events:none;z-index:var(--bs-z-backdrop);transition:opacity 0.24s cubic-bezier(0.22,1,0.36,1);will-change:opacity}.bs-root[data-dragging="true"] .bs-backdrop,.bs-root[data-animating="true"] .bs-backdrop{transition:none}.bs-sheet{position:fixed;background:var(--bs-surface,var(--bs-surface-d));box-shadow:var(--bs-shadow,var(--bs-shadow-auto,none));z-index:var(--bs-z-sheet);pointer-events:auto;overflow:hidden;display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;user-select:none;overscroll-behavior:contain}.bs-sheet[data-mode="bottom"]{left:0;right:0;bottom:0;width:100%;border-top-left-radius:var(--bs-radius,var(--bs-radius-d));border-top-right-radius:var(--bs-radius,var(--bs-radius-d));border-top:1px solid var(--bs-surface-border,var(--bs-surface-border-d));padding-bottom:env(safe-area-inset-bottom);--bs-shadow-auto:0 calc(var(--bs-progress,0) * -2px - 3px) calc(var(--bs-progress,0) * 18px + 12px) rgba(0,0,0,calc(var(--bs-progress,0) * 0.15 + 0.12))}.bs-sheet[data-mode="top"]{left:0;right:0;top:0;width:100%;border-bottom-left-radius:var(--bs-radius,var(--bs-radius-d));border-bottom-right-radius:var(--bs-radius,var(--bs-radius-d));border-bottom:1px solid var(--bs-surface-border,var(--bs-surface-border-d));flex-direction:column-reverse;--bs-shadow-auto:0 3px 12px rgba(0,0,0,0.12);padding-top:env(safe-area-inset-top)}.bs-sheet[data-mode="left"]{top:0;bottom:0;left:0;height:100%;border-top-right-radius:var(--bs-radius,var(--bs-radius-d));border-bottom-right-radius:var(--bs-radius,var(--bs-radius-d));border-right:1px solid var(--bs-surface-border,var(--bs-surface-border-d));--bs-shadow-auto:3px 0 12px rgba(0,0,0,0.12)}.bs-sheet[data-mode="right"]{top:0;bottom:0;right:0;height:100%;border-top-left-radius:var(--bs-radius,var(--bs-radius-d));border-bottom-left-radius:var(--bs-radius,var(--bs-radius-d));border-left:1px solid var(--bs-surface-border,var(--bs-surface-border-d));--bs-shadow-auto:-3px 0 12px rgba(0,0,0,0.12)}.bs-sheet[data-mode="left"] .bs-content{padding-right:36px}.bs-sheet[data-mode="right"] .bs-content{padding-left:36px}.bs-handle{flex-shrink:0;min-height:44px;display:flex;flex-direction:column;justify-content:center;padding:8px 16px 4px;cursor:grab;touch-action:none;user-select:none;background:var(--bs-surface,var(--bs-surface-d));-webkit-tap-highlight-color:transparent;outline:none;position:relative}.bs-handle:active{cursor:grabbing}.bs-handle:focus-visible{outline:2px solid currentColor;outline-offset:-2px;border-radius:var(--bs-radius,var(--bs-radius-d))}.bs-handle::before{content:"";display:block;width:var(--bs-handle-width);height:var(--bs-handle-height);background:var(--bs-handle-color,var(--bs-handle-color-d));border-radius:calc(var(--bs-handle-height) / 2);margin:0 auto 8px;transition:width 0.15s ease,background 0.15s ease,transform 0.15s ease;pointer-events:none}.bs-sheet[data-mode="left"] .bs-handle,.bs-sheet[data-mode="right"] .bs-handle{position:absolute;top:0;bottom:0;width:28px;min-width:0;min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:0;background:var(--bs-surface,var(--bs-surface-d));z-index:1;overflow:hidden}.bs-sheet[data-mode="left"] .bs-handle>*,.bs-sheet[data-mode="right"] .bs-handle>*{display:none}.bs-sheet[data-mode="left"] .bs-handle{right:0;border-left:1px solid var(--bs-surface-border,var(--bs-surface-border-d))}.bs-sheet[data-mode="right"] .bs-handle{left:0;border-right:1px solid var(--bs-surface-border,var(--bs-surface-border-d))}.bs-sheet[data-mode="left"] .bs-handle::before,.bs-sheet[data-mode="right"] .bs-handle::before{width:var(--bs-handle-height);height:var(--bs-handle-width);margin:0}.bs-sheet:hover .bs-handle::before{background:color-mix(in oklab,var(--bs-handle-color,var(--bs-handle-color-d)),#000 15%)}.bs-handle:active::before{background:color-mix(in oklab,var(--bs-handle-color,var(--bs-handle-color-d)),#000 35%);transform:scaleX(1.15)}.bs-handle.bs-handle--ticks::after{content:"";display:block;position:absolute;left:50%;bottom:6px;transform:translateX(-50%);width:calc(var(--bs-handle-width) * 2);height:3px;background-image:radial-gradient( circle,var(--bs-handle-color,var(--bs-handle-color-d)) 0 1.5px,transparent 1.6px );background-size:8px 3px;background-repeat:repeat-x;background-position:center;opacity:0;transition:opacity 0.18s ease-out;pointer-events:none}.bs-root[data-dragging="true"] .bs-handle.bs-handle--ticks::after{opacity:0.4}.bs-sheet[data-mode="top"] .bs-handle.bs-handle--ticks::after{bottom:auto;top:6px}.bs-sheet[data-mode="left"] .bs-handle.bs-handle--ticks::after,.bs-sheet[data-mode="right"] .bs-handle.bs-handle--ticks::after{left:50%;top:50%;bottom:auto;transform:translate(-50%,-50%);width:3px;height:calc(var(--bs-handle-width) * 2);background-size:3px 8px;background-repeat:repeat-y;margin-left:calc(var(--bs-handle-height) + 6px)}.bs-sheet[data-mode="right"] .bs-handle.bs-handle--ticks::after{margin-left:calc(-1 * (var(--bs-handle-height) + 6px))}.bs-header{flex:0 0 auto;padding:0 16px 8px;background:var(--bs-surface,var(--bs-surface-d))}.bs-content{flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;user-select:text;padding:0 16px 16px}.bs-footer{flex:0 0 auto;padding:12px 16px calc(12px + env(safe-area-inset-bottom));border-top:1px solid var(--bs-surface-border,var(--bs-surface-border-d));background:var(--bs-surface,var(--bs-surface-d))}.bs-sheet[data-mode="bottom"]:has(.bs-footer:not([hidden]):has(*)){padding-bottom:0}.bs-header:not(:has(*)),.bs-footer:not(:has(*)),.bs-header[hidden],.bs-footer[hidden]{display:none}.bs-screen{position:absolute;inset:0;pointer-events:none;z-index:var(--bs-z-scrim);background:var(--bs-scrim-color,var(--bs-scrim-color-d));transition:opacity 0.24s cubic-bezier(0.22,1,0.36,1);will-change:opacity}.bs-root[data-dragging="true"] .bs-screen,.bs-root[data-animating="true"] .bs-screen{transition:none}.bs-scrim-overlay{z-index:calc(var(--bs-z-sheet) + 1);pointer-events:none}.bs-button-slot{position:fixed;z-index:calc(var(--bs-z-sheet) + 1);pointer-events:auto}.bs-button-slot[data-side="left"]{left:16px;bottom:calc(var(--bs-size,0px) + 12px)}.bs-button-slot[data-side="right"]{right:16px;bottom:calc(var(--bs-size,0px) + 12px)}.bs-button-slot[data-mode="top"]{bottom:auto;top:calc(var(--bs-size,0px) + 12px)}.bs-button-slot[data-mode="left"]{left:calc(var(--bs-size,0px) + 12px);right:auto;bottom:auto;top:16px}.bs-button-slot[data-mode="right"]{right:calc(var(--bs-size,0px) + 12px);left:auto;bottom:auto;top:16px}@media (prefers-reduced-motion:reduce){.bs-backdrop,.bs-handle::before,.bs-button-slot[data-side="left"],.bs-button-slot[data-side="right"]{transition:none !important}}@media (prefers-color-scheme:dark){:where(.bs-root){--bs-surface-d:#1a1a1d;--bs-surface-border-d:rgba(255,255,255,0.08);--bs-handle-color-d:rgba(255,255,255,0.45);--bs-shadow-auto:0 -3px 16px rgba(0,0,0,0.5)}}.bs-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}:where(.ovl-root){--ovl-surface:var(--bs-surface,var(--bs-surface-d,#ffffff));--ovl-surface-border:var(--bs-surface-border,var(--bs-surface-border-d,rgba(0,0,0,0.08)));--ovl-shadow:0 -8px 40px rgba(0,0,0,0.35);--ovl-radius:var(--bs-radius,var(--bs-radius-d,20px));--ovl-backdrop-color:rgba(0,0,0,0.5);--ovl-z-backdrop:200;--ovl-z-panel:201}.ovl-backdrop{position:fixed;inset:0;background:var(--ovl-backdrop-color);opacity:0;pointer-events:none;z-index:var(--ovl-z-backdrop)}.ovl-panel{position:fixed;background:var(--ovl-surface);box-shadow:var(--ovl-shadow);z-index:var(--ovl-z-panel);-webkit-tap-highlight-color:transparent;outline:none;transition:transform 0.32s cubic-bezier(0.29,1.24,0.84,0.99),opacity 0.32s ease-out}.ovl-panel[data-state="open"]{transform:translate3d(0,0,0);opacity:1}@starting-style{.ovl-panel[data-edge="bottom"][data-state="open"]{transform:translate3d(0,100%,0);opacity:0}.ovl-panel[data-edge="top"][data-state="open"]{transform:translate3d(0,-100%,0);opacity:0}.ovl-panel[data-edge="left"][data-state="open"]{transform:translate3d(-100%,0,0);opacity:0}.ovl-panel[data-edge="right"][data-state="open"]{transform:translate3d(100%,0,0);opacity:0}}.ovl-panel[data-edge="bottom"]{left:0;right:0;bottom:0;width:100%;border-top-left-radius:var(--ovl-radius);border-top-right-radius:var(--ovl-radius);border-top:1px solid var(--ovl-surface-border);padding-bottom:env(safe-area-inset-bottom)}.ovl-panel[data-edge="top"]{left:0;right:0;top:0;width:100%;border-bottom-left-radius:var(--ovl-radius);border-bottom-right-radius:var(--ovl-radius);border-bottom:1px solid var(--ovl-surface-border);padding-top:env(safe-area-inset-top)}.ovl-panel[data-edge="left"]{top:0;bottom:0;left:0;height:100%;border-top-right-radius:var(--ovl-radius);border-bottom-right-radius:var(--ovl-radius);border-right:1px solid var(--ovl-surface-border)}.ovl-panel[data-edge="right"]{top:0;bottom:0;right:0;height:100%;border-top-left-radius:var(--ovl-radius);border-bottom-left-radius:var(--ovl-radius);border-left:1px solid var(--ovl-surface-border)}@media (prefers-reduced-motion:reduce){.ovl-panel,.ovl-backdrop{transition:none !important}}`;
|
|
3680
|
+
baseStyles = `:where(.bs-root){--bs-surface-d:#ffffff;--bs-surface-border-d:rgba(225,227,237,1);--bs-radius-d:20px;--bs-handle-color-d:rgba(26,22,20,0.3);--bs-handle-width:40px;--bs-handle-height:5px;--bs-z-backdrop:90;--bs-z-sheet:100;--bs-header-min-height:80px;--bs-backdrop-color-d:rgba(0,0,0,0.5);--bs-scrim-color-d:transparent;--bs-scrim-blur:0px;--bs-z-scrim:calc(var(--bs-z-sheet) - 1);--bs-size:0px;--bs-progress:0}.bs-backdrop{position:fixed;inset:0;background:var(--bs-backdrop-color,var(--bs-backdrop-color-d));opacity:0;pointer-events:none;z-index:var(--bs-z-backdrop);transition:opacity 0.24s cubic-bezier(0.22,1,0.36,1);will-change:opacity}.bs-root[data-dragging="true"] .bs-backdrop,.bs-root[data-animating="true"] .bs-backdrop{transition:none}.bs-sheet{position:fixed;background:var(--bs-surface,var(--bs-surface-d));box-shadow:var(--bs-shadow,var(--bs-shadow-auto,none));z-index:var(--bs-z-sheet);pointer-events:auto;overflow:hidden;display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;user-select:none;overscroll-behavior:contain}.bs-sheet[data-mode="bottom"]{left:0;right:0;bottom:0;width:100%;border-top-left-radius:var(--bs-radius,var(--bs-radius-d));border-top-right-radius:var(--bs-radius,var(--bs-radius-d));border-top:1px solid var(--bs-surface-border,var(--bs-surface-border-d));padding-bottom:env(safe-area-inset-bottom);--bs-shadow-auto:0 calc(var(--bs-progress,0) * -2px - 3px) calc(var(--bs-progress,0) * 18px + 12px) rgba(0,0,0,calc(var(--bs-progress,0) * 0.15 + 0.12))}.bs-sheet[data-mode="top"]{left:0;right:0;top:0;width:100%;border-bottom-left-radius:var(--bs-radius,var(--bs-radius-d));border-bottom-right-radius:var(--bs-radius,var(--bs-radius-d));border-bottom:1px solid var(--bs-surface-border,var(--bs-surface-border-d));flex-direction:column-reverse;--bs-shadow-auto:0 3px 12px rgba(0,0,0,0.12);padding-top:env(safe-area-inset-top)}.bs-sheet[data-mode="left"]{top:0;bottom:0;left:0;height:100%;border-top-right-radius:var(--bs-radius,var(--bs-radius-d));border-bottom-right-radius:var(--bs-radius,var(--bs-radius-d));border-right:1px solid var(--bs-surface-border,var(--bs-surface-border-d));--bs-shadow-auto:3px 0 12px rgba(0,0,0,0.12)}.bs-sheet[data-mode="right"]{top:0;bottom:0;right:0;height:100%;border-top-left-radius:var(--bs-radius,var(--bs-radius-d));border-bottom-left-radius:var(--bs-radius,var(--bs-radius-d));border-left:1px solid var(--bs-surface-border,var(--bs-surface-border-d));--bs-shadow-auto:-3px 0 12px rgba(0,0,0,0.12)}.bs-sheet[data-mode="left"] .bs-content{padding-right:36px}.bs-sheet[data-mode="right"] .bs-content{padding-left:36px}.bs-handle{flex-shrink:0;min-height:44px;display:flex;flex-direction:column;justify-content:center;padding:var(--bs-handle-padding,8px 16px 4px);cursor:grab;touch-action:none;user-select:none;background:var(--bs-surface,var(--bs-surface-d));-webkit-tap-highlight-color:transparent;outline:none;position:relative}.bs-handle:active{cursor:grabbing}.bs-handle:focus-visible{outline:2px solid currentColor;outline-offset:-2px;border-radius:var(--bs-radius,var(--bs-radius-d))}.bs-handle::before{content:"";display:block;width:var(--bs-handle-width);height:var(--bs-handle-height);background:var(--bs-handle-color,var(--bs-handle-color-d));border-radius:calc(var(--bs-handle-height) / 2);margin:0 auto 8px;transition:width 0.15s ease,background 0.15s ease,transform 0.15s ease;pointer-events:none}.bs-sheet[data-mode="left"] .bs-handle,.bs-sheet[data-mode="right"] .bs-handle{position:absolute;top:0;bottom:0;width:28px;min-width:0;min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:0;background:var(--bs-surface,var(--bs-surface-d));z-index:1;overflow:hidden}.bs-sheet[data-mode="left"] .bs-handle>*,.bs-sheet[data-mode="right"] .bs-handle>*{display:none}.bs-sheet[data-mode="left"] .bs-handle{right:0;border-left:1px solid var(--bs-surface-border,var(--bs-surface-border-d))}.bs-sheet[data-mode="right"] .bs-handle{left:0;border-right:1px solid var(--bs-surface-border,var(--bs-surface-border-d))}.bs-sheet[data-mode="left"] .bs-handle::before,.bs-sheet[data-mode="right"] .bs-handle::before{width:var(--bs-handle-height);height:var(--bs-handle-width);margin:0}.bs-sheet:hover .bs-handle::before{background:color-mix(in oklab,var(--bs-handle-color,var(--bs-handle-color-d)),#000 15%)}.bs-handle:active::before{background:color-mix(in oklab,var(--bs-handle-color,var(--bs-handle-color-d)),#000 35%);transform:scaleX(1.15)}.bs-handle.bs-handle--ticks::after{content:"";display:block;position:absolute;left:50%;bottom:6px;transform:translateX(-50%);width:calc(var(--bs-handle-width) * 2);height:3px;background-image:radial-gradient( circle,var(--bs-handle-color,var(--bs-handle-color-d)) 0 1.5px,transparent 1.6px );background-size:8px 3px;background-repeat:repeat-x;background-position:center;opacity:0;transition:opacity 0.18s ease-out;pointer-events:none}.bs-root[data-dragging="true"] .bs-handle.bs-handle--ticks::after{opacity:0.4}.bs-sheet[data-mode="top"] .bs-handle.bs-handle--ticks::after{bottom:auto;top:6px}.bs-sheet[data-mode="left"] .bs-handle.bs-handle--ticks::after,.bs-sheet[data-mode="right"] .bs-handle.bs-handle--ticks::after{left:50%;top:50%;bottom:auto;transform:translate(-50%,-50%);width:3px;height:calc(var(--bs-handle-width) * 2);background-size:3px 8px;background-repeat:repeat-y;margin-left:calc(var(--bs-handle-height) + 6px)}.bs-sheet[data-mode="right"] .bs-handle.bs-handle--ticks::after{margin-left:calc(-1 * (var(--bs-handle-height) + 6px))}.bs-header{flex:0 0 auto;padding:var(--bs-header-padding,0 16px 8px);background:var(--bs-surface,var(--bs-surface-d))}.bs-content{flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;user-select:text;padding:var(--bs-content-padding,0 16px 16px)}.bs-footer{flex:0 0 auto;padding:var(--bs-footer-padding,12px 16px calc(12px + env(safe-area-inset-bottom)));border-top:1px solid var(--bs-surface-border,var(--bs-surface-border-d));background:var(--bs-surface,var(--bs-surface-d))}.bs-sheet[data-mode="bottom"]:has(.bs-footer:not([hidden]):has(*)){padding-bottom:0}.bs-header:not(:has(*)),.bs-footer:not(:has(*)),.bs-header[hidden],.bs-footer[hidden]{display:none}.bs-screen{position:absolute;inset:0;pointer-events:none;z-index:var(--bs-z-scrim);background:var(--bs-scrim-color,var(--bs-scrim-color-d));transition:opacity 0.24s cubic-bezier(0.22,1,0.36,1);will-change:opacity}.bs-root[data-dragging="true"] .bs-screen,.bs-root[data-animating="true"] .bs-screen{transition:none}.bs-scrim-overlay{z-index:calc(var(--bs-z-sheet) + 1);pointer-events:none}.bs-button-slot{position:fixed;z-index:calc(var(--bs-z-sheet) + 1);pointer-events:auto}.bs-button-slot[data-side="left"]{left:16px;bottom:calc(var(--bs-size,0px) + 12px)}.bs-button-slot[data-side="right"]{right:16px;bottom:calc(var(--bs-size,0px) + 12px)}.bs-button-slot[data-mode="top"]{bottom:auto;top:calc(var(--bs-size,0px) + 12px)}.bs-button-slot[data-mode="left"]{left:calc(var(--bs-size,0px) + 12px);right:auto;bottom:auto;top:16px}.bs-button-slot[data-mode="right"]{right:calc(var(--bs-size,0px) + 12px);left:auto;bottom:auto;top:16px}@media (prefers-reduced-motion:reduce){.bs-backdrop,.bs-handle::before,.bs-button-slot[data-side="left"],.bs-button-slot[data-side="right"]{transition:none !important}}@media (prefers-color-scheme:dark){:where(.bs-root){--bs-surface-d:#1a1a1d;--bs-surface-border-d:rgba(255,255,255,0.08);--bs-handle-color-d:rgba(255,255,255,0.45);--bs-shadow-auto:0 -3px 16px rgba(0,0,0,0.5)}}.bs-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}:where(.ovl-root){--ovl-surface:var(--bs-surface,var(--bs-surface-d,#ffffff));--ovl-surface-border:var(--bs-surface-border,var(--bs-surface-border-d,rgba(0,0,0,0.08)));--ovl-shadow:0 -8px 40px rgba(0,0,0,0.35);--ovl-radius:var(--bs-radius,var(--bs-radius-d,20px));--ovl-backdrop-color:rgba(0,0,0,0.5);--ovl-z-backdrop:200;--ovl-z-panel:201}.ovl-backdrop{position:fixed;inset:0;background:var(--ovl-backdrop-color);opacity:0;pointer-events:none;z-index:var(--ovl-z-backdrop)}.ovl-panel{position:fixed;background:var(--ovl-surface);box-shadow:var(--ovl-shadow);z-index:var(--ovl-z-panel);-webkit-tap-highlight-color:transparent;outline:none;transition:transform 0.32s cubic-bezier(0.29,1.24,0.84,0.99),opacity 0.32s ease-out}.ovl-panel[data-state="open"]{transform:translate3d(0,0,0);opacity:1}@starting-style{.ovl-panel[data-edge="bottom"][data-state="open"]{transform:translate3d(0,100%,0);opacity:0}.ovl-panel[data-edge="top"][data-state="open"]{transform:translate3d(0,-100%,0);opacity:0}.ovl-panel[data-edge="left"][data-state="open"]{transform:translate3d(-100%,0,0);opacity:0}.ovl-panel[data-edge="right"][data-state="open"]{transform:translate3d(100%,0,0);opacity:0}}.ovl-panel[data-edge="bottom"]{left:0;right:0;bottom:0;width:100%;border-top-left-radius:var(--ovl-radius);border-top-right-radius:var(--ovl-radius);border-top:1px solid var(--ovl-surface-border);padding-bottom:env(safe-area-inset-bottom)}.ovl-panel[data-edge="top"]{left:0;right:0;top:0;width:100%;border-bottom-left-radius:var(--ovl-radius);border-bottom-right-radius:var(--ovl-radius);border-bottom:1px solid var(--ovl-surface-border);padding-top:env(safe-area-inset-top)}.ovl-panel[data-edge="left"]{top:0;bottom:0;left:0;height:100%;border-top-right-radius:var(--ovl-radius);border-bottom-right-radius:var(--ovl-radius);border-right:1px solid var(--ovl-surface-border)}.ovl-panel[data-edge="right"]{top:0;bottom:0;right:0;height:100%;border-top-left-radius:var(--ovl-radius);border-bottom-left-radius:var(--ovl-radius);border-left:1px solid var(--ovl-surface-border)}@media (prefers-reduced-motion:reduce){.ovl-panel,.ovl-backdrop{transition:none !important}}`;
|
|
3679
3681
|
}
|
|
3680
3682
|
});
|
|
3681
3683
|
|
package/dist/index.cjs
CHANGED
|
@@ -2654,8 +2654,8 @@ var BottomSheetEngine = class {
|
|
|
2654
2654
|
this.updateAriaSlider();
|
|
2655
2655
|
this.emit("snap", {
|
|
2656
2656
|
id,
|
|
2657
|
-
size:
|
|
2658
|
-
progress: this.computeProgress(
|
|
2657
|
+
size: this.size,
|
|
2658
|
+
progress: this.computeProgress(this.size)
|
|
2659
2659
|
});
|
|
2660
2660
|
if (wasClosed && target.size > 0) {
|
|
2661
2661
|
this.emit("open", { id });
|
|
@@ -2734,12 +2734,12 @@ var BottomSheetEngine = class {
|
|
|
2734
2734
|
const value = typeof h === "number" ? `${h}px` : h;
|
|
2735
2735
|
const axis = layoutAxis(this.mode);
|
|
2736
2736
|
this.element.style.setProperty(
|
|
2737
|
-
axis === "height" ? "
|
|
2737
|
+
axis === "height" ? "max-height" : "max-width",
|
|
2738
2738
|
value
|
|
2739
2739
|
);
|
|
2740
2740
|
if (typeof h === "number") {
|
|
2741
2741
|
this.maxHeightCap = h;
|
|
2742
|
-
this.
|
|
2742
|
+
this.recompute();
|
|
2743
2743
|
} else if (typeof window !== "undefined") {
|
|
2744
2744
|
const probe2 = document.createElement("div");
|
|
2745
2745
|
probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
|
|
@@ -2747,7 +2747,7 @@ var BottomSheetEngine = class {
|
|
|
2747
2747
|
const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
|
|
2748
2748
|
probe2.remove();
|
|
2749
2749
|
this.maxHeightCap = measured > 0 ? measured : void 0;
|
|
2750
|
-
this.
|
|
2750
|
+
this.recompute();
|
|
2751
2751
|
}
|
|
2752
2752
|
}
|
|
2753
2753
|
clampToMaxHeight() {
|
|
@@ -2755,9 +2755,6 @@ var BottomSheetEngine = class {
|
|
|
2755
2755
|
if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
|
|
2756
2756
|
this.snaps.setMaxAxisSize(this.maxHeightCap);
|
|
2757
2757
|
}
|
|
2758
|
-
if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
|
|
2759
|
-
this.applySize(this.maxHeightCap);
|
|
2760
|
-
}
|
|
2761
2758
|
}
|
|
2762
2759
|
setAllowed(ids, snap) {
|
|
2763
2760
|
if (this.destroyed) return;
|
|
@@ -2895,6 +2892,7 @@ var BottomSheetEngine = class {
|
|
|
2895
2892
|
recompute() {
|
|
2896
2893
|
if (this.destroyed) return;
|
|
2897
2894
|
this.snaps.recompute();
|
|
2895
|
+
this.clampToMaxHeight();
|
|
2898
2896
|
this.scrim.invalidateOpacityCache();
|
|
2899
2897
|
if (this.gesture?.isDragging) return;
|
|
2900
2898
|
const current = this.snaps.findById(this.activeId);
|
|
@@ -2952,9 +2950,10 @@ var BottomSheetEngine = class {
|
|
|
2952
2950
|
const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
|
|
2953
2951
|
const content = this.scrollContainer;
|
|
2954
2952
|
const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
|
|
2955
|
-
|
|
2953
|
+
const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
|
|
2954
|
+
if (typeof window === "undefined") return capped;
|
|
2956
2955
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
2957
|
-
return viewport > 0 ? Math.min(
|
|
2956
|
+
return viewport > 0 ? Math.min(capped, viewport) : capped;
|
|
2958
2957
|
}
|
|
2959
2958
|
installFitObserver() {
|
|
2960
2959
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3325,8 +3324,8 @@ var BottomSheetEngine = class {
|
|
|
3325
3324
|
this.updateAriaSlider();
|
|
3326
3325
|
this.emit("snap", {
|
|
3327
3326
|
id: target.id,
|
|
3328
|
-
size:
|
|
3329
|
-
progress: this.computeProgress(
|
|
3327
|
+
size: this.size,
|
|
3328
|
+
progress: this.computeProgress(this.size)
|
|
3330
3329
|
});
|
|
3331
3330
|
this.haptic();
|
|
3332
3331
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
@@ -3351,23 +3350,25 @@ var BottomSheetEngine = class {
|
|
|
3351
3350
|
}
|
|
3352
3351
|
}
|
|
3353
3352
|
applySize(size) {
|
|
3354
|
-
|
|
3355
|
-
const
|
|
3353
|
+
const cap = this.snaps.getMaxAxisSize();
|
|
3354
|
+
const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
|
|
3355
|
+
this.size = clamped;
|
|
3356
|
+
const offset = cap - clamped;
|
|
3356
3357
|
const style = this.element.style;
|
|
3357
3358
|
style.transform = this.transformTemplate(offset);
|
|
3358
|
-
if (this.sizeWriteSentinel.shouldWrite(
|
|
3359
|
-
style.setProperty("--bs-size", `${
|
|
3359
|
+
if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
|
|
3360
|
+
style.setProperty("--bs-size", `${clamped}px`);
|
|
3360
3361
|
if (this.scrimParent) {
|
|
3361
|
-
this.scrimParent.style.setProperty("--bs-size", `${
|
|
3362
|
+
this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
|
|
3362
3363
|
}
|
|
3363
3364
|
if (this.anchorHost && this.anchorHost !== this.scrimParent) {
|
|
3364
|
-
this.anchorHost.style.setProperty("--bs-size", `${
|
|
3365
|
+
this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
|
|
3365
3366
|
}
|
|
3366
3367
|
if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
|
|
3367
|
-
this.rootEl.style.setProperty("--bs-size", `${
|
|
3368
|
+
this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
|
|
3368
3369
|
}
|
|
3369
3370
|
}
|
|
3370
|
-
const progress = this.computeProgress(
|
|
3371
|
+
const progress = this.computeProgress(clamped);
|
|
3371
3372
|
const progressChanged = this.progressWriteSentinel.shouldWrite(
|
|
3372
3373
|
progress,
|
|
3373
3374
|
OPACITY_WRITE_EPSILON
|
|
@@ -3384,14 +3385,15 @@ var BottomSheetEngine = class {
|
|
|
3384
3385
|
this.scrim.applyOpacity(progress, progressChanged);
|
|
3385
3386
|
if (progressChanged && this.bus.listenerCount("progress") > 0) {
|
|
3386
3387
|
this.progressPayload.value = progress;
|
|
3387
|
-
this.progressPayload.size =
|
|
3388
|
+
this.progressPayload.size = clamped;
|
|
3388
3389
|
this.emit("progress", this.progressPayload);
|
|
3389
3390
|
}
|
|
3390
3391
|
}
|
|
3391
3392
|
computeProgress(size) {
|
|
3392
3393
|
const { min, max } = this.getAllowedRange();
|
|
3393
|
-
|
|
3394
|
-
|
|
3394
|
+
const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
|
|
3395
|
+
if (reachableMax <= min) return 0;
|
|
3396
|
+
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
3395
3397
|
}
|
|
3396
3398
|
handleOpen() {
|
|
3397
3399
|
sheetStack.promote(this.id);
|
|
@@ -3415,8 +3417,8 @@ var BottomSheetEngine = class {
|
|
|
3415
3417
|
this.updateAriaSlider();
|
|
3416
3418
|
this.emit("snap", {
|
|
3417
3419
|
id: target.id,
|
|
3418
|
-
size:
|
|
3419
|
-
progress: this.computeProgress(
|
|
3420
|
+
size: this.size,
|
|
3421
|
+
progress: this.computeProgress(this.size)
|
|
3420
3422
|
});
|
|
3421
3423
|
if (target.size > 0 && !this.lifecycle.isInstalled) {
|
|
3422
3424
|
this.emit("open", { id: target.id });
|
package/dist/index.js
CHANGED
|
@@ -2652,8 +2652,8 @@ var BottomSheetEngine = class {
|
|
|
2652
2652
|
this.updateAriaSlider();
|
|
2653
2653
|
this.emit("snap", {
|
|
2654
2654
|
id,
|
|
2655
|
-
size:
|
|
2656
|
-
progress: this.computeProgress(
|
|
2655
|
+
size: this.size,
|
|
2656
|
+
progress: this.computeProgress(this.size)
|
|
2657
2657
|
});
|
|
2658
2658
|
if (wasClosed && target.size > 0) {
|
|
2659
2659
|
this.emit("open", { id });
|
|
@@ -2732,12 +2732,12 @@ var BottomSheetEngine = class {
|
|
|
2732
2732
|
const value = typeof h === "number" ? `${h}px` : h;
|
|
2733
2733
|
const axis = layoutAxis(this.mode);
|
|
2734
2734
|
this.element.style.setProperty(
|
|
2735
|
-
axis === "height" ? "
|
|
2735
|
+
axis === "height" ? "max-height" : "max-width",
|
|
2736
2736
|
value
|
|
2737
2737
|
);
|
|
2738
2738
|
if (typeof h === "number") {
|
|
2739
2739
|
this.maxHeightCap = h;
|
|
2740
|
-
this.
|
|
2740
|
+
this.recompute();
|
|
2741
2741
|
} else if (typeof window !== "undefined") {
|
|
2742
2742
|
const probe2 = document.createElement("div");
|
|
2743
2743
|
probe2.style.cssText = `position:absolute;visibility:hidden;pointer-events:none;${axis === "height" ? "height" : "width"}:${value};`;
|
|
@@ -2745,7 +2745,7 @@ var BottomSheetEngine = class {
|
|
|
2745
2745
|
const measured = axis === "height" ? probe2.offsetHeight : probe2.offsetWidth;
|
|
2746
2746
|
probe2.remove();
|
|
2747
2747
|
this.maxHeightCap = measured > 0 ? measured : void 0;
|
|
2748
|
-
this.
|
|
2748
|
+
this.recompute();
|
|
2749
2749
|
}
|
|
2750
2750
|
}
|
|
2751
2751
|
clampToMaxHeight() {
|
|
@@ -2753,9 +2753,6 @@ var BottomSheetEngine = class {
|
|
|
2753
2753
|
if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
|
|
2754
2754
|
this.snaps.setMaxAxisSize(this.maxHeightCap);
|
|
2755
2755
|
}
|
|
2756
|
-
if (this.size > this.maxHeightCap && !this.gesture?.isDragging) {
|
|
2757
|
-
this.applySize(this.maxHeightCap);
|
|
2758
|
-
}
|
|
2759
2756
|
}
|
|
2760
2757
|
setAllowed(ids, snap) {
|
|
2761
2758
|
if (this.destroyed) return;
|
|
@@ -2893,6 +2890,7 @@ var BottomSheetEngine = class {
|
|
|
2893
2890
|
recompute() {
|
|
2894
2891
|
if (this.destroyed) return;
|
|
2895
2892
|
this.snaps.recompute();
|
|
2893
|
+
this.clampToMaxHeight();
|
|
2896
2894
|
this.scrim.invalidateOpacityCache();
|
|
2897
2895
|
if (this.gesture?.isDragging) return;
|
|
2898
2896
|
const current = this.snaps.findById(this.activeId);
|
|
@@ -2950,9 +2948,10 @@ var BottomSheetEngine = class {
|
|
|
2950
2948
|
const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
|
|
2951
2949
|
const content = this.scrollContainer;
|
|
2952
2950
|
const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
|
|
2953
|
-
|
|
2951
|
+
const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
|
|
2952
|
+
if (typeof window === "undefined") return capped;
|
|
2954
2953
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
2955
|
-
return viewport > 0 ? Math.min(
|
|
2954
|
+
return viewport > 0 ? Math.min(capped, viewport) : capped;
|
|
2956
2955
|
}
|
|
2957
2956
|
installFitObserver() {
|
|
2958
2957
|
if (typeof ResizeObserver === "undefined") return;
|
|
@@ -3323,8 +3322,8 @@ var BottomSheetEngine = class {
|
|
|
3323
3322
|
this.updateAriaSlider();
|
|
3324
3323
|
this.emit("snap", {
|
|
3325
3324
|
id: target.id,
|
|
3326
|
-
size:
|
|
3327
|
-
progress: this.computeProgress(
|
|
3325
|
+
size: this.size,
|
|
3326
|
+
progress: this.computeProgress(this.size)
|
|
3328
3327
|
});
|
|
3329
3328
|
this.haptic();
|
|
3330
3329
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
@@ -3349,23 +3348,25 @@ var BottomSheetEngine = class {
|
|
|
3349
3348
|
}
|
|
3350
3349
|
}
|
|
3351
3350
|
applySize(size) {
|
|
3352
|
-
|
|
3353
|
-
const
|
|
3351
|
+
const cap = this.snaps.getMaxAxisSize();
|
|
3352
|
+
const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
|
|
3353
|
+
this.size = clamped;
|
|
3354
|
+
const offset = cap - clamped;
|
|
3354
3355
|
const style = this.element.style;
|
|
3355
3356
|
style.transform = this.transformTemplate(offset);
|
|
3356
|
-
if (this.sizeWriteSentinel.shouldWrite(
|
|
3357
|
-
style.setProperty("--bs-size", `${
|
|
3357
|
+
if (this.sizeWriteSentinel.shouldWrite(clamped, SIZE_WRITE_EPSILON)) {
|
|
3358
|
+
style.setProperty("--bs-size", `${clamped}px`);
|
|
3358
3359
|
if (this.scrimParent) {
|
|
3359
|
-
this.scrimParent.style.setProperty("--bs-size", `${
|
|
3360
|
+
this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
|
|
3360
3361
|
}
|
|
3361
3362
|
if (this.anchorHost && this.anchorHost !== this.scrimParent) {
|
|
3362
|
-
this.anchorHost.style.setProperty("--bs-size", `${
|
|
3363
|
+
this.anchorHost.style.setProperty("--bs-size", `${clamped}px`);
|
|
3363
3364
|
}
|
|
3364
3365
|
if (this.rootEl && this.rootEl !== this.scrimParent && this.rootEl !== this.anchorHost) {
|
|
3365
|
-
this.rootEl.style.setProperty("--bs-size", `${
|
|
3366
|
+
this.rootEl.style.setProperty("--bs-size", `${clamped}px`);
|
|
3366
3367
|
}
|
|
3367
3368
|
}
|
|
3368
|
-
const progress = this.computeProgress(
|
|
3369
|
+
const progress = this.computeProgress(clamped);
|
|
3369
3370
|
const progressChanged = this.progressWriteSentinel.shouldWrite(
|
|
3370
3371
|
progress,
|
|
3371
3372
|
OPACITY_WRITE_EPSILON
|
|
@@ -3382,14 +3383,15 @@ var BottomSheetEngine = class {
|
|
|
3382
3383
|
this.scrim.applyOpacity(progress, progressChanged);
|
|
3383
3384
|
if (progressChanged && this.bus.listenerCount("progress") > 0) {
|
|
3384
3385
|
this.progressPayload.value = progress;
|
|
3385
|
-
this.progressPayload.size =
|
|
3386
|
+
this.progressPayload.size = clamped;
|
|
3386
3387
|
this.emit("progress", this.progressPayload);
|
|
3387
3388
|
}
|
|
3388
3389
|
}
|
|
3389
3390
|
computeProgress(size) {
|
|
3390
3391
|
const { min, max } = this.getAllowedRange();
|
|
3391
|
-
|
|
3392
|
-
|
|
3392
|
+
const reachableMax = Math.min(max, this.snaps.getMaxAxisSize());
|
|
3393
|
+
if (reachableMax <= min) return 0;
|
|
3394
|
+
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
3393
3395
|
}
|
|
3394
3396
|
handleOpen() {
|
|
3395
3397
|
sheetStack.promote(this.id);
|
|
@@ -3413,8 +3415,8 @@ var BottomSheetEngine = class {
|
|
|
3413
3415
|
this.updateAriaSlider();
|
|
3414
3416
|
this.emit("snap", {
|
|
3415
3417
|
id: target.id,
|
|
3416
|
-
size:
|
|
3417
|
-
progress: this.computeProgress(
|
|
3418
|
+
size: this.size,
|
|
3419
|
+
progress: this.computeProgress(this.size)
|
|
3418
3420
|
});
|
|
3419
3421
|
if (target.size > 0 && !this.lifecycle.isInstalled) {
|
|
3420
3422
|
this.emit("open", { id: target.id });
|
package/dist/qwik.cjs
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 });
|