@agrotools1/at-components 2.0.31 → 2.0.33
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/changelog/versions/components/index.d.ts.map +1 -1
- package/dist/changelog/versions/components/v2.0.32.d.ts +4 -0
- package/dist/changelog/versions/components/v2.0.32.d.ts.map +1 -0
- package/dist/changelog/versions/components/v2.0.33.d.ts +4 -0
- package/dist/changelog/versions/components/v2.0.33.d.ts.map +1 -0
- package/dist/document-input/DocumentAutoComplete.vue.d.ts +44 -0
- package/dist/document-input/DocumentAutoComplete.vue.d.ts.map +1 -1
- package/dist/document-input/DocumentAutoComplete.vue.js +118 -121
- package/dist/document-input/DocumentInput.vue.d.ts +33 -0
- package/dist/document-input/DocumentInput.vue.d.ts.map +1 -1
- package/dist/document-input/DocumentInput.vue.js +81 -76
- package/dist/index.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentInput.vue.d.ts","sourceRoot":"","sources":["../../src/document-input/DocumentInput.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DocumentInput.vue.d.ts","sourceRoot":"","sources":["../../src/document-input/DocumentInput.vue"],"names":[],"mappings":"AAogBA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,CAAA;AAElE,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACxB,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,uFAAuF;IACvF,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,uEAAuE;IACvE,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,wFAAwF;IACxF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gGAAgG;IAChG,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,yDAAyD;IACzD,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,4DAA4D;IAC5D,UAAU,CAAC,EAAE,GAAG,CAAA;IAChB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;;;;;;;;;;;;;;;;;;;cAlCY,OAAO;iBAiBJ,OAAO;aAVX,OAAO;WAFT,OAAO,GAAG,MAAM;gBAIX,OAAO;kBAjBL,YAAY;4BAmBF,OAAO;YAWvB,OAAO;mBAWA,OAAO;;;;;;;;;;;;;;;;;;;;;AA8lBzB,wBAUG"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as te, useId as
|
|
1
|
+
import { defineComponent as te, useId as le, ref as k, computed as x, watch as ae, createElementBlock as h, openBlock as d, normalizeClass as b, unref as p, createBlock as w, createCommentVNode as m, createElementVNode as R, withCtx as ne, createTextVNode as re, toDisplayString as V, createVNode as E, mergeProps as oe } from "vue";
|
|
2
2
|
import { cn as T } from "../lib/utils.js";
|
|
3
3
|
import { AtCheckCircleRegularIcon as ce } from "../packages/at-icons/dist/AtCheckCircleRegularIcon/index.js";
|
|
4
4
|
import { AtCircleXMarkRegularIcon as se } from "../packages/at-icons/dist/AtCircleXMarkRegularIcon/index.js";
|
|
5
5
|
import { AtCircleXMarkSolidIcon as ie } from "../packages/at-icons/dist/AtCircleXMarkSolidIcon/index.js";
|
|
6
6
|
import ue from "../input/Input.vue.js";
|
|
7
7
|
import pe from "../label/Label.vue.js";
|
|
8
|
-
import { isValidCpf as v, isValidCnpj as g, applyCnpjMask as
|
|
8
|
+
import { isValidCpf as v, isValidCnpj as g, applyCnpjMask as P, applyCpfMask as $ } from "./utils.js";
|
|
9
9
|
const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
10
10
|
key: 0,
|
|
11
11
|
class: "absolute right-2.5 flex items-center justify-center"
|
|
@@ -15,7 +15,7 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
15
15
|
props: {
|
|
16
16
|
id: {},
|
|
17
17
|
modelValue: {},
|
|
18
|
-
documentType: { default: "
|
|
18
|
+
documentType: { default: "cpf-cnpj" },
|
|
19
19
|
label: {},
|
|
20
20
|
description: {},
|
|
21
21
|
required: { type: Boolean },
|
|
@@ -30,13 +30,14 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
30
30
|
unmask: { type: Boolean, default: !0 },
|
|
31
31
|
customMask: {},
|
|
32
32
|
class: {},
|
|
33
|
-
inputClass: {}
|
|
33
|
+
inputClass: {},
|
|
34
|
+
withClearIcon: { type: Boolean, default: !0 }
|
|
34
35
|
},
|
|
35
36
|
emits: ["update:modelValue", "change", "blur", "focus", "validate", "clear"],
|
|
36
|
-
setup(
|
|
37
|
-
const e =
|
|
37
|
+
setup(N, { expose: D, emit: F }) {
|
|
38
|
+
const e = N, s = F, y = e.id || le(), B = `error-${y}`, I = `desc-${y}`, r = k(e.modelValue || ""), A = k(!1), _ = k(!1), M = x(
|
|
38
39
|
() => e.documentType === "cnpj" || e.documentType === "cpf" || e.documentType === "cpf-cnpj"
|
|
39
|
-
),
|
|
40
|
+
), L = x(() => {
|
|
40
41
|
switch (e.documentType) {
|
|
41
42
|
case "cnpj":
|
|
42
43
|
return e.allowAlpha ? "AA.AAA.AAA/AAAA-DV" : "00.000.000/0000-00";
|
|
@@ -50,19 +51,23 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
50
51
|
}), f = x(() => {
|
|
51
52
|
if (e.error) return !0;
|
|
52
53
|
if (e.withInternalValidation) {
|
|
53
|
-
if (!
|
|
54
|
-
const t =
|
|
54
|
+
if (!r.value || A.value) return !1;
|
|
55
|
+
const t = r.value.replace(/[^A-Z0-9]/gi, "");
|
|
55
56
|
if (!t) return !1;
|
|
56
|
-
if (t.length === 11 && !v(t) || t.length === 14 && !g(t) ||
|
|
57
|
+
if (t.length === 11 && !v(t) || t.length === 14 && !g(t) || _.value && (e.documentType === "cpf" && t.length !== 11 || e.documentType === "cnpj" && t.length !== 14 || e.documentType === "cpf-cnpj" && t.length !== 11 && t.length !== 14))
|
|
57
58
|
return !0;
|
|
58
59
|
}
|
|
59
60
|
return !1;
|
|
60
|
-
}),
|
|
61
|
+
}), Z = x(() => {
|
|
61
62
|
if (f.value) return !1;
|
|
62
|
-
if (e.success)
|
|
63
|
+
if (e.success) {
|
|
64
|
+
if (!r.value) return !1;
|
|
65
|
+
const t = j(r.value);
|
|
66
|
+
return !(e.documentType === "cpf" && t.length !== 11 || e.documentType === "cnpj" && t.length !== 14 || e.documentType === "cpf-cnpj" && t.length !== 11 && t.length !== 14);
|
|
67
|
+
}
|
|
63
68
|
if (e.withInternalValidation) {
|
|
64
|
-
if (!
|
|
65
|
-
const t =
|
|
69
|
+
if (!r.value) return !1;
|
|
70
|
+
const t = j(r.value);
|
|
66
71
|
if (e.documentType === "cpf") return v(t);
|
|
67
72
|
if (e.documentType === "cnpj") return g(t);
|
|
68
73
|
if (e.documentType === "cpf-cnpj")
|
|
@@ -70,39 +75,39 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
70
75
|
}
|
|
71
76
|
return !1;
|
|
72
77
|
});
|
|
73
|
-
function
|
|
78
|
+
function j(t) {
|
|
74
79
|
return t.replace(/[^A-Z0-9]/gi, "");
|
|
75
80
|
}
|
|
76
81
|
function X(t) {
|
|
77
|
-
const
|
|
78
|
-
return
|
|
82
|
+
const l = t.replace(e.allowAlpha ? /[^A-Z0-9]/gi : /[^0-9]/g, "");
|
|
83
|
+
return l.length === 11 ? v(l) : l.length === 14 ? g(l) : !1;
|
|
79
84
|
}
|
|
80
|
-
function q(t,
|
|
81
|
-
if (!
|
|
82
|
-
let
|
|
83
|
-
if (!
|
|
84
|
-
let c = "",
|
|
85
|
-
for (let i = 0; i <
|
|
86
|
-
const o =
|
|
87
|
-
o === "9" ? /[0-9]/.test(u) ? (c += u,
|
|
85
|
+
function q(t, l) {
|
|
86
|
+
if (!l) return t;
|
|
87
|
+
let n = t.replace(/[^0-9A-Za-z]/g, "");
|
|
88
|
+
if (!n) return "";
|
|
89
|
+
let c = "", a = 0;
|
|
90
|
+
for (let i = 0; i < l.length && a < n.length; i++) {
|
|
91
|
+
const o = l[i], u = n[a];
|
|
92
|
+
o === "9" ? /[0-9]/.test(u) ? (c += u, a++) : (a++, i--) : o === "A" ? /[A-Za-z]/.test(u) ? (c += e.toUpperCase ? u.toUpperCase() : u, a++) : (a++, i--) : o === "X" ? /[0-9A-Za-z]/.test(u) ? (c += e.toUpperCase ? u.toUpperCase() : u, a++) : (a++, i--) : c += o;
|
|
88
93
|
}
|
|
89
94
|
return c;
|
|
90
95
|
}
|
|
91
96
|
function O(t) {
|
|
92
|
-
let
|
|
93
|
-
return e.customMask && e.documentType === "generic" ?
|
|
97
|
+
let l = t;
|
|
98
|
+
return e.customMask && e.documentType === "generic" ? l = q(l, e.customMask) : (e.toUpperCase && (l = l.toUpperCase()), e.maxLength !== void 0 && l.length > e.maxLength && (l = l.slice(0, e.maxLength))), l;
|
|
94
99
|
}
|
|
95
|
-
function
|
|
100
|
+
function z(t) {
|
|
96
101
|
switch (e.documentType) {
|
|
97
102
|
case "cnpj":
|
|
98
|
-
return
|
|
103
|
+
return P(t, e.allowAlpha);
|
|
99
104
|
case "cpf":
|
|
100
|
-
return
|
|
105
|
+
return $(t);
|
|
101
106
|
case "cpf-cnpj": {
|
|
102
|
-
const
|
|
103
|
-
if (!
|
|
104
|
-
const
|
|
105
|
-
return e.allowAlpha &&
|
|
107
|
+
const l = t.replace(e.allowAlpha ? /[^A-Z0-9]/gi : /[^0-9]/g, "").slice(0, 14);
|
|
108
|
+
if (!l) return "";
|
|
109
|
+
const n = /[A-Z]/i.test(l);
|
|
110
|
+
return e.allowAlpha && n || l.length > 11 ? P(l, e.allowAlpha) : $(l);
|
|
106
111
|
}
|
|
107
112
|
default:
|
|
108
113
|
return O(t);
|
|
@@ -110,18 +115,18 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
110
115
|
}
|
|
111
116
|
function G(t) {
|
|
112
117
|
if (e.unmask) {
|
|
113
|
-
if (
|
|
114
|
-
return
|
|
118
|
+
if (M.value)
|
|
119
|
+
return j(t);
|
|
115
120
|
if (e.documentType === "generic" || e.documentType === "cpf-cnpj")
|
|
116
121
|
return e.customMask && e.documentType === "generic" || e.documentType === "cpf-cnpj" && e.allowAlpha ? t.replace(/[^0-9A-Za-z]/g, "") : t.replace(/[^0-9]/g, "");
|
|
117
122
|
}
|
|
118
123
|
return t;
|
|
119
124
|
}
|
|
120
125
|
function H(t) {
|
|
121
|
-
const
|
|
122
|
-
s("update:modelValue",
|
|
126
|
+
const l = G(t);
|
|
127
|
+
s("update:modelValue", l), s("change", l);
|
|
123
128
|
}
|
|
124
|
-
function
|
|
129
|
+
function S(t) {
|
|
125
130
|
switch (e.documentType) {
|
|
126
131
|
case "cnpj":
|
|
127
132
|
s("validate", g(t));
|
|
@@ -134,48 +139,48 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
134
139
|
break;
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
|
-
|
|
142
|
+
ae(
|
|
138
143
|
() => e.modelValue,
|
|
139
144
|
(t) => {
|
|
140
145
|
if (t === void 0 || e.unmask && (e.documentType === "generic" || e.documentType === "cpf-cnpj"))
|
|
141
146
|
return;
|
|
142
|
-
const
|
|
143
|
-
|
|
147
|
+
const l = z(t);
|
|
148
|
+
l !== r.value && (r.value = l);
|
|
144
149
|
}
|
|
145
150
|
);
|
|
146
|
-
function J(t,
|
|
147
|
-
const
|
|
151
|
+
function J(t, l, n, c) {
|
|
152
|
+
const a = e.allowAlpha ? /[A-Z0-9]/gi : /[0-9]/g, i = (l.slice(0, c).match(a) || []).length;
|
|
148
153
|
let o = 0, u = 0;
|
|
149
154
|
if (i > 0) {
|
|
150
|
-
for (let C = 0; C <
|
|
155
|
+
for (let C = 0; C < n.length && (/[A-Z0-9]/i.test(n[C]) && u++, o = C + 1, !(u >= i)); C++)
|
|
151
156
|
;
|
|
152
|
-
for (; o <
|
|
157
|
+
for (; o < n.length && !/[A-Z0-9]/i.test(n[o]); )
|
|
153
158
|
o++;
|
|
154
159
|
}
|
|
155
|
-
t.value !==
|
|
160
|
+
t.value !== n && (t.value = n, t.setSelectionRange(o, o));
|
|
156
161
|
}
|
|
157
|
-
function K(t,
|
|
158
|
-
const
|
|
159
|
-
t.value !==
|
|
162
|
+
function K(t, l, n, c) {
|
|
163
|
+
const a = e.allowAlpha ? /[A-Za-z0-9]/g : /[0-9]/g, i = (l.slice(0, c).match(a) || []).length, o = Math.min(i, n.length);
|
|
164
|
+
t.value !== n && (t.value = n, t.setSelectionRange(o, o));
|
|
160
165
|
}
|
|
161
166
|
const Q = (t) => {
|
|
162
167
|
A.value = !1;
|
|
163
|
-
const
|
|
164
|
-
|
|
168
|
+
const l = t.target, n = l.value, c = l.selectionStart || 0, a = z(n);
|
|
169
|
+
M.value ? J(l, n, a, c) : e.documentType === "cpf-cnpj" ? K(l, n, a, c) : l.value !== a && (l.value = a), r.value !== a && (r.value = a, H(a), S(a));
|
|
165
170
|
}, W = (t) => {
|
|
166
171
|
s("focus", t);
|
|
167
172
|
}, Y = (t) => {
|
|
168
|
-
|
|
173
|
+
_.value = !0, s("blur", t), S(r.value);
|
|
169
174
|
}, ee = () => {
|
|
170
|
-
|
|
171
|
-
},
|
|
172
|
-
return
|
|
173
|
-
input:
|
|
174
|
-
localValue:
|
|
175
|
-
}), (t,
|
|
175
|
+
r.value = "", A.value = !0, s("update:modelValue", ""), s("change", ""), s("clear"), e.documentType !== "generic" && s("validate", !1);
|
|
176
|
+
}, U = k(null);
|
|
177
|
+
return D({
|
|
178
|
+
input: U,
|
|
179
|
+
localValue: r
|
|
180
|
+
}), (t, l) => (d(), h("div", {
|
|
176
181
|
class: b(p(T)("space-y-1.5 w-full", e.class))
|
|
177
182
|
}, [
|
|
178
|
-
e.label ? (d(),
|
|
183
|
+
e.label ? (d(), w(p(pe), {
|
|
179
184
|
key: 0,
|
|
180
185
|
for: p(y),
|
|
181
186
|
class: b(
|
|
@@ -185,37 +190,37 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
185
190
|
)
|
|
186
191
|
)
|
|
187
192
|
}, {
|
|
188
|
-
default:
|
|
189
|
-
|
|
193
|
+
default: ne(() => [
|
|
194
|
+
re(V(e.label), 1),
|
|
190
195
|
e.required ? (d(), h("span", fe, " (Obrigatório)")) : m("", !0)
|
|
191
196
|
]),
|
|
192
197
|
_: 1
|
|
193
198
|
}, 8, ["for", "class"])) : m("", !0),
|
|
194
|
-
|
|
195
|
-
|
|
199
|
+
R("div", de, [
|
|
200
|
+
E(p(ue), oe({
|
|
196
201
|
id: p(y),
|
|
197
202
|
ref_key: "inputRef",
|
|
198
|
-
ref:
|
|
199
|
-
"model-value":
|
|
203
|
+
ref: U,
|
|
204
|
+
"model-value": r.value,
|
|
200
205
|
disabled: e.disabled,
|
|
201
206
|
class: p(T)("pr-10", f.value || e.success ? "border-[#3E2E46]" : "", e.inputClass),
|
|
202
|
-
placeholder: e.placeholder ??
|
|
207
|
+
placeholder: e.placeholder ?? L.value,
|
|
203
208
|
"aria-invalid": f.value,
|
|
204
209
|
"aria-describedby": [
|
|
205
|
-
e.error && !A.value ?
|
|
206
|
-
e.description ?
|
|
210
|
+
e.error && !A.value ? B : void 0,
|
|
211
|
+
e.description ? I : void 0
|
|
207
212
|
].filter(Boolean).join(" ") || void 0
|
|
208
213
|
}, t.$attrs, {
|
|
209
214
|
onInput: Q,
|
|
210
215
|
onBlur: Y,
|
|
211
216
|
onFocus: W
|
|
212
217
|
}), null, 16, ["id", "model-value", "disabled", "class", "placeholder", "aria-invalid", "aria-describedby"]),
|
|
213
|
-
|
|
214
|
-
|
|
218
|
+
Z.value || f.value || r.value ? (d(), h("div", me, [
|
|
219
|
+
Z.value ? (d(), w(p(ce), {
|
|
215
220
|
key: 0,
|
|
216
221
|
size: "20",
|
|
217
222
|
class: "text-[#4b715c] pointer-events-none"
|
|
218
|
-
})) : f.value ||
|
|
223
|
+
})) : (f.value || r.value) && !e.disabled && e.withClearIcon ? (d(), w(p(se), {
|
|
219
224
|
key: 1,
|
|
220
225
|
size: "20",
|
|
221
226
|
class: b(
|
|
@@ -230,19 +235,19 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
230
235
|
]),
|
|
231
236
|
e.description && !e.error ? (d(), h("div", {
|
|
232
237
|
key: 1,
|
|
233
|
-
id:
|
|
238
|
+
id: I,
|
|
234
239
|
class: "text-gray-500 text-[11px] leading-tight"
|
|
235
240
|
}, V(e.description), 1)) : m("", !0),
|
|
236
241
|
(typeof e.error == "string" || e.withInternalValidation && f.value) && f.value ? (d(), h("div", {
|
|
237
242
|
key: 2,
|
|
238
|
-
id:
|
|
243
|
+
id: B,
|
|
239
244
|
class: "text-[var(--alert-red-dark,#831511)] flex items-center gap-1 text-[11px] font-medium leading-tight pt-0.5"
|
|
240
245
|
}, [
|
|
241
|
-
|
|
246
|
+
E(p(ie), {
|
|
242
247
|
size: "14",
|
|
243
248
|
class: "text-[var(--alert-red-dark,#831511)] shrink-0"
|
|
244
249
|
}),
|
|
245
|
-
|
|
250
|
+
R("span", null, V(typeof e.error == "string" ? e.error : "Documento inválido"), 1)
|
|
246
251
|
])) : m("", !0)
|
|
247
252
|
], 2));
|
|
248
253
|
}
|