@surdeddd/bottom-sheet 0.13.0 → 0.20.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 +46 -0
  2. package/dist/{BottomSheetCore-D16lsa6g.d.ts → BottomSheetCore-Cgn8b_6A.d.ts} +36 -2
  3. package/dist/{BottomSheetCore-CsIjyq7C.d.cts → BottomSheetCore-VPJZcKcg.d.cts} +36 -2
  4. package/dist/{BottomSheetEngine-BYjAVrmd.d.cts → BottomSheetEngine-B8C2CwF9.d.cts} +1 -1
  5. package/dist/{BottomSheetEngine-YuCNugZn.d.ts → BottomSheetEngine-DwYR_ygJ.d.ts} +1 -1
  6. package/dist/core.cjs +328 -33
  7. package/dist/core.d.cts +2 -2
  8. package/dist/core.d.ts +2 -2
  9. package/dist/core.js +328 -33
  10. package/dist/debug.d.cts +1 -1
  11. package/dist/debug.d.ts +1 -1
  12. package/dist/element.cjs +404 -108
  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 +404 -108
  17. package/dist/features.cjs +6 -50
  18. package/dist/features.d.cts +4 -4
  19. package/dist/features.d.ts +4 -4
  20. package/dist/features.js +6 -50
  21. package/dist/index-CnfbOKx0.d.cts +9 -0
  22. package/dist/index-DcMkhXAy.d.ts +9 -0
  23. package/dist/index.cjs +335 -829
  24. package/dist/index.d.cts +44 -47
  25. package/dist/index.d.ts +44 -47
  26. package/dist/index.js +336 -816
  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 +323 -83
  36. package/dist/qwik-lib/index.qwik.mjs +323 -83
  37. package/dist/qwik.cjs +342 -83
  38. package/dist/qwik.d.cts +4 -2
  39. package/dist/qwik.d.ts +4 -2
  40. package/dist/qwik.js +342 -83
  41. package/dist/react.cjs +347 -85
  42. package/dist/react.d.cts +3 -4
  43. package/dist/react.d.ts +3 -4
  44. package/dist/react.js +347 -85
  45. package/dist/solid.cjs +348 -83
  46. package/dist/solid.d.cts +37 -1
  47. package/dist/solid.d.ts +37 -1
  48. package/dist/solid.js +348 -83
  49. package/dist/solid.source.jsx +356 -83
  50. package/dist/styles.css +24 -4
  51. package/dist/svelte-core.cjs +334 -83
  52. package/dist/svelte-core.js +334 -83
  53. package/dist/svelte-src/BottomSheet.svelte +14 -0
  54. package/dist/svelte.cjs +344 -83
  55. package/dist/svelte.d.cts +2 -0
  56. package/dist/svelte.d.ts +2 -0
  57. package/dist/svelte.js +344 -83
  58. package/dist/vue.cjs +350 -83
  59. package/dist/vue.js +350 -83
  60. package/dist/webgl.cjs +673 -0
  61. package/dist/webgl.d.cts +17 -0
  62. package/dist/webgl.d.ts +17 -0
  63. package/dist/webgl.js +671 -0
  64. package/package.json +64 -40
  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,28 @@ 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
+ ## Right-to-left
556
+
557
+ `left` and `right` are physical edges and stay physical. For interfaces that
558
+ flip with the writing direction, use the logical modes — `start` and `end`
559
+ resolve against the direction that applies to the sheet, so `start` is the left
560
+ edge in English and the right edge in Arabic:
561
+
562
+ ```ts
563
+ new BottomSheetEngine({ element, handle, mode: 'start', snapPoints });
564
+ ```
565
+
566
+ [Full RTL docs →](docs/rtl.md)
567
+
568
+ ## Browser support
569
+
570
+ Baseline: Chrome/Edge 80, Safari 13.1 (iOS 13.4), Firefox 72 — set by the
571
+ ES2020 build target and the APIs the engine cannot work without (Pointer
572
+ Events, CSS custom properties, `ResizeObserver`). Everything else, from
573
+ `inert` to `backdrop-filter` to WebGL, is capability-checked and degrades.
574
+
575
+ [Full support matrix →](docs/browser-support.md)
576
+
531
577
  ## Testing
