@surdeddd/bottom-sheet 0.21.0 → 0.21.2

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 (54) hide show
  1. package/README.md +9 -0
  2. package/dist/{BottomSheetCore-CK8Rh1He.d.cts → BottomSheetCore-BHv6LPmS.d.cts} +1 -1
  3. package/dist/{BottomSheetCore-CIijwtdi.d.ts → BottomSheetCore-CK_mq14p.d.ts} +1 -1
  4. package/dist/{BottomSheetEngine-hLSAxzla.d.cts → BottomSheetEngine-mmFzIK1Z.d.cts} +1 -1
  5. package/dist/{BottomSheetEngine-CZglPsTF.d.ts → BottomSheetEngine-wLn6Q2kA.d.ts} +1 -1
  6. package/dist/core.cjs +31 -21
  7. package/dist/core.d.cts +2 -2
  8. package/dist/core.d.ts +2 -2
  9. package/dist/core.js +31 -21
  10. package/dist/debug.d.cts +1 -1
  11. package/dist/debug.d.ts +1 -1
  12. package/dist/element.cjs +37 -26
  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 -26
  17. package/dist/features.d.cts +2 -2
  18. package/dist/features.d.ts +2 -2
  19. package/dist/{index-BqLHKOeM.d.ts → index-CWKv1Xy4.d.ts} +1 -1
  20. package/dist/{index-BEX-NHRJ.d.cts → index-juAyT76E.d.cts} +1 -1
  21. package/dist/index.cjs +31 -21
  22. package/dist/index.d.cts +4 -4
  23. package/dist/index.d.ts +4 -4
  24. package/dist/index.js +31 -21
  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 +29 -19
  32. package/dist/qwik-lib/index.qwik.mjs +29 -19
  33. package/dist/qwik.cjs +31 -21
  34. package/dist/qwik.d.cts +2 -2
  35. package/dist/qwik.d.ts +2 -2
  36. package/dist/qwik.js +31 -21
  37. package/dist/react.cjs +31 -21
  38. package/dist/react.d.cts +3 -3
  39. package/dist/react.d.ts +3 -3
  40. package/dist/react.js +31 -21
  41. package/dist/solid.cjs +31 -21
  42. package/dist/solid.d.cts +1 -1
  43. package/dist/solid.d.ts +1 -1
  44. package/dist/solid.js +31 -21
  45. package/dist/solid.source.jsx +31 -21
  46. package/dist/svelte-core.cjs +31 -21
  47. package/dist/svelte-core.js +31 -21
  48. package/dist/svelte.cjs +31 -21
  49. package/dist/svelte.js +31 -21
  50. package/dist/vue.cjs +31 -21
  51. package/dist/vue.js +31 -21
  52. package/dist/webgl.d.cts +1 -1
  53. package/dist/webgl.d.ts +1 -1
  54. package/package.json +2 -2
package/dist/svelte.cjs CHANGED
@@ -399,14 +399,26 @@ function notifyLinkedSheets(sheets, self) {
399
399
  }
400
400
  }
401
401
 
402
+ // src/core/primitives/hot-path-thresholds.ts
403
+ var SIZE_WRITE_EPSILON = 0.5;
404
+ var OPACITY_WRITE_EPSILON = 5e-3;
405
+ var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
406
+ var RANGE_DIVISION_EPSILON = 1e-4;
407
+
402
408
  // src/core/features/resize-observer.ts
