@surdeddd/bottom-sheet 0.13.0 → 0.14.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 (66) hide show
  1. package/README.md +33 -0
  2. package/dist/{BottomSheetCore-CsIjyq7C.d.cts → BottomSheetCore-Cp7dWy91.d.cts} +26 -1
  3. package/dist/{BottomSheetCore-D16lsa6g.d.ts → BottomSheetCore-DJYwWOqt.d.ts} +26 -1
  4. package/dist/{BottomSheetEngine-BYjAVrmd.d.cts → BottomSheetEngine-Lm7HIVHv.d.cts} +1 -1
  5. package/dist/{BottomSheetEngine-YuCNugZn.d.ts → BottomSheetEngine-O5PbeKfe.d.ts} +1 -1
  6. package/dist/core.cjs +231 -27
  7. package/dist/core.d.cts +2 -2
  8. package/dist/core.d.ts +2 -2
  9. package/dist/core.js +231 -27
  10. package/dist/debug.d.cts +1 -1
  11. package/dist/debug.d.ts +1 -1
  12. package/dist/element.cjs +300 -102
  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 +300 -102
  17. package/dist/features.cjs +6 -50
  18. package/dist/features.d.cts +2 -2
  19. package/dist/features.d.ts +2 -2
  20. package/dist/features.js +6 -50
  21. package/dist/index-Bb5TRmyg.d.cts +9 -0
  22. package/dist/index-Cl9ebCP2.d.ts +9 -0
  23. package/dist/index.cjs +238 -823
  24. package/dist/index.d.cts +42 -45
  25. package/dist/index.d.ts +42 -45
  26. package/dist/index.js +239 -810
  27. package/dist/integrations/formik.d.cts +1 -1
  28. package/dist/integrations/formik.d.ts +1 -1
  29. package/dist/integrations/react-hook-form.d.cts +1 -1
  30. package/dist/integrations/react-hook-form.d.ts +1 -1
  31. package/dist/overlay.cjs +5 -5
  32. package/dist/overlay.js +5 -5
  33. package/dist/preact.d.cts +2 -2
  34. package/dist/preact.d.ts +2 -2
  35. package/dist/qwik-lib/index.qwik.cjs +228 -77
  36. package/dist/qwik-lib/index.qwik.mjs +228 -77
  37. package/dist/qwik.cjs +245 -77
  38. package/dist/qwik.d.cts +4 -2
  39. package/dist/qwik.d.ts +4 -2
  40. package/dist/qwik.js +245 -77
  41. package/dist/react.cjs +250 -79
  42. package/dist/react.d.cts +3 -4
  43. package/dist/react.d.ts +3 -4
  44. package/dist/react.js +250 -79
  45. package/dist/solid.cjs +251 -77
  46. package/dist/solid.d.cts +27 -0
  47. package/dist/solid.d.ts +27 -0
  48. package/dist/solid.js +251 -77
  49. package/dist/solid.source.jsx +259 -77
  50. package/dist/styles.css +24 -4
  51. package/dist/svelte-core.cjs +237 -77
  52. package/dist/svelte-core.js +237 -77
  53. package/dist/svelte-src/BottomSheet.svelte +14 -0
  54. package/dist/svelte.cjs +247 -77
  55. package/dist/svelte.d.cts +2 -0
  56. package/dist/svelte.d.ts +2 -0
  57. package/dist/svelte.js +247 -77
  58. package/dist/vue.cjs +253 -77
  59. package/dist/vue.js +253 -77
  60. package/dist/webgl.cjs +583 -0
  61. package/dist/webgl.d.cts +17 -0
  62. package/dist/webgl.d.ts +17 -0
  63. package/dist/webgl.js +581 -0
  64. package/package.json +36 -12
  65. package/dist/index-DdYLOIIT.d.ts +0 -15
  66. package/dist/index-dfrzw-lI.d.cts +0 -15
package/README.md CHANGED
@@ -248,6 +248,8 @@ type SnapPoint =
248
248
  | `persistent` | `false` | Block dismissal (backdrop / Escape / back); programmatic `close()` still works |
249
249
  | `disableClose` | `false` | Block all closing, including programmatic |
250
250
  | `disableDrag` | `false` | Suppress the drag gesture (imperative snaps still work) |
