@agrotools1/at-components 2.0.29 → 2.0.31
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/button-new/ButtonNew.vue.js +1 -1
- package/dist/changelog/versions/components/index.d.ts.map +1 -1
- package/dist/changelog/versions/components/v2.0.30.d.ts +4 -0
- package/dist/changelog/versions/components/v2.0.30.d.ts.map +1 -0
- package/dist/changelog/versions/components/v2.0.31.d.ts +4 -0
- package/dist/changelog/versions/components/v2.0.31.d.ts.map +1 -0
- package/dist/document-input/DocumentAutoComplete.vue.d.ts +80 -0
- package/dist/document-input/DocumentAutoComplete.vue.d.ts.map +1 -0
- package/dist/document-input/DocumentAutoComplete.vue.js +370 -0
- package/dist/document-input/DocumentAutoComplete.vue2.js +4 -0
- package/dist/document-input/DocumentInput.vue.d.ts +4 -0
- package/dist/document-input/DocumentInput.vue.d.ts.map +1 -1
- package/dist/document-input/DocumentInput.vue.js +121 -104
- package/dist/document-input/index.d.ts +2 -0
- package/dist/document-input/index.d.ts.map +1 -1
- package/dist/document-input/index.js +9 -2
- package/dist/index.css +1 -1
- package/dist/index.js +358 -354
- package/dist/packages/at-icons/dist/AtCheckSolidIcon/AtCheckSolidIcon.vue.js +46 -0
- package/dist/packages/at-icons/dist/AtCheckSolidIcon/index.js +5 -0
- package/package.json +3 -3
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { defineComponent as te, useId as ae, ref as
|
|
2
|
-
import { cn as
|
|
3
|
-
import { AtCheckCircleRegularIcon as
|
|
1
|
+
import { defineComponent as te, useId as ae, ref as k, computed as x, watch as le, createElementBlock as h, openBlock as d, normalizeClass as b, unref as p, createBlock as j, createCommentVNode as m, createElementVNode as U, withCtx as re, createTextVNode as ne, toDisplayString as V, createVNode as R, mergeProps as oe } from "vue";
|
|
2
|
+
import { cn as T } from "../lib/utils.js";
|
|
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
|
|
8
|
+
import { isValidCpf as v, isValidCnpj as g, applyCnpjMask as E, applyCpfMask as P } from "./utils.js";
|
|
9
9
|
const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
10
10
|
key: 0,
|
|
11
|
-
class: "absolute right-2.5 flex items-center justify-center
|
|
12
|
-
},
|
|
11
|
+
class: "absolute right-2.5 flex items-center justify-center"
|
|
12
|
+
}, Te = /* @__PURE__ */ te({
|
|
13
13
|
inheritAttrs: !1,
|
|
14
14
|
__name: "DocumentInput",
|
|
15
15
|
props: {
|
|
@@ -23,6 +23,7 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
23
23
|
error: { type: [Boolean, String], default: !1 },
|
|
24
24
|
success: { type: Boolean, default: !1 },
|
|
25
25
|
allowAlpha: { type: Boolean, default: !1 },
|
|
26
|
+
withInternalValidation: { type: Boolean, default: !1 },
|
|
26
27
|
placeholder: {},
|
|
27
28
|
maxLength: {},
|
|
28
29
|
toUpperCase: { type: Boolean, default: !1 },
|
|
@@ -31,9 +32,11 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
31
32
|
class: {},
|
|
32
33
|
inputClass: {}
|
|
33
34
|
},
|
|
34
|
-
emits: ["update:modelValue", "change", "blur", "focus", "validate"],
|
|
35
|
-
setup($, { expose:
|
|
36
|
-
const e = $,
|
|
35
|
+
emits: ["update:modelValue", "change", "blur", "focus", "validate", "clear"],
|
|
36
|
+
setup($, { expose: N, emit: D }) {
|
|
37
|
+
const e = $, s = D, y = e.id || ae(), w = `error-${y}`, _ = `desc-${y}`, n = k(e.modelValue || ""), A = k(!1), B = k(!1), I = x(
|
|
38
|
+
() => e.documentType === "cnpj" || e.documentType === "cpf" || e.documentType === "cpf-cnpj"
|
|
39
|
+
), F = x(() => {
|
|
37
40
|
switch (e.documentType) {
|
|
38
41
|
case "cnpj":
|
|
39
42
|
return e.allowAlpha ? "AA.AAA.AAA/AAAA-DV" : "00.000.000/0000-00";
|
|
@@ -44,76 +47,90 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
44
47
|
default:
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
|
-
}),
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
case "cpf-cnpj":
|
|
55
|
-
return I(n.value);
|
|
56
|
-
default:
|
|
50
|
+
}), f = x(() => {
|
|
51
|
+
if (e.error) return !0;
|
|
52
|
+
if (e.withInternalValidation) {
|
|
53
|
+
if (!n.value || A.value) return !1;
|
|
54
|
+
const t = n.value.replace(/[^A-Z0-9]/gi, "");
|
|
55
|
+
if (!t) return !1;
|
|
56
|
+
if (t.length === 11 && !v(t) || t.length === 14 && !g(t) || B.value && (e.documentType === "cpf" && t.length !== 11 || e.documentType === "cnpj" && t.length !== 14 || e.documentType === "cpf-cnpj" && t.length !== 11 && t.length !== 14))
|
|
57
57
|
return !0;
|
|
58
58
|
}
|
|
59
|
+
return !1;
|
|
60
|
+
}), M = x(() => {
|
|
61
|
+
if (f.value) return !1;
|
|
62
|
+
if (e.success) return !0;
|
|
63
|
+
if (e.withInternalValidation) {
|
|
64
|
+
if (!n.value) return !1;
|
|
65
|
+
const t = n.value.replace(/[^A-Z0-9]/gi, "");
|
|
66
|
+
if (e.documentType === "cpf") return v(t);
|
|
67
|
+
if (e.documentType === "cnpj") return g(t);
|
|
68
|
+
if (e.documentType === "cpf-cnpj")
|
|
69
|
+
return t.length === 11 ? v(t) : g(t);
|
|
70
|
+
}
|
|
71
|
+
return !1;
|
|
59
72
|
});
|
|
60
|
-
function
|
|
73
|
+
function L(t) {
|
|
61
74
|
return t.replace(/[^A-Z0-9]/gi, "");
|
|
62
75
|
}
|
|
63
|
-
function
|
|
64
|
-
const a = t.replace(/[^0-9]/g, "");
|
|
65
|
-
return a.length === 11 ?
|
|
76
|
+
function X(t) {
|
|
77
|
+
const a = t.replace(e.allowAlpha ? /[^A-Z0-9]/gi : /[^0-9]/g, "");
|
|
78
|
+
return a.length === 11 ? v(a) : a.length === 14 ? g(a) : !1;
|
|
66
79
|
}
|
|
67
80
|
function q(t, a) {
|
|
68
81
|
if (!a) return t;
|
|
69
|
-
let
|
|
70
|
-
if (!
|
|
71
|
-
let
|
|
72
|
-
for (let
|
|
73
|
-
const
|
|
74
|
-
|
|
82
|
+
let r = t.replace(/[^0-9A-Za-z]/g, "");
|
|
83
|
+
if (!r) return "";
|
|
84
|
+
let c = "", l = 0;
|
|
85
|
+
for (let i = 0; i < a.length && l < r.length; i++) {
|
|
86
|
+
const o = a[i], u = r[l];
|
|
87
|
+
o === "9" ? /[0-9]/.test(u) ? (c += u, l++) : (l++, i--) : o === "A" ? /[A-Za-z]/.test(u) ? (c += e.toUpperCase ? u.toUpperCase() : u, l++) : (l++, i--) : o === "X" ? /[0-9A-Za-z]/.test(u) ? (c += e.toUpperCase ? u.toUpperCase() : u, l++) : (l++, i--) : c += o;
|
|
75
88
|
}
|
|
76
|
-
return
|
|
89
|
+
return c;
|
|
77
90
|
}
|
|
78
|
-
function
|
|
91
|
+
function O(t) {
|
|
79
92
|
let a = t;
|
|
80
93
|
return e.customMask && e.documentType === "generic" ? a = q(a, e.customMask) : (e.toUpperCase && (a = a.toUpperCase()), e.maxLength !== void 0 && a.length > e.maxLength && (a = a.slice(0, e.maxLength))), a;
|
|
81
94
|
}
|
|
82
|
-
function
|
|
95
|
+
function Z(t) {
|
|
83
96
|
switch (e.documentType) {
|
|
84
97
|
case "cnpj":
|
|
85
|
-
return
|
|
98
|
+
return E(t, e.allowAlpha);
|
|
86
99
|
case "cpf":
|
|
87
|
-
return
|
|
88
|
-
case "cpf-cnpj":
|
|
89
|
-
|
|
100
|
+
return P(t);
|
|
101
|
+
case "cpf-cnpj": {
|
|
102
|
+
const a = t.replace(e.allowAlpha ? /[^A-Z0-9]/gi : /[^0-9]/g, "").slice(0, 14);
|
|
103
|
+
if (!a) return "";
|
|
104
|
+
const r = /[A-Z]/i.test(a);
|
|
105
|
+
return e.allowAlpha && r || a.length > 11 ? E(a, e.allowAlpha) : P(a);
|
|
106
|
+
}
|
|
90
107
|
default:
|
|
91
|
-
return
|
|
108
|
+
return O(t);
|
|
92
109
|
}
|
|
93
110
|
}
|
|
94
|
-
function
|
|
111
|
+
function G(t) {
|
|
95
112
|
if (e.unmask) {
|
|
96
|
-
if (
|
|
97
|
-
return
|
|
113
|
+
if (I.value)
|
|
114
|
+
return L(t);
|
|
98
115
|
if (e.documentType === "generic" || e.documentType === "cpf-cnpj")
|
|
99
|
-
return e.customMask && e.documentType === "generic" ? t.replace(/[^0-9A-Za-z]/g, "") : t.replace(/[^0-9]/g, "");
|
|
116
|
+
return e.customMask && e.documentType === "generic" || e.documentType === "cpf-cnpj" && e.allowAlpha ? t.replace(/[^0-9A-Za-z]/g, "") : t.replace(/[^0-9]/g, "");
|
|
100
117
|
}
|
|
101
118
|
return t;
|
|
102
119
|
}
|
|
103
|
-
function
|
|
104
|
-
const a =
|
|
105
|
-
|
|
120
|
+
function H(t) {
|
|
121
|
+
const a = G(t);
|
|
122
|
+
s("update:modelValue", a), s("change", a);
|
|
106
123
|
}
|
|
107
124
|
function z(t) {
|
|
108
125
|
switch (e.documentType) {
|
|
109
126
|
case "cnpj":
|
|
110
|
-
|
|
127
|
+
s("validate", g(t));
|
|
111
128
|
break;
|
|
112
129
|
case "cpf":
|
|
113
|
-
|
|
130
|
+
s("validate", v(t));
|
|
114
131
|
break;
|
|
115
132
|
case "cpf-cnpj":
|
|
116
|
-
|
|
133
|
+
s("validate", X(t));
|
|
117
134
|
break;
|
|
118
135
|
}
|
|
119
136
|
}
|
|
@@ -122,114 +139,114 @@ const fe = { key: 0 }, de = { class: "relative flex items-center" }, me = {
|
|
|
122
139
|
(t) => {
|
|
123
140
|
if (t === void 0 || e.unmask && (e.documentType === "generic" || e.documentType === "cpf-cnpj"))
|
|
124
141
|
return;
|
|
125
|
-
const a =
|
|
142
|
+
const a = Z(t);
|
|
126
143
|
a !== n.value && (n.value = a);
|
|
127
144
|
}
|
|
128
145
|
);
|
|
129
|
-
function J(t, a,
|
|
130
|
-
const
|
|
131
|
-
let
|
|
132
|
-
if (
|
|
133
|
-
for (let
|
|
146
|
+
function J(t, a, r, c) {
|
|
147
|
+
const l = e.allowAlpha ? /[A-Z0-9]/gi : /[0-9]/g, i = (a.slice(0, c).match(l) || []).length;
|
|
148
|
+
let o = 0, u = 0;
|
|
149
|
+
if (i > 0) {
|
|
150
|
+
for (let C = 0; C < r.length && (/[A-Z0-9]/i.test(r[C]) && u++, o = C + 1, !(u >= i)); C++)
|
|
134
151
|
;
|
|
135
|
-
for (;
|
|
136
|
-
|
|
152
|
+
for (; o < r.length && !/[A-Z0-9]/i.test(r[o]); )
|
|
153
|
+
o++;
|
|
137
154
|
}
|
|
138
|
-
t.value !==
|
|
155
|
+
t.value !== r && (t.value = r, t.setSelectionRange(o, o));
|
|
139
156
|
}
|
|
140
|
-
function K(t, a,
|
|
141
|
-
const
|
|
142
|
-
t.value !==
|
|
157
|
+
function K(t, a, r, c) {
|
|
158
|
+
const l = e.allowAlpha ? /[A-Za-z0-9]/g : /[0-9]/g, i = (a.slice(0, c).match(l) || []).length, o = Math.min(i, r.length);
|
|
159
|
+
t.value !== r && (t.value = r, t.setSelectionRange(o, o));
|
|
143
160
|
}
|
|
144
161
|
const Q = (t) => {
|
|
145
|
-
|
|
146
|
-
const a = t.target,
|
|
147
|
-
|
|
162
|
+
A.value = !1;
|
|
163
|
+
const a = t.target, r = a.value, c = a.selectionStart || 0, l = Z(r);
|
|
164
|
+
I.value ? J(a, r, l, c) : e.documentType === "cpf-cnpj" ? K(a, r, l, c) : a.value !== l && (a.value = l), n.value !== l && (n.value = l, H(l), z(l));
|
|
148
165
|
}, W = (t) => {
|
|
149
|
-
|
|
166
|
+
s("focus", t);
|
|
150
167
|
}, Y = (t) => {
|
|
151
|
-
|
|
152
|
-
const a = n.value.replace(/[^0-9]/g, "");
|
|
153
|
-
let l = n.value;
|
|
154
|
-
a.length === 11 ? l = N(a) : a.length === 14 && (l = P(a)), l !== n.value && (n.value = l);
|
|
155
|
-
}
|
|
156
|
-
u("blur", t), z(n.value);
|
|
168
|
+
B.value = !0, s("blur", t), z(n.value);
|
|
157
169
|
}, ee = () => {
|
|
158
|
-
n.value = "",
|
|
159
|
-
},
|
|
160
|
-
return
|
|
161
|
-
input:
|
|
170
|
+
n.value = "", A.value = !0, s("update:modelValue", ""), s("change", ""), s("clear"), e.documentType !== "generic" && s("validate", !1);
|
|
171
|
+
}, S = k(null);
|
|
172
|
+
return N({
|
|
173
|
+
input: S,
|
|
162
174
|
localValue: n
|
|
163
|
-
}), (t, a) => (
|
|
164
|
-
class:
|
|
175
|
+
}), (t, a) => (d(), h("div", {
|
|
176
|
+
class: b(p(T)("space-y-1.5 w-full", e.class))
|
|
165
177
|
}, [
|
|
166
|
-
e.label ? (
|
|
178
|
+
e.label ? (d(), j(p(pe), {
|
|
167
179
|
key: 0,
|
|
168
|
-
for: p(
|
|
169
|
-
class:
|
|
170
|
-
p(
|
|
180
|
+
for: p(y),
|
|
181
|
+
class: b(
|
|
182
|
+
p(T)(
|
|
171
183
|
"text-[#101011] font-normal text-[10px] leading-[10px]",
|
|
172
|
-
|
|
184
|
+
f.value ? "text-[var(--alert-red-dark,#831511)]" : ""
|
|
173
185
|
)
|
|
174
186
|
)
|
|
175
187
|
}, {
|
|
176
188
|
default: re(() => [
|
|
177
|
-
ne(
|
|
178
|
-
e.required ? (
|
|
189
|
+
ne(V(e.label), 1),
|
|
190
|
+
e.required ? (d(), h("span", fe, " (Obrigatório)")) : m("", !0)
|
|
179
191
|
]),
|
|
180
192
|
_: 1
|
|
181
193
|
}, 8, ["for", "class"])) : m("", !0),
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
id: p(
|
|
194
|
+
U("div", de, [
|
|
195
|
+
R(p(ue), oe({
|
|
196
|
+
id: p(y),
|
|
185
197
|
ref_key: "inputRef",
|
|
186
|
-
ref:
|
|
198
|
+
ref: S,
|
|
187
199
|
"model-value": n.value,
|
|
188
200
|
disabled: e.disabled,
|
|
189
|
-
class: p(
|
|
201
|
+
class: p(T)("pr-10", f.value || e.success ? "border-[#3E2E46]" : "", e.inputClass),
|
|
190
202
|
placeholder: e.placeholder ?? F.value,
|
|
191
|
-
"aria-invalid":
|
|
203
|
+
"aria-invalid": f.value,
|
|
192
204
|
"aria-describedby": [
|
|
193
|
-
e.error && !
|
|
194
|
-
e.description ?
|
|
205
|
+
e.error && !A.value ? w : void 0,
|
|
206
|
+
e.description ? _ : void 0
|
|
195
207
|
].filter(Boolean).join(" ") || void 0
|
|
196
208
|
}, t.$attrs, {
|
|
197
209
|
onInput: Q,
|
|
198
210
|
onBlur: Y,
|
|
199
211
|
onFocus: W
|
|
200
212
|
}), null, 16, ["id", "model-value", "disabled", "class", "placeholder", "aria-invalid", "aria-describedby"]),
|
|
201
|
-
|
|
202
|
-
|
|
213
|
+
M.value || f.value || n.value ? (d(), h("div", me, [
|
|
214
|
+
M.value ? (d(), j(p(ce), {
|
|
203
215
|
key: 0,
|
|
204
216
|
size: "20",
|
|
205
|
-
class: "text-[#4b715c]"
|
|
206
|
-
})) :
|
|
217
|
+
class: "text-[#4b715c] pointer-events-none"
|
|
218
|
+
})) : f.value || n.value ? (d(), j(p(se), {
|
|
207
219
|
key: 1,
|
|
208
220
|
size: "20",
|
|
209
|
-
class:
|
|
221
|
+
class: b(
|
|
222
|
+
p(T)(
|
|
223
|
+
"cursor-pointer transition-opacity hover:opacity-80",
|
|
224
|
+
f.value ? "text-[var(--alert-red-dark,#831511)]" : "text-gray-400"
|
|
225
|
+
)
|
|
226
|
+
),
|
|
210
227
|
onClick: ee
|
|
211
|
-
})) : m("", !0)
|
|
228
|
+
}, null, 8, ["class"])) : m("", !0)
|
|
212
229
|
])) : m("", !0)
|
|
213
230
|
]),
|
|
214
|
-
e.description && !e.error ? (
|
|
231
|
+
e.description && !e.error ? (d(), h("div", {
|
|
215
232
|
key: 1,
|
|
216
|
-
id:
|
|
233
|
+
id: _,
|
|
217
234
|
class: "text-gray-500 text-[11px] leading-tight"
|
|
218
|
-
},
|
|
219
|
-
typeof e.error == "string" &&
|
|
235
|
+
}, V(e.description), 1)) : m("", !0),
|
|
236
|
+
(typeof e.error == "string" || e.withInternalValidation && f.value) && f.value ? (d(), h("div", {
|
|
220
237
|
key: 2,
|
|
221
|
-
id:
|
|
238
|
+
id: w,
|
|
222
239
|
class: "text-[var(--alert-red-dark,#831511)] flex items-center gap-1 text-[11px] font-medium leading-tight pt-0.5"
|
|
223
240
|
}, [
|
|
224
|
-
|
|
241
|
+
R(p(ie), {
|
|
225
242
|
size: "14",
|
|
226
243
|
class: "text-[var(--alert-red-dark,#831511)] shrink-0"
|
|
227
244
|
}),
|
|
228
|
-
|
|
245
|
+
U("span", null, V(typeof e.error == "string" ? e.error : "Documento inválido"), 1)
|
|
229
246
|
])) : m("", !0)
|
|
230
247
|
], 2));
|
|
231
248
|
}
|
|
232
249
|
});
|
|
233
250
|
export {
|
|
234
|
-
|
|
251
|
+
Te as default
|
|
235
252
|
};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { default as AgtDocumentInput } from './DocumentInput.vue';
|
|
2
|
+
export { default as AgtDocumentAutoComplete } from './DocumentAutoComplete.vue';
|
|
3
|
+
export { AgtComboboxItem as AgtDocumentAutoCompleteItem, AgtComboboxItemIndicator as AgtDocumentAutoCompleteItemIndicator } from '../combobox';
|
|
2
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/document-input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/document-input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACjE,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAC/E,OAAO,EACL,eAAe,IAAI,2BAA2B,EAC9C,wBAAwB,IAAI,oCAAoC,EACjE,MAAM,aAAa,CAAA"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as m } from "./DocumentInput.vue.js";
|
|
2
|
+
import { default as r } from "./DocumentAutoComplete.vue.js";
|
|
3
|
+
import { default as p } from "../combobox/ComboboxItem.vue.js";
|
|
4
|
+
import { default as l } from "../combobox/ComboboxItemIndicator.vue.js";
|
|
5
|
+
import "reka-ui";
|
|
2
6
|
export {
|
|
3
|
-
|
|
7
|
+
r as AgtDocumentAutoComplete,
|
|
8
|
+
p as AgtDocumentAutoCompleteItem,
|
|
9
|
+
l as AgtDocumentAutoCompleteItemIndicator,
|
|
10
|
+
m as AgtDocumentInput
|
|
4
11
|
};
|