@agrotools1/at-components 2.0.31 → 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/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 +42 -0
- package/dist/document-input/DocumentAutoComplete.vue.d.ts.map +1 -1
- package/dist/document-input/DocumentAutoComplete.vue.js +3 -2
- 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
|
@@ -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<{}>;
|
|
@@ -66,6 +107,7 @@ declare const __VLS_component: import('vue').DefineComponent<Props, {}, {}, {},
|
|
|
66
107
|
documentType: "cpf" | "cnpj" | "cpf-cnpj" | "generic";
|
|
67
108
|
withInternalValidation: boolean;
|
|
68
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"}
|
|
@@ -47,7 +47,8 @@ const Be = { key: 0 }, Ue = { class: "relative flex items-center" }, Se = {
|
|
|
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
54
|
setup(H, { emit: J }) {
|
|
@@ -267,7 +268,7 @@ const Be = { key: 0 }, Ue = { class: "relative flex items-center" }, Se = {
|
|
|
267
268
|
_("div", {
|
|
268
269
|
class: S(["absolute right-9 flex items-center justify-center z-10 h-10 w-6", e.disabled ? "pointer-events-none opacity-40" : ""])
|
|
269
270
|
}, [
|
|
270
|
-
g.value || e.modelValue && !B.value ? (n(), h("div", {
|
|
271
|
+
(g.value || e.modelValue && !B.value) && !e.disabled && e.withClearIcon ? (n(), h("div", {
|
|
271
272
|
key: 0,
|
|
272
273
|
class: "flex items-center justify-center w-full h-full cursor-pointer",
|
|
273
274
|
onMousedown: a[1] || (a[1] = q((l) => !e.disabled && ae(), ["stop", "prevent"])),
|
|
@@ -1,23 +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. */
|
|
13
30
|
withInternalValidation?: boolean;
|
|
31
|
+
/** Placeholder customizado. Se não informado, usa um padrão baseado no documentType. */
|
|
14
32
|
placeholder?: string;
|
|
33
|
+
/** Limite máximo de caracteres (apenas para modo 'generic'). */
|
|
15
34
|
maxLength?: number;
|
|
35
|
+
/** Converte automaticamente a digitação para letras maiúsculas (apenas para modo 'generic'). */
|
|
16
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
|
+
*/
|
|
17
41
|
unmask?: boolean;
|
|
42
|
+
/** Máscara customizada para o modo 'generic' (ex: '999.AAA-X'). */
|
|
18
43
|
customMask?: string;
|
|
44
|
+
/** Classes CSS adicionais para o container principal. */
|
|
19
45
|
class?: any;
|
|
46
|
+
/** Classes CSS adicionais para o elemento input interno. */
|
|
20
47
|
inputClass?: any;
|
|
48
|
+
/**
|
|
49
|
+
* Controla a exibição do ícone de limpeza (X).
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
withClearIcon?: boolean;
|
|
21
53
|
}
|
|
22
54
|
declare const _default: import('vue').DefineComponent<DocumentInputProps, {
|
|
23
55
|
input: import('vue').Ref<any, any>;
|
|
@@ -45,6 +77,7 @@ declare const _default: import('vue').DefineComponent<DocumentInputProps, {
|
|
|
45
77
|
documentType: DocumentType;
|
|
46
78
|
withInternalValidation: boolean;
|
|
47
79
|
unmask: boolean;
|
|
80
|
+
withClearIcon: boolean;
|
|
48
81
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
49
82
|
inputRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('../input/Input.vue').InputProps> & Readonly<{
|
|
50
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"}
|
|
@@ -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
|
}
|