@arkyn/shared 1.3.92 → 1.3.93

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.
@@ -0,0 +1,3 @@
1
+ declare function formatToCNPJ(value: string): string;
2
+ export { formatToCNPJ };
3
+ //# sourceMappingURL=formatToCNPJ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatToCNPJ.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCNPJ.ts"],"names":[],"mappings":"AAAA,iBAAS,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO3C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ function formatToCNPJ(value) {
2
+ const cleaned = value.replace(/\D/g, "");
3
+ const match = cleaned.match(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/);
4
+ if (match) {
5
+ return `${match[1]}.${match[2]}.${match[3]}/${match[4]}-${match[5]}`;
6
+ }
7
+ return value;
8
+ }
9
+ export { formatToCNPJ };
@@ -0,0 +1,3 @@
1
+ declare function formatToCPF(value: string): string;
2
+ export { formatToCPF };
3
+ //# sourceMappingURL=formatToCPF.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatToCPF.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCPF.ts"],"names":[],"mappings":"AAAA,iBAAS,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO1C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ function formatToCPF(value) {
2
+ const cleaned = value.replace(/\D/g, "");
3
+ const match = cleaned.match(/^(\d{3})(\d{3})(\d{3})(\d{2})$/);
4
+ if (match) {
5
+ return `${match[1]}.${match[2]}.${match[3]}-${match[4]}`;
6
+ }
7
+ return value;
8
+ }
9
+ export { formatToCPF };
@@ -0,0 +1,3 @@
1
+ declare function formatToCep(value: string): string;
2
+ export { formatToCep };
3
+ //# sourceMappingURL=formatToCep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatToCep.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCep.ts"],"names":[],"mappings":"AAAA,iBAAS,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO1C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ function formatToCep(value) {
2
+ const cleaned = value.replace(/\D/g, "");
3
+ const match = cleaned.match(/^(\d{5})(\d{3})$/);
4
+ if (match) {
5
+ return `${match[1]}-${match[2]}`;
6
+ }
7
+ return value;
8
+ }
9
+ export { formatToCep };
@@ -0,0 +1,3 @@
1
+ declare function formatToCpfCnpj(value: string): string;
2
+ export { formatToCpfCnpj };
3
+ //# sourceMappingURL=formatToCpfCnpj.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatToCpfCnpj.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCpfCnpj.ts"],"names":[],"mappings":"AAGA,iBAAS,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { formatToCNPJ } from "./formatToCNPJ";
2
+ import { formatToCPF } from "./formatToCPF";
3
+ function formatToCpfCnpj(value) {
4
+ const cleaned = value.replace(/\D/g, "");
5
+ if (cleaned.length === 11) {
6
+ return formatToCPF(cleaned);
7
+ }
8
+ else if (cleaned.length === 14) {
9
+ return formatToCNPJ(cleaned);
10
+ }
11
+ return value;
12
+ }
13
+ export { formatToCpfCnpj };
@@ -0,0 +1,3 @@
1
+ declare function formatToPhone(value: string): string;
2
+ export { formatToPhone };
3
+ //# sourceMappingURL=formatToPhone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatToPhone.d.ts","sourceRoot":"","sources":["../../src/formats/formatToPhone.ts"],"names":[],"mappings":"AAAA,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO5C;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ function formatToPhone(value) {
2
+ const cleaned = value.replace(/\D/g, "");
3
+ const match = cleaned.match(/^(\d{2})(\d{5})(\d{4})$/);
4
+ if (match) {
5
+ return `(${match[1]}) ${match[2]}-${match[3]}`;
6
+ }
7
+ return value;
8
+ }
9
+ export { formatToPhone };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  export { formatDateHour } from "./formats/formatDateWithHour";
2
2
  export { formatToBRL } from "./formats/formatToBRL";
3
+ export { formatToCep } from "./formats/formatToCep";
4
+ export { formatToCNPJ } from "./formats/formatToCNPJ";
5
+ export { formatToCPF } from "./formats/formatToCPF";
6
+ export { formatToCpfCnpj } from "./formats/formatToCpfCnpj";
3
7
  export { formatToHiddenDigits } from "./formats/formatToHiddenDigits";
