@surdeddd/bottom-sheet 0.12.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 +85 -1
  2. package/dist/{BottomSheetEngine-D6oiEfZ4.d.cts → BottomSheetCore-Cp7dWy91.d.cts} +85 -5
  3. package/dist/{BottomSheetEngine-Dhy0X_e9.d.ts → BottomSheetCore-DJYwWOqt.d.ts} +85 -5
  4. package/dist/BottomSheetEngine-Lm7HIVHv.d.cts +7 -0
  5. package/dist/BottomSheetEngine-O5PbeKfe.d.ts +7 -0
  6. package/dist/core.cjs +3680 -0
  7. package/dist/core.d.cts +3 -0
  8. package/dist/core.d.ts +3 -0
  9. package/dist/core.js +3678 -0
  10. package/dist/debug.cjs +109 -0
  11. package/dist/debug.d.cts +22 -0
  12. package/dist/debug.d.ts +22 -0
  13. package/dist/debug.js +107 -0
  14. package/dist/element.cjs +1314 -829
  15. package/dist/element.d.cts +2 -1
  16. package/dist/element.d.ts +2 -1
  17. package/dist/element.iife.global.js +2 -2
  18. package/dist/element.js +1314 -829
  19. package/dist/features.cjs +489 -0
  20. package/dist/features.d.cts +13 -0
  21. package/dist/features.d.ts +13 -0
  22. package/dist/features.js +482 -0
  23. package/dist/index-Bb5TRmyg.d.cts +9 -0
  24. package/dist/index-Cl9ebCP2.d.ts +9 -0
  25. package/dist/index.cjs +979 -1293
  26. package/dist/index.d.cts +43 -55
  27. package/dist/index.d.ts +43 -55
  28. package/dist/index.js +973 -1280
  29. package/dist/integrations/formik.d.cts +1 -1
  30. package/dist/integrations/formik.d.ts +1 -1
  31. package/dist/integrations/react-hook-form.d.cts +1 -1
  32. package/dist/integrations/react-hook-form.d.ts +1 -1
  33. package/dist/overlay.cjs +11 -10
  34. package/dist/overlay.js +11 -10
  35. package/dist/preact.d.cts +2 -1
  36. package/dist/preact.d.ts +2 -1
  37. package/dist/qwik-lib/index.qwik.cjs +4418 -0
  38. package/dist/qwik-lib/index.qwik.mjs +4418 -0
  39. package/dist/qwik.cjs +1089 -657
  40. package/dist/qwik.d.cts +4 -2
  41. package/dist/qwik.d.ts +4 -2
  42. package/dist/qwik.js +1089 -657
  43. package/dist/react.cjs +1100 -665
  44. package/dist/react.d.cts +3 -3
  45. package/dist/react.d.ts +3 -3
  46. package/dist/react.js +1100 -665
  47. package/dist/solid.cjs +1095 -657
  48. package/dist/solid.d.cts +90 -4
  49. package/dist/solid.d.ts +90 -4
  50. package/dist/solid.js +1095 -657
  51. package/dist/solid.source.jsx +1103 -657
  52. package/dist/styles.css +24 -4
  53. package/dist/svelte-core.cjs +981 -557
  54. package/dist/svelte-core.js +981 -557
  55. package/dist/svelte-src/BottomSheet.svelte +14 -0
  56. package/dist/svelte.cjs +1091 -657
  57. package/dist/svelte.d.cts +2 -0
  58. package/dist/svelte.d.ts +2 -0
  59. package/dist/svelte.js +1091 -657
  60. package/dist/vue.cjs +1105 -657
  61. package/dist/vue.js +1105 -657
  62. package/dist/webgl.cjs +583 -0
  63. package/dist/webgl.d.cts +17 -0
  64. package/dist/webgl.d.ts +17 -0
  65. package/dist/webgl.js +581 -0
  66. package/package.json +88 -12
