@agrotools1/at-components 2.0.23 → 2.0.24

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":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,EAAE,WAAW,EAU3C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/changelog/versions/components/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,EAAE,WAAW,EAW3C,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { VersionData } from '../../types';
2
+ declare const v2_0_22: VersionData;
3
+ export default v2_0_22;
4
+ //# sourceMappingURL=v2.0.22.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v2.0.22.d.ts","sourceRoot":"","sources":["../../../../src/changelog/versions/components/v2.0.22.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,QAAA,MAAM,OAAO,EAAE,WAsBd,CAAA;AAED,eAAe,OAAO,CAAA"}
@@ -1,7 +1,8 @@
1
+ export type DocumentType = 'generic' | 'cnpj' | 'cpf' | 'cpf-cnpj';
1
2
  export interface DocumentInputProps {
2
3
  id?: string;
3
4
  modelValue?: string;
4
- documentType?: 'cnpj';
5
+ documentType?: DocumentType;
5
6
  label?: string;
6
7
  description?: string;
7
8
  required?: boolean;
@@ -10,11 +11,16 @@ export interface DocumentInputProps {
10
11
  success?: boolean;
11
12
  allowAlpha?: boolean;
12
13
  placeholder?: string;
14
+ maxLength?: number;
15
+ toUpperCase?: boolean;
16
+ unmask?: boolean;
17
+ customMask?: string;
13
18
  class?: any;
14
19
  inputClass?: any;
15
20
  }
16
21
  declare const _default: import('vue').DefineComponent<DocumentInputProps, {
17
22
  input: import('vue').Ref<any, any>;
23
+ localValue: import('vue').Ref<string, string>;
18
24
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
19
25
  "update:modelValue": (payload: string) => any;
20
26
  change: (payload: string) => any;
@@ -29,10 +35,12 @@ declare const _default: import('vue').DefineComponent<DocumentInputProps, {
29
35
  onValidate?: ((isValid: boolean) => any) | undefined;
30
36
  }>, {
31
37
  disabled: boolean;
38
+ toUpperCase: boolean;
32
39
  success: boolean;
33
40
  error: boolean | string;
34
- documentType: "cnpj";
35
41
  allowAlpha: boolean;
42
+ documentType: DocumentType;
43
+ unmask: boolean;
36
44
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
37
45
  inputRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('../input/Input.vue').InputProps> & Readonly<{
38
46
  "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":"AAqPA,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,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,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,UAAU,CAAC,EAAE,GAAG,CAAA;CACjB;;;;;;;;;;;;;;;;cAPY,OAAO;aAER,OAAO;WADT,OAAO,GAAG,MAAM;kBALT,MAAM;gBAOR,OAAO;;;;;;;;;;;;;;;;;;;;;AAoXtB,wBAUG"}
1
+ {"version":3,"file":"DocumentInput.vue.d.ts","sourceRoot":"","sources":["../../src/document-input/DocumentInput.vue"],"names":[],"mappings":"AA0bA,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;;;;;;;;;;;;;;;;;;;;;AA0iBlB,wBAUG"}
@@ -1,21 +1,21 @@
1
- import { defineComponent as X, useId as H, ref as h, computed as g, watch as O, createElementBlock as u, openBlock as i, normalizeClass as j, unref as r, createBlock as y, createCommentVNode as d, createElementVNode as w, withCtx as G, createTextVNode as J, toDisplayString as A, createVNode as S, mergeProps as K } from "vue";
2
- import { cn as k } from "../lib/utils.js";
3
- import { AtCheckCircleRegularIcon as L } from "../packages/at-icons/dist/AtCheckCircleRegularIcon/index.js";
4
- import { AtCircleXMarkRegularIcon as Q } from "../packages/at-icons/dist/AtCircleXMarkRegularIcon/index.js";
5
- import { AtCircleXMarkSolidIcon as U } from "../packages/at-icons/dist/AtCircleXMarkSolidIcon/index.js";
6
- import W from "../input/Input.vue.js";
7
- import Y from "../label/Label.vue.js";
8
- import { isValidCnpj as x, applyCnpjMask as E } from "./utils.js";
9
- const ee = { key: 0 }, te = { class: "relative flex items-center" }, ae = {
1
+ import { defineComponent as te, useId as ae, ref as C, computed as A, watch as le, createElementBlock as v, openBlock as f, normalizeClass as E, unref as p, createBlock as k, createCommentVNode as m, createElementVNode as R, withCtx as re, createTextVNode as ne, toDisplayString as x, createVNode as U, mergeProps as ce } from "vue";
2
+ import { cn as b } from "../lib/utils.js";
3
+ import { AtCheckCircleRegularIcon as oe } from "../packages/at-icons/dist/AtCheckCircleRegularIcon/index.js";
4
+ import { AtCircleXMarkRegularIcon as se } from "../packages/at-icons/dist/AtCircleXMarkRegularIcon/index.js";
5
+ import { AtCircleXMarkSolidIcon as ie } from "../packages/at-icons/dist/AtCircleXMarkSolidIcon/index.js";
6
+ import ue from "../input/Input.vue.js";
7
+ import pe from "../label/Label.vue.js";
8
+ import { isValidCpf as j, isValidCnpj as T, applyCpfMask as N, applyCnpjMask as P } from "./utils.js";
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 pointer-events-none"
12
- }, ue = /* @__PURE__ */ X({
12
+ }, be = /* @__PURE__ */ te({
13
13
  inheritAttrs: !1,
14
14
  __name: "DocumentInput",
15
15
  props: {
16
16
  id: {},
17
17
  modelValue: {},
18
- documentType: { default: "cnpj" },
18
+ documentType: { default: "generic" },
19
19
  label: {},
20
20
  description: {},
21
21
  required: { type: Boolean },
@@ -24,116 +24,212 @@ const ee = { key: 0 }, te = { class: "relative flex items-center" }, ae = {
24
24
  success: { type: Boolean, default: !1 },
25
25
  allowAlpha: { type: Boolean, default: !1 },
26
26
  placeholder: {},
27
+ maxLength: {},
28
+ toUpperCase: { type: Boolean, default: !1 },
29
+ unmask: { type: Boolean, default: !0 },
30
+ customMask: {},
27
31
  class: {},
28
32
  inputClass: {}
29
33
  },
30
34
  emits: ["update:modelValue", "change", "blur", "focus", "validate"],
31
- setup(R, { expose: T, emit: $ }) {
32
- const e = R, o = $, p = e.id || H(), b = `error-${p}`, _ = `desc-${p}`, l = h(e.modelValue || ""), f = h(!1), z = g(() => e.allowAlpha ? "AA.AAA.AAA/AAAA-DV" : "00.000.000/0000-00"), n = g(() => !!e.error && !f.value), C = g(() => e.success && !n.value && l.value.length === 18 && x(l.value));
33
- O(
35
+ setup($, { expose: L, emit: D }) {
36
+ const e = $, u = D, h = e.id || ae(), _ = `error-${h}`, V = `desc-${h}`, n = C(e.modelValue || ""), g = C(!1), B = A(() => e.documentType === "cnpj" || e.documentType === "cpf"), F = A(() => {
37
+ switch (e.documentType) {
38
+ case "cnpj":
39
+ return e.allowAlpha ? "AA.AAA.AAA/AAAA-DV" : "00.000.000/0000-00";
40
+ case "cpf":
41
+ return "000.000.000-00";
42
+ case "cpf-cnpj":
43
+ return "CPF ou CNPJ";
44
+ default:
45
+ return;
46
+ }
47
+ }), d = A(() => !!e.error && !g.value), M = { cnpj: 18, cpf: 14 }, w = A(() => {
48
+ if (!e.success || d.value || !n.value) return !1;
49
+ switch (e.documentType) {
50
+ case "cnpj":
51
+ return n.value.length === M.cnpj && T(n.value);
52
+ case "cpf":
53
+ return n.value.length === M.cpf && j(n.value);
54
+ case "cpf-cnpj":
55
+ return I(n.value);
56
+ default:
57
+ return !0;
58
+ }
59
+ });
60
+ function X(t) {
61
+ return t.replace(/[^A-Z0-9]/gi, "");
62
+ }
63
+ function I(t) {
64
+ const a = t.replace(/[^0-9]/g, "");
65
+ return a.length === 11 ? j(a) : a.length === 14 ? T(a) : !1;
66
+ }
67
+ function q(t, a) {
68
+ if (!a) return t;
69
+ let l = t.replace(/[^0-9A-Za-z]/g, "");
70
+ if (!l) return "";
71
+ let o = "", r = 0;
72
+ for (let s = 0; s < a.length && r < l.length; s++) {
73
+ const c = a[s], i = l[r];
74
+ c === "9" ? /[0-9]/.test(i) ? (o += i, r++) : (r++, s--) : c === "A" ? /[A-Za-z]/.test(i) ? (o += e.toUpperCase ? i.toUpperCase() : i, r++) : (r++, s--) : c === "X" ? /[0-9A-Za-z]/.test(i) ? (o += e.toUpperCase ? i.toUpperCase() : i, r++) : (r++, s--) : o += c;
75
+ }
76
+ return o;
77
+ }
78
+ function G(t) {
79
+ let a = t;
80
+ return e.customMask && e.documentType === "generic" ? a = q(a, e.customMask) : (e.toUpperCase && (a = a.toUpperCase()), e.maxLength !== void 0 && a.length > e.maxLength && (a = a.slice(0, e.maxLength))), a;
81
+ }
82
+ function S(t) {
83
+ switch (e.documentType) {
84
+ case "cnpj":
85
+ return P(t, e.allowAlpha);
86
+ case "cpf":
87
+ return N(t);
88
+ case "cpf-cnpj":
89
+ return t.replace(/[^0-9]/g, "").slice(0, 14);
90
+ default:
91
+ return G(t);
92
+ }
93
+ }
94
+ function H(t) {
95
+ if (e.unmask) {
96
+ if (B.value)
97
+ return X(t);
98
+ if (e.documentType === "generic" || e.documentType === "cpf-cnpj")
99
+ return e.customMask && e.documentType === "generic" ? t.replace(/[^0-9A-Za-z]/g, "") : t.replace(/[^0-9]/g, "");
100
+ }
101
+ return t;
102
+ }
103
+ function O(t) {
104
+ const a = H(t);
105
+ u("update:modelValue", a), u("change", a);
106
+ }
107
+ function z(t) {
108
+ switch (e.documentType) {
109
+ case "cnpj":
110
+ u("validate", T(t));
111
+ break;
112
+ case "cpf":
113
+ u("validate", j(t));
114
+ break;
115
+ case "cpf-cnpj":
116
+ u("validate", I(t));
117
+ break;
118
+ }
119
+ }
120
+ le(
34
121
  () => e.modelValue,
35
122
  (t) => {
36
- t !== void 0 && t !== l.value && (e.documentType === "cnpj" ? l.value = E(t, e.allowAlpha) : l.value = t);
123
+ if (t === void 0 || e.unmask && (e.documentType === "generic" || e.documentType === "cpf-cnpj"))
124
+ return;
125
+ const a = S(t);
126
+ a !== n.value && (n.value = a);
37
127
  }
38
128
  );
39
- const M = (t) => {
40
- f.value = !1;
41
- const s = t.target, v = s.value, Z = s.selectionStart || 0;
42
- let a = v;
43
- e.documentType === "cnpj" && (a = E(v, e.allowAlpha));
44
- const q = e.allowAlpha ? /[A-Z0-9]/gi : /[0-9]/g, B = (v.slice(0, Z).match(q) || []).length;
45
- let c = 0, I = 0;
46
- if (B > 0) {
47
- for (let m = 0; m < a.length; m++) {
48
- const F = a[m];
49
- if (/[A-Z0-9]/.test(F) && I++, c = m + 1, I >= B) break;
50
- }
51
- for (; c < a.length && !/[A-Z0-9]/.test(a[c]); )
129
+ function J(t, a, l, o) {
130
+ const r = e.allowAlpha ? /[A-Z0-9]/gi : /[0-9]/g, s = (a.slice(0, o).match(r) || []).length;
131
+ let c = 0, i = 0;
132
+ if (s > 0) {
133
+ for (let y = 0; y < l.length && (/[A-Z0-9]/i.test(l[y]) && i++, c = y + 1, !(i >= s)); y++)
134
+ ;
135
+ for (; c < l.length && !/[A-Z0-9]/i.test(l[c]); )
52
136
  c++;
53
137
  }
54
- s.value !== a && (s.value = a, s.setSelectionRange(c, c)), l.value !== a && (l.value = a, o("update:modelValue", a), o("change", a), e.documentType === "cnpj" && o("validate", x(a)));
55
- }, N = (t) => {
56
- o("focus", t);
57
- }, D = (t) => {
58
- if (o("blur", t), e.documentType === "cnpj") {
59
- const s = x(l.value);
60
- o("validate", s);
138
+ t.value !== l && (t.value = l, t.setSelectionRange(c, c));
139
+ }
140
+ function K(t, a, l, o) {
141
+ const r = e.allowAlpha ? /[A-Za-z0-9]/g : /[0-9]/g, s = (a.slice(0, o).match(r) || []).length, c = Math.min(s, l.length);
142
+ t.value !== l && (t.value = l, t.setSelectionRange(c, c));
143
+ }
144
+ const Q = (t) => {
145
+ g.value = !1;
146
+ const a = t.target, l = a.value, o = a.selectionStart || 0, r = S(l);
147
+ B.value ? J(a, l, r, o) : e.documentType === "cpf-cnpj" ? K(a, l, r, o) : a.value !== r && (a.value = r), n.value !== r && (n.value = r, O(r), z(r));
148
+ }, W = (t) => {
149
+ u("focus", t);
150
+ }, Y = (t) => {
151
+ if (e.documentType === "cpf-cnpj" && n.value) {
152
+ const a = n.value.replace(/[^0-9]/g, "");
153
+ let l = n.value;
154
+ a.length === 11 ? l = N(a) : a.length === 14 && (l = P(a)), l !== n.value && (n.value = l);
61
155
  }
62
- }, P = () => {
63
- l.value = "", f.value = !0, o("update:modelValue", ""), o("change", ""), o("validate", !1);
64
- }, V = h(null);
65
- return T({
66
- input: V
67
- }), (t, s) => (i(), u("div", {
68
- class: j(r(k)("space-y-1.5 w-full", e.class))
156
+ u("blur", t), z(n.value);
157
+ }, ee = () => {
158
+ n.value = "", g.value = !0, u("update:modelValue", ""), u("change", ""), e.documentType !== "generic" && u("validate", !1);
159
+ }, Z = C(null);
160
+ return L({
161
+ input: Z,
162
+ localValue: n
163
+ }), (t, a) => (f(), v("div", {
164
+ class: E(p(b)("space-y-1.5 w-full", e.class))
69
165
  }, [
70
- e.label ? (i(), y(r(Y), {
166
+ e.label ? (f(), k(p(pe), {
71
167
  key: 0,
72
- for: r(p),
73
- class: j(
74
- r(k)(
168
+ for: p(h),
169
+ class: E(
170
+ p(b)(
75
171
  "text-[#101011] font-normal text-[10px] leading-[10px]",
76
- n.value ? "text-[var(--alert-red-dark,#831511)]" : ""
172
+ d.value ? "text-[var(--alert-red-dark,#831511)]" : ""
77
173
  )
78
174
  )
79
175
  }, {
80
- default: G(() => [
81
- J(A(e.label), 1),
82
- e.required ? (i(), u("span", ee, " (Obrigatório)")) : d("", !0)
176
+ default: re(() => [
177
+ ne(x(e.label), 1),
178
+ e.required ? (f(), v("span", fe, " (Obrigatório)")) : m("", !0)
83
179
  ]),
84
180
  _: 1
85
- }, 8, ["for", "class"])) : d("", !0),
86
- w("div", te, [
87
- S(r(W), K({
88
- id: r(p),
181
+ }, 8, ["for", "class"])) : m("", !0),
182
+ R("div", de, [
183
+ U(p(ue), ce({
184
+ id: p(h),
89
185
  ref_key: "inputRef",
90
- ref: V,
91
- "model-value": l.value,
186
+ ref: Z,
187
+ "model-value": n.value,
92
188
  disabled: e.disabled,
93
- class: r(k)("pr-10", n.value || e.success ? "border-[#3E2E46]" : "", e.inputClass),
94
- placeholder: e.placeholder || z.value,
95
- "aria-invalid": n.value,
189
+ class: p(b)("pr-10", d.value || e.success ? "border-[#3E2E46]" : "", e.inputClass),
190
+ placeholder: e.placeholder ?? F.value,
191
+ "aria-invalid": d.value,
96
192
  "aria-describedby": [
97
- e.error && !f.value ? b : void 0,
98
- e.description ? _ : void 0
193
+ e.error && !g.value ? _ : void 0,
194
+ e.description ? V : void 0
99
195
  ].filter(Boolean).join(" ") || void 0
100
196
  }, t.$attrs, {
101
- onInput: M,
102
- onBlur: D,
103
- onFocus: N
197
+ onInput: Q,
198
+ onBlur: Y,
199
+ onFocus: W
104
200
  }), null, 16, ["id", "model-value", "disabled", "class", "placeholder", "aria-invalid", "aria-describedby"]),
105
- C.value || n.value ? (i(), u("div", ae, [
106
- C.value ? (i(), y(r(L), {
201
+ w.value || d.value ? (f(), v("div", me, [
202
+ w.value ? (f(), k(p(oe), {
107
203
  key: 0,
108
204
  size: "20",
109
205
  class: "text-[#4b715c]"
110
- })) : n.value ? (i(), y(r(Q), {
206
+ })) : d.value ? (f(), k(p(se), {
111
207
  key: 1,
112
208
  size: "20",
113
209
  class: "text-[var(--alert-red-dark,#831511)] cursor-pointer pointer-events-auto",
114
- onClick: P
115
- })) : d("", !0)
116
- ])) : d("", !0)
210
+ onClick: ee
211
+ })) : m("", !0)
212
+ ])) : m("", !0)
117
213
  ]),
118
- e.description && !e.error ? (i(), u("div", {
214
+ e.description && !e.error ? (f(), v("div", {
119
215
  key: 1,
120
- id: _,
216
+ id: V,
121
217
  class: "text-gray-500 text-[11px] leading-tight"
122
- }, A(e.description), 1)) : d("", !0),
123
- typeof e.error == "string" && n.value ? (i(), u("div", {
218
+ }, x(e.description), 1)) : m("", !0),
219
+ typeof e.error == "string" && d.value ? (f(), v("div", {
124
220
  key: 2,
125
- id: b,
221
+ id: _,
126
222
  class: "text-[var(--alert-red-dark,#831511)] flex items-center gap-1 text-[11px] font-medium leading-tight pt-0.5"
127
223
  }, [
128
- S(r(U), {
224
+ U(p(ie), {
129
225
  size: "14",
130
226
  class: "text-[var(--alert-red-dark,#831511)] shrink-0"
131
227
  }),
132
- w("span", null, A(e.error), 1)
133
- ])) : d("", !0)
228
+ R("span", null, x(e.error), 1)
229
+ ])) : m("", !0)
134
230
  ], 2));
135
231
  }
136
232
  });
137
233
  export {
138
- ue as default
234
+ be as default
139
235
  };
@@ -1,3 +1,11 @@
1
+ export interface FilterOptions {
2
+ toUpperCase?: boolean;
3
+ maxLength?: number;
4
+ allowAlpha?: boolean;
5
+ }
6
+ export declare function filterAlphanumeric(val: string, options?: FilterOptions): string;
7
+ export declare function applyCpfMask(val: string): string;
8
+ export declare function isValidCpf(cpf: string): boolean;
1
9
  export declare function applyCnpjMask(val: string, allowAlpha?: boolean): string;
2
10
  export declare function isValidCnpj(cnpj: string): boolean;
3
11
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/document-input/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,GAAE,OAAe,GAAG,MAAM,CAkC9E;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAwCjD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/document-input/utils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CAgBnF;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAYhD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAiB/C;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,GAAE,OAAe,GAAG,MAAM,CAkC9E;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAwCjD"}
@@ -1,33 +1,55 @@
1
- function u(s, r = !1) {
2
- let l = s.toUpperCase().replace(/[^A-Z0-9]/g, "");
3
- r || (l = l.replace(/[A-Z]/g, ""));
4
- let t = "";
5
- for (let e = 0; e < l.length && t.length < 14; e++) {
6
- const i = l[e];
7
- (t.length < 12 || /[0-9]/.test(i)) && (t += i);
8
- }
9
- let n = "";
1
+ function u(f) {
2
+ const t = f.replace(/[^0-9]/g, "").slice(0, 11);
3
+ let r = "";
10
4
  for (let e = 0; e < t.length; e++)
11
- e === 2 && (n += "."), e === 5 && (n += "."), e === 8 && (n += "/"), e === 12 && (n += "-"), n += t[e];
12
- return n;
5
+ e === 3 && (r += "."), e === 6 && (r += "."), e === 9 && (r += "-"), r += t[e];
6
+ return r;
7
+ }
8
+ function p(f) {
9
+ if (!f) return !1;
10
+ const t = f.replace(/[^0-9]/g, "");
11
+ if (t.length !== 11 || /^(\d)\1{10}$/.test(t)) return !1;
12
+ const r = (e) => {
13
+ let i = 0;
14
+ for (let n = 0; n < e; n++)
15
+ i += Number(t[n]) * (e + 1 - n);
16
+ const l = i % 11;
17
+ return l < 2 ? 0 : 11 - l;
18
+ };
19
+ return r(9) === Number(t[9]) && r(10) === Number(t[10]);
20
+ }
21
+ function d(f, t = !1) {
22
+ let r = f.toUpperCase().replace(/[^A-Z0-9]/g, "");
23
+ t || (r = r.replace(/[A-Z]/g, ""));
24
+ let e = "";
25
+ for (let l = 0; l < r.length && e.length < 14; l++) {
26
+ const n = r[l];
27
+ (e.length < 12 || /[0-9]/.test(n)) && (e += n);
28
+ }
29
+ let i = "";
30
+ for (let l = 0; l < e.length; l++)
31
+ l === 2 && (i += "."), l === 5 && (i += "."), l === 8 && (i += "/"), l === 12 && (i += "-"), i += e[l];
32
+ return i;
13
33
  }
14
- function p(s) {
15
- if (!s) return !1;
16
- const r = s.toUpperCase().replace(/[^A-Z0-9]/g, "");
17
- if (r.length !== 14 || /^([A-Z0-9])\1{13}$/.test(r) || !/^[0-9]{2}$/.test(r.slice(12, 14))) return !1;
18
- const l = (i) => {
19
- const f = i.charCodeAt(0);
20
- return f >= 48 && f <= 57, f - 48;
21
- }, t = (i) => {
22
- let f = 0, a = i - 7;
23
- for (let c = 0; c < i; c++)
24
- f += l(r[c]) * a, a--, a < 2 && (a = 9);
25
- const o = f % 11;
34
+ function g(f) {
35
+ if (!f) return !1;
36
+ const t = f.toUpperCase().replace(/[^A-Z0-9]/g, "");
37
+ if (t.length !== 14 || /^([A-Z0-9])\1{13}$/.test(t) || !/^[0-9]{2}$/.test(t.slice(12, 14))) return !1;
38
+ const r = (n) => {
39
+ const s = n.charCodeAt(0);
40
+ return s >= 48 && s <= 57, s - 48;
41
+ }, e = (n) => {
42
+ let s = 0, a = n - 7;
43
+ for (let c = 0; c < n; c++)
44
+ s += r(t[c]) * a, a--, a < 2 && (a = 9);
45
+ const o = s % 11;
26
46
  return o < 2 ? 0 : 11 - o;
27
- }, n = t(12), e = t(13);
28
- return l(r[12]) === n && l(r[13]) === e;
47
+ }, i = e(12), l = e(13);
48
+ return r(t[12]) === i && r(t[13]) === l;
29
49
  }
30
50
  export {
31
- u as applyCnpjMask,
32
- p as isValidCnpj
51
+ d as applyCnpjMask,
52
+ u as applyCpfMask,
53
+ g as isValidCnpj,
54
+ p as isValidCpf
33
55
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agrotools1/at-components",
3
3
  "type": "module",
4
- "version": "2.0.23",
4
+ "version": "2.0.24",
5
5
  "private": false,
6
6
  "packageManager": "pnpm@9.1.0",
7
7
  "description": "Componentes da Agrotools - Versão 2 (com re-export da V1)",