@surdeddd/bottom-sheet 0.20.2 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +1 -1
  2. package/dist/{BottomSheetCore-Cgn8b_6A.d.ts → BottomSheetCore-CIijwtdi.d.ts} +1 -0
  3. package/dist/{BottomSheetCore-VPJZcKcg.d.cts → BottomSheetCore-CK8Rh1He.d.cts} +1 -0
  4. package/dist/{BottomSheetEngine-DwYR_ygJ.d.ts → BottomSheetEngine-CZglPsTF.d.ts} +1 -1
  5. package/dist/{BottomSheetEngine-B8C2CwF9.d.cts → BottomSheetEngine-hLSAxzla.d.cts} +1 -1
  6. package/dist/core.cjs +31 -25
  7. package/dist/core.d.cts +2 -2
  8. package/dist/core.d.ts +2 -2
  9. package/dist/core.js +31 -25
  10. package/dist/debug.d.cts +1 -1
  11. package/dist/debug.d.ts +1 -1
  12. package/dist/element.cjs +35 -25
  13. package/dist/element.d.cts +2 -2
  14. package/dist/element.d.ts +2 -2
  15. package/dist/element.iife.global.js +2 -2
  16. package/dist/element.js +35 -25
  17. package/dist/features.d.cts +2 -2
  18. package/dist/features.d.ts +2 -2
  19. package/dist/{index-CnfbOKx0.d.cts → index-BEX-NHRJ.d.cts} +1 -1
  20. package/dist/{index-DcMkhXAy.d.ts → index-BqLHKOeM.d.ts} +1 -1
  21. package/dist/index.cjs +31 -25
  22. package/dist/index.d.cts +4 -4
  23. package/dist/index.d.ts +4 -4
  24. package/dist/index.js +31 -25
  25. package/dist/integrations/formik.d.cts +1 -1
  26. package/dist/integrations/formik.d.ts +1 -1
  27. package/dist/integrations/react-hook-form.d.cts +1 -1
  28. package/dist/integrations/react-hook-form.d.ts +1 -1
  29. package/dist/preact.d.cts +2 -2
  30. package/dist/preact.d.ts +2 -2
  31. package/dist/qwik-lib/index.qwik.cjs +34 -19
  32. package/dist/qwik-lib/index.qwik.mjs +34 -19
  33. package/dist/qwik.cjs +37 -25
  34. package/dist/qwik.d.cts +2 -2
  35. package/dist/qwik.d.ts +2 -2
  36. package/dist/qwik.js +37 -25
  37. package/dist/react.cjs +36 -25
  38. package/dist/react.d.cts +3 -3
  39. package/dist/react.d.ts +3 -3
  40. package/dist/react.js +36 -25
  41. package/dist/solid.cjs +37 -25
  42. package/dist/solid.d.cts +1 -0
  43. package/dist/solid.d.ts +1 -0
  44. package/dist/solid.js +37 -25
  45. package/dist/solid.source.jsx +41 -25
  46. package/dist/svelte-core.cjs +31 -25
  47. package/dist/svelte-core.js +31 -25
  48. package/dist/svelte-src/BottomSheet.svelte +3 -0
  49. package/dist/svelte.cjs +34 -25
  50. package/dist/svelte.js +34 -25
  51. package/dist/vue.cjs +35 -25
  52. package/dist/vue.js +35 -25
  53. package/dist/webgl.d.cts +1 -1
  54. package/dist/webgl.d.ts +1 -1
  55. package/package.json +1 -1
