@surdeddd/bottom-sheet 0.20.0 → 0.20.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.
package/dist/vue.js CHANGED
@@ -838,23 +838,25 @@ var ScrimController = class {
838
838
  if (!progressChanged && this.backdropOpacitySentinel.value !== -1 && this.screenOpacitySentinel.value !== -1) {
839
839
  return;
840
840
  }
841
- if (this.backdrop && this.isTopSheet()) {
841
+ if (this.backdrop) {
842
842
  const [s, e] = this.backdropRange;
843
843
  const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
844
844
  const backdropOpacity = Math.min(
845
845
  Math.max((progress - s) / range, 0),
846
846
  1
847
847
  );
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;
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
+ }
858
860
  }
859
861
  }
860
862
  if (this.screenComponent && this.scrimMode !== "off") {
package/dist/webgl.cjs CHANGED
@@ -1,12 +1,22 @@
1
1
  'use strict';
2
2
 
3
3
  // src/webgl/gl-context.ts
4
+ var supportsHighpFragment = (gl) => {
5
+ try {
6
+ const fmt = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
7
+ return !!fmt && fmt.precision > 0;
8
+ } catch {
9
+ return false;
10
+ }
11
+ };
4
12
  var hasWebGL = () => {
5
13
  if (typeof document === "undefined") return false;
6
- if (typeof WebGLRenderingContext === "undefined") return false;
14
+ if (typeof WebGLRenderingContext === "undefined" && typeof WebGL2RenderingContext === "undefined") {
15
+ return false;
16
+ }
7
17
  try {
8
18
  const probe = document.createElement("canvas");
9
- const gl = probe.getContext("webgl", { alpha: true }) ?? probe.getContext("experimental-webgl");
19
+ const gl = probe.getContext("webgl2", { alpha: true }) ?? probe.getContext("webgl", { alpha: true }) ?? probe.getContext("experimental-webgl");
10
20
  if (!gl) return false;
11
21
  const lose = gl.getExtension(
12
22
  "WEBGL_lose_context"
@@ -25,18 +35,26 @@ var createGLHandle = (onLost) => {
25
35
  canvas.style.left = "0";
26
36
  canvas.style.top = "0";
27
37
  canvas.style.pointerEvents = "none";
38
+ const attrs = {
39
+ alpha: true,
40
+ premultipliedAlpha: true,
41
+ antialias: true,
42
+ depth: false,
43
+ stencil: false,
44
+ preserveDrawingBuffer: false
45
+ };
28
46
  let gl = null;
29
- try {
30
- gl = canvas.getContext("webgl", {
31
- alpha: true,
32
- premultipliedAlpha: true,
33
- antialias: true,
34
- depth: false,
35
- stencil: false,
36
- preserveDrawingBuffer: false
37
- });
38
- } catch {
39
- gl = null;
47
+ let isWebGL2 = false;
48
+ for (const id of ["webgl2", "webgl", "experimental-webgl"]) {
49
+ try {
50
+ const ctx = canvas.getContext(id, attrs);
51
+ if (ctx) {
52
+ gl = ctx;
53
+ isWebGL2 = id === "webgl2";
54
+ break;
55
+ }
56
+ } catch {
57
+ }
40
58
  }
41
59
  if (!gl) return null;
42
60
  const handleLost = (e) => {
@@ -47,6 +65,8 @@ var createGLHandle = (onLost) => {
47
65
  return {
48
66
  canvas,
49
67
  gl,
68
+ isWebGL2,
69
+ highp: isWebGL2 || supportsHighpFragment(gl),
50
70
  destroy: () => {
51
71
  canvas.removeEventListener("webglcontextlost", handleLost);
52
72
  const lose = gl?.getExtension("WEBGL_lose_context");
@@ -77,8 +97,8 @@ void main() {
77
97
  gl_Position = vec4(a_pos, 0.0, 1.0);
78
98
  }
79
99
  `;
80
- var FRAGMENT_SRC = `
81
- precision mediump float;
100
+ var FRAGMENT_SRC = (precision) => `
101
+ precision ${precision} float;
82
102
 
83
103
  uniform vec2 u_resolution;
84
104
  uniform vec4 u_rect;
@@ -155,9 +175,16 @@ var compile = (gl, type, src) => {
155
175
  }
156
176
  return shader;
157
177
  };
158
- var createSurfaceProgram = (gl) => {
178
+ var createSurfaceProgram = (gl, highp = true) => {
159
179
  const vs = compile(gl, gl.VERTEX_SHADER, VERTEX_SRC);
160
- const fs = compile(gl, gl.FRAGMENT_SHADER, FRAGMENT_SRC);
180
+ let fs = compile(
181
+ gl,
182
+ gl.FRAGMENT_SHADER,
183
+ FRAGMENT_SRC(highp ? "highp" : "mediump")
184
+ );
185
+ if (!fs && highp) {
186
+ fs = compile(gl, gl.FRAGMENT_SHADER, FRAGMENT_SRC("mediump"));
187
+ }
161
188
  if (!vs || !fs) return null;
162
189
  const program = gl.createProgram();
163
190
  if (!program) return null;
@@ -538,7 +565,7 @@ var webglRenderer = (options = {}) => ({
538
565
  bail("no-webgl");
539
566
  return;
540
567
  }
541
- program = createSurfaceProgram(handle.gl);
568
+ program = createSurfaceProgram(handle.gl, handle.highp);
542
569
  if (!program) {
543
570
  handle.destroy();
544
571
  handle = null;
@@ -598,10 +625,13 @@ var webglRenderer = (options = {}) => ({
598
625
  paint();
599
626
  const held = ctx.isDragging();
600
627
  bend *= held ? BEND_DECAY_HELD : BEND_DECAY_FREE;
601
- const settled = !held && !ctx.isAnimating() && Math.abs(bend) < BEND_REST;
602
- if (settled) {
628
+ const flat = Math.abs(bend) < BEND_REST;
629
+ if (!held && flat && capture) {
603
630
  bend = 0;
604
631
  releaseCapture();
632
+ }
633
+ if (!held && flat && !ctx.isAnimating()) {
634
+ bend = 0;
605
635
  paint();
606
636
  running = false;
607
637
  frameId = null;
package/dist/webgl.js CHANGED
@@ -1,10 +1,20 @@
1
1
  // src/webgl/gl-context.ts
2
+ var supportsHighpFragment = (gl) => {
3
+ try {
4
+ const fmt = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
5
+ return !!fmt && fmt.precision > 0;
6
+ } catch {
7
+ return false;
8
+ }
9
+ };
2
10
  var hasWebGL = () => {
3
11
  if (typeof document === "undefined") return false;
4
- if (typeof WebGLRenderingContext === "undefined") return false;
12
+ if (typeof WebGLRenderingContext === "undefined" && typeof WebGL2RenderingContext === "undefined") {
13
+ return false;
14
+ }
5
15
  try {
6
16
  const probe = document.createElement("canvas");
7
- const gl = probe.getContext("webgl", { alpha: true }) ?? probe.getContext("experimental-webgl");
17
+ const gl = probe.getContext("webgl2", { alpha: true }) ?? probe.getContext("webgl", { alpha: true }) ?? probe.getContext("experimental-webgl");
8
18
  if (!gl) return false;
9
19
  const lose = gl.getExtension(
10
20
  "WEBGL_lose_context"
@@ -23,18 +33,26 @@ var createGLHandle = (onLost) => {
23
33
  canvas.style.left = "0";
24
34
  canvas.style.top = "0";
25
35
  canvas.style.pointerEvents = "none";
36
+ const attrs = {
37
+ alpha: true,
38
+ premultipliedAlpha: true,
39
+ antialias: true,
40
+ depth: false,
41
+ stencil: false,
42
+ preserveDrawingBuffer: false
43
+ };
26
44
  let gl = null;
27
- try {
28
- gl = canvas.getContext("webgl", {
29
- alpha: true,
30
- premultipliedAlpha: true,
31
- antialias: true,
32
- depth: false,
33
- stencil: false,
34
- preserveDrawingBuffer: false
35
- });
36
- } catch {
37
- gl = null;
45
+ let isWebGL2 = false;
46
+ for (const id of ["webgl2", "webgl", "experimental-webgl"]) {
47
+ try {
48
+ const ctx = canvas.getContext(id, attrs);
49
+ if (ctx) {
50
+ gl = ctx;
51
+ isWebGL2 = id === "webgl2";
52
+ break;
53
+ }
54
+ } catch {
55
+ }
38
56
  }
39
57
  if (!gl) return null;
40
58
  const handleLost = (e) => {
@@ -45,6 +63,8 @@ var createGLHandle = (onLost) => {
45
63
  return {
46
64
  canvas,
47
65
  gl,
66
+ isWebGL2,
67
+ highp: isWebGL2 || supportsHighpFragment(gl),
48
68
  destroy: () => {
49
69
  canvas.removeEventListener("webglcontextlost", handleLost);
50
70
  const lose = gl?.getExtension("WEBGL_lose_context");
@@ -75,8 +95,8 @@ void main() {
75
95
  gl_Position = vec4(a_pos, 0.0, 1.0);
76
96
  }
77
97
  `;
78
- var FRAGMENT_SRC = `
79
- precision mediump float;
98
+ var FRAGMENT_SRC = (precision) => `
99
+ precision ${precision} float;
80
100
 
81
101
  uniform vec2 u_resolution;
82
102
  uniform vec4 u_rect;
@@ -153,9 +173,16 @@ var compile = (gl, type, src) => {
153
173
  }
154
174
  return shader;
155
175
  };
156
- var createSurfaceProgram = (gl) => {
176
+ var createSurfaceProgram = (gl, highp = true) => {
157
177
  const vs = compile(gl, gl.VERTEX_SHADER, VERTEX_SRC);
158
- const fs = compile(gl, gl.FRAGMENT_SHADER, FRAGMENT_SRC);
178
+ let fs = compile(
179
+ gl,
180
+ gl.FRAGMENT_SHADER,
181
+ FRAGMENT_SRC(highp ? "highp" : "mediump")
182
+ );
183
+ if (!fs && highp) {
184
+ fs = compile(gl, gl.FRAGMENT_SHADER, FRAGMENT_SRC("mediump"));
185
+ }
159
186
  if (!vs || !fs) return null;
160
187
  const program = gl.createProgram();
161
188
  if (!program) return null;
@@ -536,7 +563,7 @@ var webglRenderer = (options = {}) => ({
536
563
  bail("no-webgl");
537
564
  return;
538
565
  }
539
- program = createSurfaceProgram(handle.gl);
566
+ program = createSurfaceProgram(handle.gl, handle.highp);
540
567
  if (!program) {
541
568
  handle.destroy();
542
569
  handle = null;
@@ -596,10 +623,13 @@ var webglRenderer = (options = {}) => ({
596
623
  paint();
597
624
  const held = ctx.isDragging();
598
625
  bend *= held ? BEND_DECAY_HELD : BEND_DECAY_FREE;
599
- const settled = !held && !ctx.isAnimating() && Math.abs(bend) < BEND_REST;
600
- if (settled) {
626
+ const flat = Math.abs(bend) < BEND_REST;
627
+ if (!held && flat && capture) {
601
628
  bend = 0;
602
629
  releaseCapture();
630
+ }
631
+ if (!held && flat && !ctx.isAnimating()) {
632
+ bend = 0;
603
633
  paint();
604
634
  running = false;
605
635
  frameId = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surdeddd/bottom-sheet",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
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",
@@ -200,14 +200,38 @@
200
200
  }
201
201
  },
202
202
  "./package.json": "./package.json",
203
- "./styles": "./dist/styles.css",
204
- "./styles.css": "./dist/styles.css",
205
- "./themes/ios": "./dist/themes/ios.css",
206
- "./themes/ios.css": "./dist/themes/ios.css",
207
- "./themes/material": "./dist/themes/material.css",
208
- "./themes/material.css": "./dist/themes/material.css",
209
- "./themes/vercel": "./dist/themes/vercel.css",
210
- "./themes/vercel.css": "./dist/themes/vercel.css"
203
+ "./styles": {
204
+ "types": "./dist/styles.d.ts",
205
+ "default": "./dist/styles.css"
206
+ },
207
+ "./styles.css": {
208
+ "types": "./dist/styles.d.ts",
209
+ "default": "./dist/styles.css"
210
+ },
211
+ "./themes/ios": {
212
+ "types": "./dist/themes/ios.d.ts",
213
+ "default": "./dist/themes/ios.css"
214
+ },
215
+ "./themes/ios.css": {
216
+ "types": "./dist/themes/ios.d.ts",
217
+ "default": "./dist/themes/ios.css"
218
+ },
219
+ "./themes/material": {
220
+ "types": "./dist/themes/material.d.ts",
221
+ "default": "./dist/themes/material.css"
222
+ },
223
+ "./themes/material.css": {
224
+ "types": "./dist/themes/material.d.ts",
225
+ "default": "./dist/themes/material.css"
226
+ },
227
+ "./themes/vercel": {
228
+ "types": "./dist/themes/vercel.d.ts",
229
+ "default": "./dist/themes/vercel.css"
230
+ },
231
+ "./themes/vercel.css": {
232
+ "types": "./dist/themes/vercel.d.ts",
233
+ "default": "./dist/themes/vercel.css"
234
+ }
211
235
  },
212
236
  "workspaces": [
213
237
  "examples/*"
@@ -385,7 +409,7 @@
385
409
  "@builder.io/qwik": "^1.20.0",
386
410
  "@lhci/cli": "^0.15.1",
387
411
  "@playwright/test": "^1.62.1",
388
- "@size-limit/preset-small-lib": "^12.1.0",
412
+ "@size-limit/preset-small-lib": "^13.0.3",
389
413
  "@sveltejs/vite-plugin-svelte": "^6.2.4",
390
414
  "@types/node": "^20.19.43",
391
415
  "@types/react": "^18.3.31",
@@ -400,13 +424,13 @@
400
424
  "happy-dom": "^20.11.1",
401
425
  "husky": "^9.1.7",
402
426
  "lit": "^3.3.3",
403
- "motion": "^12.43.0",
427
+ "motion": "^13.1.0",
404
428
  "patch-package": "^8.0.1",
405
429
  "publint": "^0.3.22",
406
430
  "react": "^18.3.1",
407
431
  "react-dom": "^18.3.1",
408
432
  "rolldown": "^1.2.1",
409
- "size-limit": "^12.1.0",
433
+ "size-limit": "^13.0.3",
410
434
  "solid-js": "^1.9.14",
411
435
  "svelte": "^5.56.8",
412
436
  "three": "^0.185.1",