bord-frontend-utils 0.0.2 → 0.0.4

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/README.md CHANGED
@@ -63,8 +63,33 @@ useEffect(() => {
63
63
  ```bash
64
64
  npm run build # genera el bundle en dist/
65
65
  npm run dev # modo watch
66
+ npm run lint # corre ESLint
66
67
  ```
67
68
 
69
+ ## Pre-commit
70
+
71
+ Este proyecto usa [Husky](https://typicode.github.io/husky) y [lint-staged](https://github.com/lint-staged/lint-staged) para correr ESLint automáticamente sobre los archivos `.ts` y `.tsx` staged antes de cada commit.
72
+
73
+ Si el linting falla, el commit se cancela hasta corregir los errores.
74
+
75
+ Los mensajes de commit deben seguir el formato [Conventional Commits](https://www.conventionalcommits.org/):
76
+
77
+ ```
78
+ type: descripción corta
79
+ ```
80
+
81
+ | Tipo | Cuándo usarlo | Ejemplo |
82
+ |------|--------------|---------|
83
+ | `feat` | Nueva funcionalidad | `feat: add search filter` |
84
+ | `fix` | Corrección de bug | `fix: resolve null pointer on login` |
85
+ | `refactor` | Cambio de código sin nueva funcionalidad ni bug | `refactor: simplify date formatting` |
86
+ | `chore` | Tareas de mantenimiento, dependencias, config | `chore: update eslint to v9` |
87
+ | `docs` | Cambios en documentación | `docs: add pre-commit setup to readme` |
88
+ | `style` | Formato, espacios, comas — sin cambio de lógica | `style: fix indentation in utils` |
89
+ | `test` | Agregar o modificar tests | `test: add unit tests for removeAccents` |
90
+ | `build` | Cambios en el sistema de build | `build: update tsup config` |
91
+ | `ci` | Cambios en pipelines de CI/CD | `ci: add lint step to github actions` |
92
+
68
93
  ## Licencia
69
94
 
70
95
  MIT
package/dist/index.d.mts CHANGED
@@ -6,6 +6,8 @@
6
6
  */
7
7
  declare const removeAccents: (str: string) => string;
8
8
 
9
+ declare const formatDate: (date: Date, locale?: string) => string;
10
+
9
11
  declare const useDebounce: <T>(value: T, delay: number) => T;
10
12
 
11
- export { removeAccents, useDebounce };
13
+ export { formatDate, removeAccents, useDebounce };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,8 @@
6
6
  */
7
7
  declare const removeAccents: (str: string) => string;
8
8
 
9
+ declare const formatDate: (date: Date, locale?: string) => string;
10
+
9
11
  declare const useDebounce: <T>(value: T, delay: number) => T;
10
12
 
11
- export { removeAccents, useDebounce };
13
+ export { formatDate, removeAccents, useDebounce };
package/dist/index.js CHANGED
@@ -7,6 +7,15 @@ var removeAccents = (str) => {
7
7
  if (!str) return str;
8
8
  return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
9
9
  };
10
+
11
+ // src/utils/formatDate.ts
12
+ var formatDate = (date, locale = "es-MX") => {
13
+ return date.toLocaleDateString(locale, {
14
+ day: "2-digit",
15
+ month: "2-digit",
16
+ year: "numeric"
17
+ });
18
+ };
10
19
  var useDebounce = (value, delay) => {
11
20
  const [debouncedValue, setDebouncedValue] = react.useState(value);
12
21
  react.useEffect(() => {
@@ -20,6 +29,7 @@ var useDebounce = (value, delay) => {
20
29
  return debouncedValue;
21
30
  };
22
31
 
32
+ exports.formatDate = formatDate;
23
33
  exports.removeAccents = removeAccents;
24
34
  exports.useDebounce = useDebounce;
25
35
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/removeAccents.ts","../src/hooks/useDebounce.ts"],"names":["useState","useEffect"],"mappings":";;;;;AAMO,IAAM,aAAA,GAAgB,CAAC,GAAA,KAAwB;AACpD,EAAA,IAAI,CAAC,KAAK,OAAO,GAAA;AACjB,EAAA,OAAO,IAAI,SAAA,CAAU,KAAK,CAAA,CAAE,OAAA,CAAQ,oBAAoB,EAAE,CAAA;AAC5D;ACPO,IAAM,WAAA,GAAc,CAAI,KAAA,EAAU,KAAA,KAAqB;AAC5D,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAIA,eAAY,KAAK,CAAA;AAE7D,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,OAAA,GAAU,WAAW,MAAM;AAC/B,MAAA,iBAAA,CAAkB,KAAK,CAAA;AAAA,IACzB,GAAG,KAAK,CAAA;AACR,IAAA,OAAO,MAAM;AACX,MAAA,YAAA,CAAa,OAAO,CAAA;AAAA,IACtB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,KAAA,EAAO,KAAK,CAAC,CAAA;AAEjB,EAAA,OAAO,cAAA;AACT","file":"index.js","sourcesContent":["/**\n * Elimina los acentos de una cadena de texto\n * Usa normalize NFD para descomponer los caracteres y luego elimina los diacríticos\n * @param {string} str - Cadena de texto con posibles acentos\n * @returns {string} Cadena de texto sin acentos\n */\nexport const removeAccents = (str: string): string => {\n if (!str) return str;\n return str.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\");\n};\n","import { useState, useEffect } from \"react\";\n\nexport const useDebounce = <T>(value: T, delay: number): T => {\n const [debouncedValue, setDebouncedValue] = useState<T>(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\n};\n"]}
1
+ {"version":3,"sources":["../src/utils/removeAccents.ts","../src/utils/formatDate.ts","../src/hooks/useDebounce.ts"],"names":["useState","useEffect"],"mappings":";;;;;AAMO,IAAM,aAAA,GAAgB,CAAC,GAAA,KAAwB;AACpD,EAAA,IAAI,CAAC,KAAK,OAAO,GAAA;AACjB,EAAA,OAAO,IAAI,SAAA,CAAU,KAAK,CAAA,CAAE,OAAA,CAAQ,oBAAoB,EAAE,CAAA;AAC5D;;;ACTO,IAAM,UAAA,GAAa,CAAC,IAAA,EAAY,MAAA,GAAS,OAAA,KAAoB;AAClE,EAAA,OAAO,IAAA,CAAK,mBAAmB,MAAA,EAAQ;AAAA,IACrC,GAAA,EAAK,SAAA;AAAA,IACL,KAAA,EAAO,SAAA;AAAA,IACP,IAAA,EAAM;AAAA,GACP,CAAA;AACH;ACJO,IAAM,WAAA,GAAc,CAAI,KAAA,EAAU,KAAA,KAAqB;AAC5D,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAIA,eAAY,KAAK,CAAA;AAE7D,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,OAAA,GAAU,WAAW,MAAM;AAC/B,MAAA,iBAAA,CAAkB,KAAK,CAAA;AAAA,IACzB,GAAG,KAAK,CAAA;AACR,IAAA,OAAO,MAAM;AACX,MAAA,YAAA,CAAa,OAAO,CAAA;AAAA,IACtB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,KAAA,EAAO,KAAK,CAAC,CAAA;AAEjB,EAAA,OAAO,cAAA;AACT","file":"index.js","sourcesContent":["/**\n * Elimina los acentos de una cadena de texto\n * Usa normalize NFD para descomponer los caracteres y luego elimina los diacríticos\n * @param {string} str - Cadena de texto con posibles acentos\n * @returns {string} Cadena de texto sin acentos\n */\nexport const removeAccents = (str: string): string => {\n if (!str) return str;\n return str.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\");\n};\n","export const formatDate = (date: Date, locale = \"es-MX\"): string => {\n return date.toLocaleDateString(locale, {\n day: \"2-digit\",\n month: \"2-digit\",\n year: \"numeric\",\n });\n};\n","import { useState, useEffect } from \"react\";\n\nexport const useDebounce = <T>(value: T, delay: number): T => {\n const [debouncedValue, setDebouncedValue] = useState<T>(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\n};\n"]}
package/dist/index.mjs CHANGED
@@ -5,6 +5,15 @@ var removeAccents = (str) => {
5
5
  if (!str) return str;
6
6
  return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
7
7
  };
8
+
9
+ // src/utils/formatDate.ts
10
+ var formatDate = (date, locale = "es-MX") => {
11
+ return date.toLocaleDateString(locale, {
12
+ day: "2-digit",
13
+ month: "2-digit",
14
+ year: "numeric"
15
+ });
16
+ };
8
17
  var useDebounce = (value, delay) => {
9
18
  const [debouncedValue, setDebouncedValue] = useState(value);
10
19
  useEffect(() => {
@@ -18,6 +27,6 @@ var useDebounce = (value, delay) => {
18
27
  return debouncedValue;
19
28
  };
20
29
 
21
- export { removeAccents, useDebounce };
30
+ export { formatDate, removeAccents, useDebounce };
22
31
  //# sourceMappingURL=index.mjs.map
23
32
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/removeAccents.ts","../src/hooks/useDebounce.ts"],"names":[],"mappings":";;;AAMO,IAAM,aAAA,GAAgB,CAAC,GAAA,KAAwB;AACpD,EAAA,IAAI,CAAC,KAAK,OAAO,GAAA;AACjB,EAAA,OAAO,IAAI,SAAA,CAAU,KAAK,CAAA,CAAE,OAAA,CAAQ,oBAAoB,EAAE,CAAA;AAC5D;ACPO,IAAM,WAAA,GAAc,CAAI,KAAA,EAAU,KAAA,KAAqB;AAC5D,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAI,SAAY,KAAK,CAAA;AAE7D,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,OAAA,GAAU,WAAW,MAAM;AAC/B,MAAA,iBAAA,CAAkB,KAAK,CAAA;AAAA,IACzB,GAAG,KAAK,CAAA;AACR,IAAA,OAAO,MAAM;AACX,MAAA,YAAA,CAAa,OAAO,CAAA;AAAA,IACtB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,KAAA,EAAO,KAAK,CAAC,CAAA;AAEjB,EAAA,OAAO,cAAA;AACT","file":"index.mjs","sourcesContent":["/**\n * Elimina los acentos de una cadena de texto\n * Usa normalize NFD para descomponer los caracteres y luego elimina los diacríticos\n * @param {string} str - Cadena de texto con posibles acentos\n * @returns {string} Cadena de texto sin acentos\n */\nexport const removeAccents = (str: string): string => {\n if (!str) return str;\n return str.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\");\n};\n","import { useState, useEffect } from \"react\";\n\nexport const useDebounce = <T>(value: T, delay: number): T => {\n const [debouncedValue, setDebouncedValue] = useState<T>(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\n};\n"]}
1
+ {"version":3,"sources":["../src/utils/removeAccents.ts","../src/utils/formatDate.ts","../src/hooks/useDebounce.ts"],"names":[],"mappings":";;;AAMO,IAAM,aAAA,GAAgB,CAAC,GAAA,KAAwB;AACpD,EAAA,IAAI,CAAC,KAAK,OAAO,GAAA;AACjB,EAAA,OAAO,IAAI,SAAA,CAAU,KAAK,CAAA,CAAE,OAAA,CAAQ,oBAAoB,EAAE,CAAA;AAC5D;;;ACTO,IAAM,UAAA,GAAa,CAAC,IAAA,EAAY,MAAA,GAAS,OAAA,KAAoB;AAClE,EAAA,OAAO,IAAA,CAAK,mBAAmB,MAAA,EAAQ;AAAA,IACrC,GAAA,EAAK,SAAA;AAAA,IACL,KAAA,EAAO,SAAA;AAAA,IACP,IAAA,EAAM;AAAA,GACP,CAAA;AACH;ACJO,IAAM,WAAA,GAAc,CAAI,KAAA,EAAU,KAAA,KAAqB;AAC5D,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAI,SAAY,KAAK,CAAA;AAE7D,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,OAAA,GAAU,WAAW,MAAM;AAC/B,MAAA,iBAAA,CAAkB,KAAK,CAAA;AAAA,IACzB,GAAG,KAAK,CAAA;AACR,IAAA,OAAO,MAAM;AACX,MAAA,YAAA,CAAa,OAAO,CAAA;AAAA,IACtB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,KAAA,EAAO,KAAK,CAAC,CAAA;AAEjB,EAAA,OAAO,cAAA;AACT","file":"index.mjs","sourcesContent":["/**\n * Elimina los acentos de una cadena de texto\n * Usa normalize NFD para descomponer los caracteres y luego elimina los diacríticos\n * @param {string} str - Cadena de texto con posibles acentos\n * @returns {string} Cadena de texto sin acentos\n */\nexport const removeAccents = (str: string): string => {\n if (!str) return str;\n return str.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\");\n};\n","export const formatDate = (date: Date, locale = \"es-MX\"): string => {\n return date.toLocaleDateString(locale, {\n day: \"2-digit\",\n month: \"2-digit\",\n year: \"numeric\",\n });\n};\n","import { useState, useEffect } from \"react\";\n\nexport const useDebounce = <T>(value: T, delay: number): T => {\n const [debouncedValue, setDebouncedValue] = useState<T>(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bord-frontend-utils",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Bord frontend utilities: reusable React hooks and helper functions for building scalable web applications.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -11,7 +11,14 @@
11
11
  "sideEffects": false,
12
12
  "scripts": {
13
13
  "build": "tsup",
14
- "dev": "tsup --watch"
14
+ "dev": "tsup --watch",
15
+ "lint": "eslint .",
16
+ "prepare": "husky"
17
+ },
18
+ "lint-staged": {
19
+ "*.{ts,tsx}": [
20
+ "eslint --fix"
21
+ ]
15
22
  },
16
23
  "keywords": [
17
24
  "react",
@@ -26,11 +33,18 @@
26
33
  "node": ">=18 <21"
27
34
  },
28
35
  "peerDependencies": {
29
- "react": ">=17 <=18.3.1"
36
+ "react": ">=17 <20",
37
+ "react-dom": ">=17 <20"
30
38
  },
31
39
  "devDependencies": {
40
+ "@eslint/js": "^9.39.4",
32
41
  "@types/react": "^18",
42
+ "eslint": "^9.39.4",
43
+ "globals": "^17.6.0",
44
+ "husky": "^9.1.7",
45
+ "lint-staged": "^15.5.2",
33
46
  "tsup": "^8.5.1",
34
- "typescript": "^6.0.3"
47
+ "typescript": "^5.4.0",
48
+ "typescript-eslint": "^8.59.2"
35
49
  }
36
50
  }