package/dist/debug.cjs ADDED
@@ -0,0 +1,109 @@
1
+ 'use strict';
2
+
3
+ // src/debug/index.ts
4
+ var PANEL_GAP = 8;
5
+ var PANEL_WIDTH = 232;
6
+ var panelCount = 0;
7
+ var anchorStyles = (position, offset) => {
8
+ const main = `${PANEL_GAP + offset}px`;
9
+ const cross = `${PANEL_GAP}px`;
10
+ switch (position) {
11
+ case "top-left":
12
+ return { top: main, left: cross };
13
+ case "bottom-left":
14
+ return { bottom: main, left: cross };
15
+ case "bottom-right":
16
+ return { bottom: main, right: cross };
17
+ default:
18
+ return { top: main, right: cross };
19
+ }
20
+ };
21
+ function attachDebugOverlay(engine, opts = {}) {
22
+ if (typeof document === "undefined") {
23
+ return () => {
24
+ };
25
+ }
26
+ const index = panelCount;
27
+ panelCount += 1;
28
+ const position = opts.position ?? "top-right";
29
+ const compact = opts.compact ?? false;
30
+ const panel = document.createElement("div");
31
+ panel.setAttribute("data-bs-debug", "");
32
+ Object.assign(panel.style, {
33
+ position: "fixed",
34
+ zIndex: "2147483647",
35
+ width: `${PANEL_WIDTH}px`,
36
+ padding: "8px 10px",
37
+ borderRadius: "8px",
38
+ background: "rgba(12, 12, 16, 0.88)",
39
+ color: "#9fef9f",
40
+ font: "11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace",
41
+ pointerEvents: "auto",
42
+ whiteSpace: "pre",
43
+ boxShadow: "0 2px 12px rgba(0,0,0,0.4)"
44
+ });
45
+ Object.assign(panel.style, anchorStyles(position, index * 132));
46
+ const header = document.createElement("div");
47
+ header.style.color = "#fff";
48
+ header.style.fontWeight = "700";
49
+ header.textContent = `bs-debug #${index + 1}`;
50
+ const live = document.createElement("div");
51
+ const snapList = document.createElement("div");
52
+ snapList.style.color = "#8ab8ff";
53
+ panel.append(header, live);
54
+ if (!compact) panel.append(snapList);
55
+ document.body.appendChild(panel);
56
+ let rafId = null;
57
+ let destroyed = false;
58
+ const renderLive = () => {
59
+ const s = engine.state;
60
+ live.textContent = `active ${s.activeId}
61
+ size ${s.size.toFixed(1)}px
62
+ progress ${s.progress.toFixed(2)}
63
+ flags ${s.isDragging ? "drag " : ""}${s.isAnimating ? "anim " : ""}${engine.isTop() ? "top" : ""}`;
64
+ };
65
+ const renderSnaps = () => {
66
+ if (compact) return;
67
+ const active = engine.state.activeId;
68
+ snapList.textContent = engine.getResolvedSnaps().map((p) => `${p.id === active ? "\u25B8" : " "} ${p.id}: ${Math.round(p.size)}px`).join("\n");
69
+ };
70
+ const scheduleLive = () => {
71
+ if (destroyed || rafId !== null) return;
72
+ rafId = requestAnimationFrame(() => {
73
+ rafId = null;
74
+ if (destroyed) return;
75
+ renderLive();
76
+ });
77
+ };
78
+ const renderAll = () => {
79
+ if (destroyed) return;
80
+ renderLive();
81
+ renderSnaps();
82
+ };
83
+ const subs = [
84
+ engine.on("progress", scheduleLive),
85
+ engine.on("drag", scheduleLive),
86
+ engine.on("dragstart", renderAll),
87
+ engine.on("dragend", renderAll),
88
+ engine.on("snap", renderAll),
89
+ engine.on("open", renderAll),
90
+ engine.on("close", renderAll),
91
+ engine.on("opened", renderAll),
92
+ engine.on("closed", renderAll)
93
+ ];
94
+ renderAll();
95
+ return () => {
96
+ if (destroyed) return;
97
+ destroyed = true;
98
+ for (const off of subs) off();
99
+ if (rafId !== null && typeof cancelAnimationFrame !== "undefined") {
100
+ cancelAnimationFrame(rafId);
101
+ }
102
+ panel.remove();
103
+ panelCount = Math.max(0, panelCount - 1);
104
+ };
105
+ }
106
+
107
+ exports.attachDebugOverlay = attachDebugOverlay;
108
+ //# sourceMappingURL=debug.cjs.map
109
+ //# sourceMappingURL=debug.cjs.map
@@ -0,0 +1,22 @@
1
+ import { E as EngineState, d as SheetEventMap } from './BottomSheetCore-Cp7dWy91.cjs';
2
+ import './transform-jVfAikE9.cjs';
3
+
4
+ type DebugOverlayPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
5
+ type DebugOverlayOptions = {
6
+ position?: DebugOverlayPosition;
7
+ compact?: boolean;
8
+ };
9
+ type DebuggableEngine = {
10
+ state: EngineState & {
11
+ activeId: string;
12
+ };
13
+ on<K extends keyof SheetEventMap>(event: K, fn: (payload: SheetEventMap[K]) => void): () => void;
14
+ getResolvedSnaps(): readonly {
15
+ id: string;
16
+ size: number;
17
+ }[];
18
+ isTop(): boolean;
19
+ };
20
+ declare function attachDebugOverlay(engine: DebuggableEngine, opts?: DebugOverlayOptions): () => void;
21
+
22
+ export { type DebugOverlayOptions, type DebugOverlayPosition, type DebuggableEngine, attachDebugOverlay };
@@ -0,0 +1,22 @@
1
+ import { E as EngineState, d as SheetEventMap } from './BottomSheetCore-DJYwWOqt.js';
2
+ import './transform-jVfAikE9.js';
3
+
4
+ type DebugOverlayPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
5
+ type DebugOverlayOptions = {
6
+ position?: DebugOverlayPosition;
7
+ compact?: boolean;
8
+ };
9
+ type DebuggableEngine = {
10
+ state: EngineState & {
11
+ activeId: string;
12
+ };
13
+ on<K extends keyof SheetEventMap>(event: K, fn: (payload: SheetEventMap[K]) => void): () => void;
14
+ getResolvedSnaps(): readonly {
15
+ id: string;
16
+ size: number;
17
+ }[];
18
+ isTop(): boolean;
19
+ };
20
+ declare function attachDebugOverlay(engine: DebuggableEngine, opts?: DebugOverlayOptions): () => void;
21
+
22
+ export { type DebugOverlayOptions, type DebugOverlayPosition, type DebuggableEngine, attachDebugOverlay };
package/dist/debug.js ADDED
@@ -0,0 +1,107 @@
1
+ // src/debug/index.ts
2
+ var PANEL_GAP = 8;
3
+ var PANEL_WIDTH = 232;
4
+ var panelCount = 0;
5
+ var anchorStyles = (position, offset) => {
6
+ const main = `${PANEL_GAP + offset}px`;
7
+ const cross = `${PANEL_GAP}px`;
8
+ switch (position) {
9
+ case "top-left":
10
+ return { top: main, left: cross };
11
+ case "bottom-left":
12
+ return { bottom: main, left: cross };
13
+ case "bottom-right":
14
+ return { bottom: main, right: cross };
15
+ default:
16
+ return { top: main, right: cross };
17
+ }
18
+ };
19
+ function attachDebugOverlay(engine, opts = {}) {
20
+ if (typeof document === "undefined") {
21
+ return () => {
22
+ };
23
+ }
24
+ const index = panelCount;
25
+ panelCount += 1;
26
+ const position = opts.position ?? "top-right";
27
+ const compact = opts.compact ?? false;
28
+ const panel = document.createElement("div");
29
+ panel.setAttribute("data-bs-debug", "");
30
+ Object.assign(panel.style, {
31
+ position: "fixed",
32
+ zIndex: "2147483647",
33
+ width: `${PANEL_WIDTH}px`,
34
+ padding: "8px 10px",
35
+ borderRadius: "8px",
36
+ background: "rgba(12, 12, 16, 0.88)",
37
+ color: "#9fef9f",
38
+ font: "11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace",
39
+ pointerEvents: "auto",
40
+ whiteSpace: "pre",
41
+ boxShadow: "0 2px 12px rgba(0,0,0,0.4)"
42
+ });
43
+ Object.assign(panel.style, anchorStyles(position, index * 132));
44
+ const header = document.createElement("div");
45
+ header.style.color = "#fff";
46
+ header.style.fontWeight = "700";
47
+ header.textContent = `bs-debug #${index + 1}`;
48
+ const live = document.createElement("div");
49
+ const snapList = document.createElement("div");
50
+ snapList.style.color = "#8ab8ff";
51
+ panel.append(header, live);
52
+ if (!compact) panel.append(snapList);
53
+ document.body.appendChild(panel);
54
+ let rafId = null;
55
+ let destroyed = false;
56
+ const renderLive = () => {
57
+ const s = engine.state;
58
+ live.textContent = `active ${s.activeId}
59
+ size ${s.size.toFixed(1)}px
60
+ progress ${s.progress.toFixed(2)}
61
+ flags ${s.isDragging ? "drag " : ""}${s.isAnimating ? "anim " : ""}${engine.isTop() ? "top" : ""}`;
62
+ };
63
+ const renderSnaps = () => {
64
+ if (compact) return;
65
+ const active = engine.state.activeId;
66
+ snapList.textContent = engine.getResolvedSnaps().map((p) => `${p.id === active ? "\u25B8" : " "} ${p.id}: ${Math.round(p.size)}px`).join("\n");
67
+ };
68
+ const scheduleLive = () => {
69
+ if (destroyed || rafId !== null) return;
70
+ rafId = requestAnimationFrame(() => {
71
+ rafId = null;
72
+ if (destroyed) return;
73
+ renderLive();
74
+ });
75
+ };
76
+ const renderAll = () => {
77
+ if (destroyed) return;
78
+ renderLive();
79
+ renderSnaps();
80
+ };
81
+ const subs = [
82
+ engine.on("progress", scheduleLive),
83
+ engine.on("drag", scheduleLive),
84
+ engine.on("dragstart", renderAll),
85
+ engine.on("dragend", renderAll),
86
+ engine.on("snap", renderAll),
87
+ engine.on("open", renderAll),
88
+ engine.on("close", renderAll),
89
+ engine.on("opened", renderAll),
90
+ engine.on("closed", renderAll)
91
+ ];
92
+ renderAll();
93
+ return () => {
94
+ if (destroyed) return;
95
+ destroyed = true;
96
+ for (const off of subs) off();
97
+ if (rafId !== null && typeof cancelAnimationFrame !== "undefined") {
98
+ cancelAnimationFrame(rafId);
99
+ }
100
+ panel.remove();
101
+ panelCount = Math.max(0, panelCount - 1);
102
+ };
103
+ }
104
+
105
+ export { attachDebugOverlay };
106
+ //# sourceMappingURL=debug.js.map
107
+ //# sourceMappingURL=debug.js.map