adverich-kun-ui 0.1.182 → 0.1.184

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.
@@ -0,0 +1,237 @@
1
+ import { ref as L, computed as p, createElementBlock as l, openBlock as s, normalizeClass as f, renderSlot as i, createElementVNode as a, normalizeProps as y, guardReactiveProps as k, unref as n, createCommentVNode as d, toDisplayString as m, createBlock as h, resolveDynamicComponent as $, Fragment as q, renderList as J, withDirectives as O, vShow as Q, createTextVNode as U } from "vue";
2
+ import { kunTextareaProps as W } from "../composables/KunTextareaProps.js";
3
+ import { useKunTextarea as X } from "../composables/useKunTextareaComposable.js";
4
+ import { renderIconSlot as C } from "../../../../utils/renderIcon.js";
5
+ const Y = {
6
+ key: 0,
7
+ class: "block text-sm font-medium mb-1"
8
+ }, Z = { class: "relative" }, x = {
9
+ key: 0,
10
+ class: "absolute left-2 top-2 flex items-center"
11
+ }, _ = {
12
+ key: 1,
13
+ class: "absolute left-2 top-2 ml-1"
14
+ }, ee = ["value", "rows", "disabled", "readonly", "placeholder"], re = {
15
+ key: 3,
16
+ class: "absolute right-2 top-2 mr-1"
17
+ }, oe = {
18
+ key: 4,
19
+ class: "absolute right-2 top-2 flex items-center"
20
+ }, ne = {
21
+ key: 5,
22
+ class: "mt-1"
23
+ }, te = { class: "h-1 w-full bg-gray-200 rounded overflow-hidden" }, se = {
24
+ key: 7,
25
+ class: "text-xs text-right mt-1 text-gray-400"
26
+ }, le = { key: 0 }, pe = {
27
+ __name: "KunTextarea",
28
+ props: W,
29
+ emits: ["update:modelValue", "click:clear", "click:control", "update:focused", "mousedown:control"],
30
+ setup(R, { expose: B, emit: S }) {
31
+ const r = R, V = S, u = L(null), {
32
+ isFocused: v,
33
+ internalValue: c,
34
+ updateValue: D,
35
+ handleClear: z,
36
+ adjustHeight: F,
37
+ validate: M,
38
+ reset: T,
39
+ resetValidation: A,
40
+ hasError: b,
41
+ displayedMessages: w
42
+ } = X(r, V, u), E = p(() => {
43
+ switch (r.variant) {
44
+ case "filled":
45
+ return "bg-gray-100 dark:bg-gray-900 border border-transparent";
46
+ case "outlined":
47
+ return "border border-gray-300 bg-transparent";
48
+ case "underlined":
49
+ return "border-b border-gray-300 bg-transparent rounded-none";
50
+ case "solo":
51
+ return "bg-white dark:bg-black shadow-md border-transparent";
52
+ default:
53
+ return "";
54
+ }
55
+ }), G = p(() => {
56
+ switch (r.density) {
57
+ case "comfortable":
58
+ return "py-2";
59
+ case "compact":
60
+ return "py-1 text-sm";
61
+ default:
62
+ return "";
63
+ }
64
+ }), N = p(() => [
65
+ "w-full resize-none p-2 transition-colors duration-150",
66
+ r.inputClass,
67
+ {
68
+ "rounded-md": !r.tile,
69
+ "rounded-none": r.tile,
70
+ [`rounded-${r.rounded}`]: typeof r.rounded == "string" || typeof r.rounded == "number",
71
+ "shadow-md": r.variant === "solo" && !r.flat,
72
+ "shadow-none": r.flat,
73
+ [`text-${r.baseColor}`]: r.baseColor,
74
+ [`bg-${r.bgColor}`]: r.bgColor,
75
+ "text-gray-500 bg-gray-200": r.disabled,
76
+ "focus:outline-none focus:ring-2": !r.disabled,
77
+ [`focus:ring-${r.color}`]: r.color && !r.disabled && !b.value,
78
+ "border-red-500 ring-red-500 focus:ring-red-500": b.value,
79
+ "resize-none": r.noResize || r.autoGrow,
80
+ resize: !r.noResize && !r.autoGrow
81
+ }
82
+ ]), P = p(() => [
83
+ "relative w-full",
84
+ r.class,
85
+ r.wrapperClass
86
+ ]), I = p(() => r.counter === !0 ? 25 : typeof r.counter == "number" || typeof r.counter == "string" ? r.counter : null), H = p(() => r.persistentCounter ? !0 : !!r.counter && v.value), K = p(() => typeof r.clearIcon == "string" ? r.clearIcon : "i-heroicons-x-mark-20-solid");
87
+ function g(e, t) {
88
+ V(`click:${t}`, e);
89
+ }
90
+ return B({
91
+ validate: M,
92
+ reset: T,
93
+ resetValidation: A,
94
+ errorMessages: w,
95
+ isValid: p(() => !b.value)
96
+ }), (e, t) => (s(), l("div", {
97
+ class: f(P.value)
98
+ }, [
99
+ i(e.$slots, "label", y(k({ label: e.label, isFocused: n(v), isActive: !!n(c), controlRef: u.value, focus: () => {
100
+ var o;
101
+ return (o = u.value) == null ? void 0 : o.focus();
102
+ }, blur: () => {
103
+ var o;
104
+ return (o = u.value) == null ? void 0 : o.blur();
105
+ }, props: r })), () => [
106
+ e.label ? (s(), l("label", Y, m(e.label), 1)) : d("", !0)
107
+ ]),
108
+ a("div", Z, [
109
+ e.prependIcon || e.$slots.prepend ? (s(), l("div", x, [
110
+ i(e.$slots, "prepend", y(k(e.prependSlotBindings)), () => [
111
+ a("div", {
112
+ onClick: t[0] || (t[0] = (o) => g(o, "prepend"))
113
+ }, [
114
+ (s(), h($(n(C)(e.prependIcon))))
115
+ ])
116
+ ])
117
+ ])) : d("", !0),
118
+ e.prependInnerIcon || e.$slots["prepend-inner"] ? (s(), l("div", _, [
119
+ i(e.$slots, "prepend-inner", {}, () => [
120
+ a("div", {
121
+ onClick: t[1] || (t[1] = (o) => g(o, "prependInner"))
122
+ }, [
123
+ (s(), h($(n(C)(e.prependInnerIcon))))
124
+ ])
125
+ ])
126
+ ])) : d("", !0),
127
+ a("textarea", {
128
+ ref_key: "textareaRef",
129
+ ref: u,
130
+ value: n(c),
131
+ rows: e.rows,
132
+ disabled: e.disabled,
133
+ readonly: e.readonly,
134
+ placeholder: e.placeholder,
135
+ onInput: t[2] || (t[2] = (o) => {
136
+ n(D)(o.target.value), e.autoGrow && n(F)();
137
+ }),
138
+ onFocus: t[3] || (t[3] = (o) => {
139
+ v.value = !0, e.$emit("update:focused", !0);
140
+ }),
141
+ onBlur: t[4] || (t[4] = (o) => {
142
+ v.value = !1, e.$emit("update:focused", !1);
143
+ }),
144
+ onClick: t[5] || (t[5] = (o) => e.$emit("click:control", o)),
145
+ onMousedown: t[6] || (t[6] = (o) => e.$emit("mousedown:control", o)),
146
+ class: f([E.value, G.value, N.value])
147
+ }, null, 42, ee),
148
+ e.clearable && n(c) ? (s(), l("div", {
149
+ key: 2,
150
+ class: f(["absolute right-2 top-2", { "opacity-100": e.persistentClear, "hover:opacity-100 opacity-0 transition-opacity duration-200": !e.persistentClear }])
151
+ }, [
152
+ i(e.$slots, "clear", y(k({ isActive: !!n(c), isFocused: n(v), controlRef: u.value, focus: () => {
153
+ var o;
154
+ return (o = u.value) == null ? void 0 : o.focus();
155
+ }, blur: () => {
156
+ var o;
157
+ return (o = u.value) == null ? void 0 : o.blur();
158
+ }, props: r })), () => [
159
+ a("button", {
160
+ type: "button",
161
+ onClick: t[7] || (t[7] = (...o) => n(z) && n(z)(...o)),
162
+ class: "text-gray-500 hover:text-gray-700"
163
+ }, [
164
+ a("span", {
165
+ class: f(K.value)
166
+ }, null, 2)
167
+ ])
168
+ ])
169
+ ], 2)) : d("", !0),
170
+ e.appendInnerIcon || e.$slots["append-inner"] ? (s(), l("div", re, [
171
+ i(e.$slots, "append-inner", {}, () => [
172
+ a("div", {
173
+ onClick: t[8] || (t[8] = (o) => g(o, "appendInner"))
174
+ }, [
175
+ (s(), h($(n(C)(e.appendInnerIcon))))
176
+ ])
177
+ ])
178
+ ])) : d("", !0),
179
+ e.appendIcon || e.$slots.append ? (s(), l("div", oe, [
180
+ i(e.$slots, "append", y(k(e.appendSlotBindings)), () => [
181
+ a("div", {
182
+ onClick: t[9] || (t[9] = (o) => g(o, "append"))
183
+ }, [
184
+ (s(), h($(n(C)(e.appendIcon))))
185
+ ])
186
+ ])
187
+ ])) : d("", !0),
188
+ e.loading ? (s(), l("div", ne, [
189
+ i(e.$slots, "loader", {
190
+ color: e.loadingColor,
191
+ isActive: !0
192
+ }, () => [
193
+ a("div", te, [
194
+ a("div", {
195
+ class: f(["h-full transition-all duration-300", [`bg-${e.loadingColor}`]]),
196
+ style: { width: "100%" }
197
+ }, null, 2)
198
+ ])
199
+ ])
200
+ ])) : d("", !0),
201
+ !e.hideDetails || e.hideDetails === "auto" && (n(w).length || e.hint) ? (s(), l("div", {
202
+ key: 6,
203
+ class: f(["text-xs mt-1 space-y-1", { "text-red-500": n(b), "text-gray-500": !n(b) }])
204
+ }, [
205
+ i(e.$slots, "details", {}, () => [
206
+ n(b) ? (s(!0), l(q, { key: 0 }, J(n(w), (o, j) => i(e.$slots, "message", {
207
+ key: j,
208
+ message: o
209
+ }, () => [
210
+ a("div", null, m(o), 1)
211
+ ])), 128)) : e.hint ? i(e.$slots, "hint", {
212
+ key: 1,
213
+ hint: e.hint
214
+ }, () => [
215
+ O(a("div", null, m(e.hint), 513), [
216
+ [Q, e.persistentHint || n(v)]
217
+ ])
218
+ ]) : d("", !0)
219
+ ])
220
+ ], 2)) : d("", !0),
221
+ H.value ? (s(), l("div", se, [
222
+ i(e.$slots, "counter", {
223
+ counter: n(c).length,
224
+ max: I.value,
225
+ value: n(c).length
226
+ }, () => [
227
+ U(m(n(c).length), 1),
228
+ I.value ? (s(), l("span", le, " / " + m(I.value), 1)) : d("", !0)
229
+ ])
230
+ ])) : d("", !0)
231
+ ])
232
+ ], 2));
233
+ }
234
+ };
235
+ export {
236
+ pe as default
237
+ };
@@ -0,0 +1,66 @@
1
+ const e = {
2
+ modelValue: [String, Number, Array, Object, Boolean],
3
+ formatModel: {
4
+ type: String,
5
+ default: "auto"
6
+ // auto | raw | json
7
+ },
8
+ label: String,
9
+ placeholder: String,
10
+ rows: { type: [String, Number], default: 1 },
11
+ autoGrow: Boolean,
12
+ noResize: Boolean,
13
+ maxRows: [Number, String],
14
+ clearable: Boolean,
15
+ clearIcon: {
16
+ type: [String, Function, Object],
17
+ default: "i-mdi-close"
18
+ },
19
+ disabled: Boolean,
20
+ readonly: Boolean,
21
+ variant: { type: String, default: "filled" },
22
+ density: { type: String, default: "default" },
23
+ // Estilo
24
+ rounded: [Boolean, String, Number],
25
+ tile: Boolean,
26
+ flat: Boolean,
27
+ color: String,
28
+ bgColor: String,
29
+ baseColor: String,
30
+ iconColor: [String, Boolean],
31
+ glow: Boolean,
32
+ class: [String, Array, Object],
33
+ inputClass: [String, Array, Object],
34
+ wrapperClass: [String, Array, Object],
35
+ // Iconos
36
+ prependIcon: [String, Object, Function, Array],
37
+ appendIcon: [String, Object, Function, Array],
38
+ prependInnerIcon: [String, Object, Function, Array],
39
+ appendInnerIcon: [String, Object, Function, Array],
40
+ // Validación
41
+ rules: {
42
+ type: Array,
43
+ default: () => []
44
+ },
45
+ error: Boolean,
46
+ errorMessages: {
47
+ type: [String, Array],
48
+ default: () => []
49
+ },
50
+ maxErrors: {
51
+ type: [String, Number],
52
+ default: 1
53
+ },
54
+ validationValue: null,
55
+ validateOn: String,
56
+ hint: String,
57
+ persistentHint: Boolean,
58
+ hideDetails: { type: [Boolean, String], default: !1 },
59
+ persistentCounter: Boolean,
60
+ // Loader
61
+ loading: Boolean,
62
+ loadingColor: { type: String, default: "bg-slate-500" }
63
+ };
64
+ export {
65
+ e as kunTextareaProps
66
+ };
@@ -0,0 +1,76 @@
1
+ import { ref as n, watch as N, nextTick as M, onMounted as T, computed as V } from "vue";
2
+ function k(t, s, l) {
3
+ const h = n(!1), w = n(t.modelValue), g = (e) => {
4
+ if (t.formatModel === "raw") return String(e ?? "");
5
+ if ((t.formatModel === "json" || t.formatModel === "auto") && typeof e == "object" && e !== null)
6
+ try {
7
+ return JSON.stringify(e, null, 2);
8
+ } catch {
9
+ return String(e);
10
+ }
11
+ return String(e ?? "");
12
+ }, m = (e) => {
13
+ if (t.formatModel === "raw") return e;
14
+ try {
15
+ const a = JSON.parse(e);
16
+ if (t.formatModel === "json" || t.formatModel === "auto")
17
+ return a;
18
+ } catch {
19
+ }
20
+ return e;
21
+ }, o = n(g(t.modelValue));
22
+ N(() => t.modelValue, (e) => {
23
+ w.value = e, o.value = g(e), t.autoGrow && M(c);
24
+ });
25
+ const v = (e) => {
26
+ o.value = e;
27
+ const a = m(e);
28
+ s("update:modelValue", a);
29
+ }, H = () => {
30
+ v(""), s("click:clear");
31
+ }, c = () => {
32
+ if (!l.value) return;
33
+ l.value.style.height = "auto", l.value.style.overflowY = "hidden";
34
+ const e = l.value.scrollHeight, a = parseFloat(getComputedStyle(l.value).lineHeight || "24"), i = Number(t.maxRows || 0);
35
+ if (t.maxRows && i > 0) {
36
+ const u = i * a;
37
+ l.value.style.height = Math.min(e, u) + "px";
38
+ } else
39
+ l.value.style.height = e + "px";
40
+ };
41
+ T(() => {
42
+ t.autoGrow && M(c);
43
+ });
44
+ const r = n([]), S = n(!0), j = (e = !1) => {
45
+ const a = t.validationValue ?? m(o.value), i = t.rules ?? [], u = [];
46
+ for (const d of i) {
47
+ const f = typeof d == "function" ? d(a) : d;
48
+ typeof f == "string" ? u.push(f) : f === !1 && u.push("Campo inválido");
49
+ }
50
+ return r.value = u.slice(0, t.maxErrors ?? 1), e || s("update:focused", h.value), r.value;
51
+ }, y = () => {
52
+ r.value = [];
53
+ }, x = () => {
54
+ o.value = "", y(), s("update:modelValue", "");
55
+ }, C = V(() => t.error || r.value.length > 0), E = V(() => {
56
+ var e;
57
+ return (e = t.errorMessages) != null && e.length ? Array.isArray(t.errorMessages) ? t.errorMessages : [t.errorMessages] : r.value;
58
+ });
59
+ return {
60
+ isFocused: h,
61
+ internalValue: o,
62
+ updateValue: v,
63
+ handleClear: H,
64
+ adjustHeight: c,
65
+ isPristine: S,
66
+ validate: j,
67
+ reset: x,
68
+ resetValidation: y,
69
+ validationErrors: r,
70
+ hasError: C,
71
+ displayedMessages: E
72
+ };
73
+ }
74
+ export {
75
+ k as useKunTextarea
76
+ };
package/dist/index.js CHANGED
@@ -14,22 +14,22 @@ import c from "./components/KunCardText/src/components/KunCardText.vue.js";
14
14
  import l from "./components/KunCardTitle/src/components/KunCardTitle.vue.js";
