@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/solid.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));
@@ -4415,6 +4421,12 @@ var BottomSheet = (props) => {
4415
4421
  }, {
4416
4422
  defer: true
4417
4423
  }));
4424
+ createEffect(on(() => props.mode, (value, prev) => {
4425
+ if (!engine || prev === void 0 || value === void 0) return;
4426
+ engine.setMode(value);
4427
+ }, {
4428
+ defer: true
4429
+ }));
4418
4430
  const showBackdrop = createMemo(() => props.backdrop !== false);
4419
4431
  const mode = createMemo(() => props.mode ?? "bottom");
4420
4432
  const ariaLabel = createMemo(() => props.ariaLabel ?? "Bottom sheet");
@@ -845,22 +845,18 @@ var ScrimController = class {
845
845
  if (this.backdrop) {
846
846
  const [s, e] = this.backdropRange;
847
847
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
848
- const backdropOpacity = Math.min(
849
- Math.max((progress - s) / range, 0),
850
- 1
851
- );
852
- if (this.isTopSheet() || backdropOpacity === 0) {
853
- if (this.backdropOpacitySentinel.shouldWrite(
854
- backdropOpacity,
855
- OPACITY_WRITE_EPSILON
856
- )) {
857
- this.backdrop.style.opacity = String(backdropOpacity);
858
- }
859
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
860
- if (nextPointer !== this.lastBackdropPointer) {
861
- this.backdrop.style.pointerEvents = nextPointer;
862
- this.lastBackdropPointer = nextPointer;
863
- }
848
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
849
+ const backdropOpacity = this.isTopSheet() ? ramp : 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;
864
860
  }
865
861
  }
866
862
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1390,18 +1386,20 @@ var AnimationRunner = class {
1390
1386
  get isAnimating() {
1391
1387
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1392
1388
  }
1389
+ cancelWaapi() {
1390
+ if (!this.currentWaapi) return;
1391
+ const entry = this.currentWaapi;
1392
+ this.currentWaapi = null;
1393
+ entry.stop();
1394
+ try {
1395
+ entry.anim.cancel();
1396
+ } catch {
1397
+ }
1398
+ }
1393
1399
  cancel() {
1394
1400
  this.currentTween?.cancel();
1395
1401
  this.currentSpring?.cancel();
1396
- if (this.currentWaapi) {
1397
- const entry = this.currentWaapi;
1398
- this.currentWaapi = null;
1399
- entry.stop();
1400
- try {
1401
- entry.anim.cancel();
1402
- } catch {
1403
- }
1404
- }
1402
+ this.cancelWaapi();
1405
1403
  }
1406
1404
  async animateTo(target, velocityPxPerMs) {
1407
1405
  if (target === this.getSize()) {
@@ -1412,6 +1410,7 @@ var AnimationRunner = class {
1412
1410
  }
1413
1411
  this.currentTween?.cancel();
1414
1412
  this.currentSpring?.cancel();
1413
+ this.cancelWaapi();
1415
1414
  this.getRootEl()?.setAttribute("data-animating", "true");
1416
1415
  this.element.style.willChange = "transform";
1417
1416
  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));
@@ -4443,6 +4449,16 @@ var BottomSheet = (props) => {
4443
4449
  { defer: true }
4444
4450
  )
4445
4451
  );
4452
+ createEffect(
4453
+ on(
4454
+ () => props.mode,
4455
+ (value, prev) => {
4456
+ if (!engine || prev === void 0 || value === void 0) return;
4457
+ engine.setMode(value);
4458
+ },
4459
+ { defer: true }
4460
+ )
4461
+ );
4446
4462
  const showBackdrop = createMemo(() => props.backdrop !== false);
4447
4463
  const mode = createMemo(() => props.mode ?? "bottom");
4448
4464
  const ariaLabel = createMemo(() => props.ariaLabel ?? "Bottom sheet");
@@ -843,22 +843,18 @@ var ScrimController = class {
843
843
  if (this.backdrop) {
844
844
  const [s, e] = this.backdropRange;
845
845
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
846
- const backdropOpacity = Math.min(
847
- Math.max((progress - s) / range, 0),
848
- 1
849
- );
850
- if (this.isTopSheet() || backdropOpacity === 0) {
851
- if (this.backdropOpacitySentinel.shouldWrite(
852
- backdropOpacity,
853
- OPACITY_WRITE_EPSILON
854
- )) {
855
- this.backdrop.style.opacity = String(backdropOpacity);
856
- }
857
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
858
- if (nextPointer !== this.lastBackdropPointer) {
859
- this.backdrop.style.pointerEvents = nextPointer;
860
- this.lastBackdropPointer = nextPointer;
861
- }
846
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
847
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
848
+ if (this.backdropOpacitySentinel.shouldWrite(
849
+ backdropOpacity,
850
+ OPACITY_WRITE_EPSILON
851
+ )) {
852
+ this.backdrop.style.opacity = String(backdropOpacity);
853
+ }
854
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
855
+ if (nextPointer !== this.lastBackdropPointer) {
856
+ this.backdrop.style.pointerEvents = nextPointer;
857
+ this.lastBackdropPointer = nextPointer;
862
858
  }
863
859
  }
864
860
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1388,18 +1384,20 @@ var AnimationRunner = class {
1388
1384
  get isAnimating() {
1389
1385
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1390
1386
  }
1387
+ cancelWaapi() {
1388
+ if (!this.currentWaapi) return;
1389
+ const entry = this.currentWaapi;
1390
+ this.currentWaapi = null;
1391
+ entry.stop();
1392
+ try {
1393
+ entry.anim.cancel();
1394
+ } catch {
1395
+ }
1396
+ }
1391
1397
  cancel() {
1392
1398
  this.currentTween?.cancel();
1393
1399
  this.currentSpring?.cancel();
1394
- if (this.currentWaapi) {
1395
- const entry = this.currentWaapi;
1396
- this.currentWaapi = null;
1397
- entry.stop();
1398
- try {
1399
- entry.anim.cancel();
1400
- } catch {
1401
- }
1402
- }
1400
+ this.cancelWaapi();
1403
1401
  }
1404
1402
  async animateTo(target, velocityPxPerMs) {
1405
1403
  if (target === this.getSize()) {
@@ -1410,6 +1408,7 @@ var AnimationRunner = class {
1410
1408
  }
1411
1409
  this.currentTween?.cancel();
1412
1410
  this.currentSpring?.cancel();
1411
+ this.cancelWaapi();
1413
1412
  this.getRootEl()?.setAttribute("data-animating", "true");
1414
1413
  this.element.style.willChange = "transform";
1415
1414
  if (this.reducedMotion) {
@@ -3402,12 +3401,19 @@ var BottomSheetCore = class {
3402
3401
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3403
3402
  },
3404
3403
  setIsTop: (isTop) => {
3404
+ if (this.isTopSheet === isTop) return;
3405
3405
  this.isTopSheet = isTop;
3406
+ this.repaintScrim();
3406
3407
  },
3407
3408
  isOpen: () => this.size > 0 || this.opening,
3408
3409
  setDepth: (depth) => this.applyStackDepth(depth)
3409
3410
  }));
3410
3411
  }
3412
+ repaintScrim() {
3413
+ if (this.destroyed) return;
3414
+ this.scrim.invalidateOpacityCache();
3415
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3416
+ }
3411
3417
  applyStackDepth(depth) {
3412
3418
  if (!this.stackEffectEnabled) return;
3413
3419
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -841,22 +841,18 @@ var ScrimController = class {
841
841
  if (this.backdrop) {
842
842
  const [s, e] = this.backdropRange;
843
843
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
844
- const backdropOpacity = Math.min(
845
- Math.max((progress - s) / range, 0),
846
- 1
847
- );
848
- if (this.isTopSheet() || backdropOpacity === 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;
859
- }
844
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
845
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
846
+ if (this.backdropOpacitySentinel.shouldWrite(
847
+ backdropOpacity,
848
+ OPACITY_WRITE_EPSILON
849
+ )) {
850
+ this.backdrop.style.opacity = String(backdropOpacity);
851
+ }
852
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
853
+ if (nextPointer !== this.lastBackdropPointer) {
854
+ this.backdrop.style.pointerEvents = nextPointer;
855
+ this.lastBackdropPointer = nextPointer;
860
856
  }
861
857
  }
862
858
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1386,18 +1382,20 @@ var AnimationRunner = class {
1386
1382
  get isAnimating() {
1387
1383
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1388
1384
  }
1385
+ cancelWaapi() {
1386
+ if (!this.currentWaapi) return;
1387
+ const entry = this.currentWaapi;
1388
+ this.currentWaapi = null;
1389
+ entry.stop();
1390
+ try {
1391
+ entry.anim.cancel();
1392
+ } catch {
1393
+ }
1394
+ }
1389
1395
  cancel() {
1390
1396
  this.currentTween?.cancel();
1391
1397
  this.currentSpring?.cancel();
1392
- if (this.currentWaapi) {
1393
- const entry = this.currentWaapi;
1394
- this.currentWaapi = null;
1395
- entry.stop();
1396
- try {
1397
- entry.anim.cancel();
1398
- } catch {
1399
- }
1400
- }
1398
+ this.cancelWaapi();
1401
1399
  }
1402
1400
  async animateTo(target, velocityPxPerMs) {
1403
1401
  if (target === this.getSize()) {
@@ -1408,6 +1406,7 @@ var AnimationRunner = class {
1408
1406
  }
1409
1407
  this.currentTween?.cancel();
1410
1408
  this.currentSpring?.cancel();
1409
+ this.cancelWaapi();
1411
1410
  this.getRootEl()?.setAttribute("data-animating", "true");
1412
1411
  this.element.style.willChange = "transform";
1413
1412
  if (this.reducedMotion) {
@@ -3400,12 +3399,19 @@ var BottomSheetCore = class {
3400
3399
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3401
3400
  },
3402
3401
  setIsTop: (isTop) => {
3402
+ if (this.isTopSheet === isTop) return;
3403
3403
  this.isTopSheet = isTop;
3404
+ this.repaintScrim();
3404
3405
  },
3405
3406
  isOpen: () => this.size > 0 || this.opening,
3406
3407
  setDepth: (depth) => this.applyStackDepth(depth)
3407
3408
  }));
3408
3409
  }
3410
+ repaintScrim() {
3411
+ if (this.destroyed) return;
3412
+ this.scrim.invalidateOpacityCache();
3413
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3414
+ }
3409
3415
  applyStackDepth(depth) {
3410
3416
  if (!this.stackEffectEnabled) return;
3411
3417
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -286,6 +286,9 @@
286
286
  $effect(() => {
287
287
  if (dragFrom !== undefined) engine?.setDragFrom(dragFrom);
288
288
  });
289
+ $effect(() => {
290
+ if (mode !== undefined) engine?.setMode(mode);
291
+ });
289
292
  $effect(() => {
290
293
  if (radius !== undefined) engine?.setRadius(radius);
291
294
  });
package/dist/svelte.cjs CHANGED
@@ -865,22 +865,18 @@ var ScrimController = class {
865
865
  if (this.backdrop) {
866
866
  const [s, e] = this.backdropRange;
867
867
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
868
- const backdropOpacity = Math.min(
869
- Math.max((progress - s) / range, 0),
870
- 1
871
- );
872
- if (this.isTopSheet() || backdropOpacity === 0) {
873
- if (this.backdropOpacitySentinel.shouldWrite(
874
- backdropOpacity,
875
- OPACITY_WRITE_EPSILON
876
- )) {
877
- this.backdrop.style.opacity = String(backdropOpacity);
878
- }
879
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
880
- if (nextPointer !== this.lastBackdropPointer) {
881
- this.backdrop.style.pointerEvents = nextPointer;
882
- this.lastBackdropPointer = nextPointer;
883
- }
868
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
869
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
870
+ if (this.backdropOpacitySentinel.shouldWrite(
871
+ backdropOpacity,
872
+ OPACITY_WRITE_EPSILON
873
+ )) {
874
+ this.backdrop.style.opacity = String(backdropOpacity);
875
+ }
876
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
877
+ if (nextPointer !== this.lastBackdropPointer) {
878
+ this.backdrop.style.pointerEvents = nextPointer;
879
+ this.lastBackdropPointer = nextPointer;
884
880
  }
885
881
  }
886
882
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1410,18 +1406,20 @@ var AnimationRunner = class {
1410
1406
  get isAnimating() {
1411
1407
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1412
1408
  }
1409
+ cancelWaapi() {
1410
+ if (!this.currentWaapi) return;
1411
+ const entry = this.currentWaapi;
1412
+ this.currentWaapi = null;
1413
+ entry.stop();
1414
+ try {
1415
+ entry.anim.cancel();
1416
+ } catch {
1417
+ }
1418
+ }
1413
1419
  cancel() {
1414
1420
  this.currentTween?.cancel();
1415
1421
  this.currentSpring?.cancel();
1416
- if (this.currentWaapi) {
1417
- const entry = this.currentWaapi;
1418
- this.currentWaapi = null;
1419
- entry.stop();
1420
- try {
1421
- entry.anim.cancel();
1422
- } catch {
1423
- }
1424
- }
1422
+ this.cancelWaapi();
1425
1423
  }
1426
1424
  async animateTo(target, velocityPxPerMs) {
1427
1425
  if (target === this.getSize()) {
@@ -1432,6 +1430,7 @@ var AnimationRunner = class {
1432
1430
  }
1433
1431
  this.currentTween?.cancel();
1434
1432
  this.currentSpring?.cancel();
1433
+ this.cancelWaapi();
1435
1434
  this.getRootEl()?.setAttribute("data-animating", "true");
1436
1435
  this.element.style.willChange = "transform";
1437
1436
  if (this.reducedMotion) {
@@ -3424,12 +3423,19 @@ var BottomSheetCore = class {
3424
3423
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3425
3424
  },
3426
3425
  setIsTop: (isTop) => {
3426
+ if (this.isTopSheet === isTop) return;
3427
3427
  this.isTopSheet = isTop;
3428
+ this.repaintScrim();
3428
3429
  },
3429
3430
  isOpen: () => this.size > 0 || this.opening,
3430
3431
  setDepth: (depth) => this.applyStackDepth(depth)
3431
3432
  }));
3432
3433
  }
3434
+ repaintScrim() {
3435
+ if (this.destroyed) return;
3436
+ this.scrim.invalidateOpacityCache();
3437
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3438
+ }
3433
3439
  applyStackDepth(depth) {
3434
3440
  if (!this.stackEffectEnabled) return;
3435
3441
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -4522,6 +4528,9 @@ function BottomSheet($$anchor, $$props) {
4522
4528
  $2__namespace.user_effect(() => {
4523
4529
  if ($$props.dragFrom !== void 0) engine?.setDragFrom($$props.dragFrom);
4524
4530
  });
4531
+ $2__namespace.user_effect(() => {
4532
+ if (mode() !== void 0) engine?.setMode(mode());
4533
+ });
4525
4534
  $2__namespace.user_effect(() => {
4526
4535
  if ($$props.radius !== void 0) engine?.setRadius($$props.radius);
4527
4536
  });
package/dist/svelte.js CHANGED
@@ -843,22 +843,18 @@ var ScrimController = class {
843
843
  if (this.backdrop) {
844
844
  const [s, e] = this.backdropRange;
845
845
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
846
- const backdropOpacity = Math.min(
847
- Math.max((progress - s) / range, 0),
848
- 1
849
- );
850
- if (this.isTopSheet() || backdropOpacity === 0) {
851
- if (this.backdropOpacitySentinel.shouldWrite(
852
- backdropOpacity,
853
- OPACITY_WRITE_EPSILON
854
- )) {
855
- this.backdrop.style.opacity = String(backdropOpacity);
856
- }
857
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
858
- if (nextPointer !== this.lastBackdropPointer) {
859
- this.backdrop.style.pointerEvents = nextPointer;
860
- this.lastBackdropPointer = nextPointer;
861
- }
846
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
847
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
848
+ if (this.backdropOpacitySentinel.shouldWrite(
849
+ backdropOpacity,
850
+ OPACITY_WRITE_EPSILON
851
+ )) {
852
+ this.backdrop.style.opacity = String(backdropOpacity);
853
+ }
854
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
855
+ if (nextPointer !== this.lastBackdropPointer) {
856
+ this.backdrop.style.pointerEvents = nextPointer;
857
+ this.lastBackdropPointer = nextPointer;
862
858
  }
863
859
  }
864
860
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1388,18 +1384,20 @@ var AnimationRunner = class {
1388
1384
  get isAnimating() {
1389
1385
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1390
1386
  }
1387
+ cancelWaapi() {
1388
+ if (!this.currentWaapi) return;
1389
+ const entry = this.currentWaapi;
1390
+ this.currentWaapi = null;
1391
+ entry.stop();
1392
+ try {
1393
+ entry.anim.cancel();
1394
+ } catch {
1395
+ }
1396
+ }
1391
1397
  cancel() {
1392
1398
  this.currentTween?.cancel();
1393
1399
  this.currentSpring?.cancel();
1394
- if (this.currentWaapi) {
1395
- const entry = this.currentWaapi;
1396
- this.currentWaapi = null;
1397
- entry.stop();
1398
- try {
1399
- entry.anim.cancel();
1400
- } catch {
1401
- }
1402
- }
1400
+ this.cancelWaapi();
1403
1401
  }
1404
1402
  async animateTo(target, velocityPxPerMs) {
1405
1403
  if (target === this.getSize()) {
@@ -1410,6 +1408,7 @@ var AnimationRunner = class {
1410
1408
  }
1411
1409
  this.currentTween?.cancel();
1412
1410
  this.currentSpring?.cancel();
1411
+ this.cancelWaapi();
1413
1412
  this.getRootEl()?.setAttribute("data-animating", "true");
1414
1413
  this.element.style.willChange = "transform";
1415
1414
  if (this.reducedMotion) {
@@ -3402,12 +3401,19 @@ var BottomSheetCore = class {
3402
3401
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3403
3402
  },
3404
3403
  setIsTop: (isTop) => {
3404
+ if (this.isTopSheet === isTop) return;
3405
3405
  this.isTopSheet = isTop;
3406
+ this.repaintScrim();
3406
3407
  },
3407
3408
  isOpen: () => this.size > 0 || this.opening,
3408
3409
  setDepth: (depth) => this.applyStackDepth(depth)
3409
3410
  }));
3410
3411
  }
3412
+ repaintScrim() {
3413
+ if (this.destroyed) return;
3414
+ this.scrim.invalidateOpacityCache();
3415
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3416
+ }
3411
3417
  applyStackDepth(depth) {
3412
3418
  if (!this.stackEffectEnabled) return;
3413
3419
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -4500,6 +4506,9 @@ function BottomSheet($$anchor, $$props) {
4500
4506
  $2.user_effect(() => {
4501
4507
  if ($$props.dragFrom !== void 0) engine?.setDragFrom($$props.dragFrom);
4502
4508
  });
4509
+ $2.user_effect(() => {
4510
+ if (mode() !== void 0) engine?.setMode(mode());
4511
+ });
4503
4512
  $2.user_effect(() => {
4504
4513
  if ($$props.radius !== void 0) engine?.setRadius($$props.radius);
4505
4514
  });