@surdeddd/bottom-sheet 0.14.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 (56) hide show
  1. package/README.md +13 -0
  2. package/dist/{BottomSheetCore-DJYwWOqt.d.ts → BottomSheetCore-Cgn8b_6A.d.ts} +11 -2
  3. package/dist/{BottomSheetCore-Cp7dWy91.d.cts → BottomSheetCore-VPJZcKcg.d.cts} +11 -2
  4. package/dist/{BottomSheetEngine-Lm7HIVHv.d.cts → BottomSheetEngine-B8C2CwF9.d.cts} +1 -1
  5. package/dist/{BottomSheetEngine-O5PbeKfe.d.ts → BottomSheetEngine-DwYR_ygJ.d.ts} +1 -1
  6. package/dist/core.cjs +100 -9
  7. package/dist/core.d.cts +2 -2
  8. package/dist/core.d.ts +2 -2
  9. package/dist/core.js +100 -9
  10. package/dist/debug.d.cts +1 -1
  11. package/dist/debug.d.ts +1 -1
  12. package/dist/element.cjs +107 -9
  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 +107 -9
  17. package/dist/features.d.cts +4 -4
  18. package/dist/features.d.ts +4 -4
  19. package/dist/{index-Bb5TRmyg.d.cts → index-CnfbOKx0.d.cts} +1 -1
  20. package/dist/{index-Cl9ebCP2.d.ts → index-DcMkhXAy.d.ts} +1 -1
  21. package/dist/index.cjs +100 -9
  22. package/dist/index.d.cts +8 -8
  23. package/dist/index.d.ts +8 -8
  24. package/dist/index.js +100 -9
  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 +98 -9
  32. package/dist/qwik-lib/index.qwik.mjs +98 -9
  33. package/dist/qwik.cjs +100 -9
  34. package/dist/qwik.d.cts +2 -2
  35. package/dist/qwik.d.ts +2 -2
  36. package/dist/qwik.js +100 -9
  37. package/dist/react.cjs +100 -9
  38. package/dist/react.d.cts +3 -3
  39. package/dist/react.d.ts +3 -3
  40. package/dist/react.js +100 -9
  41. package/dist/solid.cjs +100 -9
  42. package/dist/solid.d.cts +10 -1
  43. package/dist/solid.d.ts +10 -1
  44. package/dist/solid.js +100 -9
  45. package/dist/solid.source.jsx +100 -9
  46. package/dist/svelte-core.cjs +100 -9
  47. package/dist/svelte-core.js +100 -9
  48. package/dist/svelte.cjs +100 -9
  49. package/dist/svelte.js +100 -9
  50. package/dist/vue.cjs +100 -9
  51. package/dist/vue.js +100 -9
  52. package/dist/webgl.cjs +104 -14
  53. package/dist/webgl.d.cts +1 -1
  54. package/dist/webgl.d.ts +1 -1
  55. package/dist/webgl.js +104 -14
  56. package/package.json +39 -39
package/dist/webgl.js CHANGED
@@ -271,6 +271,59 @@ var wrapLines = (ctx, text, maxWidth) => {
271
271
  lines.push(line);
272
272
  return lines;
273
273
  };
