adverich-kun-ui 0.1.447 → 0.1.448
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/adverich-kun-ui.css +1 -1
- package/dist/components/KunDrawer/src/components/KunDrawer copy.vue.js +74 -139
- package/dist/components/KunDrawer/src/components/KunDrawer.vue.js +155 -133
- package/dist/components/KunSkeleton/src/components/KunSkeleton.vue.js +51 -0
- package/dist/index.js +140 -137
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ref as c, computed as
|
|
2
|
-
import { useAppbarHeight as
|
|
3
|
-
const
|
|
1
|
+
import { ref as c, computed as i, onMounted as ee, onBeforeUnmount as te, watch as ne, createElementBlock as X, openBlock as M, Fragment as ae, withDirectives as oe, createVNode as le, createBlock as ie, resolveDynamicComponent as re, withModifiers as ue, normalizeStyle as L, normalizeClass as se, withCtx as P, renderSlot as V, vShow as de, Transition as ce, createCommentVNode as fe, nextTick as pe } from "vue";
|
|
2
|
+
import { useAppbarHeight as me } from "../../../../utils/useLayout.js";
|
|
3
|
+
const he = {
|
|
4
4
|
__name: "KunDrawer",
|
|
5
5
|
props: {
|
|
6
6
|
modelValue: Boolean,
|
|
@@ -11,7 +11,6 @@ const de = {
|
|
|
11
11
|
floating: Boolean,
|
|
12
12
|
image: String,
|
|
13
13
|
location: { type: String, default: "start" },
|
|
14
|
-
// start|end|left|right|top|bottom
|
|
15
14
|
permanent: Boolean,
|
|
16
15
|
persistent: Boolean,
|
|
17
16
|
rail: Boolean,
|
|
@@ -23,32 +22,42 @@ const de = {
|
|
|
23
22
|
width: { type: String, default: "w-[256px]" },
|
|
24
23
|
fullHeight: Boolean,
|
|
25
24
|
scrollable: { type: Boolean, default: !0 },
|
|
26
|
-
/*
|
|
25
|
+
/* Swipe */
|
|
27
26
|
swipeable: { type: Boolean, default: !1 },
|
|
28
27
|
swipeThreshold: { type: Number, default: 50 },
|
|
29
|
-
// px para decidir apertura/cierre
|
|
30
28
|
swipeEdgeSize: { type: Number, default: 30 },
|
|
31
|
-
// px desde el borde para iniciar si está cerrado
|
|
32
29
|
swipeTransition: { type: String, default: "transition-transform duration-300 ease-in-out" },
|
|
33
|
-
/* --- extras (opcionales) --- */
|
|
34
30
|
swipeHandleSize: { type: Number, default: 24 },
|
|
35
|
-
// zona interna para comenzar drag cuando está abierto
|
|
36
31
|
swipeMinVelocity: { type: Number, default: 0.35 },
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
scrimTransition: { type: String, default: "opacity 200ms ease" },
|
|
33
|
+
animationDuration: { type: Number, default: 300 },
|
|
34
|
+
animationEasing: { type: String, default: "ease-in-out" },
|
|
35
|
+
/* Nuevo */
|
|
36
|
+
peekSize: { type: Number, default: 0 }
|
|
37
|
+
// borde visible cuando está cerrado
|
|
39
38
|
},
|
|
40
|
-
emits: [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
emits: [
|
|
40
|
+
"update:model-value",
|
|
41
|
+
"update:modelValue",
|
|
42
|
+
"swipe-start",
|
|
43
|
+
"swipe-move",
|
|
44
|
+
"swipe-end"
|
|
45
|
+
],
|
|
46
|
+
setup(l, { emit: A }) {
|
|
47
|
+
const s = A;
|
|
48
|
+
function d(e) {
|
|
49
|
+
s("update:model-value", e), s("update:modelValue", e);
|
|
50
|
+
}
|
|
51
|
+
const t = l, E = me(), B = c(null), o = c(256);
|
|
52
|
+
let v = 256;
|
|
53
|
+
function w() {
|
|
54
|
+
var e;
|
|
55
|
+
v = ((e = B.value) == null ? void 0 : e.offsetWidth) || v, o.value = v;
|
|
56
|
+
}
|
|
57
|
+
const F = i(() => t.fullHeight ? "0px" : `${E.value}px`), G = i(
|
|
58
|
+
() => t.fullHeight ? typeof window < "u" && window.innerWidth < 768 ? "100dvh" : "100vh" : `calc(100vh - ${E.value}px)`
|
|
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
|
+
switch (t.location) {
|
|
52
61
|
case "start":
|
|
53
62
|
case "left":
|
|
54
63
|
return "left-0 top-0 h-full";
|
|
@@ -62,126 +71,139 @@ const de = {
|
|
|
62
71
|
default:
|
|
63
72
|
return "left-0 top-0 h-full";
|
|
64
73
|
}
|
|
65
|
-
}),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
]),
|
|
74
|
-
let
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
return
|
|
74
|
+
}), q = i(() => t.border ? typeof t.border == "string" ? `border-${t.border}` : "border" : ""), I = i(() => t.rounded === !0 ? u.value ? "rounded-r" : "rounded-l" : typeof t.rounded == "string" ? t.rounded : typeof t.rounded == "number" ? `rounded-[${t.rounded}px]` : ""), K = i(() => [
|
|
75
|
+
j.value,
|
|
76
|
+
O.value,
|
|
77
|
+
q.value,
|
|
78
|
+
t.elevation ? `shadow-${t.elevation}` : "",
|
|
79
|
+
I.value,
|
|
80
|
+
t.color ?? "bg-surface-dark",
|
|
81
|
+
t.scrollable ? "overflow-auto" : ""
|
|
82
|
+
]), h = c(0), f = c(0), a = c(!1);
|
|
83
|
+
let g = 0, b = 0, y = 0;
|
|
84
|
+
const S = i(() => {
|
|
85
|
+
const e = k(), n = o.value || 1;
|
|
86
|
+
return Math.min(1, Math.max(0, 1 - Math.abs(e) / n));
|
|
78
87
|
});
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
function p() {
|
|
89
|
+
const e = a.value ? 0 : t.peekSize;
|
|
90
|
+
return u.value ? -o.value + e : o.value - e;
|
|
91
|
+
}
|
|
92
|
+
function x() {
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
function k() {
|
|
96
|
+
if (!t.swipeable)
|
|
97
|
+
return t.modelValue ? x() : p();
|
|
82
98
|
if (a.value) {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
return t;
|
|
87
|
-
}
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
function
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
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(o.value, p() + e) : Math.max(-o.value, p() + e);
|
|
101
|
+
}
|
|
102
|
+
return t.modelValue ? x() : p();
|
|
103
|
+
}
|
|
104
|
+
const R = i(() => {
|
|
105
|
+
let e = t.animationDuration;
|
|
106
|
+
if (!a.value) {
|
|
107
|
+
const n = o.value * (1 - S.value);
|
|
108
|
+
e = Math.max(120, Math.min(300, n * 1.2));
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
transform: `translateX(${k()}px)`,
|
|
112
|
+
top: F.value,
|
|
113
|
+
height: G.value,
|
|
114
|
+
transition: a.value ? "none" : `transform ${e}ms ${t.animationEasing}`
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
function m(e) {
|
|
118
|
+
var n, r;
|
|
119
|
+
return (n = e == null ? void 0 : e.touches) != null && n.length ? e.touches[0].clientX : (r = e == null ? void 0 : e.changedTouches) != null && r.length ? e.changedTouches[0].clientX : e.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]'));
|
|
124
|
+
}
|
|
125
|
+
function D(e) {
|
|
126
|
+
a.value = !0, h.value = e, f.value = e, b = e, g = performance.now(), y = 0, w(), s("swipe-start", { x: e, width: o.value });
|
|
127
|
+
}
|
|
128
|
+
let T = null;
|
|
129
|
+
function z(e) {
|
|
130
|
+
T && cancelAnimationFrame(T), T = requestAnimationFrame(() => {
|
|
131
|
+
const n = performance.now(), r = e - b, _ = Math.max(1, n - g);
|
|
132
|
+
y = r / _, b = e, g = n, f.value = e, s("swipe-move", { x: e, progress: S.value });
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function H() {
|
|
136
|
+
const e = f.value - h.value, n = y;
|
|
137
|
+
a.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
|
+
}
|
|
139
|
+
function J(e) {
|
|
140
|
+
if (!t.swipeable || !t.modelValue || C(e.target)) return;
|
|
141
|
+
const n = m(e);
|
|
142
|
+
pe(() => {
|
|
143
|
+
w(), (u.value ? n >= o.value - t.swipeHandleSize && n <= o.value + 8 : n <= window.innerWidth - (o.value - t.swipeHandleSize) && n >= window.innerWidth - o.value - 8) && D(n);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function Q(e) {
|
|
147
|
+
a.value && (e.preventDefault(), z(m(e)));
|
|
148
|
+
}
|
|
149
|
+
function Y() {
|
|
150
|
+
a.value && H();
|
|
151
|
+
}
|
|
152
|
+
function N(e) {
|
|
153
|
+
if (!t.swipeable || t.permanent || t.modelValue || C(e.target)) return;
|
|
154
|
+
const n = m(e);
|
|
155
|
+
(u.value ? n <= t.swipeEdgeSize : n >= window.innerWidth - t.swipeEdgeSize) && D(n);
|
|
156
|
+
}
|
|
157
|
+
function $(e) {
|
|
158
|
+
a.value && z(m(e));
|
|
159
|
+
}
|
|
160
|
+
function W() {
|
|
161
|
+
a.value && H();
|
|
162
|
+
}
|
|
163
|
+
function Z() {
|
|
164
|
+
t.persistent || d(!1);
|
|
165
|
+
}
|
|
166
|
+
return ee(() => {
|
|
167
|
+
w(), t.swipeable && (window.addEventListener("pointerdown", N, { passive: !0 }), window.addEventListener("pointermove", $, { passive: !0 }), window.addEventListener("pointerup", W, { passive: !0 }));
|
|
168
|
+
}), te(() => {
|
|
169
|
+
t.swipeable && (window.removeEventListener("pointerdown", N), window.removeEventListener("pointermove", $), window.removeEventListener("pointerup", W)), a.value = !1;
|
|
170
|
+
}), ne(() => t.modelValue, () => {
|
|
133
171
|
a.value = !1;
|
|
134
|
-
}), (
|
|
135
|
-
|
|
172
|
+
}), (e, n) => (M(), X(ae, null, [
|
|
173
|
+
oe((M(), ie(re(l.tag), {
|
|
136
174
|
ref_key: "drawerEl",
|
|
137
|
-
ref:
|
|
138
|
-
class:
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
a.value ? "transition-none" : o.swipeTransition,
|
|
144
|
-
// permite scroll vertical dentro, pero gestos horizontales del drawer
|
|
175
|
+
ref: B,
|
|
176
|
+
class: se(["z-[2001] flex flex-col select-none will-change-transform", [
|
|
177
|
+
K.value,
|
|
178
|
+
l.absolute ? "absolute" : "fixed",
|
|
179
|
+
l.floating ? "border-none" : "",
|
|
180
|
+
a.value ? "transition-none" : l.swipeTransition,
|
|
145
181
|
"touch-pan-y"
|
|
146
182
|
]]),
|
|
147
|
-
style:
|
|
148
|
-
onClick: n[0] || (n[0] =
|
|
183
|
+
style: L(R.value),
|
|
184
|
+
onClick: n[0] || (n[0] = ue(() => {
|
|
149
185
|
}, ["stop"])),
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
"(cuando": "",
|
|
154
|
-
está: "",
|
|
155
|
-
abierto: "",
|
|
156
|
-
o: "",
|
|
157
|
-
ya: "",
|
|
158
|
-
se: "",
|
|
159
|
-
activó: "",
|
|
160
|
-
"isDragging)": "",
|
|
161
|
-
"--": ""
|
|
186
|
+
onTouchstartPassive: J,
|
|
187
|
+
onTouchmove: Q,
|
|
188
|
+
onTouchendPassive: Y
|
|
162
189
|
}, {
|
|
163
|
-
default:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
b(t.$slots, "append")
|
|
190
|
+
default: P(() => [
|
|
191
|
+
V(e.$slots, "prepend"),
|
|
192
|
+
V(e.$slots, "default"),
|
|
193
|
+
V(e.$slots, "append")
|
|
168
194
|
]),
|
|
169
|
-
_: 3
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
[oe, o.modelValue || o.permanent || a.value]
|
|
195
|
+
_: 3
|
|
196
|
+
}, 40, ["class", "style"])), [
|
|
197
|
+
[de, l.modelValue || l.permanent || a.value]
|
|
173
198
|
]),
|
|
174
|
-
|
|
175
|
-
default:
|
|
176
|
-
|
|
199
|
+
le(ce, { name: "kun-scrim" }, {
|
|
200
|
+
default: P(() => [
|
|
201
|
+
l.scrim && (l.modelValue || a.value) && !l.permanent && !l.persistent ? (M(), X("div", {
|
|
177
202
|
key: 0,
|
|
178
|
-
class: "fixed inset-0
|
|
179
|
-
style:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}),
|
|
183
|
-
onClick: K
|
|
184
|
-
}, null, 4)) : le("", !0)
|
|
203
|
+
class: "fixed inset-0 bg-black",
|
|
204
|
+
style: L({ opacity: 0.4 * (1 - S.value) }),
|
|
205
|
+
onClick: Z
|
|
206
|
+
}, null, 4)) : fe("", !0)
|
|
185
207
|
]),
|
|
186
208
|
_: 1
|
|
187
209
|
})
|
|
@@ -189,5 +211,5 @@ const de = {
|
|
|
189
211
|
}
|
|
190
212
|
};
|
|
191
213
|
export {
|
|
192
|
-
|
|
214
|
+
he as default
|
|
193
215
|
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { computed as t, createElementBlock as u, renderSlot as s, openBlock as d, normalizeStyle as m, normalizeClass as p } from "vue";
|
|
2
|
+
const h = {
|
|
3
|
+
__name: "KunSkeleton",
|
|
4
|
+
props: {
|
|
5
|
+
loading: { type: Boolean, default: !0 },
|
|
6
|
+
variant: { type: String, default: "rect" },
|
|
7
|
+
// rect, circle, text
|
|
8
|
+
width: { type: [String, Number], default: "100%" },
|
|
9
|
+
height: { type: [String, Number], default: "1rem" },
|
|
10
|
+
rounded: { type: String, default: "md" },
|
|
11
|
+
// none, sm, md, lg, full
|
|
12
|
+
animation: { type: String, default: "shimmer" },
|
|
13
|
+
// shimmer, pulse, shimmer-vertical, none
|
|
14
|
+
duration: { type: Number, default: 1500 },
|
|
15
|
+
// ms
|
|
16
|
+
colorFrom: { type: String, default: "bg-gray-200" },
|
|
17
|
+
colorTo: { type: String, default: "bg-gray-300" },
|
|
18
|
+
repeat: { type: Boolean, default: !0 },
|
|
19
|
+
class: { type: [String, Array, Object], default: "" }
|
|
20
|
+
},
|
|
21
|
+
setup(r) {
|
|
22
|
+
const e = r, a = t(() => {
|
|
23
|
+
switch (e.variant) {
|
|
24
|
+
case "circle":
|
|
25
|
+
return "rounded-full aspect-square";
|
|
26
|
+
case "text":
|
|
27
|
+
return "rounded-sm";
|
|
28
|
+
default:
|
|
29
|
+
return `rounded-${e.rounded}`;
|
|
30
|
+
}
|
|
31
|
+
}), n = t(() => e.animation === "none" ? "" : e.animation === "pulse" ? "animate-pulse" : e.animation === "shimmer" ? "bg-gradient-to-r from-transparent via-white/50 to-transparent bg-[length:200%_100%] animate-[shimmerX_var]".replace("var", `${e.duration}ms`) : e.animation === "shimmer-vertical" ? "bg-gradient-to-b from-transparent via-white/50 to-transparent bg-[length:100%_200%] animate-[shimmerY_var]".replace("var", `${e.duration}ms`) : ""), i = t(() => [
|
|
32
|
+
"relative overflow-hidden",
|
|
33
|
+
e.colorFrom,
|
|
34
|
+
e.colorTo,
|
|
35
|
+
a.value,
|
|
36
|
+
n.value,
|
|
37
|
+
e.class
|
|
38
|
+
]), o = t(() => ({
|
|
39
|
+
width: typeof e.width == "number" ? `${e.width}px` : e.width,
|
|
40
|
+
height: typeof e.height == "number" ? `${e.height}px` : e.height
|
|
41
|
+
}));
|
|
42
|
+
return (l, c) => r.loading ? (d(), u("div", {
|
|
43
|
+
key: 0,
|
|
44
|
+
class: p(i.value),
|
|
45
|
+
style: m(o.value)
|
|
46
|
+
}, null, 6)) : s(l.$slots, "default", { key: 1 });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
h as default
|
|
51
|
+
};
|