adverich-kun-ui 0.1.448 → 0.1.449
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref as c, computed as i, onMounted as ee, onBeforeUnmount as te, watch as ne, createElementBlock as X, openBlock as
|
|
1
|
+
import { ref as c, computed as i, onMounted as ee, onBeforeUnmount as te, watch as ne, createElementBlock as X, openBlock as V, Fragment as oe, withDirectives as ae, createVNode as ie, createBlock as le, resolveDynamicComponent as re, withModifiers as ue, normalizeStyle as L, normalizeClass as se, withCtx as P, renderSlot as E, vShow as de, Transition as ce, createCommentVNode as fe, nextTick as pe } from "vue";
|
|
2
2
|
import { useAppbarHeight as me } from "../../../../utils/useLayout.js";
|
|
3
3
|
const he = {
|
|
4
4
|
__name: "KunDrawer",
|
|
@@ -43,19 +43,19 @@ const he = {
|
|
|
43
43
|
"swipe-move",
|
|
44
44
|
"swipe-end"
|
|
45
45
|
],
|
|
46
|
-
setup(
|
|
46
|
+
setup(a, { emit: A }) {
|
|
47
47
|
const s = A;
|
|
48
48
|
function d(e) {
|
|
49
49
|
s("update:model-value", e), s("update:modelValue", e);
|
|
50
50
|
}
|
|
51
|
-
const t =
|
|
51
|
+
const t = a, B = me(), x = c(null), r = c(256);
|
|
52
52
|
let v = 256;
|
|
53
53
|
function w() {
|
|
54
54
|
var e;
|
|
55
|
-
v = ((e =
|
|
55
|
+
v = ((e = x.value) == null ? void 0 : e.offsetWidth) || v, r.value = v;
|
|
56
56
|
}
|
|
57
|
-
const F = i(() => t.fullHeight ? "0px" : `${
|
|
58
|
-
() => t.fullHeight ? typeof window < "u" && window.innerWidth < 768 ? "100dvh" : "100vh" : `calc(100vh - ${
|
|
57
|
+
const F = i(() => t.fullHeight ? "0px" : `${B.value}px`), G = i(
|
|
58
|
+
() => t.fullHeight ? typeof window < "u" && window.innerWidth < 768 ? "100dvh" : "100vh" : `calc(100vh - ${B.value}px)`
|
|
59
59
|
), O = i(() => t.rail ? t.railWidth : t.width), u = i(() => ["start", "left"].includes(t.location)), U = i(() => ["end", "right"].includes(t.location)), j = i(() => {
|
|
60
60
|
switch (t.location) {
|
|
61
61
|
case "start":
|
|
@@ -79,105 +79,109 @@ const he = {
|
|
|
79
79
|
I.value,
|
|
80
80
|
t.color ?? "bg-surface-dark",
|
|
81
81
|
t.scrollable ? "overflow-auto" : ""
|
|
82
|
-
]), h = c(0), f = c(0),
|
|
82
|
+
]), h = c(0), f = c(0), o = c(!1);
|
|
83
83
|
let g = 0, b = 0, y = 0;
|
|
84
84
|
const S = i(() => {
|
|
85
|
-
const e =
|
|
85
|
+
const e = C(), n = r.value || 1;
|
|
86
86
|
return Math.min(1, Math.max(0, 1 - Math.abs(e) / n));
|
|
87
87
|
});
|
|
88
88
|
function p() {
|
|
89
|
-
const e =
|
|
90
|
-
return u.value ? -
|
|
89
|
+
const e = o.value ? 0 : t.peekSize;
|
|
90
|
+
return u.value ? -r.value + e : r.value - e;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function k() {
|
|
93
93
|
return 0;
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function C() {
|
|
96
96
|
if (!t.swipeable)
|
|
97
|
-
return t.modelValue ?
|
|
98
|
-
if (
|
|
97
|
+
return t.modelValue ? k() : p();
|
|
98
|
+
if (o.value) {
|
|
99
99
|
const e = f.value - h.value;
|
|
100
|
-
return t.modelValue ? u.value ? Math.min(0, e) : Math.max(0, e) : u.value ? Math.min(
|
|
100
|
+
return t.modelValue ? u.value ? Math.min(0, e) : Math.max(0, e) : u.value ? Math.min(r.value, p() + e) : Math.max(-r.value, p() + e);
|
|
101
101
|
}
|
|
102
|
-
return t.modelValue ?
|
|
102
|
+
return t.modelValue ? k() : p();
|
|
103
103
|
}
|
|
104
104
|
const R = i(() => {
|
|
105
105
|
let e = t.animationDuration;
|
|
106
|
-
if (!
|
|
107
|
-
const n =
|
|
106
|
+
if (!o.value) {
|
|
107
|
+
const n = r.value * (1 - S.value);
|
|
108
108
|
e = Math.max(120, Math.min(300, n * 1.2));
|
|
109
109
|
}
|
|
110
110
|
return {
|
|
111
|
-
transform: `translateX(${
|
|
111
|
+
transform: `translateX(${C()}px)`,
|
|
112
112
|
top: F.value,
|
|
113
113
|
height: G.value,
|
|
114
|
-
transition:
|
|
114
|
+
transition: o.value ? "none" : `transform ${e}ms ${t.animationEasing}`
|
|
115
115
|
};
|
|
116
116
|
});
|
|
117
117
|
function m(e) {
|
|
118
|
-
var n,
|
|
119
|
-
return (n = e == null ? void 0 : e.touches) != null && n.length ? e.touches[0].clientX : (
|
|
120
|
-
}
|
|
121
|
-
function C(e) {
|
|
122
|
-
var r;
|
|
123
|
-
return !!e && ((r = e.closest) == null ? void 0 : r.call(e, 'input,textarea,select,button,a,[role="button"],[data-no-drag]'));
|
|
118
|
+
var n, l;
|
|
119
|
+
return (n = e == null ? void 0 : e.touches) != null && n.length ? e.touches[0].clientX : (l = e == null ? void 0 : e.changedTouches) != null && l.length ? e.changedTouches[0].clientX : e.clientX;
|
|
124
120
|
}
|
|
125
121
|
function D(e) {
|
|
126
|
-
|
|
122
|
+
var l;
|
|
123
|
+
return !!e && ((l = e.closest) == null ? void 0 : l.call(e, 'input,textarea,select,button,a,[role="button"],[data-no-drag]'));
|
|
127
124
|
}
|
|
128
|
-
|
|
125
|
+
function T(e) {
|
|
126
|
+
o.value = !0, h.value = e, f.value = e, b = e, g = performance.now(), y = 0, w(), s("swipe-start", { x: e, width: r.value });
|
|
127
|
+
}
|
|
128
|
+
let M = null;
|
|
129
129
|
function z(e) {
|
|
130
|
-
|
|
131
|
-
const n = performance.now(),
|
|
132
|
-
y =
|
|
130
|
+
M && cancelAnimationFrame(M), M = requestAnimationFrame(() => {
|
|
131
|
+
const n = performance.now(), l = e - b, _ = Math.max(1, n - g);
|
|
132
|
+
y = l / _, b = e, g = n, f.value = e, s("swipe-move", { x: e, progress: S.value });
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function N() {
|
|
136
136
|
const e = f.value - h.value, n = y;
|
|
137
|
-
|
|
137
|
+
o.value = !1, u.value ? t.modelValue ? d(!(e < -t.swipeThreshold || n < -t.swipeMinVelocity)) : d(e > t.swipeThreshold || n > t.swipeMinVelocity) : U.value && (t.modelValue ? d(!(e > t.swipeThreshold || n > t.swipeMinVelocity)) : d(e < -t.swipeThreshold || n < -t.swipeMinVelocity)), s("swipe-end", { opened: t.modelValue });
|
|
138
138
|
}
|
|
139
139
|
function J(e) {
|
|
140
|
-
if (!t.swipeable ||
|
|
140
|
+
if (!t.swipeable || D(e.target)) return;
|
|
141
141
|
const n = m(e);
|
|
142
142
|
pe(() => {
|
|
143
|
-
w(),
|
|
143
|
+
if (w(), t.modelValue) {
|
|
144
|
+
T(n);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
(u.value ? n <= t.swipeEdgeSize : n >= window.innerWidth - t.swipeEdgeSize) && T(n);
|
|
144
148
|
});
|
|
145
149
|
}
|
|
146
150
|
function Q(e) {
|
|
147
|
-
|
|
151
|
+
o.value && (e.preventDefault(), z(m(e)));
|
|
148
152
|
}
|
|
149
153
|
function Y() {
|
|
150
|
-
|
|
154
|
+
o.value && N();
|
|
151
155
|
}
|
|
152
|
-
function
|
|
153
|
-
if (!t.swipeable || t.permanent || t.modelValue ||
|
|
156
|
+
function $(e) {
|
|
157
|
+
if (!t.swipeable || t.permanent || t.modelValue || D(e.target)) return;
|
|
154
158
|
const n = m(e);
|
|
155
|
-
(u.value ? n <= t.swipeEdgeSize : n >= window.innerWidth - t.swipeEdgeSize) &&
|
|
159
|
+
(u.value ? n <= t.swipeEdgeSize : n >= window.innerWidth - t.swipeEdgeSize) && T(n);
|
|
156
160
|
}
|
|
157
|
-
function
|
|
158
|
-
|
|
161
|
+
function H(e) {
|
|
162
|
+
o.value && z(m(e));
|
|
159
163
|
}
|
|
160
164
|
function W() {
|
|
161
|
-
|
|
165
|
+
o.value && N();
|
|
162
166
|
}
|
|
163
167
|
function Z() {
|
|
164
168
|
t.persistent || d(!1);
|
|
165
169
|
}
|
|
166
170
|
return ee(() => {
|
|
167
|
-
w(), t.swipeable && (window.addEventListener("pointerdown",
|
|
171
|
+
w(), t.swipeable && (window.addEventListener("pointerdown", $, { passive: !0 }), window.addEventListener("pointermove", H, { passive: !0 }), window.addEventListener("pointerup", W, { passive: !0 }));
|
|
168
172
|
}), te(() => {
|
|
169
|
-
t.swipeable && (window.removeEventListener("pointerdown",
|
|
173
|
+
t.swipeable && (window.removeEventListener("pointerdown", $), window.removeEventListener("pointermove", H), window.removeEventListener("pointerup", W)), o.value = !1;
|
|
170
174
|
}), ne(() => t.modelValue, () => {
|
|
171
|
-
|
|
172
|
-
}), (e, n) => (
|
|
173
|
-
|
|
175
|
+
o.value = !1;
|
|
176
|
+
}), (e, n) => (V(), X(oe, null, [
|
|
177
|
+
ae((V(), le(re(a.tag), {
|
|
174
178
|
ref_key: "drawerEl",
|
|
175
|
-
ref:
|
|
179
|
+
ref: x,
|
|
176
180
|
class: se(["z-[2001] flex flex-col select-none will-change-transform", [
|
|
177
181
|
K.value,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
182
|
+
a.absolute ? "absolute" : "fixed",
|
|
183
|
+
a.floating ? "border-none" : "",
|
|
184
|
+
o.value ? "transition-none" : a.swipeTransition,
|
|
181
185
|
"touch-pan-y"
|
|
182
186
|
]]),
|
|
183
187
|
style: L(R.value),
|
|
@@ -188,17 +192,17 @@ const he = {
|
|
|
188
192
|
onTouchendPassive: Y
|
|
189
193
|
}, {
|
|
190
194
|
default: P(() => [
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
195
|
+
E(e.$slots, "prepend"),
|
|
196
|
+
E(e.$slots, "default"),
|
|
197
|
+
E(e.$slots, "append")
|
|
194
198
|
]),
|
|
195
199
|
_: 3
|
|
196
200
|
}, 40, ["class", "style"])), [
|
|
197
|
-
[de,
|
|
201
|
+
[de, a.modelValue || a.permanent || o.value]
|
|
198
202
|
]),
|
|
199
|
-
|
|
203
|
+
ie(ce, { name: "kun-scrim" }, {
|
|
200
204
|
default: P(() => [
|
|
201
|
-
|
|
205
|
+
a.scrim && (a.modelValue || o.value) && !a.permanent && !a.persistent ? (V(), X("div", {
|
|
202
206
|
key: 0,
|
|
203
207
|
class: "fixed inset-0 bg-black",
|
|
204
208
|
style: L({ opacity: 0.4 * (1 - S.value) }),
|