532
578
 
533
579
  ```bash
@@ -1,16 +1,25 @@
1
1
  import { T as TransformAxis } from './transform-jVfAikE9.js';
2
2
 
3
+ type DragFrom$1 = "handle" | "sheet" | "zones";
4
+
5
+ type LogicalAxis = "start" | "end";
6
+
3
7
  type SnapPoint = number | `${number}%` | "fit" | "content" | "full" | (string & {});
4
8
  type SnapPointDef<Id extends string = string> = {
5
9
  id: Id;
6
10
  size: SnapPoint;
11
+ dragFromContent?: boolean;
7
12
  };
8
13
  type SnapId<T extends readonly SnapPointDef<string>[] | {
9
14
  snapPoints: readonly SnapPointDef<string>[];
10
15
  }> = T extends {
11
16
  snapPoints: readonly SnapPointDef<infer U>[];
12
17
  } ? U : T extends readonly SnapPointDef<infer U>[] ? U : never;
13
- type SheetMode = TransformAxis;
18
+ type PhysicalSheetMode = TransformAxis;
19
+ type LogicalSheetMode = LogicalAxis;
20
+ type SheetMode = PhysicalSheetMode | LogicalSheetMode;
21
+ type DragFrom = DragFrom$1;
22
+ type DragSurfaceKind = "content";
14
23
  type ScrimPreset = "subtle" | "standard" | "monitoring" | "cinematic";
15
24
  type ScrimPresetConfig = {
16
25
  color: string;
@@ -93,6 +102,8 @@ type EngineOptions = {
93
102
  respectReducedMotion?: boolean;
94
103
  flickVelocity?: number;
95
104
  dragThreshold?: number;
105
+ dragFrom?: DragFrom;
106
+ dragFromContent?: boolean;
96
107
  rubberBand?: boolean;
97
108
  backdropRange?: [number, number];
98
109
  screenRange?: [number, number];
@@ -172,6 +183,7 @@ type EngineFeatureContext = {
172
183
  resyncAfterResize: () => void;
173
184
  snapTo: (id: string) => void;
174
185
  close: (reason?: CloseReason) => Promise<void>;
186
+ attachDragSurface: (surface: HTMLElement, kind: DragSurfaceKind) => (() => void) | void;
175
187
  on: <K extends keyof SheetEventMap>(event: K, fn: (payload: SheetEventMap[K]) => void) => () => void;
176
188
  addTeardown: (fn: (() => void) | null | undefined) => void;
177
189
  };
@@ -261,6 +273,8 @@ declare class BottomSheetCore {
261
273
  private mode;
262
274
  private flickVelocity;
263
275
  private dragThreshold;
276
+ private dragFromMode;
277
+ private dragFromContentDefault;
264
278
  private rubberBandEnabled;
265
279
  private scrim;
266
280
  private aria;
@@ -273,13 +287,18 @@ declare class BottomSheetCore {
273
287
  private disableDragFlag;
274
288
  private closeOnRouteChange;
275
289
  private maxHeight;
290
+ private maxHeightDeps;
276
291
  private snapPointsRaw;
277
292
  private snaps;
278
293
  private activeId;
279
294
  private size;
280
295
  private gesture;
296
+ private contentGesture;
297
+ private detachSheetGesture;
298
+ private detachSliderKeyboard;
281
299
  private rootEl;
282
300
  private destroyed;
301
+ private restClosed;
283
302
  private currentViewTransition;
284
303
  private currentAbort;
285
304
  private sizeWriteSentinel;
@@ -322,6 +341,7 @@ declare class BottomSheetCore {
322
341
  signal?: AbortSignal;
323
342
  }, _skipBeforeSnap?: boolean): Promise<void>;
324
343
  private completeSnap;
344
+ private setRestClosed;
325
345
  private emitOpenSequence;
326
346
  private emitCloseSequence;
327
347
  dragTo(targetSize: number, velocityOrOpts?: number | {
@@ -334,6 +354,11 @@ declare class BottomSheetCore {
334
354
  setPersistent(value: boolean): void;
335
355
  setDisableClose(value: boolean): void;
336
356
  setDisableDrag(value: boolean): void;
357
+ setDragFromContent(value: boolean): void;
358
+ setDragFrom(mode: DragFrom$1): void;
359
+ getDragFrom(): DragFrom$1;
360
+ setMode(mode: SheetMode): void;
361
+ getMode(): PhysicalSheetMode;
337
362
  isTop(): boolean;
338
363
  depth(): number;
339
364
  expand(): Promise<void>;
@@ -373,9 +398,18 @@ declare class BottomSheetCore {
373
398
  private updateAriaSlider;
374
399
  private registerInStack;
375
400
  private applyStackDepth;
401
+ private buildGestureDeps;
402
+ private isContentDragAllowed;
403
+ private decideContentDrag;
404
+ private attachDragSurface;
405
+ private sheetDragSurface;
406
+ private canStartSheetDrag;
407
+ private mountSheetGesture;
376
408
  private attach;
377
409
  private attachFeatures;
410
+ private mountSliderKeyboard;
378
411
  private settleAfterDrag;
412
+ private isDraggingAny;
379
413
  private clearWillChangeIfIdle;
380
414
  private haptic;
381
415
  private applySize;
@@ -385,4 +419,4 @@ declare class BottomSheetCore {
385
419
  private handleClose;
386
420
  }
387
421
 
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 };
422
+ export { type AnchorOptions as A, BottomSheetCore as B, type CloseReason as C, type EngineState as E, type LogicalSheetMode as L, type PhysicalSheetMode as P, type SheetEventMap as S, type TeardownScope as T, type SnapPointDef as a, type SheetMode as b, type EngineOptions as c, type SnapPoint as d, type ScrimStagesOptions 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, type Plugin as p, SCRIM_PRESETS as q, type ScrimOverlayOptions as r, type ScrimPreset as s, type ScrimPresetConfig as t, type ScrimStageDef as u, type ScrimUpdate as v, type SnapId as w, runAnchorTransition as x };
@@ -1,16 +1,25 @@
1
1
  import { T as TransformAxis } from './transform-jVfAikE9.cjs';
2
2
 
3
+ type DragFrom$1 = "handle" | "sheet" | "zones";
4
+
5
+ type LogicalAxis = "start" | "end";
6
+
3
7
  type SnapPoint = number | `${number}%` | "fit" | "content" | "full" | (string & {});
4
8
  type SnapPointDef<Id extends string = string> = {
5
9
  id: Id;
6
10
  size: SnapPoint;
11
+ dragFromContent?: boolean;
7
12
  };
8
13
  type SnapId<T extends readonly SnapPointDef<string>[] | {
9
14
  snapPoints: readonly SnapPointDef<string>[];
10
15
  }> = T extends {
11
16
  snapPoints: readonly SnapPointDef<infer U>[];
12
17
  } ? U : T extends readonly SnapPointDef<infer U>[] ? U : never;
13
- type SheetMode = TransformAxis;
18
+ type PhysicalSheetMode = TransformAxis;
19
+ type LogicalSheetMode = LogicalAxis;
20
+ type SheetMode = PhysicalSheetMode | LogicalSheetMode;
21
+ type DragFrom = DragFrom$1;
22
+ type DragSurfaceKind = "content";
14
23
  type ScrimPreset = "subtle" | "standard" | "monitoring" | "cinematic";
15
24
  type ScrimPresetConfig = {
16
25
  color: string;
@@ -93,6 +102,8 @@ type EngineOptions = {
93
102
  respectReducedMotion?: boolean;
94
103
  flickVelocity?: number;
95
104
  dragThreshold?: number;
105
+ dragFrom?: DragFrom;
106
+ dragFromContent?: boolean;
96
107
  rubberBand?: boolean;
97
108
  backdropRange?: [number, number];
98
109
  screenRange?: [number, number];
@@ -172,6 +183,7 @@ type EngineFeatureContext = {
172
183
  resyncAfterResize: () => void;
173
184
  snapTo: (id: string) => void;
174
185
  close: (reason?: CloseReason) => Promise<void>;
186
+ attachDragSurface: (surface: HTMLElement, kind: DragSurfaceKind) => (() => void) | void;
175
187
  on: <K extends keyof SheetEventMap>(event: K, fn: (payload: SheetEventMap[K]) => void) => () => void;
176
188
  addTeardown: (fn: (() => void) | null | undefined) => void;
177
189
  };
@@ -261,6 +273,8 @@ declare class BottomSheetCore {
261
273
  private mode;
262
274
  private flickVelocity;
263
275
  private dragThreshold;
276
+ private dragFromMode;
277
+ private dragFromContentDefault;
264
278
  private rubberBandEnabled;
265
279
  private scrim;
266
280
  private aria;
@@ -273,13 +287,18 @@ declare class BottomSheetCore {
273
287
  private disableDragFlag;
274
288
  private closeOnRouteChange;
275
289
  private maxHeight;
290
+ private maxHeightDeps;
276
291
  private snapPointsRaw;
277
292
  private snaps;
278
293
  private activeId;
279
294
  private size;
280
295
  private gesture;
296
+ private contentGesture;
297
+ private detachSheetGesture;
298
+ private detachSliderKeyboard;
281
299
  private rootEl;
282
300
  private destroyed;
301
+ private restClosed;
283
302
  private currentViewTransition;
284
303
  private currentAbort;
285
304
  private sizeWriteSentinel;
@@ -322,6 +341,7 @@ declare class BottomSheetCore {
322
341
  signal?: AbortSignal;
323
342
  }, _skipBeforeSnap?: boolean): Promise<void>;
324
343
  private completeSnap;
344
+ private setRestClosed;
325
345
  private emitOpenSequence;
326
346
  private emitCloseSequence;
327
347
  dragTo(targetSize: number, velocityOrOpts?: number | {
@@ -334,6 +354,11 @@ declare class BottomSheetCore {
334
354
  setPersistent(value: boolean): void;
335
355
  setDisableClose(value: boolean): void;
336
356
  setDisableDrag(value: boolean): void;
357
+ setDragFromContent(value: boolean): void;
358
+ setDragFrom(mode: DragFrom$1): void;
359
+ getDragFrom(): DragFrom$1;
360
+ setMode(mode: SheetMode): void;
361
+ getMode(): PhysicalSheetMode;
337
362
  isTop(): boolean;
338
363
  depth(): number;
339
364
  expand(): Promise<void>;
@@ -373,9 +398,18 @@ declare class BottomSheetCore {
373
398
  private updateAriaSlider;
374
399
  private registerInStack;
375
400
  private applyStackDepth;
401
+ private buildGestureDeps;
402
+ private isContentDragAllowed;
403
+ private decideContentDrag;
404
+ private attachDragSurface;
405
+ private sheetDragSurface;
406
+ private canStartSheetDrag;
407
+ private mountSheetGesture;
376
408
  private attach;
377
409
  private attachFeatures;
410
+ private mountSliderKeyboard;
378
411
  private settleAfterDrag;
412
+ private isDraggingAny;
379
413
  private clearWillChangeIfIdle;
380
414
  private haptic;
381
415
  private applySize;
@@ -385,4 +419,4 @@ declare class BottomSheetCore {
385
419
  private handleClose;
386
420
  }
387
421
 
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 };
422
+ export { type AnchorOptions as A, BottomSheetCore as B, type CloseReason as C, type EngineState as E, type LogicalSheetMode as L, type PhysicalSheetMode as P, type SheetEventMap as S, type TeardownScope as T, type SnapPointDef as a, type SheetMode as b, type EngineOptions as c, type SnapPoint as d, type ScrimStagesOptions 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, type Plugin as p, SCRIM_PRESETS as q, type ScrimOverlayOptions as r, type ScrimPreset as s, type ScrimPresetConfig as t, type ScrimStageDef as u, type ScrimUpdate as v, type SnapId as w, runAnchorTransition as x };
@@ -1,4 +1,4 @@
1
- import { B as BottomSheetCore, a as EngineOptions } from './BottomSheetCore-CsIjyq7C.cjs';
1
+ import { B as BottomSheetCore, c as EngineOptions } from './BottomSheetCore-VPJZcKcg.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, c as EngineOptions } from './BottomSheetCore-Cgn8b_6A.js';
2
2
 
3
3
  declare class BottomSheetEngine extends BottomSheetCore {
4
4
  constructor(opts: EngineOptions);