adverich-kun-ui 0.1.447 → 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,6 +1,6 @@
1
- import { ref as c, computed as r, onMounted as O, onBeforeUnmount as R, watch as q, createElementBlock as k, openBlock as g, Fragment as J, withDirectives as Q, createVNode as Y, createBlock as Z, resolveDynamicComponent as _, withModifiers as ee, normalizeStyle as N, normalizeClass as te, withCtx as $, createTextVNode as ne, renderSlot as b, vShow as oe, Transition as ae, createCommentVNode as le, nextTick as re } from "vue";
2
- import { useAppbarHeight as ie } from "../../../../utils/useLayout.js";
3
- const de = {
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
+ 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
- /* --- NUEVAS / ya tenías --- */
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
- // px/ms para "flick" (abrir/cerrar aunque no llegue al threshold)
38
- scrimTransition: { type: String, default: "opacity 200ms ease" }
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: ["update:model-value", "update:modelValue"],
41
- setup(o, { emit: X }) {
42
- const y = X;
43
- function i(t) {
44
- y("update:model-value", t), y("update:modelValue", t);
45
- }
46
- const e = o, M = ie(), S = c(null), z = r(
47
- () => e.fullHeight ? "0px" : `${M.value}px`
48
- ), D = r(
49
- () => e.fullHeight ? typeof window < "u" && window.innerWidth < 768 ? "100dvh" : "100vh" : `calc(100vh - ${M.value}px)`
50
- ), H = r(() => e.rail ? e.railWidth : e.width), L = r(() => {
51
- switch (e.location) {
39
+ emits: [
40
+ "update:model-value",
41
+ "update:modelValue",
42
+ "swipe-start",
43
+ "swipe-move",
44
+ "swipe-end"
45
+ ],
46
+ setup(a, { emit: A }) {
47
+ const s = A;
48
+ function d(e) {
49
+ s("update:model-value", e), s("update:modelValue", e);
50
+ }
51
+ const t = a, B = me(), x = c(null), r = c(256);
52
+ let v = 256;
53
+ function w() {
54
+ var e;
55
+ v = ((e = x.value) == null ? void 0 : e.offsetWidth) || v, r.value = v;
56
+ }
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
+ ), 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,143 @@ const de = {
62
71
  default:
63
72
  return "left-0 top-0 h-full";
64
73
  }
65
- }), u = r(() => ["start", "left"].includes(e.location)), p = r(() => ["end", "right"].includes(e.location)), W = r(() => e.border ? typeof e.border == "string" ? `border-${e.border}` : "border" : ""), P = r(() => e.rounded === !0 ? u.value ? "rounded-r" : "rounded-l" : typeof e.rounded == "string" ? e.rounded : typeof e.rounded == "number" ? `rounded-[${e.rounded}px]` : ""), G = r(() => [
66
- L.value,
67
- H.value,
68
- W.value,
69
- e.elevation ? `shadow-${e.elevation}` : "",
70
- P.value,
71
- e.color ?? "bg-surface-dark",
72
- e.scrollable ? "overflow-auto" : ""
73
- ]), v = c(0), f = c(0), a = c(!1), l = c(0);
74
- let m = 0, w = 0, h = 0;
75
- const U = r(() => {
76
- const t = V(), n = l.value || 1;
77
- return u.value || p.value ? Math.min(1, Math.max(0, 1 - Math.abs(t) / n)) : e.modelValue ? 1 : 0;
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), o = c(!1);
83
+ let g = 0, b = 0, y = 0;
84
+ const S = i(() => {
85
+ const e = C(), n = r.value || 1;
86
+ return Math.min(1, Math.max(0, 1 - Math.abs(e) / n));
87
+ });
88
+ function p() {
89
+ const e = o.value ? 0 : t.peekSize;
90
+ return u.value ? -r.value + e : r.value - e;
91
+ }
92
+ function k() {
93
+ return 0;
94
+ }
95
+ function C() {
96
+ if (!t.swipeable)
97
+ return t.modelValue ? k() : p();
98
+ if (o.value) {
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(r.value, p() + e) : Math.max(-r.value, p() + e);
101
+ }
102
+ return t.modelValue ? k() : p();
103
+ }
104
+ const R = i(() => {
105
+ let e = t.animationDuration;
106
+ if (!o.value) {
107
+ const n = r.value * (1 - S.value);
108
+ e = Math.max(120, Math.min(300, n * 1.2));
109
+ }
110
+ return {
111
+ transform: `translateX(${C()}px)`,
112
+ top: F.value,
113
+ height: G.value,
114
+ transition: o.value ? "none" : `transform ${e}ms ${t.animationEasing}`
115
+ };
78
116
  });
79
- function V() {
80
- if (!e.swipeable) return e.modelValue ? 0 : u.value ? -(l.value || 0) : l.value || 0;
81
- let t = 0;
82
- if (a.value) {
83
- const n = f.value - v.value;
84
- u.value ? t = e.modelValue ? Math.min(0, n) : Math.min(l.value, -(l.value - n)) : p.value && (t = e.modelValue ? Math.max(0, n) : Math.max(-l.value, l.value + n));
85
- } else e.modelValue || (t = u.value ? -l.value : l.value);
86
- return t;
87
- }
88
- const j = r(() => ({
89
- transform: `translateX(${V()}px)`,
90
- top: z.value,
91
- height: D.value
92
- }));
93
- function x(t) {
94
- var n, s;
95
- return (n = t == null ? void 0 : t.touches) != null && n.length ? t.touches[0].clientX : (s = t == null ? void 0 : t.changedTouches) != null && s.length ? t.changedTouches[0].clientX : t.clientX;
96
- }
97
- function A(t) {
98
- var s;
99
- return !!t && ((s = t.closest) == null ? void 0 : s.call(t, 'input,textarea,select,button,a,[role="button"],[data-no-drag]'));
100
- }
101
- function T(t) {
102
- if (!e.swipeable || e.permanent || e.modelValue || A(t.target)) return;
103
- const n = x(t);
104
- (u.value ? n <= e.swipeEdgeSize : n >= window.innerWidth - e.swipeEdgeSize) && (a.value = !0, v.value = n, f.value = n, w = n, m = performance.now(), h = 0, re(() => {
105
- var d, C;
106
- l.value = ((C = (d = S.value) == null ? void 0 : d.getBoundingClientRect) == null ? void 0 : C.call(d).width) || l.value || 256;
107
- }));
108
- }
109
- function B(t) {
110
- if (!a.value) return;
111
- const n = x(t);
112
- F(n);
113
- }
114
- function E() {
115
- a.value && I();
116
- }
117
- function F(t) {
118
- const n = performance.now(), s = t - w, d = Math.max(1, n - m);
119
- h = s / d, w = t, m = n, f.value = t;
120
- }
121
- function I() {
122
- const t = f.value - v.value, n = h;
123
- a.value = !1, u.value ? e.modelValue ? t < -e.swipeThreshold || n < -e.swipeMinVelocity ? i(!1) : i(!0) : t > e.swipeThreshold || n > e.swipeMinVelocity ? i(!0) : i(!1) : p.value && (e.modelValue ? t > e.swipeThreshold || n > e.swipeMinVelocity ? i(!1) : i(!0) : t < -e.swipeThreshold || n < -e.swipeMinVelocity ? i(!0) : i(!1));
124
- }
125
- const K = () => {
126
- e.persistent || i(!1);
127
- };
128
- return O(() => {
129
- e.swipeable && (window.addEventListener("pointerdown", T, { passive: !0 }), window.addEventListener("pointermove", B, { passive: !0 }), window.addEventListener("pointerup", E, { passive: !0 }));
130
- }), R(() => {
131
- e.swipeable && (window.removeEventListener("pointerdown", T), window.removeEventListener("pointermove", B), window.removeEventListener("pointerup", E), a.value = !1);
132
- }), q(() => e.modelValue, () => {
133
- a.value = !1;
134
- }), (t, n) => (g(), k(J, null, [
135
- Q((g(), Z(_(o.tag), {
117
+ function m(e) {
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;
120
+ }
121
+ function D(e) {
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]'));
124
+ }
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
+ function z(e) {
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
+ });
134
+ }
135
+ function N() {
136
+ const e = f.value - h.value, n = y;
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
+ }
139
+ function J(e) {
140
+ if (!t.swipeable || D(e.target)) return;
141
+ const n = m(e);
142
+ pe(() => {
143
+ if (w(), t.modelValue) {
144
+ T(n);
145
+ return;
146
+ }
147
+ (u.value ? n <= t.swipeEdgeSize : n >= window.innerWidth - t.swipeEdgeSize) && T(n);
148
+ });
149
+ }
150
+ function Q(e) {
151
+ o.value && (e.preventDefault(), z(m(e)));
152
+ }
153
+ function Y() {
154
+ o.value && N();
155
+ }
156
+ function $(e) {
157
+ if (!t.swipeable || t.permanent || t.modelValue || D(e.target)) return;
158
+ const n = m(e);
159
+ (u.value ? n <= t.swipeEdgeSize : n >= window.innerWidth - t.swipeEdgeSize) && T(n);
160
+ }
161
+ function H(e) {
162
+ o.value && z(m(e));
163
+ }
164
+ function W() {
165
+ o.value && N();
166
+ }
167
+ function Z() {
168
+ t.persistent || d(!1);
169
+ }
170
+ return ee(() => {
171
+ w(), t.swipeable && (window.addEventListener("pointerdown", $, { passive: !0 }), window.addEventListener("pointermove", H, { passive: !0 }), window.addEventListener("pointerup", W, { passive: !0 }));
172
+ }), te(() => {
173
+ t.swipeable && (window.removeEventListener("pointerdown", $), window.removeEventListener("pointermove", H), window.removeEventListener("pointerup", W)), o.value = !1;
174
+ }), ne(() => t.modelValue, () => {
175
+ o.value = !1;
176
+ }), (e, n) => (V(), X(oe, null, [
177
+ ae((V(), le(re(a.tag), {
136
178
  ref_key: "drawerEl",
137
- ref: S,
138
- class: te(["fixed z-[2001] flex flex-col select-none will-change-transform", [
139
- G.value,
140
- o.absolute ? "absolute" : "fixed",
141
- o.floating ? "border-none" : "",
142
- // cuando arrastro: sin transición; cuando suelto/aprieto: usa la transición configurable
143
- a.value ? "transition-none" : o.swipeTransition,
144
- // permite scroll vertical dentro, pero gestos horizontales del drawer
179
+ ref: x,
180
+ class: se(["z-[2001] flex flex-col select-none will-change-transform", [
181
+ K.value,
182
+ a.absolute ? "absolute" : "fixed",
183
+ a.floating ? "border-none" : "",
184
+ o.value ? "transition-none" : a.swipeTransition,
145
185
  "touch-pan-y"
146
186
  ]]),
147
- style: N(j.value),
148
- onClick: n[0] || (n[0] = ee(() => {
187
+ style: L(R.value),
188
+ onClick: n[0] || (n[0] = ue(() => {
149
189
  }, ["stop"])),
150
- "<!--": "",
151
- listeners: "",
152
- locales: "",
153
- "(cuando": "",
154
- está: "",
155
- abierto: "",
156
- o: "",
157
- ya: "",
158
- se: "",
159
- activó: "",
160
- "isDragging)": "",
161
- "--": ""
190
+ onTouchstartPassive: J,
191
+ onTouchmove: Q,
192
+ onTouchendPassive: Y
162
193
  }, {
163
- default: $(() => [
164
- n[1] || (n[1] = ne(' @touchstart.passive="onTouchStart" @touchmove.passive="onTouchMove" @touchend.passive="onTouchEnd" > ')),
165
- b(t.$slots, "prepend"),
166
- b(t.$slots, "default"),
167
- b(t.$slots, "append")
194
+ default: P(() => [
195
+ E(e.$slots, "prepend"),
196
+ E(e.$slots, "default"),
197
+ E(e.$slots, "append")
168
198
  ]),
169
- _: 3,
170
- __: [1]
171
- }, 8, ["class", "style"])), [
172
- [oe, o.modelValue || o.permanent || a.value]
199
+ _: 3
200
+ }, 40, ["class", "style"])), [
201
+ [de, a.modelValue || a.permanent || o.value]
173
202
  ]),
174
- Y(ae, { name: "kun-scrim" }, {
175
- default: $(() => [
176
- o.scrim && (o.modelValue || a.value) && !o.permanent && !o.persistent ? (g(), k("div", {
203
+ ie(ce, { name: "kun-scrim" }, {
204
+ default: P(() => [
205
+ a.scrim && (a.modelValue || o.value) && !a.permanent && !a.persistent ? (V(), X("div", {
177
206
  key: 0,
178
- class: "fixed inset-0 z-30",
179
- style: N({
180
- backgroundColor: `rgba(0,0,0,${0.4 * U.value})`,
181
- transition: a.value ? "none" : o.scrimTransition
182
- }),
183
- onClick: K
184
- }, null, 4)) : le("", !0)
207
+ class: "fixed inset-0 bg-black",
208
+ style: L({ opacity: 0.4 * (1 - S.value) }),
209
+ onClick: Z
210
+ }, null, 4)) : fe("", !0)
185
211
  ]),
186
212
  _: 1
187
213
  })
@@ -189,5 +215,5 @@ const de = {
189
215
  }
190
216
  };
191
217
  export {
192
- de as default
218
+ he as default
193
219
  };
@@ -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
+ };