15
15
  import $ from "./components/KunChip/src/components/KunChip.vue.js";
16
16
  import d from "./components/KunCol/src/components/KunCol.vue.js";
17
- import C from "./components/KunContainer/src/components/KunContainer.vue.js";
18
- import L from "./components/KunCurrency/src/components/KunCurrency.vue.js";
19
- import T from "./components/KunDialog/src/components/KunDialog.vue.js";
17
+ import T from "./components/KunContainer/src/components/KunContainer.vue.js";
18
+ import C from "./components/KunCurrency/src/components/KunCurrency.vue.js";
19
+ import L from "./components/KunDialog/src/components/KunDialog.vue.js";
20
20
  import b from "./components/KunDivider/src/components/KunDivider.vue.js";
21
21
  import I from "./components/KunDrawer/src/components/KunDrawer.vue.js";
22
22
  import A from "./components/KunForm/src/components/KunForm.vue.js";
23
23
  import S from "./components/KunIcon/src/components/KunIcon.vue.js";
24
- import F from "./components/KunList/src/components/KunList.vue.js";
25
- import x from "./components/KunListGroup/src/components/KunListGroup.vue.js";
24
+ import x from "./components/KunList/src/components/KunList.vue.js";
25
+ import F from "./components/KunListGroup/src/components/KunListGroup.vue.js";
26
26
  import g from "./components/KunListImg/src/components/KunListImg.vue.js";