8
+ export { formatToPhone } from "./formats/formatToPhone";
4
9
  export { generateColorByString } from "./generators/generateColorByString";
5
10
  export { generateId } from "./generators/generateId";
6
11
  export { generateSlug } from "./generators/generateSlug";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAGtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,12 @@
1
1
  // Formats
2
2
  export { formatDateHour } from "./formats/formatDateWithHour";
3
3
  export { formatToBRL } from "./formats/formatToBRL";
4
+ export { formatToCep } from "./formats/formatToCep";
5
+ export { formatToCNPJ } from "./formats/formatToCNPJ";
6
+ export { formatToCPF } from "./formats/formatToCPF";
7
+ export { formatToCpfCnpj } from "./formats/formatToCpfCnpj";
4
8
  export { formatToHiddenDigits } from "./formats/formatToHiddenDigits";
9
+ export { formatToPhone } from "./formats/formatToPhone";
5
10
  // Generators
6
11
  export { generateColorByString } from "./generators/generateColorByString";
7
12
  export { generateId } from "./generators/generateId";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/shared",
3
- "version": "1.3.92",
3
+ "version": "1.3.93",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./src/index.ts",
6
6
  "type": "module",
@@ -0,0 +1,10 @@
1
+ function formatToCNPJ(value: string): string {
2
+ const cleaned = value.replace(/\D/g, "");
3
+ const match = cleaned.match(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/);
4
+ if (match) {
5
+ return `${match[1]}.${match[2]}.${match[3]}/${match[4]}-${match[5]}`;
6
+ }
7
+ return value;
8
+ }
9
+
10
+ export { formatToCNPJ };
@@ -0,0 +1,10 @@
1
+ function formatToCPF(value: string): string {
2
+ const cleaned = value.replace(/\D/g, "");
3
+ const match = cleaned.match(/^(\d{3})(\d{3})(\d{3})(\d{2})$/);
4
+ if (match) {
5
+ return `${match[1]}.${match[2]}.${match[3]}-${match[4]}`;
6
+ }
7
+ return value;
8
+ }
9
+
10
+ export { formatToCPF };
@@ -0,0 +1,10 @@
1
+ function formatToCep(value: string): string {
2
+ const cleaned = value.replace(/\D/g, "");
3
+ const match = cleaned.match(/^(\d{5})(\d{3})$/);
4
+ if (match) {
5
+ return `${match[1]}-${match[2]}`;
6
+ }
7
+ return value;
8
+ }
9
+
10
+ export { formatToCep };
@@ -0,0 +1,14 @@
1
+ import { formatToCNPJ } from "./formatToCNPJ";
2
+ import { formatToCPF } from "./formatToCPF";
3
+
4
+ function formatToCpfCnpj(value: string): string {
5
+ const cleaned = value.replace(/\D/g, "");
6
+ if (cleaned.length === 11) {
7
+ return formatToCPF(cleaned);
8
+ } else if (cleaned.length === 14) {
9
+ return formatToCNPJ(cleaned);
10
+ }
11
+ return value;
12
+ }
13
+
14
+ export { formatToCpfCnpj };
@@ -0,0 +1,10 @@
1
+ function formatToPhone(value: string): string {
2
+ const cleaned = value.replace(/\D/g, "");
3
+ const match = cleaned.match(/^(\d{2})(\d{5})(\d{4})$/);
4
+ if (match) {
5
+ return `(${match[1]}) ${match[2]}-${match[3]}`;
6
+ }
7
+ return value;
8
+ }
9
+
10
+ export { formatToPhone };
package/src/index.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  // Formats
2
2
  export { formatDateHour } from "./formats/formatDateWithHour";
3
3
  export { formatToBRL } from "./formats/formatToBRL";
4
+ export { formatToCep } from "./formats/formatToCep";
5
+ export { formatToCNPJ } from "./formats/formatToCNPJ";
6
+ export { formatToCPF } from "./formats/formatToCPF";
7
+ export { formatToCpfCnpj } from "./formats/formatToCpfCnpj";
4
8
  export { formatToHiddenDigits } from "./formats/formatToHiddenDigits";
9
+ export { formatToPhone } from "./formats/formatToPhone";
5
10
 
6
11
  // Generators
7
12
  export { generateColorByString } from "./generators/generateColorByString";