@agrotools1/at-components 2.0.30 → 2.0.32
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.31.d.ts +4 -0
- package/dist/changelog/versions/components/v2.0.31.d.ts.map +1 -0
- 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/document-input/DocumentAutoComplete.vue.d.ts +43 -1
- package/dist/document-input/DocumentAutoComplete.vue.d.ts.map +1 -1
- package/dist/document-input/DocumentAutoComplete.vue.js +110 -111
- package/dist/document-input/DocumentInput.vue.d.ts +35 -0
- package/dist/document-input/DocumentInput.vue.d.ts.map +1 -1
- package/dist/document-input/DocumentInput.vue.js +124 -108
- package/dist/index.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/changelog/versions/components/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/changelog/versions/components/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,EAAE,WAAW,EAgB3C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v2.0.31.d.ts","sourceRoot":"","sources":["../../../../src/changelog/versions/components/v2.0.31.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,QAAA,MAAM,OAAO,EAAE,WAYd,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v2.0.32.d.ts","sourceRoot":"","sources":["../../../../src/changelog/versions/components/v2.0.32.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,QAAA,MAAM,OAAO,EAAE,WAiBd,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -1,28 +1,69 @@
|
|
|
1
1
|
interface Props {
|
|
2
|
+
/** ID único do componente. */
|
|
2
3
|
id?: string;
|
|
4
|
+
/** Valor selecionado ou digitado (v-model). */
|
|
3
5
|
modelValue?: any;
|
|
6
|
+
/**
|
|
7
|
+
* Tipo de documento. Define máscara e validação.
|
|
8
|
+
* @default 'cpf-cnpj'
|
|
9
|
+
*/
|
|
4
10
|
documentType?: 'cpf' | 'cnpj' | 'cpf-cnpj' | 'generic';
|
|
11
|
+
/** Texto do rótulo (label) acima do campo. */
|
|
5
12
|
label?: string;
|
|
13
|
+
/** Texto de ajuda ou descrição abaixo do campo. */
|
|
6
14
|
description?: string;
|
|
15
|
+
/** Indica se o campo é obrigatório. */
|
|
7
16
|
required?: boolean;
|
|
17
|
+
/** Desabilita o componente e oculta o ícone de limpeza. */
|
|
8
18
|
disabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Estado de erro. Se for string, exibe a mensagem.
|
|
21
|
+
* Se for true, destaca o campo em vermelho.
|
|
22
|
+
*/
|
|
9
23
|
error?: boolean | string;
|
|
24
|
+
/** Exibe o ícone de sucesso (check) quando o documento é válido. */
|
|
10
25
|
success?: boolean;
|
|
26
|
+
/** Permite caracteres alfanuméricos (letras) no CNPJ (Padrão 2026). */
|
|
11
27
|
allowAlpha?: boolean;
|
|
28
|
+
/** Placeholder customizado. */
|
|
12
29
|
placeholder?: string;
|
|
30
|
+
/** Limite máximo de caracteres (modo generic). */
|
|
13
31
|
maxLength?: number;
|
|
32
|
+
/** Converte a digitação para maiúsculas (modo generic). */
|
|
14
33
|
toUpperCase?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Se true, o modelValue emitirá apenas os caracteres limpos.
|
|
36
|
+
* Se false, emitirá o valor formatado.
|
|
37
|
+
*/
|
|
15
38
|
unmask?: boolean;
|
|
39
|
+
/** Máscara customizada para o modo generic. */
|
|
16
40
|
customMask?: string;
|
|
41
|
+
/** Classes CSS para o container. */
|
|
17
42
|
class?: any;
|
|
43
|
+
/** Classes CSS para o input interno. */
|
|
18
44
|
inputClass?: any;
|
|
45
|
+
/** Exibe o ícone de lupa (search) à esquerda. */
|
|
19
46
|
withIcon?: boolean;
|
|
47
|
+
/** Habilita a validação matemática automática. */
|
|
20
48
|
withInternalValidation?: boolean;
|
|
49
|
+
/** Lista de opções para o autocomplete. */
|
|
21
50
|
options?: any[];
|
|
51
|
+
/** Indica estado de carregamento. */
|
|
22
52
|
loading?: boolean;
|
|
53
|
+
/** Texto exibido quando nenhum resultado é encontrado. */
|
|
23
54
|
notFoundText?: string;
|
|
55
|
+
/** Texto exibido durante o carregamento das opções. */
|
|
24
56
|
loadingText?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Chave do objeto que identifica unicamente a opção.
|
|
59
|
+
* @default 'identifier'
|
|
60
|
+
*/
|
|
25
61
|
optionId?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Controla a exibição do ícone de limpeza (X).
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
withClearIcon?: boolean;
|
|
26
67
|
}
|
|
27
68
|
declare function __VLS_template(): {
|
|
28
69
|
attrs: Partial<{}>;
|
|
@@ -64,8 +105,9 @@ declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {},
|
|
|
64
105
|
withIcon: boolean;
|
|
65
106
|
allowAlpha: boolean;
|
|
66
107
|
documentType: "cpf" | "cnpj" | "cpf-cnpj" | "generic";
|
|
67
|
-
unmask: boolean;
|
|
68
108
|
withInternalValidation: boolean;
|
|
109
|
+
unmask: boolean;
|
|
110
|
+
withClearIcon: boolean;
|
|
69
111
|
optionId: string;
|
|
70
112
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
71
113
|
wrapperRef: HTMLDivElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentAutoComplete.vue.d.ts","sourceRoot":"","sources":["../../src/document-input/DocumentAutoComplete.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DocumentAutoComplete.vue.d.ts","sourceRoot":"","sources":["../../src/document-input/DocumentAutoComplete.vue"],"names":[],"mappings":"AAmnBA,UAAU,KAAK;IACb,8BAA8B;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,+CAA+C;IAC/C,UAAU,CAAC,EAAE,GAAG,CAAA;IAChB;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAA;IACtD,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACxB,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,uEAAuE;IACvE,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,+BAA+B;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oCAAoC;IACpC,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,wCAAwC;IACxC,UAAU,CAAC,EAAE,GAAG,CAAA;IAChB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,kDAAkD;IAClD,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,2CAA2C;IAC3C,OAAO,CAAC,EAAE,GAAG,EAAE,CAAA;IACf,qCAAqC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AA0XD,iBAAS,cAAc;WAiWT,OAAO,IAA6B;;uBAhBtB,GAAG;sBACJ,GAAG;yBACA,GAAG;uBACL,GAAG;yBACD,GAAG;;;YACJ,GAAG;;;;;;EAgB/B;AA4CD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;cA9zBR,OAAO;iBAeJ,OAAO;aARX,OAAO;WAFT,OAAO,GAAG,MAAM;cAuBb,OAAO;gBAnBL,OAAO;kBAjBL,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS;4BAsC7B,OAAO;YAVvB,OAAO;mBA4BA,OAAO;cALZ,MAAM;;;kBA6xBjB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAapG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as ie, useId as ue, ref as y, watch as ce, computed as U, createElementBlock as h, openBlock as n, normalizeClass as S, unref as r, createBlock as A, createCommentVNode as v, createVNode as f, withCtx as m, createTextVNode as z, toDisplayString as k, mergeProps as pe, createElementVNode as _, renderSlot as w, withModifiers as q, withDirectives as de, Fragment as fe, renderList as me, vShow as ge, nextTick as E } from "vue";
|
|
2
2
|
import { cn as F } from "../lib/utils.js";
|
|
3
|
-
import { AtCheckCircleRegularIcon as
|
|
4
|
-
import { AtCheckSolidIcon as
|
|
5
|
-
import { AtCircleXMarkRegularIcon as
|
|
6
|
-
import { AtCircleXMarkSolidIcon as
|
|
7
|
-
import { reactiveOmit as
|
|
8
|
-
import { useForwardPropsEmits as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import { isValidCpf as
|
|
20
|
-
import
|
|
21
|
-
const
|
|
3
|
+
import { AtCheckCircleRegularIcon as he } from "../packages/at-icons/dist/AtCheckCircleRegularIcon/index.js";
|
|
4
|
+
import { AtCheckSolidIcon as ve } from "../packages/at-icons/dist/AtCheckSolidIcon/index.js";
|
|
5
|
+
import { AtCircleXMarkRegularIcon as ye } from "../packages/at-icons/dist/AtCircleXMarkRegularIcon/index.js";
|
|
6
|
+
import { AtCircleXMarkSolidIcon as R } from "../packages/at-icons/dist/AtCircleXMarkSolidIcon/index.js";
|
|
7
|
+
import { reactiveOmit as Ae } from "@vueuse/core";
|
|
8
|
+
import { useForwardPropsEmits as ke } from "reka-ui";
|
|
9
|
+
import we from "../combobox/Combobox.vue.js";
|
|
10
|
+
import xe from "../combobox/ComboboxAnchor.vue.js";
|
|
11
|
+
import Te from "../combobox/ComboboxEmpty.vue.js";
|
|
12
|
+
import Ce from "../combobox/ComboboxGroup.vue.js";
|
|
13
|
+
import Ve from "../combobox/ComboboxInput.vue.js";
|
|
14
|
+
import be from "../combobox/ComboboxItem.vue.js";
|
|
15
|
+
import _e from "../combobox/ComboboxItemIndicator.vue.js";
|
|
16
|
+
import Ie from "../combobox/ComboboxList.vue.js";
|
|
17
|
+
import $e from "../combobox/ComboboxViewport.vue.js";
|
|
18
|
+
import Me from "../label/Label.vue.js";
|
|
19
|
+
import { isValidCpf as x, isValidCnpj as T, applyCpfMask as O, applyCnpjMask as X } from "./utils.js";
|
|
20
|
+
import je from "../node_modules/.pnpm/lucide-vue-next@0.542.0_vue@3.5.19_typescript@5.8.3_/node_modules/lucide-vue-next/dist/esm/icons/loader-circle.js";
|
|
21
|
+
const Be = { key: 0 }, Ue = { class: "relative flex items-center" }, Se = {
|
|
22
22
|
key: 0,
|
|
23
23
|
class: "py-6 flex items-center justify-center text-sm text-gray-500"
|
|
24
|
-
},
|
|
24
|
+
}, Ze = { class: "flex items-center gap-2" }, at = /* @__PURE__ */ ie({
|
|
25
25
|
__name: "DocumentAutoComplete",
|
|
26
26
|
props: {
|
|
27
27
|
id: {},
|
|
@@ -47,11 +47,12 @@ const je = { key: 0 }, Be = { class: "relative flex items-center" }, Ue = {
|
|
|
47
47
|
loading: { type: Boolean },
|
|
48
48
|
notFoundText: {},
|
|
49
49
|
loadingText: {},
|
|
50
|
-
optionId: { default: "identifier" }
|
|
50
|
+
optionId: { default: "identifier" },
|
|
51
|
+
withClearIcon: { type: Boolean, default: !0 }
|
|
51
52
|
},
|
|
52
53
|
emits: ["update:modelValue", "select", "validate", "blur", "focus", "clear"],
|
|
53
|
-
setup(
|
|
54
|
-
const e =
|
|
54
|
+
setup(H, { emit: J }) {
|
|
55
|
+
const e = H, s = J, C = e.id || ue(), G = `error-${C}`, K = `desc-${C}`, Q = Ae(
|
|
55
56
|
e,
|
|
56
57
|
"modelValue",
|
|
57
58
|
"documentType",
|
|
@@ -75,25 +76,25 @@ const je = { key: 0 }, Be = { class: "relative flex items-center" }, Ue = {
|
|
|
75
76
|
"loadingText",
|
|
76
77
|
"optionId",
|
|
77
78
|
"modelValue"
|
|
78
|
-
),
|
|
79
|
-
function
|
|
79
|
+
), W = ke(Q, s), i = y(""), V = y(!1), I = y(!1), L = y(!1), $ = y(null), M = y(e.modelValue);
|
|
80
|
+
function Y(t, a) {
|
|
80
81
|
if (!a) return t;
|
|
81
82
|
const l = t.replace(/[^0-9A-Za-z]/g, "");
|
|
82
83
|
if (!l) return "";
|
|
83
|
-
let c = "",
|
|
84
|
-
for (let p = 0; p < a.length &&
|
|
85
|
-
const u = a[p], d = l[
|
|
86
|
-
u === "9" ? /[0-9]/.test(d) ? (c += d,
|
|
84
|
+
let c = "", o = 0;
|
|
85
|
+
for (let p = 0; p < a.length && o < l.length; p++) {
|
|
86
|
+
const u = a[p], d = l[o];
|
|
87
|
+
u === "9" ? /[0-9]/.test(d) ? (c += d, o++) : (o++, p--) : u === "A" ? /[A-Za-z]/.test(d) ? (c += e.toUpperCase ? d.toUpperCase() : d, o++) : (o++, p--) : u === "X" ? /[0-9A-Za-z]/.test(d) ? (c += e.toUpperCase ? d.toUpperCase() : d, o++) : (o++, p--) : (c += u, d === u && o++);
|
|
87
88
|
}
|
|
88
89
|
return c;
|
|
89
90
|
}
|
|
90
91
|
function j(t) {
|
|
91
92
|
if (e.customMask && e.documentType === "generic")
|
|
92
|
-
return
|
|
93
|
+
return Y(t, e.customMask);
|
|
93
94
|
const a = /[A-Z]/i.test(t);
|
|
94
|
-
return e.documentType === "cpf" ?
|
|
95
|
+
return e.documentType === "cpf" ? O(t) : e.documentType === "cnpj" ? X(t, e.allowAlpha) : e.documentType === "cpf-cnpj" ? e.allowAlpha && a || t.length > 11 ? X(t, e.allowAlpha) : O(t) : t;
|
|
95
96
|
}
|
|
96
|
-
const
|
|
97
|
+
const P = (t) => {
|
|
97
98
|
if (!t) return i.value || "";
|
|
98
99
|
if (typeof t == "string") {
|
|
99
100
|
const c = t.replace(
|
|
@@ -108,19 +109,19 @@ const je = { key: 0 }, Be = { class: "relative flex items-center" }, Ue = {
|
|
|
108
109
|
);
|
|
109
110
|
return j(l);
|
|
110
111
|
};
|
|
111
|
-
|
|
112
|
+
ce(
|
|
112
113
|
() => e.modelValue,
|
|
113
114
|
(t) => {
|
|
114
115
|
if (M.value = t, t == null || t === "") {
|
|
115
116
|
i.value !== "" && (i.value = ""), M.value = void 0;
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
|
-
const a =
|
|
119
|
+
const a = P(t);
|
|
119
120
|
i.value !== a && (i.value = a);
|
|
120
121
|
},
|
|
121
122
|
{ immediate: !0 }
|
|
122
123
|
);
|
|
123
|
-
const
|
|
124
|
+
const ee = U(() => e.maxLength ? e.maxLength : e.customMask && e.documentType === "generic" ? e.customMask.length : e.documentType === "cpf" ? 14 : 18), te = U(() => {
|
|
124
125
|
switch (e.documentType) {
|
|
125
126
|
case "cnpj":
|
|
126
127
|
return e.allowAlpha ? "AA.AAA.AAA/AAAA-DV" : "00.000.000/0000-00";
|
|
@@ -138,10 +139,8 @@ const je = { key: 0 }, Be = { class: "relative flex items-center" }, Ue = {
|
|
|
138
139
|
if (!t || I.value) return !1;
|
|
139
140
|
const l = (typeof t == "string" ? t : t.identifier || t.value || "").replace(/[^A-Z0-9]/gi, "");
|
|
140
141
|
if (!l) return !1;
|
|
141
|
-
if (e.documentType === "cpf"
|
|
142
|
-
|
|
143
|
-
if (e.documentType === "cpf-cnpj")
|
|
144
|
-
return l.length === 11 ? !y(l) : l.length === 14 ? !A(l) : l.length > 0 && l.length !== 11 && l.length !== 14;
|
|
142
|
+
if (l.length === 11 && !x(l) || l.length === 14 && !T(l) || L.value && (e.documentType === "cpf" && l.length !== 11 || e.documentType === "cnpj" && l.length !== 14 || e.documentType === "cpf-cnpj" && l.length !== 11 && l.length !== 14))
|
|
143
|
+
return !0;
|
|
145
144
|
}
|
|
146
145
|
return !1;
|
|
147
146
|
}), B = U(() => {
|
|
@@ -151,114 +150,114 @@ const je = { key: 0 }, Be = { class: "relative flex items-center" }, Ue = {
|
|
|
151
150
|
const t = e.modelValue;
|
|
152
151
|
if (!t) return !1;
|
|
153
152
|
const l = (typeof t == "string" ? t : t.identifier || t.value || "").replace(/[^A-Z0-9]/gi, "");
|
|
154
|
-
if (e.documentType === "cpf") return
|
|
155
|
-
if (e.documentType === "cnpj") return
|
|
153
|
+
if (e.documentType === "cpf") return x(l);
|
|
154
|
+
if (e.documentType === "cnpj") return T(l);
|
|
156
155
|
if (e.documentType === "cpf-cnpj")
|
|
157
|
-
return l.length === 11 ?
|
|
156
|
+
return l.length === 11 ? x(l) : T(l);
|
|
158
157
|
}
|
|
159
158
|
return !1;
|
|
160
159
|
});
|
|
161
|
-
function
|
|
160
|
+
function D(t) {
|
|
162
161
|
let a = !1;
|
|
163
|
-
e.documentType === "cpf" ? a =
|
|
162
|
+
e.documentType === "cpf" ? a = x(t) : e.documentType === "cnpj" ? a = T(t) : e.documentType === "cpf-cnpj" && (a = t.length === 11 ? x(t) : T(t)), s("validate", a);
|
|
164
163
|
}
|
|
165
|
-
function
|
|
164
|
+
function le(t) {
|
|
166
165
|
const a = t.target;
|
|
167
166
|
let l = a.value;
|
|
168
167
|
const c = a.selectionStart || 0;
|
|
169
168
|
I.value = !1, e.toUpperCase && (l = l.toUpperCase());
|
|
170
|
-
let
|
|
169
|
+
let o = l.replace(
|
|
171
170
|
e.documentType === "generic" && e.customMask || e.allowAlpha ? /[^A-Z0-9]/gi : /[^0-9]/g,
|
|
172
171
|
""
|
|
173
172
|
), p = e.maxLength;
|
|
174
|
-
p || (e.customMask && e.documentType === "generic" ? p = e.customMask.length : p = e.documentType === "cpf" ? 11 : 14),
|
|
175
|
-
const u = j(
|
|
176
|
-
s("update:modelValue",
|
|
173
|
+
p || (e.customMask && e.documentType === "generic" ? p = e.customMask.length : p = e.documentType === "cpf" ? 11 : 14), o = o.slice(0, p);
|
|
174
|
+
const u = j(o), d = e.allowAlpha ? /[A-Z0-9]/gi : /[0-9]/g, ne = (l.slice(0, c).match(d) || []).length, se = (e.unmask ? o : u) || void 0;
|
|
175
|
+
s("update:modelValue", se), D(o), i.value = u, E(() => {
|
|
177
176
|
a.value = u;
|
|
178
|
-
let Z = 0,
|
|
179
|
-
for (let
|
|
177
|
+
let Z = 0, N = 0;
|
|
178
|
+
for (let b = 0; b < u.length && ((e.documentType === "generic" && e.customMask || e.allowAlpha ? /[A-Z0-9]/i.test(u[b]) : /[0-9]/.test(u[b])) && N++, Z = b + 1, !(N >= ne)); b++)
|
|
180
179
|
;
|
|
181
180
|
a.setSelectionRange(Z, Z);
|
|
182
181
|
});
|
|
183
182
|
}
|
|
184
|
-
function
|
|
183
|
+
function ae(t) {
|
|
185
184
|
i.value = "", M.value = null, s("update:modelValue", null), E(() => {
|
|
186
185
|
if (!$.value) return;
|
|
187
|
-
const a = $.value.querySelector(`[id="${
|
|
186
|
+
const a = $.value.querySelector(`[id="${C}"]`) || $.value.querySelector("input"), l = (a == null ? void 0 : a.tagName) === "INPUT" ? a : a == null ? void 0 : a.querySelector("input");
|
|
188
187
|
l && (l.value = "", l.dispatchEvent(new Event("input", { bubbles: !0 }))), E(() => {
|
|
189
|
-
|
|
188
|
+
V.value = !1;
|
|
190
189
|
});
|
|
191
|
-
}), I.value = !0, s("validate", !1), s("clear"),
|
|
190
|
+
}), I.value = !0, s("validate", !1), s("clear"), V.value = !1;
|
|
192
191
|
}
|
|
193
|
-
function
|
|
192
|
+
function re(t) {
|
|
194
193
|
if (!t) {
|
|
195
194
|
i.value = "", I.value = !0, s("update:modelValue", null);
|
|
196
195
|
return;
|
|
197
196
|
}
|
|
198
197
|
s("update:modelValue", t), s("select", t);
|
|
199
198
|
const l = (t.identifier || t.value || t.text || "").replace(/[^A-Z0-9]/gi, "");
|
|
200
|
-
i.value = j(l),
|
|
199
|
+
i.value = j(l), D(l), V.value = !1;
|
|
201
200
|
}
|
|
202
201
|
function oe(t) {
|
|
203
|
-
s("blur", t);
|
|
202
|
+
L.value = !0, s("blur", t);
|
|
204
203
|
const a = i.value.replace(e.allowAlpha ? /[^A-Z0-9]/gi : /[^0-9]/g, "");
|
|
205
204
|
let l = !1;
|
|
206
|
-
a.length === 11 ? l =
|
|
205
|
+
a.length === 11 ? l = x(a) : a.length === 14 && (l = T(a)), l && s("update:modelValue", e.toUpperCase ? a.toUpperCase() : a);
|
|
207
206
|
}
|
|
208
207
|
return (t, a) => (n(), h("div", {
|
|
209
|
-
class: S(
|
|
208
|
+
class: S(r(F)("space-y-1.5 w-full", e.class)),
|
|
210
209
|
ref_key: "wrapperRef",
|
|
211
210
|
ref: $
|
|
212
211
|
}, [
|
|
213
|
-
e.label ? (n(),
|
|
212
|
+
e.label ? (n(), A(r(Me), {
|
|
214
213
|
key: 0,
|
|
215
|
-
for:
|
|
214
|
+
for: r(C),
|
|
216
215
|
class: S(
|
|
217
|
-
|
|
216
|
+
r(F)(
|
|
218
217
|
"text-[#101011] font-normal text-[10px] leading-[10px]",
|
|
219
218
|
g.value ? "text-[var(--alert-red-dark,#831511)]" : ""
|
|
220
219
|
)
|
|
221
220
|
)
|
|
222
221
|
}, {
|
|
223
222
|
default: m(() => [
|
|
224
|
-
z(
|
|
225
|
-
e.required && !e.label.includes("(Obrigatório)") ? (n(), h("span",
|
|
223
|
+
z(k(e.label), 1),
|
|
224
|
+
e.required && !e.label.includes("(Obrigatório)") ? (n(), h("span", Be, " (Obrigatório)")) : v("", !0)
|
|
226
225
|
]),
|
|
227
226
|
_: 1
|
|
228
227
|
}, 8, ["for", "class"])) : v("", !0),
|
|
229
|
-
f(
|
|
228
|
+
f(r(we), pe(r(W), {
|
|
230
229
|
"model-value": M.value,
|
|
231
230
|
searchTerm: i.value,
|
|
232
231
|
"onUpdate:searchTerm": a[3] || (a[3] = (l) => i.value = l),
|
|
233
|
-
open:
|
|
234
|
-
"onUpdate:open": a[4] || (a[4] = (l) =>
|
|
232
|
+
open: V.value,
|
|
233
|
+
"onUpdate:open": a[4] || (a[4] = (l) => V.value = l),
|
|
235
234
|
"reset-search-term-on-select": !1,
|
|
236
235
|
"filter-function": () => !0,
|
|
237
|
-
"onUpdate:modelValue":
|
|
236
|
+
"onUpdate:modelValue": re
|
|
238
237
|
}), {
|
|
239
238
|
default: m(() => [
|
|
240
|
-
_("div",
|
|
241
|
-
f(
|
|
239
|
+
_("div", Ue, [
|
|
240
|
+
f(r(xe), { class: "w-full h-full" }, {
|
|
242
241
|
default: m(() => [
|
|
243
|
-
|
|
244
|
-
f(
|
|
245
|
-
id:
|
|
246
|
-
"display-value":
|
|
247
|
-
placeholder: e.placeholder ||
|
|
242
|
+
w(t.$slots, "input", {}, () => [
|
|
243
|
+
f(r(Ve), {
|
|
244
|
+
id: r(C),
|
|
245
|
+
"display-value": P,
|
|
246
|
+
placeholder: e.placeholder || te.value,
|
|
248
247
|
"with-icon": e.withIcon,
|
|
249
248
|
"with-clear-button": !1,
|
|
250
249
|
disabled: e.disabled,
|
|
251
250
|
error: g.value,
|
|
252
251
|
success: B.value,
|
|
253
252
|
class: S(
|
|
254
|
-
|
|
253
|
+
r(F)(
|
|
255
254
|
"pr-20",
|
|
256
255
|
g.value || B.value ? "border-[#3E2E46]" : "",
|
|
257
256
|
e.inputClass
|
|
258
257
|
)
|
|
259
258
|
),
|
|
260
|
-
maxlength:
|
|
261
|
-
onInput:
|
|
259
|
+
maxlength: ee.value,
|
|
260
|
+
onInput: le,
|
|
262
261
|
onBlur: oe,
|
|
263
262
|
onFocus: a[0] || (a[0] = (l) => s("focus", l))
|
|
264
263
|
}, null, 8, ["id", "placeholder", "with-icon", "disabled", "error", "success", "class", "maxlength"])
|
|
@@ -269,63 +268,63 @@ const je = { key: 0 }, Be = { class: "relative flex items-center" }, Ue = {
|
|
|
269
268
|
_("div", {
|
|
270
269
|
class: S(["absolute right-9 flex items-center justify-center z-10 h-10 w-6", e.disabled ? "pointer-events-none opacity-40" : ""])
|
|
271
270
|
}, [
|
|
272
|
-
g.value || e.modelValue && !B.value ? (n(), h("div", {
|
|
271
|
+
(g.value || e.modelValue && !B.value) && !e.disabled && e.withClearIcon ? (n(), h("div", {
|
|
273
272
|
key: 0,
|
|
274
273
|
class: "flex items-center justify-center w-full h-full cursor-pointer",
|
|
275
|
-
onMousedown: a[1] || (a[1] =
|
|
276
|
-
onClick: a[2] || (a[2] =
|
|
274
|
+
onMousedown: a[1] || (a[1] = q((l) => !e.disabled && ae(), ["stop", "prevent"])),
|
|
275
|
+
onClick: a[2] || (a[2] = q(() => {
|
|
277
276
|
}, ["stop", "prevent"]))
|
|
278
277
|
}, [
|
|
279
|
-
g.value ? (n(),
|
|
278
|
+
g.value ? (n(), A(r(R), {
|
|
280
279
|
key: 0,
|
|
281
280
|
size: "20",
|
|
282
281
|
class: "text-[var(--alert-red-dark,#831511)] transition-opacity hover:opacity-80"
|
|
283
|
-
})) : (n(),
|
|
282
|
+
})) : (n(), A(r(ye), {
|
|
284
283
|
key: 1,
|
|
285
284
|
size: "20",
|
|
286
285
|
class: "text-gray-400 transition-colors hover:text-[#831511]"
|
|
287
286
|
}))
|
|
288
|
-
], 32)) : B.value ? (n(),
|
|
287
|
+
], 32)) : B.value ? (n(), A(r(he), {
|
|
289
288
|
key: 1,
|
|
290
289
|
size: "20",
|
|
291
290
|
class: "text-[#4b715c] pointer-events-none"
|
|
292
291
|
})) : v("", !0)
|
|
293
292
|
], 2)
|
|
294
293
|
]),
|
|
295
|
-
|
|
296
|
-
f(
|
|
294
|
+
w(t.$slots, "list", {}, () => [
|
|
295
|
+
f(r(Ie), null, {
|
|
297
296
|
default: m(() => [
|
|
298
|
-
e.loading && (e.loadingText || t.$slots.loading) ? (n(), h("div",
|
|
299
|
-
|
|
300
|
-
_("div",
|
|
301
|
-
f(
|
|
302
|
-
_("span", null,
|
|
297
|
+
e.loading && (e.loadingText || t.$slots.loading) ? (n(), h("div", Se, [
|
|
298
|
+
w(t.$slots, "loading", {}, () => [
|
|
299
|
+
_("div", Ze, [
|
|
300
|
+
f(r(je), { class: "size-4 animate-spin" }),
|
|
301
|
+
_("span", null, k(e.loadingText), 1)
|
|
303
302
|
])
|
|
304
303
|
])
|
|
305
|
-
])) : !e.loading && (e.notFoundText || t.$slots.empty) ? (n(),
|
|
304
|
+
])) : !e.loading && (e.notFoundText || t.$slots.empty) ? (n(), A(r(Te), { key: 1 }, {
|
|
306
305
|
default: m(() => [
|
|
307
|
-
|
|
308
|
-
z(
|
|
306
|
+
w(t.$slots, "empty", {}, () => [
|
|
307
|
+
z(k(e.notFoundText), 1)
|
|
309
308
|
])
|
|
310
309
|
]),
|
|
311
310
|
_: 3
|
|
312
311
|
})) : v("", !0),
|
|
313
|
-
|
|
312
|
+
de(f(r($e), null, {
|
|
314
313
|
default: m(() => [
|
|
315
|
-
f(
|
|
314
|
+
f(r(Ce), null, {
|
|
316
315
|
default: m(() => [
|
|
317
|
-
|
|
318
|
-
e.options && e.options.length ? (n(!0), h(
|
|
316
|
+
w(t.$slots, "default", {}, () => [
|
|
317
|
+
e.options && e.options.length ? (n(!0), h(fe, { key: 0 }, me(e.options, (l, c) => (n(), A(r(be), {
|
|
319
318
|
key: l[e.optionId] || c,
|
|
320
319
|
value: l
|
|
321
320
|
}, {
|
|
322
321
|
default: m(() => [
|
|
323
|
-
|
|
324
|
-
z(
|
|
322
|
+
w(t.$slots, "option", { item: l }, () => [
|
|
323
|
+
z(k(l.text || l.label || l), 1)
|
|
325
324
|
]),
|
|
326
|
-
f(
|
|
325
|
+
f(r(_e), { class: "ml-auto" }, {
|
|
327
326
|
default: m(() => [
|
|
328
|
-
f(
|
|
327
|
+
f(r(ve), { size: "16" })
|
|
329
328
|
]),
|
|
330
329
|
_: 1
|
|
331
330
|
})
|
|
@@ -339,7 +338,7 @@ const je = { key: 0 }, Be = { class: "relative flex items-center" }, Ue = {
|
|
|
339
338
|
]),
|
|
340
339
|
_: 3
|
|
341
340
|
}, 512), [
|
|
342
|
-
[
|
|
341
|
+
[ge, !e.loading]
|
|
343
342
|
])
|
|
344
343
|
]),
|
|
345
344
|
_: 3
|
|
@@ -350,23 +349,23 @@ const je = { key: 0 }, Be = { class: "relative flex items-center" }, Ue = {
|
|
|
350
349
|
}, 16, ["model-value", "searchTerm", "open"]),
|
|
351
350
|
e.description && !g.value ? (n(), h("div", {
|
|
352
351
|
key: 1,
|
|
353
|
-
id:
|
|
352
|
+
id: K,
|
|
354
353
|
class: "text-gray-500 text-[11px] leading-tight"
|
|
355
|
-
},
|
|
354
|
+
}, k(e.description), 1)) : v("", !0),
|
|
356
355
|
typeof e.error == "string" && g.value ? (n(), h("div", {
|
|
357
356
|
key: 2,
|
|
358
|
-
id:
|
|
357
|
+
id: G,
|
|
359
358
|
class: "text-[var(--alert-red-dark,#831511)] flex items-center gap-1 text-[11px] font-medium leading-tight pt-0.5"
|
|
360
359
|
}, [
|
|
361
|
-
f(
|
|
360
|
+
f(r(R), {
|
|
362
361
|
size: "14",
|
|
363
362
|
class: "text-[var(--alert-red-dark,#831511)] shrink-0"
|
|
364
363
|
}),
|
|
365
|
-
_("span", null,
|
|
364
|
+
_("span", null, k(e.error), 1)
|
|
366
365
|
])) : v("", !0)
|
|
367
366
|
], 2));
|
|
368
367
|
}
|
|
369
368
|
});
|
|
370
369
|
export {
|
|
371
|
-
|
|
370
|
+
at as default
|
|
372
371
|
};
|
|
@@ -1,22 +1,55 @@
|
|
|
1
1
|
export type DocumentType = 'generic' | 'cnpj' | 'cpf' | 'cpf-cnpj';
|
|
2
2
|
export interface DocumentInputProps {
|
|
3
|
+
/** ID único do componente. Se não informado, um ID aleatório será gerado. */
|
|
3
4
|
id?: string;
|
|
5
|
+
/** Valor do campo (v-model). */
|
|
4
6
|
modelValue?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Tipo de documento. Define máscara e validação.
|
|
9
|
+
* @default 'cpf-cnpj'
|
|
10
|
+
*/
|
|
5
11
|
documentType?: DocumentType;
|
|
12
|
+
/** Texto do rótulo (label) acima do input. */
|
|
6
13
|
label?: string;
|
|
14
|
+
/** Texto de ajuda ou descrição abaixo do input. */
|
|
7
15
|
description?: string;
|
|
16
|
+
/** Indica se o campo é obrigatório. */
|
|
8
17
|
required?: boolean;
|
|
18
|
+
/** Desabilita o campo e oculta o ícone de limpeza. */
|
|
9
19
|
disabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Estado de erro. Se for string, exibe a mensagem abaixo do campo.
|
|
22
|
+
* Se for true, apenas destaca o campo em vermelho.
|
|
23
|
+
*/
|
|
10
24
|
error?: boolean | string;
|
|
25
|
+
/** Exibe o ícone de sucesso (check) quando o documento é válido. */
|
|
11
26
|
success?: boolean;
|
|
27
|
+
/** Permite caracteres alfanuméricos (letras) no CNPJ (Padrão Receita Federal 2026). */
|
|
12
28
|
allowAlpha?: boolean;
|
|
29
|
+
/** Habilita a validação matemática automática (CPF/CNPJ) integrada. */
|
|
30
|
+
withInternalValidation?: boolean;
|
|
31
|
+
/** Placeholder customizado. Se não informado, usa um padrão baseado no documentType. */
|
|
13
32
|
placeholder?: string;
|
|
33
|
+
/** Limite máximo de caracteres (apenas para modo 'generic'). */
|
|
14
34
|
maxLength?: number;
|
|
35
|
+
/** Converte automaticamente a digitação para letras maiúsculas (apenas para modo 'generic'). */
|
|
15
36
|
toUpperCase?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Se true (default), o v-model emitirá apenas os números/letras.
|
|
39
|
+
* Se false, emitirá o valor com a máscara formatada.
|
|
40
|
+
*/
|
|
16
41
|
unmask?: boolean;
|
|
42
|
+
/** Máscara customizada para o modo 'generic' (ex: '999.AAA-X'). */
|
|
17
43
|
customMask?: string;
|
|
44
|
+
/** Classes CSS adicionais para o container principal. */
|
|
18
45
|
class?: any;
|
|
46
|
+
/** Classes CSS adicionais para o elemento input interno. */
|
|
19
47
|
inputClass?: any;
|
|
48
|
+
/**
|
|
49
|
+
* Controla a exibição do ícone de limpeza (X).
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
withClearIcon?: boolean;
|
|
20
53
|
}
|
|
21
54
|
declare const _default: import('vue').DefineComponent<DocumentInputProps, {
|
|
22
55
|
input: import('vue').Ref<any, any>;
|
|
@@ -42,7 +75,9 @@ declare const _default: import('vue').DefineComponent<DocumentInputProps, {
|
|
|
42
75
|
error: boolean | string;
|
|
43
76
|
allowAlpha: boolean;
|
|
44
77
|
documentType: DocumentType;
|
|
78
|
+
withInternalValidation: boolean;
|
|
45
79
|
unmask: boolean;
|
|
80
|
+
withClearIcon: boolean;
|
|
46
81
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
47
82
|
inputRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('../input/Input.vue').InputProps> & Readonly<{
|
|
48
83
|
"onUpdate:modelValue"?: ((payload: string | number) => any) | undefined;
|
|
@@ -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"}
|