adverich-kun-ui 0.1.182 → 0.1.183

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,77 @@
1
+ const e = {
2
+ modelValue: [String, Number],
3
+ label: String,
4
+ placeholder: String,
5
+ rows: {
6
+ type: [String, Number],
7
+ default: 1
8
+ },
9
+ autoGrow: Boolean,
10
+ noResize: Boolean,
11
+ maxRows: [Number, String],
12
+ // 🔧 Agregado
13
+ clearable: Boolean,
14
+ clearIcon: {
15
+ type: [String, Function, Object],
16
+ default: "i-mdi-close"
17
+ },
18
+ disabled: Boolean,
19
+ readonly: Boolean,
20
+ variant: {
21
+ type: String,
22
+ default: "filled"
23
+ },
24
+ density: {
25
+ type: String,
26
+ default: "default"
27
+ },
28
+ // Estilo
29
+ rounded: [Boolean, String, Number],
30
+ tile: Boolean,
31
+ flat: Boolean,
32
+ color: String,
33
+ bgColor: String,
34
+ baseColor: String,
35
+ iconColor: [String, Boolean],
36
+ glow: Boolean,
37
+ class: [String, Array, Object],
38
+ inputClass: [String, Array, Object],
39
+ wrapperClass: [String, Array, Object],
40
+ // Iconos
41
+ prependIcon: [String, Object, Function, Array],
42
+ appendIcon: [String, Object, Function, Array],
43
+ prependInnerIcon: [String, Object, Function, Array],
44
+ appendInnerIcon: [String, Object, Function, Array],
45
+ // Validación
46
+ rules: {
47
+ type: Array,
48
+ default: () => []
49
+ },
50
+ error: Boolean,
51
+ errorMessages: {
52
+ type: [String, Array],
53
+ default: () => []
54
+ },
55
+ maxErrors: {
56
+ type: [String, Number],
57
+ default: 1
58
+ },
59
+ validationValue: null,
60
+ validateOn: String,
61
+ hint: String,
62
+ persistentHint: Boolean,
63
+ hideDetails: {
64
+ type: [Boolean, String],
65
+ default: !1
66
+ },
67
+ persistentCounter: Boolean,
68
+ // Loader
69
+ loading: Boolean,
70
+ loadingColor: {
71
+ type: String,
72
+ default: "bg-slate-500"
73
+ }
74
+ };
75
+ export {
76
+ e as kunTextareaProps
77
+ };
@@ -0,0 +1,58 @@
1
+ import { ref as i, watch as E, nextTick as m, onMounted as k, computed as y } from "vue";
2
+ function F(t, n, h) {
3
+ const f = i(!1), s = i(t.modelValue ?? "");
4
+ E(() => t.modelValue, (e) => {
5
+ s.value = e ?? "", t.autoGrow && m(c);
6
+ });
7
+ const g = (e) => {
8
+ s.value = e, n("update:modelValue", e);
9
+ }, x = () => {
10
+ g(""), n("click:clear");
11
+ }, c = () => {
12
+ if (!h.value) return;
13
+ const e = h.value;
14
+ e.style.height = "auto", e.style.overflowY = "hidden";
15
+ const u = e.scrollHeight, d = getComputedStyle(e).lineHeight, o = parseFloat(d) || 24, l = Number(t.maxRows || 0);
16
+ if (t.maxRows && l > 0) {
17
+ const r = l * o;
18
+ e.style.height = Math.min(u, r) + "px";
19
+ } else
20
+ e.style.height = u + "px";
21
+ };
22
+ k(() => {
23
+ t.autoGrow && m(c);
24
+ });
25
+ const a = i([]), V = i(!0), w = (e = !1) => {
26
+ const u = t.validationValue ?? s.value, d = t.rules ?? [], o = [];
27
+ for (const l of d) {
28
+ const r = typeof l == "function" ? l(u) : l;
29
+ typeof r == "string" ? o.push(r) : r === !1 && o.push("Campo inválido");
30
+ }
31
+ return a.value = o.slice(0, t.maxErrors ?? 1), e || n("update:focused", f.value), a.value;
32
+ }, v = () => {
33
+ a.value = [];
34
+ }, H = () => {
35
+ s.value = "", v(), n("update:modelValue", "");
36
+ }, M = y(() => t.error || a.value.length > 0), C = y(() => {
37
+ var e;
38
+ return (e = t.errorMessages) != null && e.length ? Array.isArray(t.errorMessages) ? t.errorMessages : [t.errorMessages] : a.value;
39
+ });
40
+ return {
41
+ isFocused: f,
42
+ internalValue: s,
43
+ updateValue: g,
44
+ handleClear: x,
45
+ adjustHeight: c,
46
+ // validación
47
+ isPristine: V,
48
+ validate: w,
49
+ reset: H,
50
+ resetValidation: v,
51
+ validationErrors: a,
52
+ hasError: M,
53
+ displayedMessages: C
54
+ };
55
+ }
56
+ export {
57
+ F as useKunTextarea
58
+ };
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.183",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",