@agrotools1/at-components 2.0.31 → 2.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentInput.vue.d.ts","sourceRoot":"","sources":["../../src/document-input/DocumentInput.vue"],"names":[],"mappings":"AA2dA,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,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,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;;;;;;;;;;;;;;;;;;;cAZY,OAAO;iBAOJ,OAAO;aALX,OAAO;WADT,OAAO,GAAG,MAAM;gBAEX,OAAO;kBAPL,YAAY;4BAQF,OAAO;YAIvB,OAAO;;;;;;;;;;;;;;;;;;;;;AAulBlB,wBAUG"}
1
+ {"version":3,"file":"DocumentInput.vue.d.ts","sourceRoot":"","sources":["../../src/document-input/DocumentIn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O;YAWvB,OAAO;mBAWA,OAAO;;;;;;;;;;;;;;;;;;;;;AA8lBzB,wBAUG"}
@@ -1,11 +1,11 @@
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";
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 E, applyCpfMask as P } from "./utils.js";
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: "generic" },
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($, { 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(
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
- ), F = x(() => {
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 (!n.value || A.value) return !1;
54
- const t = n.value.replace(/[^A-Z0-9]/gi, "");
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) || 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
+ 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
- }), M = x(() => {
61
+ }), Z = x(() => {
61
62
  if (f.value) return !1;
62
- if (e.success) return !0;
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 (!n.value) return !1;
65
- const t = n.value.replace(/[^A-Z0-9]/gi, "");
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 L(t) {
78
+ function j(t) {
74
79
  return t.replace(/[^A-Z0-9]/gi, "");
75
80
  }
76
81
  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;
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, a) {
81
- if (!a) return t;
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;
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 a = t;
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;
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 Z(t) {
100
+ function z(t) {
96
101
  switch (e.documentType) {
97
102
  case "cnpj":
98
- return E(t, e.allowAlpha);
103
+ return P(t, e.allowAlpha);
99
104
  case "cpf":
100
- return P(t);
105
+ return $(t);
101
106
  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);
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 (I.value)
114
- return L(t);
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 a = G(t);
122
- s("update:modelValue", a), s("change", a);
126
+ const l = G(t);
127
+ s("update:modelValue", l), s("change", l);
123
128
  }
124
- function z(t) {
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
- le(
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 a = Z(t);
143
- a !== n.value && (n.value = a);
147
+ const l = z(t);
148
+ l !== r.value && (r.value = l);
144
149
  }
145
150
  );
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;
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 < r.length && (/[A-Z0-9]/i.test(r[C]) && u++, o = C + 1, !(u >= i)); 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 < r.length && !/[A-Z0-9]/i.test(r[o]); )
157
+ for (; o < n.length && !/[A-Z0-9]/i.test(n[o]); )
153
158
  o++;
154
159
  }
155
- t.value !== r && (t.value = r, t.setSelectionRange(o, o));
160
+ t.value !== n && (t.value = n, t.setSelectionRange(o, o));
156
161
  }
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));
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 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));
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
- B.value = !0, s("blur", t), z(n.value);
173
+ _.value = !0, s("blur", t), S(r.value);
169
174
  }, ee = () => {
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,
174
- localValue: n
175
- }), (t, a) => (d(), h("div", {
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(), j(p(pe), {
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: re(() => [
189
- ne(V(e.label), 1),
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
- U("div", de, [
195
- R(p(ue), oe({
199
+ R("div", de, [
200
+ E(p(ue), oe({
196
201
  id: p(y),
197
202
  ref_key: "inputRef",
198
- ref: S,
199
- "model-value": n.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 ?? F.value,
207
+ placeholder: e.placeholder ?? L.value,
203
208
  "aria-invalid": f.value,
204
209
  "aria-describedby": [
205
- e.error && !A.value ? w : void 0,
206
- e.description ? _ : void 0
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
- M.value || f.value || n.value ? (d(), h("div", me, [
214
- M.value ? (d(), j(p(ce), {
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 || n.value ? (d(), j(p(se), {
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: w,
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
- R(p(ie), {
246
+ E(p(ie), {
242
247
  size: "14",
243
248
  class: "text-[var(--alert-red-dark,#831511)] shrink-0"
244
249
  }),
245
- U("span", null, V(typeof e.error == "string" ? e.error : "Documento inválido"), 1)
250
+ R("span", null, V(typeof e.error == "string" ? e.error : "Documento inválido"), 1)
246
251
  ])) : m("", !0)
247
252
  ], 2));
248
253
  }