251
+ | `dragFrom` | `"handle"` | Which regions start a drag: `"handle"`, `"sheet"` (whole sheet), or `"zones"` (only `[data-bs-drag]` subtrees). Defaults to `"sheet"` when no handle is given. `[data-bs-no-drag]` opts a subtree out in every mode. Also `setDragFrom()` / `getDragFrom()` — switching remounts the gesture, no component remount |
252
+ | `dragFromContent` | `true` | Whether a touch gesture on the scroll container drags the sheet; override per snap point with `{ id, size, dragFromContent: false }`. Also `setDragFromContent()` |
251
253
  | `radius` | token default | Corner radius (`string` CSS length or `number` px); also `setRadius()` |
252
254
  | `maxHeight` | none | Cap the sheet height. `number` (px) or a string (`"92dvh"`, `"50%"`) re-resolved on viewport / orientation changes |
253
255
  | `returnFocusTo` | opener | Focus target on dismiss — an `HTMLElement`, a selector `string`, or a `() => HTMLElement` factory |
@@ -418,6 +420,28 @@ trap, scroll lock, scrim, stacking) is core. Setting an option whose feature
418
420
  is missing dev-warns once and is ignored in production. Custom features
419
421
  implement `{ name, install(ctx) }` — the same seam the built-ins use.
420
422
 
423
+ ### WebGL renderer (opt-in)
424
+
425
+ ```ts
426
+ import { webglRenderer } from '@surdeddd/bottom-sheet/webgl';
427
+
428
+ const engine = new BottomSheetEngine({
429
+ element, handle, snapPoints,
430
+ features: [webglRenderer({ jelly: 0.6 })],
431
+ });
432
+ ```
433
+
434
+ Paints the sheet surface — panel, radii, shadow, edge sheen — on the GPU. The
435
+ moment a drag starts, the sheet's text is lifted into a texture so the whole
436
+ sheet bends as one surface, and handed straight back to the DOM once it
437
+ settles. Layout, scrolling, gestures and the accessibility tree never leave the
438
+ DOM. 4.2 KB gzip, and only if you import it.
439
+ Falls back to the DOM renderer, silently and mid-session if it has to, when
440
+ there is no WebGL, under `prefers-reduced-motion`, or when the browser drops
441
+ the GL context.
442
+
443
+ [Full WebGL docs →](docs/webgl.md)
444
+
421
445
  ### Debug overlay
422
446
 
423
447
  ```ts
@@ -528,6 +552,15 @@ The editorial demo showcases the adapters, every gesture, every mode
528
552
  (`bottom · top · left · right · overlay`), and live engine readouts (active
529
553
  snap, progress, velocity, FPS). EN/RU and light/dark toggles in the corner.
530
554
 
555
+ ## Browser support
556
+
557
+ Baseline: Chrome/Edge 80, Safari 13.1 (iOS 13.4), Firefox 72 — set by the
558
+ ES2020 build target and the APIs the engine cannot work without (Pointer
559
+ Events, CSS custom properties, `ResizeObserver`). Everything else, from
560
+ `inert` to `backdrop-filter` to WebGL, is capability-checked and degrades.
561
+
562
+ [Full support matrix →](docs/browser-support.md)
563
+
531
564
  ## Testing
532
565
 
533
566
  ```bash
@@ -1,9 +1,12 @@
1
1
  import { T as TransformAxis } from './transform-jVfAikE9.cjs';
2
2
 
3
+ type DragFrom$1 = "handle" | "sheet" | "zones";
4
+
3
5
  type SnapPoint = number | `${number}%` | "fit" | "content" | "full" | (string & {});
4
6
  type SnapPointDef<Id extends string = string> = {
5
7
  id: Id;
6
8
  size: SnapPoint;
9
+ dragFromContent?: boolean;
7
10
  };
