@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/vue.cjs 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));
@@ -4740,6 +4746,10 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
4740
4746
  if (next === void 0) return;
4741
4747
  getEngine()?.setDragFrom(next);
4742
4748
  });
4749
+ vue.watch(() => props.mode, (next) => {
4750
+ if (next === void 0) return;
4751
+ getEngine()?.setMode(next);
4752
+ });
4743
4753
  const mounted = vue.ref(false);
4744
4754
  const anchorHosts = vue.shallowRef({});
4745
4755
  const anchorDetachers = vue.ref([]);
package/dist/vue.js 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));
@@ -4738,6 +4744,10 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
4738
4744
  if (next === void 0) return;
4739
4745
  getEngine()?.setDragFrom(next);
4740
4746
  });
4747
+ watch(() => props.mode, (next) => {
4748
+ if (next === void 0) return;
4749
+ getEngine()?.setMode(next);
4750
+ });
4741
4751
  const mounted = ref(false);
4742
4752
  const anchorHosts = shallowRef({});
4743
4753
  const anchorDetachers = ref([]);
package/dist/webgl.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { f as EngineFeature } from './BottomSheetCore-VPJZcKcg.cjs';
1
+ import { f as EngineFeature } from './BottomSheetCore-CK8Rh1He.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-Cgn8b_6A.js';
1
+ import { f as EngineFeature } from './BottomSheetCore-CIijwtdi.js';
2
2
  import './transform-jVfAikE9.js';
3
3
 
4
4
  type WebGLRendererOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surdeddd/bottom-sheet",
3
- "version": "0.20.2",
3
+ "version": "0.21.0",
4
4
  "description": "Universal, headless bottom sheet — framework-agnostic core with React, Vue 3, Svelte, Solid, Qwik, Preact, Lit and Custom Element adapters. Pointer Events, snap points, momentum, a11y, SSR-safe.",
5
5
  "type": "module",
6
6
  "license": "MIT",