@surdeddd/bottom-sheet 0.20.2 → 0.21.1

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 +10 -1
  2. package/dist/{BottomSheetCore-VPJZcKcg.d.cts → BottomSheetCore-BHv6LPmS.d.cts} +1 -0
  3. package/dist/{BottomSheetCore-Cgn8b_6A.d.ts → BottomSheetCore-CK_mq14p.d.ts} +1 -0
  4. package/dist/{BottomSheetEngine-B8C2CwF9.d.cts → BottomSheetEngine-mmFzIK1Z.d.cts} +1 -1
  5. package/dist/{BottomSheetEngine-DwYR_ygJ.d.ts → BottomSheetEngine-wLn6Q2kA.d.ts} +1 -1
  6. package/dist/core.cjs +33 -27
  7. package/dist/core.d.cts +2 -2
  8. package/dist/core.d.ts +2 -2
  9. package/dist/core.js +33 -27
  10. package/dist/debug.d.cts +1 -1
  11. package/dist/debug.d.ts +1 -1
  12. package/dist/element.cjs +37 -27
  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 +37 -27
  17. package/dist/features.d.cts +2 -2
  18. package/dist/features.d.ts +2 -2
  19. package/dist/{index-DcMkhXAy.d.ts → index-CWKv1Xy4.d.ts} +1 -1
  20. package/dist/{index-CnfbOKx0.d.cts → index-juAyT76E.d.cts} +1 -1
  21. package/dist/index.cjs +33 -27
  22. package/dist/index.d.cts +4 -4
  23. package/dist/index.d.ts +4 -4
  24. package/dist/index.js +33 -27
  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 +36 -24
  32. package/dist/qwik-lib/index.qwik.mjs +36 -24
  33. package/dist/qwik.cjs +39 -27
  34. package/dist/qwik.d.cts +2 -2
  35. package/dist/qwik.d.ts +2 -2
  36. package/dist/qwik.js +39 -27
  37. package/dist/react.cjs +38 -27
  38. package/dist/react.d.cts +3 -3
  39. package/dist/react.d.ts +3 -3
  40. package/dist/react.js +38 -27
  41. package/dist/solid.cjs +39 -27
  42. package/dist/solid.d.cts +1 -0
  43. package/dist/solid.d.ts +1 -0
  44. package/dist/solid.js +39 -27
  45. package/dist/solid.source.jsx +43 -27
  46. package/dist/svelte-core.cjs +33 -27
  47. package/dist/svelte-core.js +33 -27
  48. package/dist/svelte-src/BottomSheet.svelte +3 -0
  49. package/dist/svelte.cjs +36 -27
  50. package/dist/svelte.js +36 -27
  51. package/dist/vue.cjs +37 -27
  52. package/dist/vue.js +37 -27
  53. package/dist/webgl.d.cts +1 -1
  54. package/dist/webgl.d.ts +1 -1
  55. package/package.json +2 -2
package/README.md CHANGED
@@ -227,7 +227,7 @@ type SnapPoint =
227
227
  | `snapPoints` | required | Ordered list of `{ id, size }` |
228
228
  | `allowed` | all ids | Subset the sheet may settle on right now |
229
229
  | `initial` | first allowed | Snap id to start at |
230
- | `mode` | `"bottom"` | `bottom`, `top`, `left`, `right` |
230
+ | `mode` | `"bottom"` | `bottom`, `top`, `left`, `right`, or logical `start` / `end`; reactive in React and Vue adapters |
231
231
  | `animation` | `"spring"` | `spring`, `tween`, `ios-spring`, `material-bounce`, `linear`, `snappy` |
232
232
  | `settleAnimation` | off | `"waapi"` — settle runs as a compositor-driven Web Animation (pre-sampled spring keyframes); falls back to rAF automatically |
233
233
  | `features` | all defaults | `EngineFeature[]` — override/extend the composable feature set (see Slim core below) |