8
11
  type SnapId<T extends readonly SnapPointDef<string>[] | {
9
12
  snapPoints: readonly SnapPointDef<string>[];
@@ -11,6 +14,8 @@ type SnapId<T extends readonly SnapPointDef<string>[] | {
11
14
  snapPoints: readonly SnapPointDef<infer U>[];
12
15
  } ? U : T extends readonly SnapPointDef<infer U>[] ? U : never;
13
16
  type SheetMode = TransformAxis;
17
+ type DragFrom = DragFrom$1;
18
+ type DragSurfaceKind = "content";
14
19
  type ScrimPreset = "subtle" | "standard" | "monitoring" | "cinematic";
15
20
  type ScrimPresetConfig = {
16
21
  color: string;
@@ -93,6 +98,8 @@ type EngineOptions = {
93
98
  respectReducedMotion?: boolean;
94
99
  flickVelocity?: number;
95
100
  dragThreshold?: number;
101
+ dragFrom?: DragFrom;
102
+ dragFromContent?: boolean;
96
103
  rubberBand?: boolean;
97
104
  backdropRange?: [number, number];
98
105
  screenRange?: [number, number];
@@ -172,6 +179,7 @@ type EngineFeatureContext = {
172
179
  resyncAfterResize: () => void;
173
180
  snapTo: (id: string) => void;
174
181
  close: (reason?: CloseReason) => Promise<void>;
182
+ attachDragSurface: (surface: HTMLElement, kind: DragSurfaceKind) => (() => void) | void;
175
183
  on: <K extends keyof SheetEventMap>(event: K, fn: (payload: SheetEventMap[K]) => void) => () => void;
176
184
  addTeardown: (fn: (() => void) | null | undefined) => void;
177
185
  };
@@ -261,6 +269,8 @@ declare class BottomSheetCore {
261
269
  private mode;
262
270
  private flickVelocity;
263
271
  private dragThreshold;
272
+ private dragFromMode;
273
+ private dragFromContentDefault;
264
274
  private rubberBandEnabled;
265
275
  private scrim;
266
276
  private aria;
@@ -278,8 +288,11 @@ declare class BottomSheetCore {
278
288
  private activeId;
279
289
  private size;
280
290
  private gesture;
291
+ private contentGesture;
292
+ private detachSheetGesture;
281
293
  private rootEl;
282
294
  private destroyed;
295
+ private restClosed;
283
296
  private currentViewTransition;
284
297
  private currentAbort;
285
298
  private sizeWriteSentinel;
@@ -322,6 +335,7 @@ declare class BottomSheetCore {
322
335
  signal?: AbortSignal;
323
336
  }, _skipBeforeSnap?: boolean): Promise<void>;
324
337
  private completeSnap;
338
+ private setRestClosed;
325
339
  private emitOpenSequence;
326
340
  private emitCloseSequence;
327
341
  dragTo(targetSize: number, velocityOrOpts?: number | {
@@ -334,6 +348,9 @@ declare class BottomSheetCore {
334
348
  setPersistent(value: boolean): void;
335
349
  setDisableClose(value: boolean): void;
336
350
  setDisableDrag(value: boolean): void;
351
+ setDragFromContent(value: boolean): void;
352
+ setDragFrom(mode: DragFrom$1): void;
353
+ getDragFrom(): DragFrom$1;
337
354
  isTop(): boolean;
338
355
  depth(): number;
339
356
  expand(): Promise<void>;
@@ -373,9 +390,17 @@ declare class BottomSheetCore {
373
390
  private updateAriaSlider;
374
391
  private registerInStack;
375
392
  private applyStackDepth;
393
+ private buildGestureDeps;
394
+ private isContentDragAllowed;
395
+ private decideContentDrag;
396
+ private attachDragSurface;
397
+ private sheetDragSurface;
398
+ private canStartSheetDrag;
399
+ private mountSheetGesture;
376
400
  private attach;
377
401
  private attachFeatures;
378
402
  private settleAfterDrag;
403
+ private isDraggingAny;
379
404
  private clearWillChangeIfIdle;
380
405
  private haptic;
381
406
  private applySize;
@@ -385,4 +410,4 @@ declare class BottomSheetCore {
385
410
  private handleClose;
386
411
  }
387
412
 
388
- export { type AnchorOptions as A, BottomSheetCore as B, type CloseReason as C, type EngineState as E, type Plugin as P, type ScrimStagesOptions as S, type TeardownScope as T, type EngineOptions as a, type SnapPointDef as b, type SheetMode as c, type SheetEventMap as d, type SnapPoint as e, type ScrimOverlayPosition as f, type AnchorAnimationPreset as g, type AnchorAnimationSpec as h, type AnchorHandle as i, type AnchorPosition as j, type AnchorState as k, type EngineFeature as l, type EngineFeatureContext as m, type EngineFeatureOptions as n, type EngineFeatureStage as o, SCRIM_PRESETS as p, type ScrimOverlayOptions as q, type ScrimPreset as r, type ScrimPresetConfig as s, type ScrimStageDef as t, type ScrimUpdate as u, type SnapId as v, runAnchorTransition as w };
413
+ export { type AnchorOptions as A, BottomSheetCore as B, type CloseReason as C, type EngineState as E, type Plugin as P, type ScrimStagesOptions as S, type TeardownScope as T, type EngineOptions as a, type SnapPointDef as b, type SheetMode as c, type SheetEventMap as d, type SnapPoint as e, type EngineFeature as f, type ScrimOverlayPosition as g, type AnchorAnimationPreset as h, type AnchorAnimationSpec as i, type AnchorHandle as j, type AnchorPosition as k, type AnchorState as l, type EngineFeatureContext as m, type EngineFeatureOptions as n, type EngineFeatureStage as o, SCRIM_PRESETS as p, type ScrimOverlayOptions as q, type ScrimPreset as r, type ScrimPresetConfig as s, type ScrimStageDef as t, type ScrimUpdate as u, type SnapId as v, runAnchorTransition as w };
@@ -1,9 +1,12 @@
1
1
  import { T as TransformAxis } from './transform-jVfAikE9.js';
2
2
 
3
+ type DragFrom$1 = "handle" | "sheet" | "zones";
4
+
3
5
  type SnapPoint = number | `${number}%` | "fit" | "content" | "full" | (string & {});
4
6
  type SnapPointDef<Id extends string = string> = {
5
7
  id: Id;
6
8
  size: SnapPoint;
9
+ dragFromContent?: boolean;
7
10
  };
8
11
  type SnapId<T extends readonly SnapPointDef<string>[] | {
9
12
  snapPoints: readonly SnapPointDef<string>[];
@@ -11,6 +14,8 @@ type SnapId<T extends readonly SnapPointDef<string>[] | {
11
14
  snapPoints: readonly SnapPointDef<infer U>[];
12
15
  } ? U : T extends readonly SnapPointDef<infer U>[] ? U : never;
13
16
  type SheetMode = TransformAxis;
17
+ type DragFrom = DragFrom$1;
18
+ type DragSurfaceKind = "content";
14
19
  type ScrimPreset = "subtle" | "standard" | "monitoring" | "cinematic";
15
20
  type ScrimPresetConfig = {
16
21
  color: string;
@@ -93,6 +98,8 @@ type EngineOptions = {
93
98
  respectReducedMotion?: boolean;
94
99
  flickVelocity?: number;
95
100
  dragThreshold?: number;
101
+ dragFrom?: DragFrom;
102
+ dragFromContent?: boolean;
96
103
  rubberBand?: boolean;
97
104
  backdropRange?: [number, number];
98
105
  screenRange?: [number, number];
@@ -172,6 +179,7 @@ type EngineFeatureContext = {
172
179
  resyncAfterResize: () => void;
173
180
  snapTo: (id: string) => void;
174
181
  close: (reason?: CloseReason) => Promise<void>;
182
+ attachDragSurface: (surface: HTMLElement, kind: DragSurfaceKind) => (() => void) | void;
175
183
  on: <K extends keyof SheetEventMap>(event: K, fn: (payload: SheetEventMap[K]) => void) => () => void;
176
184
  addTeardown: (fn: (() => void) | null | undefined) => void;
177
185
  };
@@ -261,6 +269,8 @@ declare class BottomSheetCore {
261
269
  private mode;
262
270
  private flickVelocity;
263
271
  private dragThreshold;
272
+ private dragFromMode;
273
+ private dragFromContentDefault;
264
274
  private rubberBandEnabled;
265
275
  private scrim;
266
276
  private aria;
@@ -278,8 +288,11 @@ declare class BottomSheetCore {
278
288
  private activeId;
279
289
  private size;
280
290
  private gesture;
291
+ private contentGesture;
292
+ private detachSheetGesture;
281
293
  private rootEl;
282
294
  private destroyed;
295
+ private restClosed;
283
296
  private currentViewTransition;
284
297
  private currentAbort;
285
298
  private sizeWriteSentinel;
@@ -322,6 +335,7 @@ declare class BottomSheetCore {
322
335
  signal?: AbortSignal;
323
336
  }, _skipBeforeSnap?: boolean): Promise<void>;
324
337
  private completeSnap;
338
+ private setRestClosed;
325
339
  private emitOpenSequence;
326
340
  private emitCloseSequence;
327
341
  dragTo(targetSize: number, velocityOrOpts?: number | {
@@ -334,6 +348,9 @@ declare class BottomSheetCore {
334
348
  setPersistent(value: boolean): void;
335
349
  setDisableClose(value: boolean): void;
336
350
  setDisableDrag(value: boolean): void;
351
+ setDragFromContent(value: boolean): void;
352
+ setDragFrom(mode: DragFrom$1): void;
353
+ getDragFrom(): DragFrom$1;
337
354
  isTop(): boolean;
338
355
  depth(): number;
339
356
  expand(): Promise<void>;
@@ -373,9 +390,17 @@ declare class BottomSheetCore {
373
390
  private updateAriaSlider;
374
391
  private registerInStack;
375
392
  private applyStackDepth;
393
+ private buildGestureDeps;
394
+ private isContentDragAllowed;
395
+ private decideContentDrag;
396
+ private attachDragSurface;
397
+ private sheetDragSurface;
398
+ private canStartSheetDrag;
399
+ private mountSheetGesture;
376
400
  private attach;
377
401
  private attachFeatures;
378
402
  private settleAfterDrag;
403
+ private isDraggingAny;
379
404
  private clearWillChangeIfIdle;
380
405
  private haptic;
381
406
  private applySize;
@@ -385,4 +410,4 @@ declare class BottomSheetCore {
385
410
  private handleClose;
386
411
  }
387
412
 
388
- export { type AnchorOptions as A, BottomSheetCore as B, type CloseReason as C, type EngineState as E, type Plugin as P, type ScrimStagesOptions as S, type TeardownScope as T, type EngineOptions as a, type SnapPointDef as b, type SheetMode as c, type SheetEventMap as d, type SnapPoint as e, type ScrimOverlayPosition as f, type AnchorAnimationPreset as g, type AnchorAnimationSpec as h, type AnchorHandle as i, type AnchorPosition as j, type AnchorState as k, type EngineFeature as l, type EngineFeatureContext as m, type EngineFeatureOptions as n, type EngineFeatureStage as o, SCRIM_PRESETS as p, type ScrimOverlayOptions as q, type ScrimPreset as r, type ScrimPresetConfig as s, type ScrimStageDef as t, type ScrimUpdate as u, type SnapId as v, runAnchorTransition as w };
413
+ export { type AnchorOptions as A, BottomSheetCore as B, type CloseReason as C, type EngineState as E, type Plugin as P, type ScrimStagesOptions as S, type TeardownScope as T, type EngineOptions as a, type SnapPointDef as b, type SheetMode as c, type SheetEventMap as d, type SnapPoint as e, type EngineFeature as f, type ScrimOverlayPosition as g, type AnchorAnimationPreset as h, type AnchorAnimationSpec as i, type AnchorHandle as j, type AnchorPosition as k, type AnchorState as l, type EngineFeatureContext as m, type EngineFeatureOptions as n, type EngineFeatureStage as o, SCRIM_PRESETS as p, type ScrimOverlayOptions as q, type ScrimPreset as r, type ScrimPresetConfig as s, type ScrimStageDef as t, type ScrimUpdate as u, type SnapId as v, runAnchorTransition as w };
@@ -1,4 +1,4 @@
1
- import { B as BottomSheetCore, a as EngineOptions } from './BottomSheetCore-CsIjyq7C.cjs';
1
+ import { B as BottomSheetCore, a as EngineOptions } from './BottomSheetCore-Cp7dWy91.cjs';
2
2
 
3
3
  declare class BottomSheetEngine extends BottomSheetCore {
4
4
  constructor(opts: EngineOptions);
@@ -1,4 +1,4 @@
1
- import { B as BottomSheetCore, a as EngineOptions } from './BottomSheetCore-D16lsa6g.js';
1
+ import { B as BottomSheetCore, a as EngineOptions } from './BottomSheetCore-DJYwWOqt.js';
2
2
 
3
3
  declare class BottomSheetEngine extends BottomSheetCore {
4
4
  constructor(opts: EngineOptions);