@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/element.js CHANGED
@@ -950,22 +950,18 @@ var init_scrim_controller = __esm({
950
950
  if (this.backdrop) {
951
951
  const [s, e] = this.backdropRange;
952
952
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
953
- const backdropOpacity = Math.min(
954
- Math.max((progress - s) / range, 0),
955
- 1
956
- );
957
- if (this.isTopSheet() || backdropOpacity === 0) {
958
- if (this.backdropOpacitySentinel.shouldWrite(
959
- backdropOpacity,
960
- OPACITY_WRITE_EPSILON
961
- )) {
962
- this.backdrop.style.opacity = String(backdropOpacity);
963
- }
964
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
965
- if (nextPointer !== this.lastBackdropPointer) {
966
- this.backdrop.style.pointerEvents = nextPointer;
967
- this.lastBackdropPointer = nextPointer;
968
- }
953
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
954
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
955
+ if (this.backdropOpacitySentinel.shouldWrite(
956
+ backdropOpacity,
957
+ OPACITY_WRITE_EPSILON
958
+ )) {
959
+ this.backdrop.style.opacity = String(backdropOpacity);
960
+ }
961
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
962
+ if (nextPointer !== this.lastBackdropPointer) {
963
+ this.backdrop.style.pointerEvents = nextPointer;
964
+ this.lastBackdropPointer = nextPointer;
969
965
  }
970
966
  }
971
967
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1526,18 +1522,20 @@ var init_animation_runner = __esm({
1526
1522
  get isAnimating() {
1527
1523
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1528
1524
  }
1525
+ cancelWaapi() {
1526
+ if (!this.currentWaapi) return;
1527
+ const entry = this.currentWaapi;
1528
+ this.currentWaapi = null;
1529
+ entry.stop();
1530
+ try {
1531
+ entry.anim.cancel();
1532
+ } catch {
1533
+ }
1534
+ }
1529
1535
  cancel() {
1530
1536
  this.currentTween?.cancel();
1531
1537
  this.currentSpring?.cancel();
1532
- if (this.currentWaapi) {
1533
- const entry = this.currentWaapi;
1534
- this.currentWaapi = null;
1535
- entry.stop();
1536
- try {
1537
- entry.anim.cancel();
1538
- } catch {
1539
- }
1540
- }
1538
+ this.cancelWaapi();
1541
1539
  }
1542
1540
  async animateTo(target, velocityPxPerMs) {
1543
1541
  if (target === this.getSize()) {
@@ -1548,6 +1546,7 @@ var init_animation_runner = __esm({
1548
1546
  }
1549
1547
  this.currentTween?.cancel();
1550
1548
  this.currentSpring?.cancel();
1549
+ this.cancelWaapi();
1551
1550
  this.getRootEl()?.setAttribute("data-animating", "true");
1552
1551
  this.element.style.willChange = "transform";
1553
1552
  if (this.reducedMotion) {
@@ -3676,12 +3675,19 @@ var init_BottomSheetCore = __esm({
3676
3675
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3677
3676
  },
3678
3677
  setIsTop: (isTop) => {
3678
+ if (this.isTopSheet === isTop) return;
3679
3679
  this.isTopSheet = isTop;
3680
+ this.repaintScrim();
3680
3681
  },
3681
3682
  isOpen: () => this.size > 0 || this.opening,
3682
3683
  setDepth: (depth) => this.applyStackDepth(depth)
3683
3684
  }));
3684
3685
  }
3686
+ repaintScrim() {
3687
+ if (this.destroyed) return;
3688
+ this.scrim.invalidateOpacityCache();
3689
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3690
+ }
3685
3691
  applyStackDepth(depth) {
3686
3692
  if (!this.stackEffectEnabled) return;
3687
3693
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -4688,6 +4694,7 @@ var init_attributes = __esm({
4688
4694
  ATTR_SCRIM_COLOR = "scrim-color";
4689
4695
  ATTR_SNAP = "snap";
4690
4696
  LIVE_ATTRS = /* @__PURE__ */ new Set([
4697
+ ATTR_MODE,
4691
4698
  ATTR_RADIUS,
4692
4699
  ATTR_MAX_HEIGHT,
4693
4700
  ATTR_BACKDROP_COLOR,
@@ -4914,6 +4921,9 @@ var init_BottomSheetElement = __esm({
4914
4921
  if (mode) this.engine.setDragFrom(mode);
4915
4922
  break;
4916
4923
  }
4924
+ case ATTR_MODE:
4925
+ this.engine.setMode(parseMode(value));
4926
+ break;
4917
4927
  case ATTR_SNAP:
4918
4928
  if (value && value !== this.engine.state.activeId) {
4919
4929
  void this.engine.snapTo(value);
@@ -1,5 +1,5 @@
1
- import { f as EngineFeature } from './BottomSheetCore-VPJZcKcg.cjs';
2
- export { m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage } from './BottomSheetCore-VPJZcKcg.cjs';
1
+ import { f as EngineFeature } from './BottomSheetCore-CK8Rh1He.cjs';
2
+ export { m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage } from './BottomSheetCore-CK8Rh1He.cjs';
3
3
  import './transform-jVfAikE9.cjs';
4
4
 
5
5
  declare function routeFeature(): EngineFeature;
@@ -1,5 +1,5 @@
1
- import { f as EngineFeature } from './BottomSheetCore-Cgn8b_6A.js';
2
- export { m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage } from './BottomSheetCore-Cgn8b_6A.js';
1
+ import { f as EngineFeature } from './BottomSheetCore-CIijwtdi.js';
2
+ export { m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage } from './BottomSheetCore-CIijwtdi.js';
3
3
  import './transform-jVfAikE9.js';
4
4
 
5
5
  declare function routeFeature(): EngineFeature;
@@ -1,4 +1,4 @@
1
- import { a as SnapPointDef, b as SheetMode } from './BottomSheetCore-VPJZcKcg.cjs';
1
+ import { a as SnapPointDef, b as SheetMode } from './BottomSheetCore-CK8Rh1He.cjs';
2
2
 
3
3
  type ResolvedSnap = {
4
4
  id: string;
@@ -1,4 +1,4 @@
1
- import { a as SnapPointDef, b as SheetMode } from './BottomSheetCore-Cgn8b_6A.js';
1
+ import { a as SnapPointDef, b as SheetMode } from './BottomSheetCore-CIijwtdi.js';
2
2
 
3
3
  type ResolvedSnap = {
4
4
  id: string;
package/dist/index.cjs CHANGED
@@ -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));
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- export { B as BottomSheetEngine } from './BottomSheetEngine-B8C2CwF9.cjs';
2
- import { d as SnapPoint, b as SheetMode, c as EngineOptions, P as PhysicalSheetMode, g as ScrimOverlayPosition } from './BottomSheetCore-VPJZcKcg.cjs';
3
- export { h as AnchorAnimationPreset, i as AnchorAnimationSpec, j as AnchorHandle, A as AnchorOptions, k as AnchorPosition, l as AnchorState, B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, E as EngineState, L as LogicalSheetMode, p as Plugin, q as SCRIM_PRESETS, r as ScrimOverlayOptions, s as ScrimPreset, t as ScrimPresetConfig, u as ScrimStageDef, e as ScrimStagesOptions, v as ScrimUpdate, S as SheetEventMap, w as SnapId, a as SnapPointDef, T as TeardownScope, x as runAnchorTransition } from './BottomSheetCore-VPJZcKcg.cjs';
1
+ export { B as BottomSheetEngine } from './BottomSheetEngine-hLSAxzla.cjs';
2
+ import { d as SnapPoint, b as SheetMode, c as EngineOptions, P as PhysicalSheetMode, g as ScrimOverlayPosition } from './BottomSheetCore-CK8Rh1He.cjs';
3
+ export { h as AnchorAnimationPreset, i as AnchorAnimationSpec, j as AnchorHandle, A as AnchorOptions, k as AnchorPosition, l as AnchorState, B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, E as EngineState, L as LogicalSheetMode, p as Plugin, q as SCRIM_PRESETS, r as ScrimOverlayOptions, s as ScrimPreset, t as ScrimPresetConfig, u as ScrimStageDef, e as ScrimStagesOptions, v as ScrimUpdate, S as SheetEventMap, w as SnapId, a as SnapPointDef, T as TeardownScope, x as runAnchorTransition } from './BottomSheetCore-CK8Rh1He.cjs';
4
4
  export { autoCollapseFeature, contentSwipeFeature, defaultEngineFeatures, persistFeature, routeFeature, visualViewportFeature } from './features.cjs';
5
- export { R as ResolvedSnap, r as resolveSnapList } from './index-CnfbOKx0.cjs';
5
+ export { R as ResolvedSnap, r as resolveSnapList } from './index-BEX-NHRJ.cjs';
6
6
  import './transform-jVfAikE9.cjs';
7
7
 
8
8
  declare const resolveSnap: (point: SnapPoint | string, mode: SheetMode, measureFit?: () => number) => number;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export { B as BottomSheetEngine } from './BottomSheetEngine-DwYR_ygJ.js';
2
- import { d as SnapPoint, b as SheetMode, c as EngineOptions, P as PhysicalSheetMode, g as ScrimOverlayPosition } from './BottomSheetCore-Cgn8b_6A.js';
3
- export { h as AnchorAnimationPreset, i as AnchorAnimationSpec, j as AnchorHandle, A as AnchorOptions, k as AnchorPosition, l as AnchorState, B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, E as EngineState, L as LogicalSheetMode, p as Plugin, q as SCRIM_PRESETS, r as ScrimOverlayOptions, s as ScrimPreset, t as ScrimPresetConfig, u as ScrimStageDef, e as ScrimStagesOptions, v as ScrimUpdate, S as SheetEventMap, w as SnapId, a as SnapPointDef, T as TeardownScope, x as runAnchorTransition } from './BottomSheetCore-Cgn8b_6A.js';
1
+ export { B as BottomSheetEngine } from './BottomSheetEngine-CZglPsTF.js';
2
+ import { d as SnapPoint, b as SheetMode, c as EngineOptions, P as PhysicalSheetMode, g as ScrimOverlayPosition } from './BottomSheetCore-CIijwtdi.js';
3
+ export { h as AnchorAnimationPreset, i as AnchorAnimationSpec, j as AnchorHandle, A as AnchorOptions, k as AnchorPosition, l as AnchorState, B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, E as EngineState, L as LogicalSheetMode, p as Plugin, q as SCRIM_PRESETS, r as ScrimOverlayOptions, s as ScrimPreset, t as ScrimPresetConfig, u as ScrimStageDef, e as ScrimStagesOptions, v as ScrimUpdate, S as SheetEventMap, w as SnapId, a as SnapPointDef, T as TeardownScope, x as runAnchorTransition } from './BottomSheetCore-CIijwtdi.js';
4
4
  export { autoCollapseFeature, contentSwipeFeature, defaultEngineFeatures, persistFeature, routeFeature, visualViewportFeature } from './features.js';
5
- export { R as ResolvedSnap, r as resolveSnapList } from './index-DcMkhXAy.js';
5
+ export { R as ResolvedSnap, r as resolveSnapList } from './index-BqLHKOeM.js';
6
6
  import './transform-jVfAikE9.js';
7
7
 
8
8
  declare const resolveSnap: (point: SnapPoint | string, mode: SheetMode, measureFit?: () => number) => number;
package/dist/index.js CHANGED
@@ -839,22 +839,18 @@ var ScrimController = class {
839
839
  if (this.backdrop) {
840
840
  const [s, e] = this.backdropRange;
841
841
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
842
- const backdropOpacity = Math.min(
843
- Math.max((progress - s) / range, 0),
844
- 1
845
- );
846
- if (this.isTopSheet() || backdropOpacity === 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;
857
- }
842
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
843
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
844
+ if (this.backdropOpacitySentinel.shouldWrite(
845
+ backdropOpacity,
846
+ OPACITY_WRITE_EPSILON
847
+ )) {
848
+ this.backdrop.style.opacity = String(backdropOpacity);
849
+ }
850
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
851
+ if (nextPointer !== this.lastBackdropPointer) {
852
+ this.backdrop.style.pointerEvents = nextPointer;
853
+ this.lastBackdropPointer = nextPointer;
858
854
  }
859
855
  }
860
856
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1384,18 +1380,20 @@ var AnimationRunner = class {
1384
1380
  get isAnimating() {
1385
1381
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1386
1382
  }
1383
+ cancelWaapi() {
1384
+ if (!this.currentWaapi) return;
1385
+ const entry = this.currentWaapi;
1386
+ this.currentWaapi = null;
1387
+ entry.stop();
1388
+ try {
1389
+ entry.anim.cancel();
1390
+ } catch {
1391
+ }
1392
+ }
1387
1393
  cancel() {
1388
1394
  this.currentTween?.cancel();
1389
1395
  this.currentSpring?.cancel();
1390
- if (this.currentWaapi) {
1391
- const entry = this.currentWaapi;
1392
- this.currentWaapi = null;
1393
- entry.stop();
1394
- try {
1395
- entry.anim.cancel();
1396
- } catch {
1397
- }
1398
- }
1396
+ this.cancelWaapi();
1399
1397
  }
1400
1398
  async animateTo(target, velocityPxPerMs) {
1401
1399
  if (target === this.getSize()) {
@@ -1406,6 +1404,7 @@ var AnimationRunner = class {
1406
1404
  }
1407
1405
  this.currentTween?.cancel();
1408
1406
  this.currentSpring?.cancel();
1407
+ this.cancelWaapi();
1409
1408
  this.getRootEl()?.setAttribute("data-animating", "true");
1410
1409
  this.element.style.willChange = "transform";
1411
1410
  if (this.reducedMotion) {
@@ -3398,12 +3397,19 @@ var BottomSheetCore = class {
3398
3397
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3399
3398
  },
3400
3399
  setIsTop: (isTop) => {
3400
+ if (this.isTopSheet === isTop) return;
3401
3401
  this.isTopSheet = isTop;
3402
+ this.repaintScrim();
3402
3403
  },
3403
3404
  isOpen: () => this.size > 0 || this.opening,
3404
3405
  setDepth: (depth) => this.applyStackDepth(depth)
3405
3406
  }));
3406
3407
  }
3408
+ repaintScrim() {
3409
+ if (this.destroyed) return;
3410
+ this.scrim.invalidateOpacityCache();
3411
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3412
+ }
3407
3413
  applyStackDepth(depth) {
3408
3414
  if (!this.stackEffectEnabled) return;
3409
3415
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -1,4 +1,4 @@
1
- import { S as SheetEventMap } from '../BottomSheetCore-VPJZcKcg.cjs';
1
+ import { S as SheetEventMap } from '../BottomSheetCore-CK8Rh1He.cjs';
2
2
  import '../transform-jVfAikE9.cjs';
3
3
 
4
4
  type FormikStateLike = {
@@ -1,4 +1,4 @@
1
- import { S as SheetEventMap } from '../BottomSheetCore-Cgn8b_6A.js';
1
+ import { S as SheetEventMap } from '../BottomSheetCore-CIijwtdi.js';
2
2
  import '../transform-jVfAikE9.js';
3
3
 
4
4
  type FormikStateLike = {
@@ -1,4 +1,4 @@
1
- import { S as SheetEventMap } from '../BottomSheetCore-VPJZcKcg.cjs';
1
+ import { S as SheetEventMap } from '../BottomSheetCore-CK8Rh1He.cjs';
2
2
  import '../transform-jVfAikE9.cjs';
3
3
 
4
4
  type RhfFormStateLike = {
@@ -1,4 +1,4 @@
1
- import { S as SheetEventMap } from '../BottomSheetCore-Cgn8b_6A.js';
1
+ import { S as SheetEventMap } from '../BottomSheetCore-CIijwtdi.js';
2
2
  import '../transform-jVfAikE9.js';
3
3
 
4
4
  type RhfFormStateLike = {
package/dist/preact.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { BottomSheet, BottomSheetFromConfig, BottomSheetFromConfigProps, BottomSheetHandle, BottomSheetProps, HeaderProp, Overlay, OverlayHandle, OverlayProps, SheetConfig, UseBottomSheetRefs, UseBottomSheetReturn, UseOverlayReturn, useBottomSheet, useOverlay } from './react.cjs';
2
- export { E as EngineState, b as SheetMode, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-VPJZcKcg.cjs';
2
+ export { E as EngineState, b as SheetMode, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-CK8Rh1He.cjs';
3
3
  export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.cjs';
4
4
  import 'react';
5
- import './BottomSheetEngine-B8C2CwF9.cjs';
5
+ import './BottomSheetEngine-hLSAxzla.cjs';
6
6
  import './teleport-7uYNiEAT.cjs';
7
7
  import './transform-jVfAikE9.cjs';
package/dist/preact.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { BottomSheet, BottomSheetFromConfig, BottomSheetFromConfigProps, BottomSheetHandle, BottomSheetProps, HeaderProp, Overlay, OverlayHandle, OverlayProps, SheetConfig, UseBottomSheetRefs, UseBottomSheetReturn, UseOverlayReturn, useBottomSheet, useOverlay } from './react.js';
2
- export { E as EngineState, b as SheetMode, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-Cgn8b_6A.js';
2
+ export { E as EngineState, b as SheetMode, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-CIijwtdi.js';
3
3
  export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.js';
4
4
  import 'react';
5
- import './BottomSheetEngine-DwYR_ygJ.js';
5
+ import './BottomSheetEngine-CZglPsTF.js';
6
6
  import './teleport-7uYNiEAT.js';
7
7
  import './transform-jVfAikE9.js';
@@ -856,16 +856,15 @@ class ScrimController {
856
856
  if (this.backdrop) {
857
857
  const [s, e] = this.backdropRange;
858
858
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
859
- const backdropOpacity = Math.min(Math.max((progress - s) / range, 0), 1);
860
- if (this.isTopSheet() || backdropOpacity === 0) {
861
- if (this.backdropOpacitySentinel.shouldWrite(backdropOpacity, OPACITY_WRITE_EPSILON)) {
862
- this.backdrop.style.opacity = String(backdropOpacity);
863
- }
864
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
865
- if (nextPointer !== this.lastBackdropPointer) {
866
- this.backdrop.style.pointerEvents = nextPointer;
867
- this.lastBackdropPointer = nextPointer;
868
- }
859
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
860
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
861
+ if (this.backdropOpacitySentinel.shouldWrite(backdropOpacity, OPACITY_WRITE_EPSILON)) {
862
+ this.backdrop.style.opacity = String(backdropOpacity);
863
+ }
864
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
865
+ if (nextPointer !== this.lastBackdropPointer) {
866
+ this.backdrop.style.pointerEvents = nextPointer;
867
+ this.lastBackdropPointer = nextPointer;
869
868
  }
870
869
  }
871
870
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1410,18 +1409,20 @@ class AnimationRunner {
1410
1409
  get isAnimating() {
1411
1410
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1412
1411
  }
1412
+ cancelWaapi() {
1413
+ if (!this.currentWaapi) return;
1414
+ const entry = this.currentWaapi;
1415
+ this.currentWaapi = null;
1416
+ entry.stop();
1417
+ try {
1418
+ entry.anim.cancel();
1419
+ } catch {
1420
+ }
1421
+ }
1413
1422
  cancel() {
1414
1423
  this.currentTween?.cancel();
1415
1424
  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
- }
1425
+ this.cancelWaapi();
1425
1426
  }
1426
1427
  async animateTo(target, velocityPxPerMs) {
1427
1428
  if (target === this.getSize()) {
@@ -1432,6 +1433,7 @@ class AnimationRunner {
1432
1433
  }
1433
1434
  this.currentTween?.cancel();
1434
1435
  this.currentSpring?.cancel();
1436
+ this.cancelWaapi();
1435
1437
  this.getRootEl()?.setAttribute("data-animating", "true");
1436
1438
  this.element.style.willChange = "transform";
1437
1439
  if (this.reducedMotion) {
@@ -3422,12 +3424,19 @@ class BottomSheetCore {
3422
3424
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3423
3425
  },
3424
3426
  setIsTop: (isTop) => {
3427
+ if (this.isTopSheet === isTop) return;
3425
3428
  this.isTopSheet = isTop;
3429
+ this.repaintScrim();
3426
3430
  },
3427
3431
  isOpen: () => this.size > 0 || this.opening,
3428
3432
  setDepth: (depth) => this.applyStackDepth(depth)
3429
3433
  }));
3430
3434
  }
3435
+ repaintScrim() {
3436
+ if (this.destroyed) return;
3437
+ this.scrim.invalidateOpacityCache();
3438
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3439
+ }
3431
3440
  applyStackDepth(depth) {
3432
3441
  if (!this.stackEffectEnabled) return;
3433
3442
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -4424,6 +4433,12 @@ const BottomSheet = qwik.component$((props) => {
4424
4433
  }
4425
4434
  if (dragFrom !== void 0) engine.setDragFrom(dragFrom);
4426
4435
  });
4436
+ qwik.useTask$(({ track }) => {
4437
+ const nextMode = track(() => props.mode);
4438
+ const engine = engineStore.engine;
4439
+ if (!engine || nextMode === void 0) return;
4440
+ engine.setMode(nextMode);
4441
+ });
4427
4442
  const showBackdrop = props.backdrop !== false;
4428
4443
  const mode = props.mode ?? "bottom";
4429
4444
  const ariaLabel = props.ariaLabel ?? "Bottom sheet";
@@ -854,16 +854,15 @@ class ScrimController {
854
854
  if (this.backdrop) {
855
855
  const [s, e] = this.backdropRange;
856
856
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
857
- const backdropOpacity = Math.min(Math.max((progress - s) / range, 0), 1);
858
- if (this.isTopSheet() || backdropOpacity === 0) {
859
- if (this.backdropOpacitySentinel.shouldWrite(backdropOpacity, OPACITY_WRITE_EPSILON)) {
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;
866
- }
857
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
858
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
859
+ if (this.backdropOpacitySentinel.shouldWrite(backdropOpacity, OPACITY_WRITE_EPSILON)) {
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;
867
866
  }
868
867
  }
869
868
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1408,18 +1407,20 @@ class AnimationRunner {
1408
1407
  get isAnimating() {
1409
1408
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1410
1409
  }
1410
+ cancelWaapi() {
1411
+ if (!this.currentWaapi) return;
1412
+ const entry = this.currentWaapi;
1413
+ this.currentWaapi = null;
1414
+ entry.stop();
1415
+ try {
1416
+ entry.anim.cancel();
1417
+ } catch {
1418
+ }
1419
+ }
1411
1420
  cancel() {
1412
1421
  this.currentTween?.cancel();
1413
1422
  this.currentSpring?.cancel();
1414
- if (this.currentWaapi) {
1415
- const entry = this.currentWaapi;
1416
- this.currentWaapi = null;
1417
- entry.stop();
1418
- try {
1419
- entry.anim.cancel();
1420
- } catch {
1421
- }
1422
- }
1423
+ this.cancelWaapi();
1423
1424
  }
1424
1425
  async animateTo(target, velocityPxPerMs) {
1425
1426
  if (target === this.getSize()) {
@@ -1430,6 +1431,7 @@ class AnimationRunner {
1430
1431
  }
1431
1432
  this.currentTween?.cancel();
1432
1433
  this.currentSpring?.cancel();
1434
+ this.cancelWaapi();
1433
1435
  this.getRootEl()?.setAttribute("data-animating", "true");
1434
1436
  this.element.style.willChange = "transform";
1435
1437
  if (this.reducedMotion) {
@@ -3420,12 +3422,19 @@ class BottomSheetCore {
3420
3422
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3421
3423
  },
3422
3424
  setIsTop: (isTop) => {
3425
+ if (this.isTopSheet === isTop) return;
3423
3426
  this.isTopSheet = isTop;
3427
+ this.repaintScrim();
3424
3428
  },
3425
3429
  isOpen: () => this.size > 0 || this.opening,
3426
3430
  setDepth: (depth) => this.applyStackDepth(depth)
3427
3431
  }));
3428
3432
  }
3433
+ repaintScrim() {
3434
+ if (this.destroyed) return;
3435
+ this.scrim.invalidateOpacityCache();
3436
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3437
+ }
3429
3438
  applyStackDepth(depth) {
3430
3439
  if (!this.stackEffectEnabled) return;
3431
3440
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -4422,6 +4431,12 @@ const BottomSheet = component$((props) => {
4422
4431
  }
4423
4432
  if (dragFrom !== void 0) engine.setDragFrom(dragFrom);
4424
4433
  });
4434
+ useTask$(({ track }) => {
4435
+ const nextMode = track(() => props.mode);
4436
+ const engine = engineStore.engine;
4437
+ if (!engine || nextMode === void 0) return;
4438
+ engine.setMode(nextMode);
4439
+ });
4425
4440
  const showBackdrop = props.backdrop !== false;
4426
4441
  const mode = props.mode ?? "bottom";
4427
4442
  const ariaLabel = props.ariaLabel ?? "Bottom sheet";