package/dist/qwik.cjs CHANGED
@@ -844,22 +844,18 @@ var ScrimController = class {
844
844
  if (this.backdrop) {
845
845
  const [s, e] = this.backdropRange;
846
846
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
847
- const backdropOpacity = Math.min(
848
- Math.max((progress - s) / range, 0),
849
- 1
850
- );
851
- if (this.isTopSheet() || backdropOpacity === 0) {
852
- if (this.backdropOpacitySentinel.shouldWrite(
853
- backdropOpacity,
854
- OPACITY_WRITE_EPSILON
855
- )) {
856
- this.backdrop.style.opacity = String(backdropOpacity);
857
- }
858
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
859
- if (nextPointer !== this.lastBackdropPointer) {
860
- this.backdrop.style.pointerEvents = nextPointer;
861
- this.lastBackdropPointer = nextPointer;
862
- }
847
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
848
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
849
+ if (this.backdropOpacitySentinel.shouldWrite(
850
+ backdropOpacity,
851
+ OPACITY_WRITE_EPSILON
852
+ )) {
853
+ this.backdrop.style.opacity = String(backdropOpacity);
854
+ }
855
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
856
+ if (nextPointer !== this.lastBackdropPointer) {
857
+ this.backdrop.style.pointerEvents = nextPointer;
858
+ this.lastBackdropPointer = nextPointer;
863
859
  }
864
860
  }
865
861
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1389,18 +1385,20 @@ var AnimationRunner = class {
1389
1385
  get isAnimating() {
1390
1386
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1391
1387
  }
1388
+ cancelWaapi() {
1389
+ if (!this.currentWaapi) return;
1390
+ const entry = this.currentWaapi;
1391
+ this.currentWaapi = null;
1392
+ entry.stop();
1393
+ try {
1394
+ entry.anim.cancel();
1395
+ } catch {
1396
+ }
1397
+ }
1392
1398
  cancel() {
1393
1399
  this.currentTween?.cancel();
1394
1400
  this.currentSpring?.cancel();
1395
- if (this.currentWaapi) {
1396
- const entry = this.currentWaapi;
1397
- this.currentWaapi = null;
1398
- entry.stop();
1399
- try {
1400
- entry.anim.cancel();
1401
- } catch {
1402
- }
1403
- }
1401
+ this.cancelWaapi();
1404
1402
  }
1405
1403
  async animateTo(target, velocityPxPerMs) {
1406
1404
  if (target === this.getSize()) {
@@ -1411,6 +1409,7 @@ var AnimationRunner = class {
1411
1409
  }
1412
1410
  this.currentTween?.cancel();
1413
1411
  this.currentSpring?.cancel();
1412
+ this.cancelWaapi();
1414
1413
  this.getRootEl()?.setAttribute("data-animating", "true");
1415
1414
  this.element.style.willChange = "transform";
1416
1415
  if (this.reducedMotion) {
@@ -3403,12 +3402,19 @@ var BottomSheetCore = class {
3403
3402
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3404
3403
  },
3405
3404
  setIsTop: (isTop) => {
3405
+ if (this.isTopSheet === isTop) return;
3406
3406
  this.isTopSheet = isTop;
3407
+ this.repaintScrim();
3407
3408
  },
3408
3409
  isOpen: () => this.size > 0 || this.opening,
3409
3410
  setDepth: (depth) => this.applyStackDepth(depth)
3410
3411
  }));
3411
3412
  }
3413
+ repaintScrim() {
3414
+ if (this.destroyed) return;
3415
+ this.scrim.invalidateOpacityCache();
3416
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3417
+ }
3412
3418
  applyStackDepth(depth) {
3413
3419
  if (!this.stackEffectEnabled) return;
3414
3420
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -4436,6 +4442,12 @@ var BottomSheet = qwik.component$((props) => {
4436
4442
  }
4437
4443
  if (dragFrom !== void 0) engine.setDragFrom(dragFrom);
4438
4444
  });
4445
+ qwik.useTask$(({ track }) => {
4446
+ const nextMode = track(() => props.mode);
4447
+ const engine = engineStore.engine;
4448
+ if (!engine || nextMode === void 0) return;
4449
+ engine.setMode(nextMode);
4450
+ });
4439
4451
  const showBackdrop = props.backdrop !== false;
4440
4452
  const mode = props.mode ?? "bottom";
4441
4453
  const ariaLabel = props.ariaLabel ?? "Bottom sheet";
package/dist/qwik.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _builder_io_qwik from '@builder.io/qwik';
2
2
  import { QRL } from '@builder.io/qwik';
3
3
  import { T as TeleportTarget } from './teleport-7uYNiEAT.cjs';
4
- import { a as SnapPointDef, b as SheetMode, c as EngineOptions, S as SheetEventMap, E as EngineState } from './BottomSheetCore-VPJZcKcg.cjs';
5
- export { d as SnapPoint } from './BottomSheetCore-VPJZcKcg.cjs';
4
+ import { a as SnapPointDef, b as SheetMode, c as EngineOptions, S as SheetEventMap, E as EngineState } from './BottomSheetCore-CK8Rh1He.cjs';
5
+ export { d as SnapPoint } from './BottomSheetCore-CK8Rh1He.cjs';
6
6
  import './transform-jVfAikE9.cjs';
7
7
 
8
8
  type BottomSheetProps<TId extends string = string> = {
package/dist/qwik.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _builder_io_qwik from '@builder.io/qwik';
2
2
  import { QRL } from '@builder.io/qwik';
3
3
  import { T as TeleportTarget } from './teleport-7uYNiEAT.js';
4
- import { a as SnapPointDef, b as SheetMode, c as EngineOptions, S as SheetEventMap, E as EngineState } from './BottomSheetCore-Cgn8b_6A.js';
5
- export { d as SnapPoint } from './BottomSheetCore-Cgn8b_6A.js';
4
+ import { a as SnapPointDef, b as SheetMode, c as EngineOptions, S as SheetEventMap, E as EngineState } from './BottomSheetCore-CIijwtdi.js';
5
+ export { d as SnapPoint } from './BottomSheetCore-CIijwtdi.js';
6
6
  import './transform-jVfAikE9.js';
7
7
 
8
8
  type BottomSheetProps<TId extends string = string> = {
package/dist/qwik.js CHANGED
@@ -842,22 +842,18 @@ var ScrimController = class {
842
842
  if (this.backdrop) {
843
843
  const [s, e] = this.backdropRange;
844
844
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
845
- const backdropOpacity = Math.min(
846
- Math.max((progress - s) / range, 0),
847
- 1
848
- );
849
- if (this.isTopSheet() || backdropOpacity === 0) {
850
- if (this.backdropOpacitySentinel.shouldWrite(
851
- backdropOpacity,
852
- OPACITY_WRITE_EPSILON
853
- )) {
854
- this.backdrop.style.opacity = String(backdropOpacity);
855
- }
856
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
857
- if (nextPointer !== this.lastBackdropPointer) {
858
- this.backdrop.style.pointerEvents = nextPointer;
859
- this.lastBackdropPointer = nextPointer;
860
- }
845
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
846
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
847
+ if (this.backdropOpacitySentinel.shouldWrite(
848
+ backdropOpacity,
849
+ OPACITY_WRITE_EPSILON
850
+ )) {
851
+ this.backdrop.style.opacity = String(backdropOpacity);
852
+ }
853
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
854
+ if (nextPointer !== this.lastBackdropPointer) {
855
+ this.backdrop.style.pointerEvents = nextPointer;
856
+ this.lastBackdropPointer = nextPointer;
861
857
  }
862
858
  }
863
859
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1387,18 +1383,20 @@ var AnimationRunner = class {
1387
1383
  get isAnimating() {
1388
1384
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1389
1385
  }
1386
+ cancelWaapi() {
1387
+ if (!this.currentWaapi) return;
1388
+ const entry = this.currentWaapi;
1389
+ this.currentWaapi = null;
1390
+ entry.stop();
1391
+ try {
1392
+ entry.anim.cancel();
1393
+ } catch {
1394
+ }
1395
+ }
1390
1396
  cancel() {
1391
1397
  this.currentTween?.cancel();
1392
1398
  this.currentSpring?.cancel();
1393
- if (this.currentWaapi) {
1394
- const entry = this.currentWaapi;
1395
- this.currentWaapi = null;
1396
- entry.stop();
1397
- try {
1398
- entry.anim.cancel();
1399
- } catch {
1400
- }
1401
- }
1399
+ this.cancelWaapi();
1402
1400
  }
1403
1401
  async animateTo(target, velocityPxPerMs) {
1404
1402
  if (target === this.getSize()) {
@@ -1409,6 +1407,7 @@ var AnimationRunner = class {
1409
1407
  }
1410
1408
  this.currentTween?.cancel();
1411
1409
  this.currentSpring?.cancel();
1410
+ this.cancelWaapi();
1412
1411
  this.getRootEl()?.setAttribute("data-animating", "true");
1413
1412
  this.element.style.willChange = "transform";
1414
1413
  if (this.reducedMotion) {
@@ -3401,12 +3400,19 @@ var BottomSheetCore = class {
3401
3400
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3402
3401
  },
3403
3402
  setIsTop: (isTop) => {
3403
+ if (this.isTopSheet === isTop) return;
3404
3404
  this.isTopSheet = isTop;
3405
+ this.repaintScrim();
3405
3406
  },
3406
3407
  isOpen: () => this.size > 0 || this.opening,
3407
3408
  setDepth: (depth) => this.applyStackDepth(depth)
3408
3409
  }));
3409
3410
  }
3411
+ repaintScrim() {
3412
+ if (this.destroyed) return;
3413
+ this.scrim.invalidateOpacityCache();
3414
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3415
+ }
3410
3416
  applyStackDepth(depth) {
3411
3417
  if (!this.stackEffectEnabled) return;
3412
3418
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -4434,6 +4440,12 @@ var BottomSheet = component$((props) => {
4434
4440
  }
4435
4441
  if (dragFrom !== void 0) engine.setDragFrom(dragFrom);
4436
4442
  });
4443
+ useTask$(({ track }) => {
4444
+ const nextMode = track(() => props.mode);
4445
+ const engine = engineStore.engine;
4446
+ if (!engine || nextMode === void 0) return;
4447
+ engine.setMode(nextMode);
4448
+ });
4437
4449
  const showBackdrop = props.backdrop !== false;
4438
4450
  const mode = props.mode ?? "bottom";
4439
4451
  const ariaLabel = props.ariaLabel ?? "Bottom sheet";
package/dist/react.cjs CHANGED
@@ -851,22 +851,18 @@ var ScrimController = class {
851
851
  if (this.backdrop) {
852
852
  const [s, e] = this.backdropRange;
853
853
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
854
- const backdropOpacity = Math.min(
855
- Math.max((progress - s) / range, 0),
856
- 1
857
- );
858
- if (this.isTopSheet() || backdropOpacity === 0) {
859
- if (this.backdropOpacitySentinel.shouldWrite(
860
- backdropOpacity,
861
- OPACITY_WRITE_EPSILON
862
- )) {
863
- this.backdrop.style.opacity = String(backdropOpacity);
864
- }
865
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
866
- if (nextPointer !== this.lastBackdropPointer) {
867
- this.backdrop.style.pointerEvents = nextPointer;
868
- this.lastBackdropPointer = nextPointer;
869
- }
854
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
855
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
856
+ if (this.backdropOpacitySentinel.shouldWrite(
857
+ backdropOpacity,
858
+ OPACITY_WRITE_EPSILON
859
+ )) {
860
+ this.backdrop.style.opacity = String(backdropOpacity);
861
+ }
862
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
863
+ if (nextPointer !== this.lastBackdropPointer) {
864
+ this.backdrop.style.pointerEvents = nextPointer;
865
+ this.lastBackdropPointer = nextPointer;
870
866
  }
871
867
  }
872
868
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1396,18 +1392,20 @@ var AnimationRunner = class {
1396
1392
  get isAnimating() {
1397
1393
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1398
1394
  }
1395
+ cancelWaapi() {
1396
+ if (!this.currentWaapi) return;
1397
+ const entry = this.currentWaapi;
1398
+ this.currentWaapi = null;
1399
+ entry.stop();
1400
+ try {
1401
+ entry.anim.cancel();
1402
+ } catch {
1403
+ }
1404
+ }
1399
1405
  cancel() {
1400
1406
  this.currentTween?.cancel();
1401
1407
  this.currentSpring?.cancel();
1402
- if (this.currentWaapi) {
1403
- const entry = this.currentWaapi;
1404
- this.currentWaapi = null;
1405
- entry.stop();
1406
- try {
1407
- entry.anim.cancel();
1408
- } catch {
1409
- }
1410
- }
1408
+ this.cancelWaapi();
1411
1409
  }
1412
1410
  async animateTo(target, velocityPxPerMs) {
1413
1411
  if (target === this.getSize()) {
@@ -1418,6 +1416,7 @@ var AnimationRunner = class {
1418
1416
  }
1419
1417
  this.currentTween?.cancel();
1420
1418
  this.currentSpring?.cancel();
1419
+ this.cancelWaapi();
1421
1420
  this.getRootEl()?.setAttribute("data-animating", "true");
1422
1421
  this.element.style.willChange = "transform";
1423
1422
  if (this.reducedMotion) {
@@ -3410,12 +3409,19 @@ var BottomSheetCore = class {
3410
3409
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3411
3410
  },
3412
3411
  setIsTop: (isTop) => {
3412
+ if (this.isTopSheet === isTop) return;
3413
3413
  this.isTopSheet = isTop;
3414
+ this.repaintScrim();
3414
3415
  },
3415
3416
  isOpen: () => this.size > 0 || this.opening,
3416
3417
  setDepth: (depth) => this.applyStackDepth(depth)
3417
3418
  }));
3418
3419
  }
3420
+ repaintScrim() {
3421
+ if (this.destroyed) return;
3422
+ this.scrim.invalidateOpacityCache();
3423
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3424
+ }
3419
3425
  applyStackDepth(depth) {
3420
3426
  if (!this.stackEffectEnabled) return;
3421
3427
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -4667,6 +4673,11 @@ var BottomSheet = react.forwardRef(
4667
4673
  react.useEffect(() => {
4668
4674
  onChange?.(state);
4669
4675
  }, [state, onChange]);
4676
+ const mode = engineOpts.mode;
4677
+ react.useEffect(() => {
4678
+ if (mode === void 0) return;
4679
+ getEngine()?.setMode(mode);
4680
+ }, [getEngine, mode]);
4670
4681
  const [anchorHosts, setAnchorHosts] = react.useState([]);
4671
4682
  const anchorsKey = anchors ? JSON.stringify(
4672
4683
  anchors.map((a) => [
package/dist/react.d.cts CHANGED
@@ -1,10 +1,10 @@
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';
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-CK8Rh1He.cjs';
2
+ export { d as SnapPoint } from './BottomSheetCore-CK8Rh1He.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-B8C2CwF9.cjs';
7
+ import { B as BottomSheetEngine } from './BottomSheetEngine-hLSAxzla.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 { 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';
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-CIijwtdi.js';
2
+ export { d as SnapPoint } from './BottomSheetCore-CIijwtdi.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-DwYR_ygJ.js';
7
+ import { B as BottomSheetEngine } from './BottomSheetEngine-CZglPsTF.js';
8
8
  import { T as TeleportTarget } from './teleport-7uYNiEAT.js';
9
9
  import './transform-jVfAikE9.js';
10
10
 
package/dist/react.js CHANGED
@@ -849,22 +849,18 @@ var ScrimController = class {
849
849
  if (this.backdrop) {
850
850
  const [s, e] = this.backdropRange;
851
851
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
852
- const backdropOpacity = Math.min(
853
- Math.max((progress - s) / range, 0),
854
- 1
855
- );
856
- if (this.isTopSheet() || backdropOpacity === 0) {
857
- if (this.backdropOpacitySentinel.shouldWrite(
858
- backdropOpacity,
859
- OPACITY_WRITE_EPSILON
860
- )) {
861
- this.backdrop.style.opacity = String(backdropOpacity);
862
- }
863
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
864
- if (nextPointer !== this.lastBackdropPointer) {
865
- this.backdrop.style.pointerEvents = nextPointer;
866
- this.lastBackdropPointer = nextPointer;
867
- }
852
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
853
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
854
+ if (this.backdropOpacitySentinel.shouldWrite(
855
+ backdropOpacity,
856
+ OPACITY_WRITE_EPSILON
857
+ )) {
858
+ this.backdrop.style.opacity = String(backdropOpacity);
859
+ }
860
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
861
+ if (nextPointer !== this.lastBackdropPointer) {
862
+ this.backdrop.style.pointerEvents = nextPointer;
863
+ this.lastBackdropPointer = nextPointer;
868
864
  }
869
865
  }
870
866
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1394,18 +1390,20 @@ var AnimationRunner = class {
1394
1390
  get isAnimating() {
1395
1391
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1396
1392
  }
1393
+ cancelWaapi() {
1394
+ if (!this.currentWaapi) return;
1395
+ const entry = this.currentWaapi;
1396
+ this.currentWaapi = null;
1397
+ entry.stop();
1398
+ try {
1399
+ entry.anim.cancel();
1400
+ } catch {
1401
+ }
1402
+ }
1397
1403
  cancel() {
1398
1404
  this.currentTween?.cancel();
1399
1405
  this.currentSpring?.cancel();
1400
- if (this.currentWaapi) {
1401
- const entry = this.currentWaapi;
1402
- this.currentWaapi = null;
1403
- entry.stop();
1404
- try {
1405
- entry.anim.cancel();
1406
- } catch {
1407
- }
1408
- }
1406
+ this.cancelWaapi();
1409
1407
  }
1410
1408
  async animateTo(target, velocityPxPerMs) {
1411
1409
  if (target === this.getSize()) {
@@ -1416,6 +1414,7 @@ var AnimationRunner = class {
1416
1414
  }
1417
1415
  this.currentTween?.cancel();
1418
1416
  this.currentSpring?.cancel();
1417
+ this.cancelWaapi();
1419
1418
  this.getRootEl()?.setAttribute("data-animating", "true");
1420
1419
  this.element.style.willChange = "transform";
1421
1420
  if (this.reducedMotion) {
@@ -3408,12 +3407,19 @@ var BottomSheetCore = class {
3408
3407
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3409
3408
  },
3410
3409
  setIsTop: (isTop) => {
3410
+ if (this.isTopSheet === isTop) return;
3411
3411
  this.isTopSheet = isTop;
3412
+ this.repaintScrim();
3412
3413
  },
3413
3414
  isOpen: () => this.size > 0 || this.opening,
3414
3415
  setDepth: (depth) => this.applyStackDepth(depth)
3415
3416
  }));
3416
3417
  }
3418
+ repaintScrim() {
3419
+ if (this.destroyed) return;
3420
+ this.scrim.invalidateOpacityCache();
3421
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3422
+ }
3417
3423
  applyStackDepth(depth) {
3418
3424
  if (!this.stackEffectEnabled) return;
3419
3425
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -4665,6 +4671,11 @@ var BottomSheet = forwardRef(
4665
4671
  useEffect(() => {
4666
4672
  onChange?.(state);
4667
4673
  }, [state, onChange]);
4674
+ const mode = engineOpts.mode;
4675
+ useEffect(() => {
4676
+ if (mode === void 0) return;
4677
+ getEngine()?.setMode(mode);
4678
+ }, [getEngine, mode]);
4668
4679
  const [anchorHosts, setAnchorHosts] = useState([]);
4669
4680
  const anchorsKey = anchors ? JSON.stringify(
4670
4681
  anchors.map((a) => [
package/dist/solid.cjs CHANGED
@@ -844,22 +844,18 @@ var ScrimController = class {
844
844
  if (this.backdrop) {
845
845
  const [s, e] = this.backdropRange;
846
846
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
847
- const backdropOpacity = Math.min(
848
- Math.max((progress - s) / range, 0),
849
- 1
850
- );
851
- if (this.isTopSheet() || backdropOpacity === 0) {
852
- if (this.backdropOpacitySentinel.shouldWrite(
853
- backdropOpacity,
854
- OPACITY_WRITE_EPSILON
855
- )) {
856
- this.backdrop.style.opacity = String(backdropOpacity);
857
- }
858
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
859
- if (nextPointer !== this.lastBackdropPointer) {
860
- this.backdrop.style.pointerEvents = nextPointer;
861
- this.lastBackdropPointer = nextPointer;
862
- }
847
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
848
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
849
+ if (this.backdropOpacitySentinel.shouldWrite(
850
+ backdropOpacity,
851
+ OPACITY_WRITE_EPSILON
852
+ )) {
853
+ this.backdrop.style.opacity = String(backdropOpacity);
854
+ }
855
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
856
+ if (nextPointer !== this.lastBackdropPointer) {
857
+ this.backdrop.style.pointerEvents = nextPointer;
858
+ this.lastBackdropPointer = nextPointer;
863
859
  }
864
860
  }
865
861
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1389,18 +1385,20 @@ var AnimationRunner = class {
1389
1385
  get isAnimating() {
1390
1386
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1391
1387
  }
1388
+ cancelWaapi() {
1389
+ if (!this.currentWaapi) return;
1390
+ const entry = this.currentWaapi;
1391
+ this.currentWaapi = null;
1392
+ entry.stop();
1393
+ try {
1394
+ entry.anim.cancel();
1395
+ } catch {
1396
+ }
1397
+ }
1392
1398
  cancel() {
1393
1399
  this.currentTween?.cancel();
1394
1400
  this.currentSpring?.cancel();
1395
- if (this.currentWaapi) {
1396
- const entry = this.currentWaapi;
1397
- this.currentWaapi = null;
1398
- entry.stop();
1399
- try {
1400
- entry.anim.cancel();
1401
- } catch {
1402
- }
1403
- }
1401
+ this.cancelWaapi();
1404
1402
  }
1405
1403
  async animateTo(target, velocityPxPerMs) {
1406
1404
  if (target === this.getSize()) {
@@ -1411,6 +1409,7 @@ var AnimationRunner = class {
1411
1409
  }
1412
1410
  this.currentTween?.cancel();
1413
1411
  this.currentSpring?.cancel();
1412
+ this.cancelWaapi();
1414
1413
  this.getRootEl()?.setAttribute("data-animating", "true");
1415
1414
  this.element.style.willChange = "transform";
1416
1415
  if (this.reducedMotion) {
@@ -3403,12 +3402,19 @@ var BottomSheetCore = class {
3403
3402
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3404
3403
  },
3405
3404
  setIsTop: (isTop) => {
3405
+ if (this.isTopSheet === isTop) return;
3406
3406
  this.isTopSheet = isTop;
3407
+ this.repaintScrim();
3407
3408
  },
3408
3409
  isOpen: () => this.size > 0 || this.opening,
3409
3410
  setDepth: (depth) => this.applyStackDepth(depth)
3410
3411
  }));
3411
3412
  }
3413
+ repaintScrim() {
3414
+ if (this.destroyed) return;
3415
+ this.scrim.invalidateOpacityCache();
3416
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3417
+ }
3412
3418
  applyStackDepth(depth) {
3413
3419
  if (!this.stackEffectEnabled) return;
3414
3420
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -4417,6 +4423,12 @@ var BottomSheet = (props) => {
4417
4423
  }, {
4418
4424
  defer: true
4419
4425
  }));
4426
+ solidJs.createEffect(solidJs.on(() => props.mode, (value, prev) => {
4427
+ if (!engine || prev === void 0 || value === void 0) return;
4428
+ engine.setMode(value);
4429
+ }, {
4430
+ defer: true
4431
+ }));
4420
4432
  const showBackdrop = solidJs.createMemo(() => props.backdrop !== false);
4421
4433
  const mode = solidJs.createMemo(() => props.mode ?? "bottom");
4422
4434
  const ariaLabel = solidJs.createMemo(() => props.ariaLabel ?? "Bottom sheet");
package/dist/solid.d.cts CHANGED
@@ -377,6 +377,7 @@ declare class BottomSheetCore {
377
377
  private allowedIdsBySize;
378
378
  private updateAriaSlider;
379
379
  private registerInStack;
380
+ private repaintScrim;
380
381
  private applyStackDepth;
381
382
  private buildGestureDeps;
382
383
  private isContentDragAllowed;
package/dist/solid.d.ts CHANGED
@@ -377,6 +377,7 @@ declare class BottomSheetCore {
377
377
  private allowedIdsBySize;
378
378
  private updateAriaSlider;
379
379
  private registerInStack;
380
+ private repaintScrim;
380
381
  private applyStackDepth;
381
382
  private buildGestureDeps;
382
383
  private isContentDragAllowed;