@balikjs/mobile 0.1.14 → 0.1.15
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/BottomSheet/BottomSheet.js +19 -19
- package/package.json +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { createComponent as F, Portal as R, effect as b, className as c, setAttribute as E, use as w, insert as P, memo as G, template as C, delegateEvents as I } from "solid-js/web";
|
|
2
|
-
import { splitProps as N, mergeProps as U, createSignal as x, createEffect as y, on as _ } from "solid-js";
|
|
3
|
-
import { trapFocus as
|
|
4
|
-
import { bem as
|
|
2
|
+
import { splitProps as N, mergeProps as U, createSignal as x, createEffect as y, on as _, onCleanup as H } from "solid-js";
|
|
3
|
+
import { trapFocus as M } from "@zag-js/focus-trap";
|
|
4
|
+
import { bem as V } from "../utils/bem.js";
|
|
5
5
|
import { cn as g } from "../utils/cn.js";
|
|
6
|
-
import { useScrollLock as
|
|
6
|
+
import { useScrollLock as j } from "../utils/useScrollLock.js";
|
|
7
7
|
import s from "./BottomSheet.module.css.js";
|
|
8
|
-
var
|
|
9
|
-
const
|
|
8
|
+
var q = /* @__PURE__ */ C("<div data-part=backdrop>"), z = /* @__PURE__ */ C("<div role=dialog aria-modal=true aria-label=BottomSheet><div data-part=content>"), J = /* @__PURE__ */ C("<div data-part=grabber><div>");
|
|
9
|
+
const K = {
|
|
10
10
|
dismissible: !0,
|
|
11
11
|
backdropBlur: !0,
|
|
12
12
|
draggable: !0
|
|
13
|
-
},
|
|
14
|
-
function
|
|
15
|
-
const [r] = N(U(
|
|
13
|
+
}, Q = 0.3, W = 0.5, X = 3;
|
|
14
|
+
function ie(B) {
|
|
15
|
+
const [r] = N(U(K, B), ["open", "onOpen", "onClose", "onOpenChange", "dismissible", "draggable", "backdropBlur", "class", "contentClass", "children"]);
|
|
16
16
|
let l;
|
|
17
17
|
const [d, h] = x(!1);
|
|
18
18
|
let O = 0, p = 0, m = 0, f = 0, v = 0;
|
|
@@ -22,7 +22,7 @@ function ae(B) {
|
|
|
22
22
|
if (!d()) return;
|
|
23
23
|
const t = e.clientY - O, o = e.timeStamp - f;
|
|
24
24
|
o > 0 && (v = (e.clientY - m) / o), m = e.clientY, f = e.timeStamp, p = t;
|
|
25
|
-
const n = t >= 0 ? t : t /
|
|
25
|
+
const n = t >= 0 ? t : t / X;
|
|
26
26
|
l.style.transform = `translateY(${n}px)`;
|
|
27
27
|
}, $ = (e) => {
|
|
28
28
|
h(!1), l.style.transform = "", e && k({
|
|
@@ -30,7 +30,7 @@ function ae(B) {
|
|
|
30
30
|
});
|
|
31
31
|
}, T = () => {
|
|
32
32
|
if (!d()) return;
|
|
33
|
-
const e = l.offsetHeight || 1, t = p > e *
|
|
33
|
+
const e = l.offsetHeight || 1, t = p > e * Q, o = p > 0 && v > W;
|
|
34
34
|
$(r.dismissible && (t || o));
|
|
35
35
|
}, L = () => {
|
|
36
36
|
d() && $(!1);
|
|
@@ -38,16 +38,16 @@ function ae(B) {
|
|
|
38
38
|
var t;
|
|
39
39
|
(t = r.onOpenChange) == null || t.call(r, e);
|
|
40
40
|
};
|
|
41
|
-
return
|
|
41
|
+
return j(() => r.open), y(_(() => r.open, (e) => {
|
|
42
42
|
if (!e) return;
|
|
43
|
-
const t =
|
|
43
|
+
const t = M(l, {
|
|
44
44
|
initialFocus: !1,
|
|
45
45
|
escapeDeactivates: !1,
|
|
46
46
|
clickOutsideDeactivates: !1,
|
|
47
47
|
allowOutsideClick: !0,
|
|
48
48
|
returnFocusOnDeactivate: !0
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
H(t);
|
|
51
51
|
})), y(_(() => r.open, (e) => {
|
|
52
52
|
var t, o;
|
|
53
53
|
e ? (t = r.onOpen) == null || t.call(r) : (o = r.onClose) == null || o.call(r);
|
|
@@ -59,7 +59,7 @@ function ae(B) {
|
|
|
59
59
|
},
|
|
60
60
|
get children() {
|
|
61
61
|
return [(() => {
|
|
62
|
-
var e =
|
|
62
|
+
var e = q();
|
|
63
63
|
return e.$$click = () => {
|
|
64
64
|
r.dismissible && k({
|
|
65
65
|
open: !1
|
|
@@ -72,11 +72,11 @@ function ae(B) {
|
|
|
72
72
|
t: void 0
|
|
73
73
|
}), e;
|
|
74
74
|
})(), (() => {
|
|
75
|
-
var e =
|
|
75
|
+
var e = z(), t = e.firstChild, o = l;
|
|
76
76
|
return typeof o == "function" ? w(o, e) : l = e, P(e, (() => {
|
|
77
77
|
var n = G(() => !!r.draggable);
|
|
78
78
|
return () => n() && (() => {
|
|
79
|
-
var a =
|
|
79
|
+
var a = J(), u = a.firstChild;
|
|
80
80
|
return a.addEventListener("pointercancel", L), a.$$pointerup = T, a.$$pointermove = A, a.$$pointerdown = Y, b((i) => {
|
|
81
81
|
var S = s.grabberArea, D = s.grabber;
|
|
82
82
|
return S !== i.e && c(a, i.e = S), D !== i.t && c(u, i.t = D), i;
|
|
@@ -86,7 +86,7 @@ function ae(B) {
|
|
|
86
86
|
}), a;
|
|
87
87
|
})();
|
|
88
88
|
})(), t), P(t, () => r.children), b((n) => {
|
|
89
|
-
var a = g(
|
|
89
|
+
var a = g(V(), s.sheet, d() && s.dragging, r.class), u = r.open ? "" : void 0, i = g(s.content, r.contentClass);
|
|
90
90
|
return a !== n.e && c(e, n.e = a), u !== n.t && E(e, "data-open", n.t = u), i !== n.a && c(t, n.a = i), n;
|
|
91
91
|
}, {
|
|
92
92
|
e: void 0,
|
|
@@ -99,5 +99,5 @@ function ae(B) {
|
|
|
99
99
|
}
|
|
100
100
|
I(["click", "pointerdown", "pointermove", "pointerup"]);
|
|
101
101
|
export {
|
|
102
|
-
|
|
102
|
+
ie as BottomSheet
|
|
103
103
|
};
|