@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/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) |
@@ -397,6 +397,7 @@ declare class BottomSheetCore {
397
397
  private allowedIdsBySize;
398
398
  private updateAriaSlider;
399
399
  private registerInStack;
400
+ private repaintScrim;
400
401
  private applyStackDepth;
401
402
  private buildGestureDeps;
402
403
  private isContentDragAllowed;
@@ -397,6 +397,7 @@ declare class BottomSheetCore {
397
397
  private allowedIdsBySize;
398
398
  private updateAriaSlider;
399
399
  private registerInStack;
400
+ private repaintScrim;
400
401
  private applyStackDepth;
401
402
  private buildGestureDeps;
402
403
  private isContentDragAllowed;
@@ -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-CIijwtdi.js';
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-VPJZcKcg.cjs';
1
+ import { B as BottomSheetCore, c as EngineOptions } from './BottomSheetCore-CK8Rh1He.cjs';
2
2
 
3
3
  declare class BottomSheetEngine extends BottomSheetCore {
4
4
  constructor(opts: EngineOptions);
package/dist/core.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/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-CK8Rh1He.cjs';
2
+ export { R as ResolvedSnap } from './index-BEX-NHRJ.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-CIijwtdi.js';
2
+ export { R as ResolvedSnap } from './index-BqLHKOeM.js';
3
3
  import './transform-jVfAikE9.js';
package/dist/core.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));
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-CK8Rh1He.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-CIijwtdi.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
@@ -952,22 +952,18 @@ var init_scrim_controller = __esm({
952
952
  if (this.backdrop) {
953
953
  const [s, e] = this.backdropRange;
954
954
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
955
- const backdropOpacity = Math.min(
956
- Math.max((progress - s) / range, 0),
957
- 1
958
- );
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
- }
955
+ const ramp = Math.min(Math.max((progress - s) / range, 0), 1);
956
+ const backdropOpacity = this.isTopSheet() ? ramp : 0;
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) {
@@ -3678,12 +3677,19 @@ var init_BottomSheetCore = __esm({
3678
3677
  for (const anchor of this.anchors) anchor.syncZ(z + 1);
3679
3678
  },
3680
3679
  setIsTop: (isTop) => {
3680
+ if (this.isTopSheet === isTop) return;
3681
3681
  this.isTopSheet = isTop;
3682
+ this.repaintScrim();
3682
3683
  },
3683
3684
  isOpen: () => this.size > 0 || this.opening,
3684
3685
  setDepth: (depth) => this.applyStackDepth(depth)
3685
3686
  }));
3686
3687
  }
3688
+ repaintScrim() {
3689
+ if (this.destroyed) return;
3690
+ this.scrim.invalidateOpacityCache();
3691
+ this.scrim.applyOpacity(this.computeProgress(this.size), true);
3692
+ }
3687
3693
  applyStackDepth(depth) {
3688
3694
  if (!this.stackEffectEnabled) return;
3689
3695
  this.element.setAttribute("data-stack-depth", String(depth));
@@ -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-hLSAxzla.cjs';
2
+ import { C as CloseReason, A as AnchorOptions, e as ScrimStagesOptions, E as EngineState } from './BottomSheetCore-CK8Rh1He.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-CZglPsTF.js';
2
+ import { C as CloseReason, A as AnchorOptions, e as ScrimStagesOptions, E as EngineState } from './BottomSheetCore-CIijwtdi.js';
3
3
  import './transform-jVfAikE9.js';
4
4
 
5
5
  declare const BaseHTMLElement: typeof HTMLElement;