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.
@@ -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 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
- /* --- 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(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
- }), 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), 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 V() {
80
- if (!e.swipeable) return e.modelValue ? 0 : u.value ? -(l.value || 0) : l.value || 0;
81
- let t = 0;
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 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, () => {
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
- }), (t, n) => (g(), k(J, null, [
135
- Q((g(), Z(_(o.tag), {
172
+ }), (e, n) => (M(), X(ae, null, [
173
+ oe((M(), ie(re(l.tag), {
136
174
  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
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: N(j.value),
148
- onClick: n[0] || (n[0] = ee(() => {
183
+ style: L(R.value),
184
+ onClick: n[0] || (n[0] = ue(() => {
149
185
  }, ["stop"])),
150
- "<!--": "",
151
- listeners: "",
152
- locales: "",
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
- 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")
190
+ default: P(() => [
191
+ V(e.$slots, "prepend"),
192
+ V(e.$slots, "default"),
193
+ V(e.$slots, "append")
168
194
  ]),
169
- _: 3,
170
- __: [1]
171
- }, 8, ["class", "style"])), [
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
- Y(ae, { name: "kun-scrim" }, {
175
- default: $(() => [
176
- o.scrim && (o.modelValue || a.value) && !o.permanent && !o.persistent ? (g(), k("div", {
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 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)
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
- de as default
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
+ };