@@ -499,6 +499,15 @@ element — drive any CSS animation from drag without touching JS:
499
499
  > `z-index` on bs-managed elements. See
500
500
  > [Architecture → z-index & the sheet stack](docs/ARCHITECTURE.md).
501
501
 
502
+ **Every sheet owns its backdrop.** Open a list, then a detail sheet over it,
503
+ and both backdrops stay live: the dimming deepens with each level, and the
504
+ sheet underneath stays masked for the whole time the one above it closes, so
505
+ taps never reach the page mid-animation. Each backdrop follows its own sheet's
506
+ progress, so a buried sheet that closes clears its own scrim. The stack keeps
507
+ the order sheets started opening in — a sheet opened while another is still
508
+ animating stays on top. If you want a single dim level, pass `backdrop={false}`
509
+ (`:backdrop="false"` in Vue) to the sheets you open on top.
510
+
502
511
  ### Scrim, blur & high contrast
503
512
 
504
513
  | Token | Default | Region |
@@ -305,6 +305,7 @@ declare class BottomSheetCore {
305
305
  private progressWriteSentinel;
306
306
  private isTopSheet;
307
307
  private opening;
308
+ private promotedForOpen;
308
309
  private allowOvershoot;
309
310
  private progressPayload;
310
311
  private dragContextBuf;
@@ -305,6 +305,7 @@ declare class BottomSheetCore {
305
305
  private progressWriteSentinel;
306
306
  private isTopSheet;
307
307
  private opening;
308
+ private promotedForOpen;
308
309
  private allowOvershoot;
309
310
  private progressPayload;
310
311
  private dragContextBuf;
@@ -1,4 +1,4 @@
1
- import { B as BottomSheetCore, c as EngineOptions } from './BottomSheetCore-VPJZcKcg.cjs';
1
+ import { B as BottomSheetCore, c as EngineOptions } from './BottomSheetCore-BHv6LPmS.cjs';
2
2
 
3
3
  declare class BottomSheetEngine extends BottomSheetCore {
4
4
  constructor(opts: EngineOptions);
@@ -1,4 +1,4 @@
1
- import { B as BottomSheetCore, c as EngineOptions } from './BottomSheetCore-Cgn8b_6A.js';
1
+ import { B as BottomSheetCore, c as EngineOptions } from './BottomSheetCore-CK_mq14p.js';
2
2
 
3
3
  declare class BottomSheetEngine extends BottomSheetCore {
4
4
  constructor(opts: EngineOptions);
package/dist/core.cjs CHANGED
@@ -774,7 +774,6 @@ var ScrimController = class {
774
774
  __publicField(this, "backdrop");
775
775
  __publicField(this, "mode");
776
776
  __publicField(this, "isDestroyed");
777
- __publicField(this, "isTopSheet");
778
777
  __publicField(this, "getAllowedIds");
779
778
  __publicField(this, "getResolvedSnaps");
780
779
  __publicField(this, "snapToFn");
@@ -796,7 +795,6 @@ var ScrimController = class {
796
795
  this.backdrop = deps.backdrop;
797
796
  this.mode = deps.mode;
798
797
  this.isDestroyed = deps.isDestroyed;
799
- this.isTopSheet = deps.isTopSheet;
800
798
  this.getAllowedIds = deps.getAllowedIds;
801
799
  this.getResolvedSnaps = deps.getResolvedSnaps;
802
800
  this.snapToFn = deps.snapTo;
@@ -845,18 +843,16 @@ var ScrimController = class {
845
843
  Math.max((progress - s) / range, 0),
846
844
  1
847
845
  );
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
- }
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) {
@@ -2618,6 +2617,7 @@ var BottomSheetCore = class {
2618
2617
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2619
2618
  __publicField(this, "isTopSheet", true);
2620
2619
  __publicField(this, "opening", false);
2620
+ __publicField(this, "promotedForOpen", false);
2621
2621
  __publicField(this, "allowOvershoot", false);
2622
2622
  __publicField(this, "progressPayload", {
2623
2623
  value: 0,
@@ -2674,7 +2674,6 @@ var BottomSheetCore = class {
2674
2674
  screenComponent: this.screenComponent,
2675
2675
  backdrop: this.backdrop,
2676
2676
  isDestroyed: () => this.destroyed,
2677
- isTopSheet: () => this.isTopSheet,
2678
2677
  getAllowedIds: () => this.snaps.getAllowedIds().slice(),
2679
2678
  getResolvedSnaps: () => this.snaps.getResolvedSnaps().slice(),
2680
2679
  snapTo: (id) => {
@@ -2944,13 +2943,14 @@ var BottomSheetCore = class {
2944
2943
  if (!_skipBeforeSnap && this.emitBeforeSnap(target, this.activeId)) {
2945
2944
  return;
2946
2945
  }
2946
+ const resumingOpen = this.opening;
2947
2947
  const signal = this.newCycle();
2948
2948
  const onExternalAbort = () => {
2949
2949
  this.animation.cancel();
2950
2950
  this.newCycle();
2951
2951
  };
2952
2952
  externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
2953
- const wasClosed = this.size === 0;
2953
+ const wasClosed = this.size === 0 || resumingOpen;
2954
2954
  const previousId = this.activeId;
2955
2955
  const previousSize = this.size;
2956
2956
  this.scrollCache.cache(previousId, previousSize, target.size);
@@ -2959,7 +2959,10 @@ var BottomSheetCore = class {
2959
2959
  const opensToRest = id === "closed" || rawTargetSize === 0;
2960
2960
  if (wasClosed && !opensToRest) {
2961
2961
  this.opening = true;
2962
- sheetStack.promote(this.id);
2962
+ if (!resumingOpen) {
2963
+ this.promotedForOpen = true;
2964
+ sheetStack.promote(this.id);
2965
+ }
2963
2966
  }
2964
2967
  if (this.animation.viewTransitionsAvailable) {
2965
2968
  this.currentViewTransition?.skipTransition?.();
@@ -3650,6 +3653,7 @@ var BottomSheetCore = class {
3650
3653
  this.activeId = target.id;
3651
3654
  if (previousSnapSize === 0 && target.size > 0) {
3652
3655
  this.opening = true;
3656
+ this.promotedForOpen = true;
3653
3657
  sheetStack.promote(this.id);
3654
3658
  }
3655
3659
  const settleCap = this.snaps.getMaxAxisSize();
@@ -3731,7 +3735,8 @@ var BottomSheetCore = class {
3731
3735
  return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
3732
3736
  }
3733
3737
  handleOpen() {
3734
- sheetStack.promote(this.id);
3738
+ if (this.promotedForOpen) this.promotedForOpen = false;
3739
+ else sheetStack.promote(this.id);
3735
3740
  try {
3736
3741
  this.lifecycle.install();
3737
3742
  } catch (err) {
@@ -3763,6 +3768,7 @@ var BottomSheetCore = class {
3763
3768
  }
3764
3769
  handleClose() {
3765
3770
  this.opening = false;
3771
+ this.promotedForOpen = false;
3766
3772
  this.lifecycle.release();
3767
3773
  sheetStack.update();
3768
3774
  }
package/dist/core.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- export { B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, c as EngineOptions, E as EngineState, S as SheetEventMap, b as SheetMode, w as SnapId, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-VPJZcKcg.cjs';
2
- export { R as ResolvedSnap } from './index-CnfbOKx0.cjs';
1
+ export { B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, c as EngineOptions, E as EngineState, S as SheetEventMap, b as SheetMode, w as SnapId, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-BHv6LPmS.cjs';
2
+ export { R as ResolvedSnap } from './index-juAyT76E.cjs';
3
3
  import './transform-jVfAikE9.cjs';
package/dist/core.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, c as EngineOptions, E as EngineState, S as SheetEventMap, b as SheetMode, w as SnapId, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-Cgn8b_6A.js';
2
- export { R as ResolvedSnap } from './index-DcMkhXAy.js';
1
+ export { B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, c as EngineOptions, E as EngineState, S as SheetEventMap, b as SheetMode, w as SnapId, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-CK_mq14p.js';
2
+ export { R as ResolvedSnap } from './index-CWKv1Xy4.js';
3
3
  import './transform-jVfAikE9.js';
package/dist/core.js CHANGED
@@ -772,7 +772,6 @@ var ScrimController = class {
772
772
  __publicField(this, "backdrop");
773
773
  __publicField(this, "mode");
774
774
  __publicField(this, "isDestroyed");
775
- __publicField(this, "isTopSheet");
776
775
  __publicField(this, "getAllowedIds");
777
776
  __publicField(this, "getResolvedSnaps");
778
777
  __publicField(this, "snapToFn");
@@ -794,7 +793,6 @@ var ScrimController = class {
794
793
  this.backdrop = deps.backdrop;
795
794
  this.mode = deps.mode;
796
795
  this.isDestroyed = deps.isDestroyed;
797
- this.isTopSheet = deps.isTopSheet;
798
796
  this.getAllowedIds = deps.getAllowedIds;
799
797
  this.getResolvedSnaps = deps.getResolvedSnaps;
800
798
  this.snapToFn = deps.snapTo;
@@ -843,18 +841,16 @@ var ScrimController = class {
843
841
  Math.max((progress - s) / range, 0),
844
842
  1
845
843
  );
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
- }
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) {
@@ -2616,6 +2615,7 @@ var BottomSheetCore = class {
2616
2615
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2617
2616
  __publicField(this, "isTopSheet", true);
2618
2617
  __publicField(this, "opening", false);
2618
+ __publicField(this, "promotedForOpen", false);
2619
2619
  __publicField(this, "allowOvershoot", false);
2620
2620
  __publicField(this, "progressPayload", {
2621
2621
  value: 0,
@@ -2672,7 +2672,6 @@ var BottomSheetCore = class {
2672
2672
  screenComponent: this.screenComponent,
2673
2673
  backdrop: this.backdrop,
2674
2674
  isDestroyed: () => this.destroyed,
2675
- isTopSheet: () => this.isTopSheet,
2676
2675
  getAllowedIds: () => this.snaps.getAllowedIds().slice(),
2677
2676
  getResolvedSnaps: () => this.snaps.getResolvedSnaps().slice(),
2678
2677
  snapTo: (id) => {
@@ -2942,13 +2941,14 @@ var BottomSheetCore = class {
2942
2941
  if (!_skipBeforeSnap && this.emitBeforeSnap(target, this.activeId)) {
2943
2942
  return;
2944
2943
  }
2944
+ const resumingOpen = this.opening;
2945
2945
  const signal = this.newCycle();
2946
2946
  const onExternalAbort = () => {
2947
2947
  this.animation.cancel();
2948
2948
  this.newCycle();
2949
2949
  };
2950
2950
  externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
2951
- const wasClosed = this.size === 0;
2951
+ const wasClosed = this.size === 0 || resumingOpen;
2952
2952
  const previousId = this.activeId;
2953
2953
  const previousSize = this.size;
2954
2954
  this.scrollCache.cache(previousId, previousSize, target.size);
@@ -2957,7 +2957,10 @@ var BottomSheetCore = class {
2957
2957
  const opensToRest = id === "closed" || rawTargetSize === 0;
2958
2958
  if (wasClosed && !opensToRest) {
2959
2959
  this.opening = true;
2960
- sheetStack.promote(this.id);
2960
+ if (!resumingOpen) {
2961
+ this.promotedForOpen = true;
2962
+ sheetStack.promote(this.id);
2963
+ }
2961
2964
  }
2962
2965
  if (this.animation.viewTransitionsAvailable) {
2963
2966
  this.currentViewTransition?.skipTransition?.();
@@ -3648,6 +3651,7 @@ var BottomSheetCore = class {
3648
3651
  this.activeId = target.id;
3649
3652
  if (previousSnapSize === 0 && target.size > 0) {
3650
3653
  this.opening = true;
3654
+ this.promotedForOpen = true;
3651
3655
  sheetStack.promote(this.id);
3652
3656
  }
3653
3657
  const settleCap = this.snaps.getMaxAxisSize();
@@ -3729,7 +3733,8 @@ var BottomSheetCore = class {
3729
3733
  return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
3730
3734
  }
3731
3735
  handleOpen() {
3732
- sheetStack.promote(this.id);
3736
+ if (this.promotedForOpen) this.promotedForOpen = false;
3737
+ else sheetStack.promote(this.id);
3733
3738
  try {
3734
3739
  this.lifecycle.install();
3735
3740
  } catch (err) {
@@ -3761,6 +3766,7 @@ var BottomSheetCore = class {
3761
3766
  }
3762
3767
  handleClose() {
3763
3768
  this.opening = false;
3769
+ this.promotedForOpen = false;
3764
3770
  this.lifecycle.release();
3765
3771
  sheetStack.update();
3766
3772
  }
package/dist/debug.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { E as EngineState, S as SheetEventMap } from './BottomSheetCore-VPJZcKcg.cjs';
1
+ import { E as EngineState, S as SheetEventMap } from './BottomSheetCore-BHv6LPmS.cjs';
2
2
  import './transform-jVfAikE9.cjs';
3
3
 
4
4
  type DebugOverlayPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
package/dist/debug.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { E as EngineState, S as SheetEventMap } from './BottomSheetCore-Cgn8b_6A.js';
1
+ import { E as EngineState, S as SheetEventMap } from './BottomSheetCore-CK_mq14p.js';
2
2
  import './transform-jVfAikE9.js';
3
3
 
4
4
  type DebugOverlayPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
package/dist/element.cjs CHANGED
@@ -885,7 +885,6 @@ var init_scrim_controller = __esm({
885
885
  __publicField(this, "backdrop");
886
886
  __publicField(this, "mode");
887
887
  __publicField(this, "isDestroyed");
888
- __publicField(this, "isTopSheet");
889
888
  __publicField(this, "getAllowedIds");
890
889
  __publicField(this, "getResolvedSnaps");
891
890
  __publicField(this, "snapToFn");
@@ -907,7 +906,6 @@ var init_scrim_controller = __esm({
907
906
  this.backdrop = deps.backdrop;
908
907
  this.mode = deps.mode;
909
908
  this.isDestroyed = deps.isDestroyed;
910
- this.isTopSheet = deps.isTopSheet;
911
909
  this.getAllowedIds = deps.getAllowedIds;
912
910
  this.getResolvedSnaps = deps.getResolvedSnaps;
913
911
  this.snapToFn = deps.snapTo;
@@ -956,18 +954,16 @@ var init_scrim_controller = __esm({
956
954
  Math.max((progress - s) / range, 0),
957
955
  1
958
956
  );
959
- if (this.isTopSheet() || backdropOpacity === 0) {
960
- if (this.backdropOpacitySentinel.shouldWrite(
961
- backdropOpacity,
962
- OPACITY_WRITE_EPSILON
963
- )) {
964
- this.backdrop.style.opacity = String(backdropOpacity);
965
- }
966
- const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
967
- if (nextPointer !== this.lastBackdropPointer) {
968
- this.backdrop.style.pointerEvents = nextPointer;
969
- this.lastBackdropPointer = nextPointer;
970
- }
957
+ if (this.backdropOpacitySentinel.shouldWrite(
958
+ backdropOpacity,
959
+ OPACITY_WRITE_EPSILON
960
+ )) {
961
+ this.backdrop.style.opacity = String(backdropOpacity);
962
+ }
963
+ const nextPointer = backdropOpacity > POINTER_EVENTS_OPACITY_THRESHOLD ? "auto" : "none";
964
+ if (nextPointer !== this.lastBackdropPointer) {
965
+ this.backdrop.style.pointerEvents = nextPointer;
966
+ this.lastBackdropPointer = nextPointer;
971
967
  }
972
968
  }
973
969
  if (this.screenComponent && this.scrimMode !== "off") {
@@ -1528,18 +1524,20 @@ var init_animation_runner = __esm({
1528
1524
  get isAnimating() {
1529
1525
  return this.currentTween !== null || this.currentSpring !== null || this.currentWaapi !== null;
1530
1526
  }
1527
+ cancelWaapi() {
1528
+ if (!this.currentWaapi) return;
1529
+ const entry = this.currentWaapi;
1530
+ this.currentWaapi = null;
1531
+ entry.stop();
1532
+ try {
1533
+ entry.anim.cancel();
1534
+ } catch {
1535
+ }
1536
+ }
1531
1537
  cancel() {
1532
1538
  this.currentTween?.cancel();
1533
1539
  this.currentSpring?.cancel();
1534
- if (this.currentWaapi) {
1535
- const entry = this.currentWaapi;
1536
- this.currentWaapi = null;
1537
- entry.stop();
1538
- try {
1539
- entry.anim.cancel();
1540
- } catch {
1541
- }
1542
- }
1540
+ this.cancelWaapi();
1543
1541
  }
1544
1542
  async animateTo(target, velocityPxPerMs) {
1545
1543
  if (target === this.getSize()) {
@@ -1550,6 +1548,7 @@ var init_animation_runner = __esm({
1550
1548
  }
1551
1549
  this.currentTween?.cancel();
1552
1550
  this.currentSpring?.cancel();
1551
+ this.cancelWaapi();
1553
1552
  this.getRootEl()?.setAttribute("data-animating", "true");
1554
1553
  this.element.style.willChange = "transform";
1555
1554
  if (this.reducedMotion) {
@@ -2896,6 +2895,7 @@ var init_BottomSheetCore = __esm({
2896
2895
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2897
2896
  __publicField(this, "isTopSheet", true);
2898
2897
  __publicField(this, "opening", false);
2898
+ __publicField(this, "promotedForOpen", false);
2899
2899
  __publicField(this, "allowOvershoot", false);
2900
2900
  __publicField(this, "progressPayload", {
2901
2901
  value: 0,
@@ -2952,7 +2952,6 @@ var init_BottomSheetCore = __esm({
2952
2952
  screenComponent: this.screenComponent,
2953
2953
  backdrop: this.backdrop,
2954
2954
  isDestroyed: () => this.destroyed,
2955
- isTopSheet: () => this.isTopSheet,
2956
2955
  getAllowedIds: () => this.snaps.getAllowedIds().slice(),
2957
2956
  getResolvedSnaps: () => this.snaps.getResolvedSnaps().slice(),
2958
2957
  snapTo: (id) => {
@@ -3222,13 +3221,14 @@ var init_BottomSheetCore = __esm({
3222
3221
  if (!_skipBeforeSnap && this.emitBeforeSnap(target, this.activeId)) {
3223
3222
  return;
3224
3223
  }
3224
+ const resumingOpen = this.opening;
3225
3225
  const signal = this.newCycle();
3226
3226
  const onExternalAbort = () => {
3227
3227
  this.animation.cancel();
3228
3228
  this.newCycle();
3229
3229
  };
3230
3230
  externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
3231
- const wasClosed = this.size === 0;
3231
+ const wasClosed = this.size === 0 || resumingOpen;
3232
3232
  const previousId = this.activeId;
3233
3233
  const previousSize = this.size;
3234
3234
  this.scrollCache.cache(previousId, previousSize, target.size);
@@ -3237,7 +3237,10 @@ var init_BottomSheetCore = __esm({
3237
3237
  const opensToRest = id === "closed" || rawTargetSize === 0;
3238
3238
  if (wasClosed && !opensToRest) {
3239
3239
  this.opening = true;
3240
- sheetStack.promote(this.id);
3240
+ if (!resumingOpen) {
3241
+ this.promotedForOpen = true;
3242
+ sheetStack.promote(this.id);
3243
+ }
3241
3244
  }
3242
3245
  if (this.animation.viewTransitionsAvailable) {
3243
3246
  this.currentViewTransition?.skipTransition?.();
@@ -3928,6 +3931,7 @@ var init_BottomSheetCore = __esm({
3928
3931
  this.activeId = target.id;
3929
3932
  if (previousSnapSize === 0 && target.size > 0) {
3930
3933
  this.opening = true;
3934
+ this.promotedForOpen = true;
3931
3935
  sheetStack.promote(this.id);
3932
3936
  }
3933
3937
  const settleCap = this.snaps.getMaxAxisSize();
@@ -4009,7 +4013,8 @@ var init_BottomSheetCore = __esm({
4009
4013
  return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
4010
4014
  }
4011
4015
  handleOpen() {
4012
- sheetStack.promote(this.id);
4016
+ if (this.promotedForOpen) this.promotedForOpen = false;
4017
+ else sheetStack.promote(this.id);
4013
4018
  try {
4014
4019
  this.lifecycle.install();
4015
4020
  } catch (err) {
@@ -4041,6 +4046,7 @@ var init_BottomSheetCore = __esm({
4041
4046
  }
4042
4047
  handleClose() {
4043
4048
  this.opening = false;
4049
+ this.promotedForOpen = false;
4044
4050
  this.lifecycle.release();
4045
4051
  sheetStack.update();
4046
4052
  }
@@ -4690,6 +4696,7 @@ var init_attributes = __esm({
4690
4696
  ATTR_SCRIM_COLOR = "scrim-color";
4691
4697
  ATTR_SNAP = "snap";
4692
4698
  LIVE_ATTRS = /* @__PURE__ */ new Set([
4699
+ ATTR_MODE,
4693
4700
  ATTR_RADIUS,
4694
4701
  ATTR_MAX_HEIGHT,
4695
4702
  ATTR_BACKDROP_COLOR,
@@ -4916,6 +4923,9 @@ var init_BottomSheetElement = __esm({
4916
4923
  if (mode) this.engine.setDragFrom(mode);
4917
4924
  break;
4918
4925
  }
4926
+ case ATTR_MODE:
4927
+ this.engine.setMode(parseMode(value));
4928
+ break;
4919
4929
  case ATTR_SNAP:
4920
4930
  if (value && value !== this.engine.state.activeId) {
4921
4931
  void this.engine.snapTo(value);
@@ -1,5 +1,5 @@
1
- import { B as BottomSheetEngine } from './BottomSheetEngine-B8C2CwF9.cjs';
2
- import { C as CloseReason, A as AnchorOptions, e as ScrimStagesOptions, E as EngineState } from './BottomSheetCore-VPJZcKcg.cjs';
1
+ import { B as BottomSheetEngine } from './BottomSheetEngine-mmFzIK1Z.cjs';
2
+ import { C as CloseReason, A as AnchorOptions, e as ScrimStagesOptions, E as EngineState } from './BottomSheetCore-BHv6LPmS.cjs';
3
3
  import './transform-jVfAikE9.cjs';
4
4
 
5
5
  declare const BaseHTMLElement: typeof HTMLElement;
package/dist/element.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BottomSheetEngine } from './BottomSheetEngine-DwYR_ygJ.js';
2
- import { C as CloseReason, A as AnchorOptions, e as ScrimStagesOptions, E as EngineState } from './BottomSheetCore-Cgn8b_6A.js';
1
+ import { B as BottomSheetEngine } from './BottomSheetEngine-wLn6Q2kA.js';
2
+ import { C as CloseReason, A as AnchorOptions, e as ScrimStagesOptions, E as EngineState } from './BottomSheetCore-CK_mq14p.js';
3
3
  import './transform-jVfAikE9.js';
4
4
 
5
5
  declare const BaseHTMLElement: typeof HTMLElement;