27
27
  import M from "./components/KunListItem/src/components/KunListItem.vue.js";
28
28
  import h from "./components/KunListItemAction/src/components/KunListItemAction.vue.js";
29
29
  import v from "./components/KunListItemAvatar/src/components/KunListItemAvatar.vue.js";
30
30
  import w from "./components/KunListItemSubtitle/src/components/KunListItemSubtitle.vue.js";
31
- import B from "./components/KunListItemTitle/src/components/KunListItemTitle.vue.js";
32
- import D from "./components/KunListItemText/src/components/KunListItemText.vue.js";
31
+ import D from "./components/KunListItemTitle/src/components/KunListItemTitle.vue.js";
32
+ import B from "./components/KunListItemText/src/components/KunListItemText.vue.js";
33
33
  import y from "./components/KunListSubheader/src/components/KunListSubheader.vue.js";
34
34
  import G from "./components/kunMenu/src/components/kunMenu.vue.js";
35
35
  import R from "./components/KunModalFooter/src/components/KunModalFooter.vue.js";
@@ -41,11 +41,12 @@ import N from "./components/KunSlider/src/components/KunSlider.vue.js";
41
41
  import E from "./components/KunSpacer/src/components/KunSpacer.vue.js";
42
42
  import H from "./components/KunSwitch/src/components/KunSwitch.vue.js";
