@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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/changelog/versions/components/index.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,EAAE,WAAW,EAe3C,CAAA"}
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,4 @@
1
+ import { VersionData } from '../../types';
2
+ declare const v2_0_31: VersionData;
3
+ export default v2_0_31;
4
+ //# sourceMappingURL=v2.0.31.d.ts.map
@@ -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,4 @@
1
+ import { VersionData } from '../../types';
2
+ declare const v2_0_32: VersionData;
3
+ export default v2_0_32;
4
+ //# sourceMappingURL=v2.0.32.d.ts.map
@@ -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":"AAikBA,UAAU,KAAK;IACb,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,UAAU,CAAC,EAAE,GAAG,CAAA;IAChB,YAAY,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAA;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAA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,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 se, useId as ie, ref as b, watch as ue, computed as U, createElementBlock as h, openBlock as n, normalizeClass as S, unref as o, createBlock as k, createCommentVNode as v, createVNode as f, withCtx as m, createTextVNode as z, toDisplayString as w, mergeProps as ce, createElementVNode as _, renderSlot as x, withModifiers as N, withDirectives as pe, Fragment as de, renderList as fe, vShow as me, nextTick as E } from "vue";
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 ge } from "../packages/at-icons/dist/AtCheckCircleRegularIcon/index.js";
4
- import { AtCheckSolidIcon as he } from "../packages/at-icons/dist/AtCheckSolidIcon/index.js";
5
- import { AtCircleXMarkRegularIcon as ve } from "../packages/at-icons/dist/AtCircleXMarkRegularIcon/index.js";
6
- import { AtCircleXMarkSolidIcon as q } from "../packages/at-icons/dist/AtCircleXMarkSolidIcon/index.js";
7
- import { reactiveOmit as ye } from "@vueuse/core";
8
- import { useForwardPropsEmits as Ae } from "reka-ui";
9
- import ke from "../combobox/Combobox.vue.js";
10
- import we from "../combobox/ComboboxAnchor.vue.js";
11
- import xe from "../combobox/ComboboxEmpty.vue.js";
12
- import Te from "../combobox/ComboboxGroup.vue.js";
13
- import Ce from "../combobox/ComboboxInput.vue.js";
14
- import Ve from "../combobox/ComboboxItem.vue.js";
15
- import be from "../combobox/ComboboxItemIndicator.vue.js";
16
- import _e from "../combobox/ComboboxList.vue.js";
17
- import Ie from "../combobox/ComboboxViewport.vue.js";
18
- import $e from "../label/Label.vue.js";
19
- import { isValidCpf as y, isValidCnpj as A, applyCpfMask as R, applyCnpjMask as O } from "./utils.js";
20
- import Me 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 je = { key: 0 }, Be = { class: "relative flex items-center" }, Ue = {
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
- }, Se = { class: "flex items-center gap-2" }, lt = /* @__PURE__ */ se({
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(X, { emit: H }) {
54
- const e = X, s = H, T = e.id || ie(), J = `error-${T}`, G = `desc-${T}`, K = ye(
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
- ), Q = Ae(K, s), i = b(""), C = b(!1), I = b(!1), $ = b(null), M = b(e.modelValue);
79
- function W(t, a) {
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 = "", r = 0;
84
- for (let p = 0; p < a.length && r < l.length; p++) {
85
- const u = a[p], d = l[r];
86
- u === "9" ? /[0-9]/.test(d) ? (c += d, r++) : (r++, p--) : u === "A" ? /[A-Za-z]/.test(d) ? (c += e.toUpperCase ? d.toUpperCase() : d, r++) : (r++, p--) : u === "X" ? /[0-9A-Za-z]/.test(d) ? (c += e.toUpperCase ? d.toUpperCase() : d, r++) : (r++, p--) : (c += u, d === u && r++);
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 W(t, e.customMask);
93
+ return Y(t, e.customMask);
93
94
  const a = /[A-Z]/i.test(t);
94
- return e.documentType === "cpf" ? R(t) : e.documentType === "cnpj" ? O(t, e.allowAlpha) : e.documentType === "cpf-cnpj" ? e.allowAlpha && a || t.length > 11 ? O(t, e.allowAlpha) : R(t) : t;
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 L = (t) => {
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
- ue(
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 = L(t);
119
+ const a = P(t);
119
120
  i.value !== a && (i.value = a);
120
121
  },
121
122
  { immediate: !0 }
122
123
  );
123
- const Y = U(() => e.maxLength ? e.maxLength : e.customMask && e.documentType === "generic" ? e.customMask.length : e.documentType === "cpf" ? 14 : 18), ee = U(() => {
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") return !y(l);
142
- if (e.documentType === "cnpj") return !A(l);
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 y(l);
155
- if (e.documentType === "cnpj") return A(l);
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 ? y(l) : A(l);
156
+ return l.length === 11 ? x(l) : T(l);
158
157
  }
159
158
  return !1;
160
159
  });
161
- function P(t) {
160
+ function D(t) {
162
161
  let a = !1;
163
- e.documentType === "cpf" ? a = y(t) : e.documentType === "cnpj" ? a = A(t) : e.documentType === "cpf-cnpj" && (a = t.length === 11 ? y(t) : A(t)), s("validate", 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 te(t) {
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 r = l.replace(
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), r = r.slice(0, p);
175
- const u = j(r), d = e.allowAlpha ? /[A-Z0-9]/gi : /[0-9]/g, re = (l.slice(0, c).match(d) || []).length, ne = (e.unmask ? r : u) || void 0;
176
- s("update:modelValue", ne), P(r), i.value = u, E(() => {
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, D = 0;
179
- for (let V = 0; V < u.length && ((e.documentType === "generic" && e.customMask || e.allowAlpha ? /[A-Z0-9]/i.test(u[V]) : /[0-9]/.test(u[V])) && D++, Z = V + 1, !(D >= re)); V++)
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 le(t) {
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="${T}"]`) || $.value.querySelector("input"), l = (a == null ? void 0 : a.tagName) === "INPUT" ? a : a == null ? void 0 : a.querySelector("input");
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
- C.value = !1;
188
+ V.value = !1;
190
189
  });
191
- }), I.value = !0, s("validate", !1), s("clear"), C.value = !1;
190
+ }), I.value = !0, s("validate", !1), s("clear"), V.value = !1;
192
191
  }
193
- function ae(t) {
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), P(l), C.value = !1;
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 = y(a) : a.length === 14 && (l = A(a)), l && s("update:modelValue", e.toUpperCase ? a.toUpperCase() : a);
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(o(F)("space-y-1.5 w-full", e.class)),
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(), k(o($e), {
212
+ e.label ? (n(), A(r(Me), {
214
213
  key: 0,
215
- for: o(T),
214
+ for: r(C),
216
215
  class: S(
217
- o(F)(
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(w(e.label), 1),
225
- e.required && !e.label.includes("(Obrigatório)") ? (n(), h("span", je, " (Obrigatório)")) : v("", !0)
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(o(ke), ce(o(Q), {
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: C.value,
234
- "onUpdate:open": a[4] || (a[4] = (l) => C.value = 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": ae
236
+ "onUpdate:modelValue": re
238
237
  }), {
239
238
  default: m(() => [
240
- _("div", Be, [
241
- f(o(we), { class: "w-full h-full" }, {
239
+ _("div", Ue, [
240
+ f(r(xe), { class: "w-full h-full" }, {
242
241
  default: m(() => [
243
- x(t.$slots, "input", {}, () => [
244
- f(o(Ce), {
245
- id: o(T),
246
- "display-value": L,
247
- placeholder: e.placeholder || ee.value,
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
- o(F)(
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: Y.value,
261
- onInput: te,
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] = N((l) => !e.disabled && le(), ["stop", "prevent"])),
276
- onClick: a[2] || (a[2] = N(() => {
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(), k(o(q), {
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(), k(o(ve), {
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(), k(o(ge), {
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
- x(t.$slots, "list", {}, () => [
296
- f(o(_e), null, {
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", Ue, [
299
- x(t.$slots, "loading", {}, () => [
300
- _("div", Se, [
301
- f(o(Me), { class: "size-4 animate-spin" }),
302
- _("span", null, w(e.loadingText), 1)
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(), k(o(xe), { key: 1 }, {
304
+ ])) : !e.loading && (e.notFoundText || t.$slots.empty) ? (n(), A(r(Te), { key: 1 }, {
306
305
  default: m(() => [
307
- x(t.$slots, "empty", {}, () => [
308
- z(w(e.notFoundText), 1)
306
+ w(t.$slots, "empty", {}, () => [
307
+ z(k(e.notFoundText), 1)
309
308
  ])
310
309
  ]),
311
310
  _: 3
312
311
  })) : v("", !0),
313
- pe(f(o(Ie), null, {
312
+ de(f(r($e), null, {
314
313
  default: m(() => [
315
- f(o(Te), null, {
314
+ f(r(Ce), null, {
316
315
  default: m(() => [
317
- x(t.$slots, "default", {}, () => [
318
- e.options && e.options.length ? (n(!0), h(de, { key: 0 }, fe(e.options, (l, c) => (n(), k(o(Ve), {
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
- x(t.$slots, "option", { item: l }, () => [
324
- z(w(l.text || l.label || l), 1)
322
+ w(t.$slots, "option", { item: l }, () => [
323
+ z(k(l.text || l.label || l), 1)
325
324
  ]),
326
- f(o(be), { class: "ml-auto" }, {
325
+ f(r(_e), { class: "ml-auto" }, {
327
326
  default: m(() => [
328
- f(o(he), { size: "16" })
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
- [me, !e.loading]
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: G,
352
+ id: K,
354
353
  class: "text-gray-500 text-[11px] leading-tight"
355
- }, w(e.description), 1)) : v("", !0),
354
+ }, k(e.description), 1)) : v("", !0),
356
355
  typeof e.error == "string" && g.value ? (n(), h("div", {
357
356
  key: 2,
358
- id: J,
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(o(q), {
360
+ f(r(R), {
362
361
  size: "14",
363
362
  class: "text-[var(--alert-red-dark,#831511)] shrink-0"
364
363
  }),
365
- _("span", null, w(e.error), 1)
364
+ _("span", null, k(e.error), 1)
366
365
  ])) : v("", !0)
367
366
  ], 2));
368
367
  }
369
368
  });
370
369
  export {
371
- lt as default
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":"AA8bA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,CAAA;AAElE,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,UAAU,CAAC,EAAE,GAAG,CAAA;CACjB;;;;;;;;;;;;;;;;;;;cAXY,OAAO;iBAMJ,OAAO;aAJX,OAAO;WADT,OAAO,GAAG,MAAM;gBAEX,OAAO;kBAPL,YAAY;YAWlB,OAAO;;;;;;;;;;;;;;;;;;;;;AA0jBlB,wBAUG"}
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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