403
409
  function installResizeObserver(deps) {
404
410
  if (typeof window === "undefined") {
405
411
  return () => {
406
412
  };
407
413
  }
414
+ const seatFor = () => {
415
+ const snap = deps.resolveActiveSnap();
416
+ const max = deps.getMaxAxisSize();
417
+ return { target: snap ? Math.min(snap.size, max) : null, max };
418
+ };
408
419
  const onResize = () => {
409
420
  if (deps.isDestroyed()) return;
421
+ const before = seatFor();
410
422
  deps.recomputeSnaps();
411
423
  const mode = deps.getMode();
412
424
  const isVerticalAxis = mode === "bottom" || mode === "top";
@@ -415,6 +427,10 @@ function installResizeObserver(deps) {
415
427
  if (viewportSize2 > 0 && viewportSize2 < max) {
416
428
  deps.setMaxAxisSize(viewportSize2);
417
429
  }
430
+ const after = seatFor();
431
+ if (before.target !== null && after.target !== null && Math.abs(after.target - before.target) < SIZE_WRITE_EPSILON && Math.abs(after.max - before.max) < SIZE_WRITE_EPSILON) {
432
+ return;
433
+ }
418
434
  const wasAnimating = deps.isAnimating?.() ?? false;
419
435
  deps.cancelInFlight();
420
436
  deps.newCycle();
@@ -683,12 +699,6 @@ var SCRIM_PRESETS = Object.freeze({
683
699
  }
684
700
  });
685
701
 
686
- // src/core/primitives/hot-path-thresholds.ts
687
- var SIZE_WRITE_EPSILON = 0.5;
688
- var OPACITY_WRITE_EPSILON = 5e-3;
689
- var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
690
- var RANGE_DIVISION_EPSILON = 1e-4;
691
-
692
702
  // src/core/primitives/opacity-dedup.ts
693
703
  var WriteSentinel = class {
694
704
  constructor() {
@@ -798,7 +808,6 @@ var ScrimController = class {
798
808
  __publicField(this, "backdrop");
799
809
  __publicField(this, "mode");
800
810
  __publicField(this, "isDestroyed");
801
- __publicField(this, "isTopSheet");
802
811
  __publicField(this, "getAllowedIds");
803
812
  __publicField(this, "getResolvedSnaps");
804
813
  __publicField(this, "snapToFn");
@@ -820,7 +829,6 @@ var ScrimController = class {
820
829
  this.backdrop = deps.backdrop;
821
830
  this.mode = deps.mode;
822
831
  this.isDestroyed = deps.isDestroyed;
823
- this.isTopSheet = deps.isTopSheet;
824
832
  this.getAllowedIds = deps.getAllowedIds;
825
833
  this.getResolvedSnaps = deps.getResolvedSnaps;
826
834
  this.snapToFn = deps.snapTo;
@@ -865,8 +873,10 @@ var ScrimController = class {
865
873
  if (this.backdrop) {
866
874
  const [s, e] = this.backdropRange;
867
875
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
868
- const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
869
- const backdropOpacity = this.isTopSheet() ? ramp : 0;
876
+ const backdropOpacity = Math.min(
877
+ Math.max((progress - s) / range, 0),
878
+ 1
879
+ );
870
880
  if (this.backdropOpacitySentinel.shouldWrite(
871
881
  backdropOpacity,
872
882
  OPACITY_WRITE_EPSILON
@@ -2641,6 +2651,7 @@ var BottomSheetCore = class {
2641
2651
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2642
2652
  __publicField(this, "isTopSheet", true);
2643
2653
  __publicField(this, "opening", false);
2654
+ __publicField(this, "promotedForOpen", false);
2644
2655
  __publicField(this, "allowOvershoot", false);
2645
2656
  __publicField(this, "progressPayload", {
2646
2657
  value: 0,
@@ -2697,7 +2708,6 @@ var BottomSheetCore = class {
2697
2708
  screenComponent: this.screenComponent,
2698
2709
  backdrop: this.backdrop,
2699
2710
  isDestroyed: () => this.destroyed,
2700
- isTopSheet: () => this.isTopSheet,
2701
2711
  getAllowedIds: () => this.snaps.getAllowedIds().slice(),
2702
2712
  getResolvedSnaps: () => this.snaps.getResolvedSnaps().slice(),
2703
2713
  snapTo: (id) => {
@@ -2967,13 +2977,14 @@ var BottomSheetCore = class {
2967
2977
  if (!_skipBeforeSnap && this.emitBeforeSnap(target, this.activeId)) {
2968
2978
  return;
2969
2979
  }
2980
+ const resumingOpen = this.opening;
2970
2981
  const signal = this.newCycle();
2971
2982
  const onExternalAbort = () => {
2972
2983
  this.animation.cancel();
2973
2984
  this.newCycle();
2974
2985
  };
2975
2986
  externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
2976
- const wasClosed = this.size === 0;
2987
+ const wasClosed = this.size === 0 || resumingOpen;
2977
2988
  const previousId = this.activeId;
2978
2989
  const previousSize = this.size;
2979
2990
  this.scrollCache.cache(previousId, previousSize, target.size);
@@ -2982,7 +2993,10 @@ var BottomSheetCore = class {
2982
2993
  const opensToRest = id === "closed" || rawTargetSize === 0;
2983
2994
  if (wasClosed && !opensToRest) {
2984
2995
  this.opening = true;
2985
- sheetStack.promote(this.id);
2996
+ if (!resumingOpen) {
2997
+ this.promotedForOpen = true;
2998
+ sheetStack.promote(this.id);
2999
+ }
2986
3000
  }
2987
3001
  if (this.animation.viewTransitionsAvailable) {
2988
3002
  this.currentViewTransition?.skipTransition?.();
@@ -3423,19 +3437,12 @@ var BottomSheetCore = class {
3423
3437
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3424
3438
  },
3425
3439
  setIsTop: (isTop) => {
3426
- if (this.isTopSheet === isTop) return;
3427
3440
  this.isTopSheet = isTop;
3428
- this.repaintScrim();
3429
3441
  },
3430
3442
  isOpen: () => this.size > 0 || this.opening,
3431
3443
  setDepth: (depth) => this.applyStackDepth(depth)
3432
3444
  }));
3433
3445
  }
3434
- repaintScrim() {
3435
- if (this.destroyed) return;
3436
- this.scrim.invalidateOpacityCache();
3437
- this.scrim.applyOpacity(this.computeProgress(this.size), true);
3438
- }
3439
3446
  applyStackDepth(depth) {
3440
3447
  if (!this.stackEffectEnabled) return;
3441
3448
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -3680,6 +3687,7 @@ var BottomSheetCore = class {
3680
3687
  this.activeId = target.id;
3681
3688
  if (previousSnapSize === 0 && target.size > 0) {
3682
3689
  this.opening = true;
3690
+ this.promotedForOpen = true;
3683
3691
  sheetStack.promote(this.id);
3684
3692
  }
3685
3693
  const settleCap = this.snaps.getMaxAxisSize();
@@ -3761,7 +3769,8 @@ var BottomSheetCore = class {
3761
3769
  return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
3762
3770
  }
3763
3771
  handleOpen() {
3764
- sheetStack.promote(this.id);
3772
+ if (this.promotedForOpen) this.promotedForOpen = false;
3773
+ else sheetStack.promote(this.id);
3765
3774
  try {
3766
3775
  this.lifecycle.install();
3767
3776
  } catch (err) {
@@ -3793,6 +3802,7 @@ var BottomSheetCore = class {
3793
3802
  }
3794
3803
  handleClose() {
3795
3804
  this.opening = false;
3805
+ this.promotedForOpen = false;
3796
3806
  this.lifecycle.release();
3797
3807
  sheetStack.update();
3798
3808
  }
package/dist/svelte.js CHANGED
@@ -377,14 +377,26 @@ function notifyLinkedSheets(sheets, self) {
377
377
  }
378
378
  }
379
379
 
380
+ // src/core/primitives/hot-path-thresholds.ts
381
+ var SIZE_WRITE_EPSILON = 0.5;
382
+ var OPACITY_WRITE_EPSILON = 5e-3;
383
+ var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
384
+ var RANGE_DIVISION_EPSILON = 1e-4;
385
+
380
386
  // src/core/features/resize-observer.ts
381
387
  function installResizeObserver(deps) {
382
388
  if (typeof window === "undefined") {
383
389
  return () => {
384
390
  };
385
391
  }
392
+ const seatFor = () => {
393
+ const snap = deps.resolveActiveSnap();
394
+ const max = deps.getMaxAxisSize();
395
+ return { target: snap ? Math.min(snap.size, max) : null, max };
396
+ };
386
397
  const onResize = () => {
387
398
  if (deps.isDestroyed()) return;
399
+ const before = seatFor();
388
400
  deps.recomputeSnaps();
389
401
  const mode = deps.getMode();
390
402
  const isVerticalAxis = mode === "bottom" || mode === "top";
@@ -393,6 +405,10 @@ function installResizeObserver(deps) {
393
405
  if (viewportSize2 > 0 && viewportSize2 < max) {
394
406
  deps.setMaxAxisSize(viewportSize2);
395
407
  }
408
+ const after = seatFor();
409
+ if (before.target !== null && after.target !== null && Math.abs(after.target - before.target) < SIZE_WRITE_EPSILON && Math.abs(after.max - before.max) < SIZE_WRITE_EPSILON) {
410
+ return;
411
+ }
396
412
  const wasAnimating = deps.isAnimating?.() ?? false;
397
413
  deps.cancelInFlight();
398
414
  deps.newCycle();
@@ -661,12 +677,6 @@ var SCRIM_PRESETS = Object.freeze({
661
677
  }
662
678
  });
663
679
 
664
- // src/core/primitives/hot-path-thresholds.ts
665
- var SIZE_WRITE_EPSILON = 0.5;
666
- var OPACITY_WRITE_EPSILON = 5e-3;
667
- var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
668
- var RANGE_DIVISION_EPSILON = 1e-4;
669
-
670
680
  // src/core/primitives/opacity-dedup.ts
671
681
  var WriteSentinel = class {
672
682
  constructor() {
@@ -776,7 +786,6 @@ var ScrimController = class {
776
786
  __publicField(this, "backdrop");
777
787
  __publicField(this, "mode");
778
788
  __publicField(this, "isDestroyed");
779
- __publicField(this, "isTopSheet");
780
789
  __publicField(this, "getAllowedIds");
781
790
  __publicField(this, "getResolvedSnaps");
782
791
  __publicField(this, "snapToFn");
@@ -798,7 +807,6 @@ var ScrimController = class {
798
807
  this.backdrop = deps.backdrop;
799
808
  this.mode = deps.mode;
800
809
  this.isDestroyed = deps.isDestroyed;
801
- this.isTopSheet = deps.isTopSheet;
802
810
  this.getAllowedIds = deps.getAllowedIds;
803
811
  this.getResolvedSnaps = deps.getResolvedSnaps;
804
812
  this.snapToFn = deps.snapTo;
@@ -843,8 +851,10 @@ var ScrimController = class {
843
851
  if (this.backdrop) {
844
852
  const [s, e] = this.backdropRange;
845
853
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
846
- const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
847
- const backdropOpacity = this.isTopSheet() ? ramp : 0;
854
+ const backdropOpacity = Math.min(
855
+ Math.max((progress - s) / range, 0),
856
+ 1
857
+ );
848
858
  if (this.backdropOpacitySentinel.shouldWrite(
849
859
  backdropOpacity,
850
860
  OPACITY_WRITE_EPSILON
@@ -2619,6 +2629,7 @@ var BottomSheetCore = class {
2619
2629
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2620
2630
  __publicField(this, "isTopSheet", true);
2621
2631
  __publicField(this, "opening", false);
2632
+ __publicField(this, "promotedForOpen", false);
2622
2633
  __publicField(this, "allowOvershoot", false);
2623
2634
  __publicField(this, "progressPayload", {
2624
2635
  value: 0,
@@ -2675,7 +2686,6 @@ var BottomSheetCore = class {
2675
2686
  screenComponent: this.screenComponent,
2676
2687
  backdrop: this.backdrop,
2677
2688
  isDestroyed: () => this.destroyed,
2678
- isTopSheet: () => this.isTopSheet,
2679
2689
  getAllowedIds: () => this.snaps.getAllowedIds().slice(),
2680
2690
  getResolvedSnaps: () => this.snaps.getResolvedSnaps().slice(),
2681
2691
  snapTo: (id) => {
@@ -2945,13 +2955,14 @@ var BottomSheetCore = class {
2945
2955
  if (!_skipBeforeSnap && this.emitBeforeSnap(target, this.activeId)) {
2946
2956
  return;
2947
2957
  }
2958
+ const resumingOpen = this.opening;
2948
2959
  const signal = this.newCycle();
2949
2960
  const onExternalAbort = () => {
2950
2961
  this.animation.cancel();
2951
2962
  this.newCycle();
2952
2963
  };
2953
2964
  externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
2954
- const wasClosed = this.size === 0;
2965
+ const wasClosed = this.size === 0 || resumingOpen;
2955
2966
  const previousId = this.activeId;
2956
2967
  const previousSize = this.size;
2957
2968
  this.scrollCache.cache(previousId, previousSize, target.size);
@@ -2960,7 +2971,10 @@ var BottomSheetCore = class {
2960
2971
  const opensToRest = id === "closed" || rawTargetSize === 0;
2961
2972
  if (wasClosed && !opensToRest) {
2962
2973
  this.opening = true;
2963
- sheetStack.promote(this.id);
2974
+ if (!resumingOpen) {
2975
+ this.promotedForOpen = true;
2976
+ sheetStack.promote(this.id);
2977
+ }
2964
2978
  }
2965
2979
  if (this.animation.viewTransitionsAvailable) {
2966
2980
  this.currentViewTransition?.skipTransition?.();
@@ -3401,19 +3415,12 @@ var BottomSheetCore = class {
3401
3415
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3402
3416
  },
3403
3417
  setIsTop: (isTop) => {
3404
- if (this.isTopSheet === isTop) return;
3405
3418
  this.isTopSheet = isTop;
3406
- this.repaintScrim();
3407
3419
  },
3408
3420
  isOpen: () => this.size > 0 || this.opening,
3409
3421
  setDepth: (depth) => this.applyStackDepth(depth)
3410
3422
  }));
3411
3423
  }
3412
- repaintScrim() {
3413
- if (this.destroyed) return;
3414
- this.scrim.invalidateOpacityCache();
3415
- this.scrim.applyOpacity(this.computeProgress(this.size), true);
3416
- }
3417
3424
  applyStackDepth(depth) {
3418
3425
  if (!this.stackEffectEnabled) return;
3419
3426
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -3658,6 +3665,7 @@ var BottomSheetCore = class {
3658
3665
  this.activeId = target.id;
3659
3666
  if (previousSnapSize === 0 && target.size > 0) {
3660
3667
  this.opening = true;
3668
+ this.promotedForOpen = true;
3661
3669
  sheetStack.promote(this.id);
3662
3670
  }
3663
3671
  const settleCap = this.snaps.getMaxAxisSize();
@@ -3739,7 +3747,8 @@ var BottomSheetCore = class {
3739
3747
  return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
3740
3748
  }
3741
3749
  handleOpen() {
3742
- sheetStack.promote(this.id);
3750
+ if (this.promotedForOpen) this.promotedForOpen = false;
3751
+ else sheetStack.promote(this.id);
3743
3752
  try {
3744
3753
  this.lifecycle.install();
3745
3754
  } catch (err) {
@@ -3771,6 +3780,7 @@ var BottomSheetCore = class {
3771
3780
  }
3772
3781
  handleClose() {
3773
3782
  this.opening = false;
3783
+ this.promotedForOpen = false;
3774
3784
  this.lifecycle.release();
3775
3785
  sheetStack.update();
3776
3786
  }
package/dist/vue.cjs CHANGED
@@ -377,14 +377,26 @@ function notifyLinkedSheets(sheets, self) {
377
377
  }
378
378
  }
379
379
 
380
+ // src/core/primitives/hot-path-thresholds.ts
381
+ var SIZE_WRITE_EPSILON = 0.5;
382
+ var OPACITY_WRITE_EPSILON = 5e-3;
383
+ var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
384
+ var RANGE_DIVISION_EPSILON = 1e-4;
385
+
380
386
  // src/core/features/resize-observer.ts
381
387
  function installResizeObserver(deps) {
382
388
  if (typeof window === "undefined") {
383
389
  return () => {
384
390
  };
385
391
  }
392
+ const seatFor = () => {
393
+ const snap = deps.resolveActiveSnap();
394
+ const max = deps.getMaxAxisSize();
395
+ return { target: snap ? Math.min(snap.size, max) : null, max };
396
+ };
386
397
  const onResize = () => {
387
398
  if (deps.isDestroyed()) return;
399
+ const before = seatFor();
388
400
  deps.recomputeSnaps();
389
401
  const mode = deps.getMode();
390
402
  const isVerticalAxis = mode === "bottom" || mode === "top";
@@ -393,6 +405,10 @@ function installResizeObserver(deps) {
393
405
  if (viewportSize2 > 0 && viewportSize2 < max) {
394
406
  deps.setMaxAxisSize(viewportSize2);
395
407
  }
408
+ const after = seatFor();
409
+ if (before.target !== null && after.target !== null && Math.abs(after.target - before.target) < SIZE_WRITE_EPSILON && Math.abs(after.max - before.max) < SIZE_WRITE_EPSILON) {
410
+ return;
411
+ }
396
412
  const wasAnimating = deps.isAnimating?.() ?? false;
397
413
  deps.cancelInFlight();
398
414
  deps.newCycle();
@@ -661,12 +677,6 @@ var SCRIM_PRESETS = Object.freeze({
661
677
  }
662
678
  });
663
679
 
664
- // src/core/primitives/hot-path-thresholds.ts
665
- var SIZE_WRITE_EPSILON = 0.5;
666
- var OPACITY_WRITE_EPSILON = 5e-3;
667
- var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
668
- var RANGE_DIVISION_EPSILON = 1e-4;
669
-
670
680
  // src/core/primitives/opacity-dedup.ts
671
681
  var WriteSentinel = class {
672
682
  constructor() {
@@ -776,7 +786,6 @@ var ScrimController = class {
776
786
  __publicField(this, "backdrop");
777
787
  __publicField(this, "mode");
778
788
  __publicField(this, "isDestroyed");
779
- __publicField(this, "isTopSheet");
780
789
  __publicField(this, "getAllowedIds");
781
790
  __publicField(this, "getResolvedSnaps");
782
791
  __publicField(this, "snapToFn");
@@ -798,7 +807,6 @@ var ScrimController = class {
798
807
  this.backdrop = deps.backdrop;
799
808
  this.mode = deps.mode;
800
809
  this.isDestroyed = deps.isDestroyed;
801
- this.isTopSheet = deps.isTopSheet;
802
810
  this.getAllowedIds = deps.getAllowedIds;
803
811
  this.getResolvedSnaps = deps.getResolvedSnaps;
804
812
  this.snapToFn = deps.snapTo;
@@ -843,8 +851,10 @@ var ScrimController = class {
843
851
  if (this.backdrop) {
844
852
  const [s, e] = this.backdropRange;
845
853
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
846
- const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
847
- const backdropOpacity = this.isTopSheet() ? ramp : 0;
854
+ const backdropOpacity = Math.min(
855
+ Math.max((progress - s) / range, 0),
856
+ 1
857
+ );
848
858
  if (this.backdropOpacitySentinel.shouldWrite(
849
859
  backdropOpacity,
850
860
  OPACITY_WRITE_EPSILON
@@ -2619,6 +2629,7 @@ var BottomSheetCore = class {
2619
2629
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2620
2630
  __publicField(this, "isTopSheet", true);
2621
2631
  __publicField(this, "opening", false);
2632
+ __publicField(this, "promotedForOpen", false);
2622
2633
  __publicField(this, "allowOvershoot", false);
2623
2634
  __publicField(this, "progressPayload", {
2624
2635
  value: 0,
@@ -2675,7 +2686,6 @@ var BottomSheetCore = class {
2675
2686
  screenComponent: this.screenComponent,
2676
2687
  backdrop: this.backdrop,
2677
2688
  isDestroyed: () => this.destroyed,
2678
- isTopSheet: () => this.isTopSheet,
2679
2689
  getAllowedIds: () => this.snaps.getAllowedIds().slice(),
2680
2690
  getResolvedSnaps: () => this.snaps.getResolvedSnaps().slice(),
2681
2691
  snapTo: (id) => {
@@ -2945,13 +2955,14 @@ var BottomSheetCore = class {
2945
2955
  if (!_skipBeforeSnap && this.emitBeforeSnap(target, this.activeId)) {
2946
2956
  return;
2947
2957
  }
2958
+ const resumingOpen = this.opening;
2948
2959
  const signal = this.newCycle();
2949
2960
  const onExternalAbort = () => {
2950
2961
  this.animation.cancel();
2951
2962
  this.newCycle();
2952
2963
  };
2953
2964
  externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
2954
- const wasClosed = this.size === 0;
2965
+ const wasClosed = this.size === 0 || resumingOpen;
2955
2966
  const previousId = this.activeId;
2956
2967
  const previousSize = this.size;
2957
2968
  this.scrollCache.cache(previousId, previousSize, target.size);
@@ -2960,7 +2971,10 @@ var BottomSheetCore = class {
2960
2971
  const opensToRest = id === "closed" || rawTargetSize === 0;
2961
2972
  if (wasClosed && !opensToRest) {
2962
2973
  this.opening = true;
2963
- sheetStack.promote(this.id);
2974
+ if (!resumingOpen) {
2975
+ this.promotedForOpen = true;
2976
+ sheetStack.promote(this.id);
2977
+ }
2964
2978
  }
2965
2979
  if (this.animation.viewTransitionsAvailable) {
2966
2980
  this.currentViewTransition?.skipTransition?.();
@@ -3401,19 +3415,12 @@ var BottomSheetCore = class {
3401
3415
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3402
3416
  },
3403
3417
  setIsTop: (isTop) => {
3404
- if (this.isTopSheet === isTop) return;
3405
3418
  this.isTopSheet = isTop;
3406
- this.repaintScrim();
3407
3419
  },
3408
3420
  isOpen: () => this.size > 0 || this.opening,
3409
3421
  setDepth: (depth) => this.applyStackDepth(depth)
3410
3422
  }));
3411
3423
  }
3412
- repaintScrim() {
3413
- if (this.destroyed) return;
3414
- this.scrim.invalidateOpacityCache();
3415
- this.scrim.applyOpacity(this.computeProgress(this.size), true);
3416
- }
3417
3424
  applyStackDepth(depth) {
3418
3425
  if (!this.stackEffectEnabled) return;
3419
3426
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -3658,6 +3665,7 @@ var BottomSheetCore = class {
3658
3665
  this.activeId = target.id;
3659
3666
  if (previousSnapSize === 0 && target.size > 0) {
3660
3667
  this.opening = true;
3668
+ this.promotedForOpen = true;
3661
3669
  sheetStack.promote(this.id);
3662
3670
  }
3663
3671
  const settleCap = this.snaps.getMaxAxisSize();
@@ -3739,7 +3747,8 @@ var BottomSheetCore = class {
3739
3747
  return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
3740
3748
  }
3741
3749
  handleOpen() {
3742
- sheetStack.promote(this.id);
3750
+ if (this.promotedForOpen) this.promotedForOpen = false;
3751
+ else sheetStack.promote(this.id);
3743
3752
  try {
3744
3753
  this.lifecycle.install();
3745
3754
  } catch (err) {
@@ -3771,6 +3780,7 @@ var BottomSheetCore = class {
3771
3780
  }
3772
3781
  handleClose() {
3773
3782
  this.opening = false;
3783
+ this.promotedForOpen = false;
3774
3784
  this.lifecycle.release();
3775
3785
  sheetStack.update();
3776
3786
  }
package/dist/vue.js CHANGED
@@ -375,14 +375,26 @@ function notifyLinkedSheets(sheets, self) {
375
375
  }
376
376
  }
377
377
 
378
+ // src/core/primitives/hot-path-thresholds.ts
379
+ var SIZE_WRITE_EPSILON = 0.5;
380
+ var OPACITY_WRITE_EPSILON = 5e-3;
381
+ var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
382
+ var RANGE_DIVISION_EPSILON = 1e-4;
383
+
378
384
  // src/core/features/resize-observer.ts
379
385
  function installResizeObserver(deps) {
380
386
  if (typeof window === "undefined") {
381
387
  return () => {
382
388
  };
383
389
  }
390
+ const seatFor = () => {
391
+ const snap = deps.resolveActiveSnap();
392
+ const max = deps.getMaxAxisSize();
393
+ return { target: snap ? Math.min(snap.size, max) : null, max };
394
+ };
384
395
  const onResize = () => {
385
396
  if (deps.isDestroyed()) return;
397
+ const before = seatFor();
386
398
  deps.recomputeSnaps();
387
399
  const mode = deps.getMode();
388
400
  const isVerticalAxis = mode === "bottom" || mode === "top";
@@ -391,6 +403,10 @@ function installResizeObserver(deps) {
391
403
  if (viewportSize2 > 0 && viewportSize2 < max) {
392
404
  deps.setMaxAxisSize(viewportSize2);
393
405
  }
406
+ const after = seatFor();
407
+ if (before.target !== null && after.target !== null && Math.abs(after.target - before.target) < SIZE_WRITE_EPSILON && Math.abs(after.max - before.max) < SIZE_WRITE_EPSILON) {
408
+ return;
409
+ }
394
410
  const wasAnimating = deps.isAnimating?.() ?? false;
395
411
  deps.cancelInFlight();
396
412
  deps.newCycle();
@@ -659,12 +675,6 @@ var SCRIM_PRESETS = Object.freeze({
659
675
  }
660
676
  });
661
677
 
662
- // src/core/primitives/hot-path-thresholds.ts
663
- var SIZE_WRITE_EPSILON = 0.5;
664
- var OPACITY_WRITE_EPSILON = 5e-3;
665
- var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
666
- var RANGE_DIVISION_EPSILON = 1e-4;
667
-
668
678
  // src/core/primitives/opacity-dedup.ts
669
679
  var WriteSentinel = class {
670
680
  constructor() {
@@ -774,7 +784,6 @@ var ScrimController = class {
774
784
  __publicField(this, "backdrop");
775
785
  __publicField(this, "mode");
776
786
  __publicField(this, "isDestroyed");
777
- __publicField(this, "isTopSheet");
778
787
  __publicField(this, "getAllowedIds");
779
788
  __publicField(this, "getResolvedSnaps");
780
789
  __publicField(this, "snapToFn");
@@ -796,7 +805,6 @@ var ScrimController = class {
796
805
  this.backdrop = deps.backdrop;
797
806
  this.mode = deps.mode;
798
807
  this.isDestroyed = deps.isDestroyed;
799
- this.isTopSheet = deps.isTopSheet;
800
808
  this.getAllowedIds = deps.getAllowedIds;
801
809
  this.getResolvedSnaps = deps.getResolvedSnaps;
802
810
  this.snapToFn = deps.snapTo;
@@ -841,8 +849,10 @@ var ScrimController = class {
841
849
  if (this.backdrop) {
842
850
  const [s, e] = this.backdropRange;
843
851
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
844
- const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
845
- const backdropOpacity = this.isTopSheet() ? ramp : 0;
852
+ const backdropOpacity = Math.min(
853
+ Math.max((progress - s) / range, 0),
854
+ 1
855
+ );
846
856
  if (this.backdropOpacitySentinel.shouldWrite(
847
857
  backdropOpacity,
848
858
  OPACITY_WRITE_EPSILON
@@ -2617,6 +2627,7 @@ var BottomSheetCore = class {
2617
2627
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2618
2628
  __publicField(this, "isTopSheet", true);
2619
2629
  __publicField(this, "opening", false);
2630
+ __publicField(this, "promotedForOpen", false);
2620
2631
  __publicField(this, "allowOvershoot", false);
2621
2632
  __publicField(this, "progressPayload", {
2622
2633
  value: 0,
@@ -2673,7 +2684,6 @@ var BottomSheetCore = class {
2673
2684
  screenComponent: this.screenComponent,
2674
2685
  backdrop: this.backdrop,
2675
2686
  isDestroyed: () => this.destroyed,
2676
- isTopSheet: () => this.isTopSheet,
2677
2687
  getAllowedIds: () => this.snaps.getAllowedIds().slice(),
2678
2688
  getResolvedSnaps: () => this.snaps.getResolvedSnaps().slice(),
2679
2689
  snapTo: (id) => {
@@ -2943,13 +2953,14 @@ var BottomSheetCore = class {
2943
2953
  if (!_skipBeforeSnap && this.emitBeforeSnap(target, this.activeId)) {
2944
2954
  return;
2945
2955
  }
2956
+ const resumingOpen = this.opening;
2946
2957
  const signal = this.newCycle();
2947
2958
  const onExternalAbort = () => {
2948
2959
  this.animation.cancel();
2949
2960
  this.newCycle();
2950
2961
  };
2951
2962
  externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
2952
- const wasClosed = this.size === 0;
2963
+ const wasClosed = this.size === 0 || resumingOpen;
2953
2964
  const previousId = this.activeId;
2954
2965
  const previousSize = this.size;
2955
2966
  this.scrollCache.cache(previousId, previousSize, target.size);
@@ -2958,7 +2969,10 @@ var BottomSheetCore = class {
2958
2969
  const opensToRest = id === "closed" || rawTargetSize === 0;
2959
2970
  if (wasClosed && !opensToRest) {
2960
2971
  this.opening = true;
2961
- sheetStack.promote(this.id);
2972
+ if (!resumingOpen) {
2973
+ this.promotedForOpen = true;
2974
+ sheetStack.promote(this.id);
2975
+ }
2962
2976
  }
2963
2977
  if (this.animation.viewTransitionsAvailable) {
2964
2978
  this.currentViewTransition?.skipTransition?.();
@@ -3399,19 +3413,12 @@ var BottomSheetCore = class {
3399
3413
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3400
3414
  },
3401
3415
  setIsTop: (isTop) => {
3402
- if (this.isTopSheet === isTop) return;
3403
3416
  this.isTopSheet = isTop;
3404
- this.repaintScrim();
3405
3417
  },
3406
3418
  isOpen: () => this.size > 0 || this.opening,
3407
3419
  setDepth: (depth) => this.applyStackDepth(depth)
3408
3420
  }));
3409
3421
  }
3410
- repaintScrim() {
3411
- if (this.destroyed) return;
3412
- this.scrim.invalidateOpacityCache();
3413
- this.scrim.applyOpacity(this.computeProgress(this.size), true);
3414
- }
3415
3422
  applyStackDepth(depth) {
3416
3423
  if (!this.stackEffectEnabled) return;
3417
3424
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -3656,6 +3663,7 @@ var BottomSheetCore = class {
3656
3663
  this.activeId = target.id;
3657
3664
  if (previousSnapSize === 0 && target.size > 0) {
3658
3665
  this.opening = true;
3666
+ this.promotedForOpen = true;
3659
3667
  sheetStack.promote(this.id);
3660
3668
  }
3661
3669
  const settleCap = this.snaps.getMaxAxisSize();
@@ -3737,7 +3745,8 @@ var BottomSheetCore = class {
3737
3745
  return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
3738
3746
  }
3739
3747
  handleOpen() {
3740
- sheetStack.promote(this.id);
3748
+ if (this.promotedForOpen) this.promotedForOpen = false;
3749
+ else sheetStack.promote(this.id);
3741
3750
  try {
3742
3751
  this.lifecycle.install();
3743
3752
  } catch (err) {
@@ -3769,6 +3778,7 @@ var BottomSheetCore = class {
3769
3778
  }
3770
3779
  handleClose() {
3771
3780
  this.opening = false;
3781
+ this.promotedForOpen = false;
3772
3782
  this.lifecycle.release();
3773
3783
  sheetStack.update();
3774
3784
  }
package/dist/webgl.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { f as EngineFeature } from './BottomSheetCore-CK8Rh1He.cjs';
1
+ import { f as EngineFeature } from './BottomSheetCore-BHv6LPmS.cjs';
2
2
  import './transform-jVfAikE9.cjs';
3
3
 
4
4
  type WebGLRendererOptions = {
package/dist/webgl.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { f as EngineFeature } from './BottomSheetCore-CIijwtdi.js';
1
+ import { f as EngineFeature } from './BottomSheetCore-CK_mq14p.js';
2
2
  import './transform-jVfAikE9.js';
3
3
 
4
4
  type WebGLRendererOptions = {