43
43
  import J from "./components/KunTable/src/components/KunTable.vue.js";
44
- import O from "./components/KunTextField/src/components/KunTextField.vue.js";
45
- import P from "./components/KunToolbar/src/components/KunToolbar.vue.js";
46
- import Q from "./components/KunToolbar/src/components/KunToolbarTitle.vue.js";
47
- import U from "./components/KunTooltip/src/components/KunTooltip.vue.js";
48
- const n = {
44
+ import O from "./components/KunTextarea/src/components/KunTextarea.vue.js";
45
+ import P from "./components/KunTextField/src/components/KunTextField.vue.js";
46
+ import Q from "./components/KunToolbar/src/components/KunToolbar.vue.js";
47
+ import U from "./components/KunToolbar/src/components/KunToolbarTitle.vue.js";
48
+ import V from "./components/KunTooltip/src/components/KunTooltip.vue.js";
49
+ const r = {
49
50
  KunAlert: o,
50
51
  KunAppbar: i,
51
52
  KunAppbarTitle: t,
@@ -57,26 +58,26 @@ const n = {
57
58
  KunCardActions: _,
58
59
  KunCardItem: e,
59
60
  KunCardSubtitle: p,
60
- KunListItemTitle: B,
61
+ KunListItemTitle: D,
61
62
  KunCardText: c,
62
63
  KunCardTitle: l,
63
64
  KunChip: $,
64
65
  KunCol: d,
65
- KunContainer: C,
66
- KunCurrency: L,
67
- KunDialog: T,
66
+ KunContainer: T,
67
+ KunCurrency: C,
68
+ KunDialog: L,
68
69
  KunDivider: b,
69
70
  KunDrawer: I,
70
71
  KunForm: A,
71
72
  KunIcon: S,
72
- KunList: F,
73
- KunListGroup: x,
73
+ KunList: x,
74
+ KunListGroup: F,
74
75
  KunListImg: g,
75
76
  KunListItem: M,
76
77
  KunListItemAction: h,
77
78
  KunListItemAvatar: v,
78
79
  KunListItemSubtitle: w,
79
- KunListItemText: D,
80
+ KunListItemText: B,
80
81
  KunListSubheader: y,
81
82
  KunMenu: G,
82
83
  KunModalFooter: R,
@@ -88,14 +89,15 @@ const n = {
88
89
  KunSpacer: E,
89
90
  KunSwitch: H,
90
91
  KunTable: J,
91
- KunTextField: O,
92
- KunToolbar: P,
93
- KunToolbarTitle: Q,
94
- KunTooltip: U
92
+ KunTextarea: O,
93
+ KunTextField: P,
94
+ KunToolbar: Q,
95
+ KunToolbarTitle: U,
96
+ KunTooltip: V
95
97
  };
96
- function Em(r) {
97
- for (const m in n)
98
- r.component(m, n[m]);
98
+ function Jm(n) {
99
+ for (const m in r)
100
+ n.component(m, r[m]);
99
101
  }
100
102
  export {
101
103
  o as KunAlert,
@@ -113,22 +115,22 @@ export {
113
115
  l as KunCardTitle,
114
116
  $ as KunChip,
115
117
  d as KunCol,
116
- C as KunContainer,
117
- L as KunCurrency,
118
- T as KunDialog,
118
+ T as KunContainer,
119
+ C as KunCurrency,
120
+ L as KunDialog,
119
121
  b as KunDivider,
120
122
  I as KunDrawer,
121
123
  A as KunForm,
122
124
  S as KunIcon,
123
- F as KunList,
124
- x as KunListGroup,
125
+ x as KunList,
126
+ F as KunListGroup,
125
127
  g as KunListImg,
126
128
  M as KunListItem,
127
129
  h as KunListItemAction,
128
130
  v as KunListItemAvatar,
129
131
  w as KunListItemSubtitle,
130
- D as KunListItemText,
131
- B as KunListItemTitle,
132
+ B as KunListItemText,
133
+ D as KunListItemTitle,
132
134
  y as KunListSubheader,
133
135
  q as KunLoaderCircular,
134
136
  G as KunMenu,
@@ -139,9 +141,10 @@ export {
139
141
  E as KunSpacer,
140
142
  H as KunSwitch,
141
143
  J as KunTable,
142
- O as KunTextField,
143
- P as KunToolbar,
144
- Q as KunToolbarTitle,
145
- U as KunTooltip,
146
- Em as install
144
+ P as KunTextField,
145
+ O as KunTextarea,
146
+ Q as KunToolbar,
147
+ U as KunToolbarTitle,
148
+ V as KunTooltip,
149
+ Jm as install
147
150
  };
@@ -0,0 +1,6 @@
1
+ function r(e, n = {}, t = null) {
2
+ return e ? typeof e == "string" ? h("span", { class: e, ...n }) : typeof e == "function" ? h(e, n) : h(resolveComponent("KunIcon"), { icon: e, ...n }) : t;
3
+ }
4
+ export {
5
+ r as renderIconSlot
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.182",
3
+ "version": "0.1.184",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",