274
+ var isPaintedColor = (value) => !!value && value !== "transparent" && !/rgba\(\s*0,\s*0,\s*0,\s*0\s*\)/.test(value);
275
+ var roundedPath = (ctx, x, y, w, h, r) => {
276
+ const rad = Math.min(r, w / 2, h / 2);
277
+ ctx.beginPath();
278
+ if (rad <= 0) {
279
+ ctx.rect(x, y, w, h);
280
+ return;
281
+ }
282
+ ctx.moveTo(x + rad, y);
283
+ ctx.arcTo(x + w, y, x + w, y + h, rad);
284
+ ctx.arcTo(x + w, y + h, x, y + h, rad);
285
+ ctx.arcTo(x, y + h, x, y, rad);
286
+ ctx.arcTo(x, y, x + w, y, rad);
287
+ ctx.closePath();
288
+ };
289
+ var drawBox = (ctx, cs, rect, rootRect) => {
290
+ const bg = cs.backgroundColor;
291
+ const borderWidth = parseFloat(cs.borderTopWidth) || 0;
292
+ const hasBorder = borderWidth > 0 && isPaintedColor(cs.borderTopColor);
293
+ if (!isPaintedColor(bg) && !hasBorder) return false;
294
+ const x = rect.left - rootRect.left;
295
+ const y = rect.top - rootRect.top;
296
+ const radius = parseFloat(cs.borderTopLeftRadius) || 0;
297
+ if (isPaintedColor(bg)) {
298
+ roundedPath(ctx, x, y, rect.width, rect.height, radius);
299
+ ctx.fillStyle = bg;
300
+ ctx.fill();
301
+ }
302
+ if (hasBorder) {
303
+ roundedPath(ctx, x, y, rect.width, rect.height, radius);
304
+ ctx.strokeStyle = cs.borderTopColor;
305
+ ctx.lineWidth = borderWidth;
306
+ ctx.stroke();
307
+ }
308
+ return true;
309
+ };
310
+ var drawImage = (ctx, img, rootRect) => {
311
+ if (!img.complete || img.naturalWidth === 0) return false;
312
+ const rect = img.getBoundingClientRect();
313
+ if (rect.width < 1 || rect.height < 1) return false;
314
+ try {
315
+ ctx.drawImage(
316
+ img,
317
+ rect.left - rootRect.left,
318
+ rect.top - rootRect.top,
319
+ rect.width,
320
+ rect.height
321
+ );
322
+ return true;
323
+ } catch {
324
+ return false;
325
+ }
326
+ };
274
327
  var captureContent = (gl, root, dpr) => {
275
328
  const rootRect = root.getBoundingClientRect();
276
329
  const w = Math.max(1, Math.round(rootRect.width * dpr));
@@ -287,12 +340,24 @@ var captureContent = (gl, root, dpr) => {
287
340
  let painted = 0;
288
341
  while (walker.nextNode()) {
289
342
  const el = walker.currentNode;
343
+ if (el.tagName === "IMG") {
344
+ if (drawImage(ctx, el, rootRect)) {
345
+ painted++;
346
+ hiddenNodes.push(el);
347
+ }
348
+ continue;
349
+ }
290
350
  if (!isRenderable(el)) continue;
291
- const text = directText(el);
292
- if (!text) continue;
293
351
  const rect = el.getBoundingClientRect();
294
352
  if (rect.width < 1 || rect.height < 1) continue;
295
353
  const cs = getComputedStyle(el);
354
+ const boxed = drawBox(ctx, cs, rect, rootRect);
355
+ if (boxed) {
356
+ painted++;
357
+ hiddenNodes.push(el);
358
+ }
359
+ const text = directText(el);
360
+ if (!text) continue;
296
361
  ctx.font = `${cs.fontStyle} ${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`;
297
362
  ctx.fillStyle = cs.color;
298
363
  ctx.textBaseline = "top";
@@ -319,7 +384,7 @@ var captureContent = (gl, root, dpr) => {
319
384
  });
320
385
  if (lines.length) {
321
386
  painted++;
322
- hiddenNodes.push(el);
387
+ if (!boxed) hiddenNodes.push(el);
323
388
  }
324
389
  }
325
390
  if (!painted) return null;
@@ -327,14 +392,19 @@ var captureContent = (gl, root, dpr) => {
327
392
  if (!texture) return null;
328
393
  gl.bindTexture(gl.TEXTURE_2D, texture);
329
394
  gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
330
- gl.texImage2D(
331
- gl.TEXTURE_2D,
332
- 0,
333
- gl.RGBA,
334
- gl.RGBA,
335
- gl.UNSIGNED_BYTE,
336
- surface
337
- );
395
+ try {
396
+ gl.texImage2D(
397
+ gl.TEXTURE_2D,
398
+ 0,
399
+ gl.RGBA,
400
+ gl.RGBA,
401
+ gl.UNSIGNED_BYTE,
402
+ surface
403
+ );
404
+ } catch {
405
+ gl.deleteTexture(texture);
406
+ return null;
407
+ }
338
408
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
339
409
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
340
410
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
@@ -342,10 +412,30 @@ var captureContent = (gl, root, dpr) => {
342
412
  return { texture, width: w, height: h, hiddenNodes };
343
413
  };
344
414
  var hideCapturedText = (nodes) => {
345
- const restore = nodes.map((el) => ({ el, prev: el.style.color }));
346
- for (const { el } of restore) el.style.color = "transparent";
415
+ const restore = nodes.map((el) => ({
416
+ el,
417
+ color: el.style.color,
418
+ background: el.style.background,
419
+ borderColor: el.style.borderColor,
420
+ opacity: el.style.opacity,
421
+ isImage: el.tagName === "IMG"
422
+ }));
423
+ for (const entry of restore) {
424
+ if (entry.isImage) {
425
+ entry.el.style.opacity = "0";
426
+ continue;
427
+ }
428
+ entry.el.style.color = "transparent";
429
+ entry.el.style.background = "transparent";
430
+ entry.el.style.borderColor = "transparent";
431
+ }
347
432
  return () => {
348
- for (const { el, prev } of restore) el.style.color = prev;
433
+ for (const entry of restore) {
434
+ entry.el.style.color = entry.color;
435
+ entry.el.style.background = entry.background;
436
+ entry.el.style.borderColor = entry.borderColor;
437
+ entry.el.style.opacity = entry.opacity;
438
+ }
349
439
  };
350
440
  };
351
441
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surdeddd/bottom-sheet",
3
- "version": "0.14.0",
3
+ "version": "0.20.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",
@@ -216,37 +216,37 @@
216
216
  {
217
217
  "name": "core (engine + types)",
218
218
  "path": "dist/index.js",
219
- "limit": "21.5 KB",
219
+ "limit": "21.74 KB",
220
220
  "gzip": true
221
221
  },
222
222
  {
223
223
  "name": "react adapter",
224
224
  "path": "dist/react.js",
225
- "limit": "29 KB",
225
+ "limit": "29.16 KB",
226
226
  "gzip": true
227
227
  },
228
228
  {
229
229
  "name": "vue adapter",
230
230
  "path": "dist/vue.js",
231
- "limit": "24.5 KB",
231
+ "limit": "24.98 KB",
232
232
  "gzip": true
233
233
  },
234
234
  {
235
235
  "name": "svelte adapter",
236
236
  "path": "dist/svelte.js",
237
- "limit": "24.5 KB",
237
+ "limit": "24.59 KB",
238
238
  "gzip": true
239
239
  },
240
240
  {
241
241
  "name": "solid adapter",
242
242
  "path": "dist/solid.js",
243
- "limit": "23 KB",
243
+ "limit": "23.23 KB",
244
244
  "gzip": true
245
245
  },
246
246
  {
247
247
  "name": "qwik adapter",
248
248
  "path": "dist/qwik.js",
249
- "limit": "23 KB",
249
+ "limit": "23.25 KB",
250
250
  "gzip": true
251
251
  },
252
252
  {
@@ -261,13 +261,13 @@
261
261
  {
262
262
  "name": "web component (self-contained)",
263
263
  "path": "dist/element.js",
264
- "limit": "28 KB",
264
+ "limit": "28.35 KB",
265
265
  "gzip": true
266
266
  },
267
267
  {
268
268
  "name": "web component (IIFE / CDN)",
269
269
  "path": "dist/element.iife.global.js",
270
- "limit": "27.5 KB",
270
+ "limit": "27.9 KB",
271
271
  "gzip": true
272
272
  },
273
273
  {
@@ -285,7 +285,7 @@
285
285
  {
286
286
  "name": "slim core (subpath, no optional features)",
287
287
  "path": "dist/core.js",
288
- "limit": "19.5 KB",
288
+ "limit": "19.85 KB",
289
289
  "gzip": true
290
290
  },
291
291
  {
@@ -297,7 +297,7 @@
297
297
  {
298
298
  "name": "webgl renderer (subpath)",
299
299
  "path": "dist/webgl.js",
300
- "limit": "4.5 KB",
300
+ "limit": "5 KB",
301
301
  "gzip": true
302
302
  }
303
303
  ],
@@ -380,45 +380,45 @@
380
380
  "seroval-plugins": "^1.5.6"
381
381
  },
382
382
  "devDependencies": {
383
- "@arethetypeswrong/cli": "^0.18.3",
384
- "@axe-core/playwright": "^4.11.2",
385
- "@builder.io/qwik": "^1.19.2",
383
+ "@arethetypeswrong/cli": "^0.18.5",
384
+ "@axe-core/playwright": "^4.12.1",
385
+ "@builder.io/qwik": "^1.20.0",
386
386
  "@lhci/cli": "^0.15.1",
387
- "@playwright/test": "^1.59.1",
387
+ "@playwright/test": "^1.62.1",
388
388
  "@size-limit/preset-small-lib": "^12.1.0",
389
- "@sveltejs/vite-plugin-svelte": "^4.0.4",
390
- "@types/node": "^20.11.0",
391
- "@types/react": "^18.2.0",
392
- "@types/react-dom": "^18.2.0",
389
+ "@sveltejs/vite-plugin-svelte": "^6.2.4",
390
+ "@types/node": "^20.19.43",
391
+ "@types/react": "^18.3.31",
392
+ "@types/react-dom": "^18.3.7",
393
393
  "@types/three": "^0.185.1",
394
- "@vitejs/plugin-react": "^4.2.0",
395
- "@vitejs/plugin-vue": "^5.0.0",
396
- "@vitest/coverage-v8": "^1.2.0",
394
+ "@vitejs/plugin-react": "^5.2.0",
395
+ "@vitejs/plugin-vue": "^6.0.8",
396
+ "@vitest/coverage-v8": "^4.1.10",
397
397
  "esbuild-plugin-solid": "^0.6.0",
398
- "esbuild-svelte": "^0.9.4",
399
- "fast-check": "^4.7.0",
400
- "happy-dom": "^13.3.0",
398
+ "esbuild-svelte": "0.9.4",
399
+ "fast-check": "^4.9.0",
400
+ "happy-dom": "^20.11.1",
401
401
  "husky": "^9.1.7",
402
- "lit": "^3.3.2",
403
- "motion": "^12.42.2",
402
+ "lit": "^3.3.3",
403
+ "motion": "^12.43.0",
404
404
  "patch-package": "^8.0.1",
405
- "publint": "^0.3.21",
406
- "react": "^18.2.0",
407
- "react-dom": "^18.2.0",
408
- "rolldown": "^1.0.0-rc.18",
405
+ "publint": "^0.3.22",
406
+ "react": "^18.3.1",
407
+ "react-dom": "^18.3.1",
408
+ "rolldown": "^1.2.1",
409
409
  "size-limit": "^12.1.0",
410
- "solid-js": "^1.9.12",
411
- "svelte": "^5.55.5",
410
+ "solid-js": "^1.9.14",
411
+ "svelte": "^5.56.8",
412
412
  "three": "^0.185.1",
413
- "tsup": "^8.0.1",
413
+ "tsup": "^8.5.1",
414
414
  "typedoc": "^0.28.20",
415
415
  "typescript": "^5.9.3",
416
416
  "unplugin-vue": "^7.2.0",
417
- "vite": "^5.0.10",
418
- "vite-plugin-solid": "^2.11.12",
419
- "vitest": "^1.6.1",
420
- "vue": "^3.4.0",
421
- "vue-tsc": "^1.8.27"
417
+ "vite": "^7.3.6",
418
+ "vite-plugin-solid": "^2.11.14",
419
+ "vitest": "^4.1.10",
420
+ "vue": "^3.5.40",
421
+ "vue-tsc": "^3.3.9"
422
422
  },
423
423
  "engines": {
424
424
  "node": ">=20"