@surdeddd/bottom-sheet 0.23.4 → 0.24.1
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/README.md +513 -527
- package/README.ru.md +533 -545
- package/dist/{BottomSheetCore-C5tJYVMY.d.cts → BottomSheetCore-B_r4KCQL.d.cts} +48 -13
- package/dist/{BottomSheetCore-DxSrC4QC.d.ts → BottomSheetCore-B_r4KCQL.d.ts} +48 -13
- package/dist/{BottomSheetEngine-B3F9qukX.d.cts → BottomSheetEngine-0F7mjyvF.d.cts} +1 -1
- package/dist/{BottomSheetEngine-BchzgqGG.d.ts → BottomSheetEngine-CJV_DDrM.d.ts} +1 -1
- package/dist/core.cjs +810 -436
- package/dist/core.d.cts +2 -3
- package/dist/core.d.ts +2 -3
- package/dist/core.js +810 -436
- package/dist/debug.d.cts +0 -1
- package/dist/debug.d.ts +0 -1
- package/dist/{default-features-DwVTzDwP.d.ts → default-features-4Xwv6aVt.d.ts} +4 -2
- package/dist/{default-features-BGiCSmV1.d.cts → default-features-DX2NOxP6.d.cts} +4 -2
- package/dist/element.cjs +1421 -697
- package/dist/element.d.cts +11 -3
- package/dist/element.d.ts +11 -3
- package/dist/element.iife.global.js +2 -2
- package/dist/element.js +1421 -697
- package/dist/features.cjs +334 -190
- package/dist/features.d.cts +3 -4
- package/dist/features.d.ts +3 -4
- package/dist/features.js +334 -191
- package/dist/{index-C7TSQkVK.d.cts → index-2shlxhcG.d.cts} +1 -1
- package/dist/{index-CdM1tke5.d.ts → index-CNCRQnpc.d.ts} +1 -1
- package/dist/index.cjs +1129 -631
- package/dist/index.d.cts +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +1129 -632
- package/dist/integrations/formik.cjs +21 -10
- package/dist/integrations/formik.d.cts +0 -1
- package/dist/integrations/formik.d.ts +0 -1
- package/dist/integrations/formik.js +22 -11
- package/dist/integrations/react-hook-form.cjs +21 -12
- package/dist/integrations/react-hook-form.d.cts +0 -1
- package/dist/integrations/react-hook-form.d.ts +0 -1
- package/dist/integrations/react-hook-form.js +21 -12
- package/dist/option-keys-DItuAjUw.d.cts +6 -0
- package/dist/option-keys-a5DYNwwO.d.ts +6 -0
- package/dist/overlay.cjs +386 -189
- package/dist/overlay.d.cts +1 -3
- package/dist/overlay.d.ts +1 -3
- package/dist/overlay.js +386 -189
- package/dist/preact.d.cts +3 -4
- package/dist/preact.d.ts +3 -4
- package/dist/qwik-lib/index.qwik.cjs +1306 -671
- package/dist/qwik-lib/index.qwik.mjs +1306 -671
- package/dist/qwik.cjs +1326 -701
- package/dist/qwik.d.cts +12 -30
- package/dist/qwik.d.ts +12 -30
- package/dist/qwik.js +1326 -701
- package/dist/react.cjs +1373 -750
- package/dist/react.d.cts +26 -12
- package/dist/react.d.ts +26 -12
- package/dist/react.js +1375 -752
- package/dist/solid.cjs +1332 -727
- package/dist/solid.d.cts +13 -438
- package/dist/solid.d.ts +13 -438
- package/dist/solid.js +1334 -729
- package/dist/solid.source.jsx +1374 -751
- package/dist/styles.css +20 -6
- package/dist/svelte-core.cjs +1209 -676
- package/dist/svelte-core.js +1207 -677
- package/dist/svelte-src/BottomSheet.svelte +101 -58
- package/dist/svelte.cjs +1323 -705
- package/dist/svelte.d.cts +45 -25
- package/dist/svelte.d.ts +45 -25
- package/dist/svelte.js +1323 -705
- package/dist/vue.cjs +1354 -773
- package/dist/vue.d.cts +20 -3
- package/dist/vue.d.ts +20 -3
- package/dist/vue.js +1354 -773
- package/dist/webgl.cjs +159 -53
- package/dist/webgl.d.cts +2 -2
- package/dist/webgl.d.ts +2 -2
- package/dist/webgl.js +159 -53
- package/llms.txt +330 -0
- package/package.json +42 -20
- package/dist/transform-jVfAikE9.d.cts +0 -3
- package/dist/transform-jVfAikE9.d.ts +0 -3
package/dist/webgl.js
CHANGED
|
@@ -7,6 +7,22 @@ var supportsHighpFragment = (gl) => {
|
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
+
var SOFTWARE = /swiftshader|llvmpipe|softpipe|software|basic render/i;
|
|
11
|
+
var MASKED = /^webkit webgl$/i;
|
|
12
|
+
var rendererName = (gl) => {
|
|
13
|
+
const plain = String(gl.getParameter(gl.RENDERER) ?? "");
|
|
14
|
+
if (plain && !MASKED.test(plain)) return plain;
|
|
15
|
+
const info = gl.getExtension("WEBGL_debug_renderer_info");
|
|
16
|
+
if (!info) return "";
|
|
17
|
+
return String(gl.getParameter(info.UNMASKED_RENDERER_WEBGL) ?? "");
|
|
18
|
+
};
|
|
19
|
+
var drawsOnCpu = (gl) => {
|
|
20
|
+
try {
|
|
21
|
+
return SOFTWARE.test(rendererName(gl));
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
10
26
|
var hasWebGL = () => {
|
|
11
27
|
if (typeof document === "undefined") return false;
|
|
12
28
|
if (typeof WebGLRenderingContext === "undefined" && typeof WebGL2RenderingContext === "undefined") {
|
|
@@ -32,14 +48,16 @@ var createGLHandle = (onLost) => {
|
|
|
32
48
|
canvas.style.position = "fixed";
|
|
33
49
|
canvas.style.left = "0";
|
|
34
50
|
canvas.style.top = "0";
|
|
51
|
+
canvas.style.width = "100%";
|
|
52
|
+
canvas.style.height = "100%";
|
|
35
53
|
canvas.style.pointerEvents = "none";
|
|
36
54
|
const attrs = {
|
|
37
55
|
alpha: true,
|
|
38
56
|
premultipliedAlpha: true,
|
|
39
|
-
antialias:
|
|
57
|
+
antialias: false,
|
|
40
58
|
depth: false,
|
|
41
59
|
stencil: false,
|
|
42
|
-
preserveDrawingBuffer:
|
|
60
|
+
preserveDrawingBuffer: true
|
|
43
61
|
};
|
|
44
62
|
let gl = null;
|
|
45
63
|
let isWebGL2 = false;
|
|
@@ -83,8 +101,6 @@ var resizeDrawingBuffer = (handle, cssWidth, cssHeight, dpr) => {
|
|
|
83
101
|
handle.canvas.width = w;
|
|
84
102
|
handle.canvas.height = h;
|
|
85
103
|
}
|
|
86
|
-
handle.canvas.style.width = `${cssWidth}px`;
|
|
87
|
-
handle.canvas.style.height = `${cssHeight}px`;
|
|
88
104
|
handle.gl.viewport(0, 0, w, h);
|
|
89
105
|
};
|
|
90
106
|
|
|
@@ -100,7 +116,7 @@ precision ${precision} float;
|
|
|
100
116
|
|
|
101
117
|
uniform vec2 u_resolution;
|
|
102
118
|
uniform vec4 u_rect;
|
|
103
|
-
uniform
|
|
119
|
+
uniform vec4 u_radius;
|
|
104
120
|
uniform vec4 u_color;
|
|
105
121
|
uniform float u_shadow;
|
|
106
122
|
uniform float u_bend;
|
|
@@ -113,7 +129,9 @@ uniform sampler2D u_scroll;
|
|
|
113
129
|
uniform vec4 u_scrollRect;
|
|
114
130
|
uniform vec2 u_scrollMap;
|
|
115
131
|
|
|
116
|
-
float roundedBoxSDF(vec2 p, vec2 halfSize,
|
|
132
|
+
float roundedBoxSDF(vec2 p, vec2 halfSize, vec4 radii) {
|
|
133
|
+
vec2 side = p.x < 0.0 ? radii.xw : radii.yz;
|
|
134
|
+
float r = min(p.y < 0.0 ? side.x : side.y, min(halfSize.x, halfSize.y));
|
|
117
135
|
vec2 q = abs(p) - halfSize + r;
|
|
118
136
|
return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r;
|
|
119
137
|
}
|
|
@@ -129,8 +147,7 @@ void main() {
|
|
|
129
147
|
vec2 p = frag - center;
|
|
130
148
|
p.y -= bend;
|
|
131
149
|
|
|
132
|
-
float
|
|
133
|
-
float d = roundedBoxSDF(p, halfSize, r);
|
|
150
|
+
float d = roundedBoxSDF(p, halfSize, u_radius);
|
|
134
151
|
float surface = 1.0 - smoothstep(-1.0, 1.0, d);
|
|
135
152
|
|
|
136
153
|
vec2 uv = (p + halfSize) / u_rect.zw;
|
|
@@ -254,7 +271,14 @@ var createSurfaceProgram = (gl, highp = true) => {
|
|
|
254
271
|
frame.width * dpr,
|
|
255
272
|
frame.height * dpr
|
|
256
273
|
);
|
|
257
|
-
|
|
274
|
+
const [topLeft, topRight, bottomRight, bottomLeft] = frame.radii;
|
|
275
|
+
gl.uniform4f(
|
|
276
|
+
uRadius,
|
|
277
|
+
topLeft * dpr,
|
|
278
|
+
topRight * dpr,
|
|
279
|
+
bottomRight * dpr,
|
|
280
|
+
bottomLeft * dpr
|
|
281
|
+
);
|
|
258
282
|
gl.uniform4f(uColor, ...frame.color);
|
|
259
283
|
gl.uniform1f(uShadow, frame.shadow);
|
|
260
284
|
gl.uniform1f(uBend, state.bend * dpr);
|
|
@@ -585,13 +609,36 @@ var BEND_DECAY_HELD = 0.86;
|
|
|
585
609
|
var BEND_DECAY_FREE = 0.62;
|
|
586
610
|
var BEND_REST = 0.35;
|
|
587
611
|
var prefersReducedMotion = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
612
|
+
var WHITE = [1, 1, 1, 1];
|
|
613
|
+
var SENTINEL = "#010203";
|
|
614
|
+
var colorProbe;
|
|
615
|
+
var readColor = (value) => {
|
|
616
|
+
if (colorProbe === void 0) {
|
|
617
|
+
const canvas = document.createElement("canvas");
|
|
618
|
+
canvas.width = 1;
|
|
619
|
+
canvas.height = 1;
|
|
620
|
+
colorProbe = canvas.getContext("2d", { willReadFrequently: true });
|
|
621
|
+
}
|
|
622
|
+
const probe = colorProbe;
|
|
623
|
+
if (!probe) return WHITE;
|
|
624
|
+
probe.fillStyle = SENTINEL;
|
|
625
|
+
probe.fillStyle = value;
|
|
626
|
+
if (probe.fillStyle === SENTINEL) return WHITE;
|
|
627
|
+
probe.clearRect(0, 0, 1, 1);
|
|
628
|
+
probe.fillRect(0, 0, 1, 1);
|
|
629
|
+
const [r = 255, g = 255, b = 255, a = 255] = probe.getImageData(0, 0, 1, 1).data;
|
|
630
|
+
return [r / 255, g / 255, b / 255, a / 255];
|
|
631
|
+
};
|
|
588
632
|
var parseColor = (value) => {
|
|
589
|
-
const
|
|
590
|
-
if (
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
633
|
+
const legacy = value.match(/^rgba?\(([^()]+)\)$/);
|
|
634
|
+
if (legacy && legacy[1].includes(",")) {
|
|
635
|
+
const parts = legacy[1].split(",").map((p) => parseFloat(p.trim()));
|
|
636
|
+
const [r = 255, g = 255, b = 255, a = 1] = parts;
|
|
637
|
+
return [r / 255, g / 255, b / 255, a];
|
|
638
|
+
}
|
|
639
|
+
return readColor(value);
|
|
594
640
|
};
|
|
641
|
+
var parentAcrossShadow = (node) => node.parentElement ?? node.getRootNode().host ?? null;
|
|
595
642
|
var parseRadius = (value) => {
|
|
596
643
|
const n = parseFloat(value);
|
|
597
644
|
return Number.isFinite(n) ? n : 0;
|
|
@@ -637,7 +684,12 @@ var webglRenderer = (options = {}) => ({
|
|
|
637
684
|
const cs = getComputedStyle(element);
|
|
638
685
|
return {
|
|
639
686
|
color: parseColor(cs.backgroundColor),
|
|
640
|
-
|
|
687
|
+
radii: [
|
|
688
|
+
parseRadius(cs.borderTopLeftRadius),
|
|
689
|
+
parseRadius(cs.borderTopRightRadius),
|
|
690
|
+
parseRadius(cs.borderBottomRightRadius),
|
|
691
|
+
parseRadius(cs.borderBottomLeftRadius)
|
|
692
|
+
]
|
|
641
693
|
};
|
|
642
694
|
};
|
|
643
695
|
let surfaceStyle = readSurfaceStyle();
|
|
@@ -672,6 +724,12 @@ var webglRenderer = (options = {}) => ({
|
|
|
672
724
|
bail("no-webgl");
|
|
673
725
|
return;
|
|
674
726
|
}
|
|
727
|
+
if (!options.allowSoftware && drawsOnCpu(handle.gl)) {
|
|
728
|
+
handle.destroy();
|
|
729
|
+
handle = null;
|
|
730
|
+
bail("software-renderer");
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
675
733
|
program = createSurfaceProgram(handle.gl, handle.highp);
|
|
676
734
|
if (!program) {
|
|
677
735
|
handle.destroy();
|
|
@@ -681,23 +739,23 @@ var webglRenderer = (options = {}) => ({
|
|
|
681
739
|
}
|
|
682
740
|
const parent = element.parentElement ?? document.body;
|
|
683
741
|
parent.insertBefore(handle.canvas, element);
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
const
|
|
690
|
-
if (
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
shadow: shadowStrength
|
|
699
|
-
};
|
|
742
|
+
let canvasZ = "";
|
|
743
|
+
let canvasPosition = "fixed";
|
|
744
|
+
const followStack = () => {
|
|
745
|
+
if (!handle) return;
|
|
746
|
+
const cs = getComputedStyle(element);
|
|
747
|
+
const position = cs.position === "absolute" ? "absolute" : "fixed";
|
|
748
|
+
if (position !== canvasPosition) {
|
|
749
|
+
canvasPosition = position;
|
|
750
|
+
handle.canvas.style.position = position;
|
|
751
|
+
}
|
|
752
|
+
const next = cs.zIndex && cs.zIndex !== "auto" ? String(Number(cs.zIndex) - 1) : "0";
|
|
753
|
+
if (next === canvasZ) return;
|
|
754
|
+
canvasZ = next;
|
|
755
|
+
handle.canvas.style.zIndex = next;
|
|
700
756
|
};
|
|
757
|
+
followStack();
|
|
758
|
+
suppressDomPaint();
|
|
701
759
|
const dprOf = () => options.dpr ?? window.devicePixelRatio ?? 1;
|
|
702
760
|
const releaseCapture = () => {
|
|
703
761
|
releaseText?.();
|
|
@@ -721,41 +779,52 @@ var webglRenderer = (options = {}) => ({
|
|
|
721
779
|
capture = next;
|
|
722
780
|
releaseText = hideCapturedText(next.hiddenNodes);
|
|
723
781
|
};
|
|
724
|
-
const scrollLayer = (
|
|
782
|
+
const scrollLayer = (sheet) => {
|
|
725
783
|
const scroll = capture?.scroll;
|
|
726
784
|
const scroller = ctx.scrollContainer;
|
|
727
785
|
if (!scroll || !scroller) return null;
|
|
728
786
|
const box = scroller.getBoundingClientRect();
|
|
729
|
-
const left = box.left + scroller.clientLeft -
|
|
730
|
-
const top = box.top + scroller.clientTop -
|
|
787
|
+
const left = box.left + scroller.clientLeft - sheet.left;
|
|
788
|
+
const top = box.top + scroller.clientTop - sheet.top;
|
|
731
789
|
return {
|
|
732
790
|
texture: scroll.texture,
|
|
733
791
|
rect: [
|
|
734
|
-
left /
|
|
735
|
-
top /
|
|
736
|
-
(left + scroller.clientWidth) /
|
|
737
|
-
(top + scroller.clientHeight) /
|
|
792
|
+
left / sheet.width,
|
|
793
|
+
top / sheet.height,
|
|
794
|
+
(left + scroller.clientWidth) / sheet.width,
|
|
795
|
+
(top + scroller.clientHeight) / sheet.height
|
|
738
796
|
],
|
|
739
797
|
map: [
|
|
740
|
-
|
|
798
|
+
sheet.height / scroll.height,
|
|
741
799
|
(scroll.above + scroller.scrollTop - scroll.top) / scroll.height
|
|
742
800
|
]
|
|
743
801
|
};
|
|
744
802
|
};
|
|
745
803
|
const paint = () => {
|
|
746
804
|
if (disposed || !handle || !program) return;
|
|
747
|
-
const
|
|
748
|
-
|
|
805
|
+
const sheet = element.getBoundingClientRect();
|
|
806
|
+
const area = handle.canvas.getBoundingClientRect();
|
|
807
|
+
if (sheet.width <= 0 || sheet.height <= 0) return;
|
|
808
|
+
if (area.width <= 0 || area.height <= 0) return;
|
|
749
809
|
const dpr = dprOf();
|
|
750
|
-
resizeDrawingBuffer(handle,
|
|
810
|
+
resizeDrawingBuffer(handle, area.width, area.height, dpr);
|
|
751
811
|
const motion = Math.min(1, Math.abs(bend) / MAX_BEND_PX);
|
|
812
|
+
const frame = {
|
|
813
|
+
x: sheet.left - area.left,
|
|
814
|
+
y: sheet.top - area.top,
|
|
815
|
+
width: sheet.width,
|
|
816
|
+
height: sheet.height,
|
|
817
|
+
radii: surfaceStyle.radii,
|
|
818
|
+
color: surfaceStyle.color,
|
|
819
|
+
shadow: shadowStrength
|
|
820
|
+
};
|
|
752
821
|
program.draw(frame, {
|
|
753
822
|
bend,
|
|
754
823
|
dpr,
|
|
755
824
|
sheen: sheenStrength,
|
|
756
825
|
glass: glassStrength * motion,
|
|
757
826
|
content: capture?.texture ?? null,
|
|
758
|
-
scroll: scrollLayer(
|
|
827
|
+
scroll: scrollLayer(sheet)
|
|
759
828
|
});
|
|
760
829
|
};
|
|
761
830
|
const tick = () => {
|
|
@@ -774,6 +843,7 @@ var webglRenderer = (options = {}) => ({
|
|
|
774
843
|
paint();
|
|
775
844
|
running = false;
|
|
776
845
|
frameId = null;
|
|
846
|
+
queueRefresh();
|
|
777
847
|
return;
|
|
778
848
|
}
|
|
779
849
|
frameId = requestAnimationFrame(tick);
|
|
@@ -812,35 +882,71 @@ var webglRenderer = (options = {}) => ({
|
|
|
812
882
|
subtree: true,
|
|
813
883
|
characterData: true
|
|
814
884
|
});
|
|
815
|
-
const
|
|
885
|
+
const onGeometry = () => {
|
|
886
|
+
followStack();
|
|
816
887
|
if (!ctx.isDragging()) paint();
|
|
817
888
|
wake();
|
|
818
|
-
}
|
|
889
|
+
};
|
|
890
|
+
const geometryObserver = new MutationObserver(onGeometry);
|
|
819
891
|
geometryObserver.observe(element, {
|
|
820
892
|
attributes: true,
|
|
821
893
|
attributeFilter: ["style"]
|
|
822
894
|
});
|
|
823
895
|
const refreshSurfaceStyle = () => {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
896
|
+
const moved = geometryObserver.takeRecords().length > 0;
|
|
897
|
+
const style = element.style;
|
|
898
|
+
const transition = style.transition;
|
|
899
|
+
style.transition = "none";
|
|
900
|
+
restoreDom();
|
|
901
|
+
const next = readSurfaceStyle();
|
|
902
|
+
suppressDomPaint();
|
|
903
|
+
void getComputedStyle(element).backgroundColor;
|
|
904
|
+
style.transition = transition;
|
|
905
|
+
geometryObserver.takeRecords();
|
|
906
|
+
const changed = next.radii.some((radius, i) => radius !== surfaceStyle.radii[i]) || next.color.some((channel, i) => channel !== surfaceStyle.color[i]);
|
|
907
|
+
surfaceStyle = next;
|
|
908
|
+
if (!moved) {
|
|
909
|
+
followStack();
|
|
910
|
+
return changed;
|
|
911
|
+
}
|
|
912
|
+
onGeometry();
|
|
913
|
+
return false;
|
|
914
|
+
};
|
|
915
|
+
let refreshQueued = false;
|
|
916
|
+
const queueRefresh = () => {
|
|
917
|
+
if (disposed || refreshQueued) return;
|
|
918
|
+
refreshQueued = true;
|
|
919
|
+
requestAnimationFrame(() => {
|
|
920
|
+
refreshQueued = false;
|
|
921
|
+
if (!disposed && refreshSurfaceStyle()) paint();
|
|
922
|
+
});
|
|
923
|
+
};
|
|
924
|
+
const onThemeSignal = () => {
|
|
925
|
+
if (!ctx.isDragging() && !ctx.isAnimating()) queueRefresh();
|
|
830
926
|
};
|
|
927
|
+
const themeObserver = new MutationObserver(onThemeSignal);
|
|
928
|
+
themeObserver.observe(element, {
|
|
929
|
+
attributes: true,
|
|
930
|
+
attributeFilter: ["class"]
|
|
931
|
+
});
|
|
932
|
+
for (let node = parentAcrossShadow(element); node; node = parentAcrossShadow(node)) {
|
|
933
|
+
themeObserver.observe(node, { attributes: true });
|
|
934
|
+
}
|
|
935
|
+
const scheme = typeof matchMedia === "function" ? matchMedia("(prefers-color-scheme: dark)") : null;
|
|
936
|
+
scheme?.addEventListener?.("change", onThemeSignal);
|
|
831
937
|
const onResize = () => {
|
|
832
938
|
if (disposed) return;
|
|
833
939
|
refreshSurfaceStyle();
|
|
834
940
|
paint();
|
|
835
941
|
};
|
|
836
942
|
window.addEventListener("resize", onResize, { passive: true });
|
|
837
|
-
window.addEventListener("scroll", onResize, { passive: true });
|
|
838
943
|
paint();
|
|
839
944
|
return () => {
|
|
840
945
|
contentObserver.disconnect();
|
|
841
946
|
geometryObserver.disconnect();
|
|
947
|
+
themeObserver.disconnect();
|
|
948
|
+
scheme?.removeEventListener?.("change", onThemeSignal);
|
|
842
949
|
window.removeEventListener("resize", onResize);
|
|
843
|
-
window.removeEventListener("scroll", onResize);
|
|
844
950
|
teardown();
|
|
845
951
|
};
|
|
846
952
|
}
|