@maz-ui/utils 4.0.0-beta.24 → 4.0.0-beta.27

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.
@@ -3,54 +3,58 @@ import { capitalize as m } from "./capitalize.js";
3
3
  import { checkAvailability as f } from "./checkAvailability.js";
4
4
  import { countryCodeToUnicodeFlag as a } from "./countryCodeToUnicodeFlag.js";
5
5
  import { debounce as l } from "./debounce.js";
6
- import { debounceCallback as n } from "./debounceCallback.js";
6
+ import { debounceCallback as c } from "./debounceCallback.js";
7
7
  import { debounceId as d } from "./debounceId.js";
8
8
  import { formatCurrency as b } from "./formatCurrency.js";
9
- import { formatDate as C } from "./formatDate.js";
9
+ import { formatDate as g } from "./formatDate.js";
10
10
  import { formatNumber as S } from "./formatNumber.js";
11
- import { getCountryFlagUrl as F } from "./getCountryFlagUrl.js";
12
- import { getErrorMessage as T } from "./getErrorMessage.js";
13
- import { IdleTimeout as k } from "./idleTimeout.js";
11
+ import { getCountryFlagUrl as k } from "./getCountryFlagUrl.js";
12
+ import { getErrorMessage as I } from "./getErrorMessage.js";
13
+ import { IdleTimeout as U } from "./idleTimeout.js";
14
14
  import { isClient as w } from "./isClient.js";
15
15
  import { isEqual as A } from "./isEqual.js";
16
16
  import { isServer as M } from "./isServer.js";
17
17
  import { isStandaloneMode as D } from "./isStandaloneMode.js";
18
- import { normalizeString as N } from "./normalizeString.js";
19
- import { pascalCase as j } from "./pascalCase.js";
20
- import { ScriptLoader as G } from "./scriptLoader.js";
21
- import { sleep as J } from "./sleep.js";
22
- import { Swipe as O } from "./swipeHandler.js";
23
- import { TextareaAutogrow as Q } from "./TextareaAutogrow.js";
24
- import { throttle as W } from "./throttle.js";
25
- import { throttleId as Y } from "./throttleId.js";
26
- import { truthyFilter as _ } from "./truthyFilter.js";
27
- import { UserVisibility as rr } from "./userVisibility.js";
18
+ import { kebabCase as N } from "./kebabCase.js";
19
+ import { normalizeString as j } from "./normalizeString.js";
20
+ import { pascalCase as G } from "./pascalCase.js";
21
+ import { ScriptLoader as J } from "./scriptLoader.js";
22
+ import { sleep as O } from "./sleep.js";
23
+ import { snakeCase as Q } from "./snakeCase.js";
24
+ import { Swipe as W } from "./swipeHandler.js";
25
+ import { TextareaAutogrow as Y } from "./TextareaAutogrow.js";
26
+ import { throttle as _ } from "./throttle.js";
27
+ import { throttleId as rr } from "./throttleId.js";
28
+ import { truthyFilter as er } from "./truthyFilter.js";
29
+ import { UserVisibility as mr } from "./userVisibility.js";
28
30
  export {
29
- k as IdleTimeout,
30
- G as ScriptLoader,
31
- O as Swipe,
32
- Q as TextareaAutogrow,
33
- rr as UserVisibility,
31
+ U as IdleTimeout,
32
+ J as ScriptLoader,
33
+ W as Swipe,
34
+ Y as TextareaAutogrow,
35
+ mr as UserVisibility,
34
36
  e as camelCase,
35
37
  m as capitalize,
36
38
  f as checkAvailability,
37
39
  a as countryCodeToUnicodeFlag,
38
40
  l as debounce,
39
- n as debounceCallback,
41
+ c as debounceCallback,
40
42
  d as debounceId,
41
43
  b as formatCurrency,
42
- C as formatDate,
44
+ g as formatDate,
43
45
  S as formatNumber,
44
- F as getCountryFlagUrl,
45
- T as getErrorMessage,
46
+ k as getCountryFlagUrl,
47
+ I as getErrorMessage,
46
48
  w as isClient,
47
49
  A as isEqual,
48
50
  M as isServer,
49
51
  D as isStandaloneMode,
50
- N as normalizeString,
51
- j as pascalCase,
52
- J as sleep,
53
- W as throttle,
54
- Y as throttleId,
55
- _ as truthyFilter
52
+ N as kebabCase,
53
+ j as normalizeString,
54
+ G as pascalCase,
55
+ O as sleep,
56
+ Q as snakeCase,
57
+ _ as throttle,
58
+ rr as throttleId,
59
+ er as truthyFilter
56
60
  };
@@ -0,0 +1,6 @@
1
+ function a(e) {
2
+ return e.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z])([A-Z][a-z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase().replace(/-+/g, "-").replace(/(^-)|(-$)/g, "");
3
+ }
4
+ export {
5
+ a as kebabCase
6
+ };
@@ -1,4 +1,8 @@
1
- const l = {
1
+ import { camelCase as t } from "./camelCase.js";
2
+ import { kebabCase as i } from "./kebabCase.js";
3
+ import { pascalCase as l } from "./pascalCase.js";
4
+ import { snakeCase as m } from "./snakeCase.js";
5
+ const n = {
2
6
  removeAccents: !0,
3
7
  caseSensitive: !1,
4
8
  replaceSpaces: !0,
@@ -6,10 +10,29 @@ const l = {
6
10
  trim: !0,
7
11
  normalizeSpaces: !0,
8
12
  removeNumbers: !1,
13
+ case: void 0,
9
14
  customNormalizationForms: ["NFC", "NFKD"]
10
15
  };
11
- function s(o, i) {
12
- const r = { ...l, ...i }, t = {
16
+ function u(r, s) {
17
+ switch (s) {
18
+ case "kebab-case":
19
+ return i(r);
20
+ case "camelCase":
21
+ return t(r);
22
+ case "PascalCase":
23
+ return l(r);
24
+ case "snake_case":
25
+ return m(r);
26
+ case "lowercase":
27
+ return r.toLowerCase();
28
+ case "UPPERCASE":
29
+ return r.toUpperCase();
30
+ default:
31
+ return r;
32
+ }
33
+ }
34
+ function S(r, s) {
35
+ const a = { ...n, ...s }, c = {
13
36
  À: "A",
14
37
  Á: "A",
15
38
  Â: "A",
@@ -58,12 +81,12 @@ function s(o, i) {
58
81
  ñ: "n",
59
82
  ó: "o"
60
83
  };
61
- let e = o.toString();
62
- if (r.trim && (e = e.trim()), r.normalizeSpaces && (e = e.replaceAll(/\s+/g, " ")), r.replaceSpaces && (e = e.replaceAll(" ", "-")), r.removeNumbers && (e = e.replaceAll(/\d/g, "")), r.removeAccents && (e = e.replaceAll(/[ÀÁÂÃÄÅÇÈÉÊËÎÏÑÔÕÖØÙÚÛÜàáâãäåçèéêëíîïñóôõöøùúûüÿ]/g, (a) => t[a] || a), e = e.replaceAll(/[\u0300-\u036F]/g, "")), r.caseSensitive === !1 && (e = e.toLowerCase()), r.removeSpecialCharacters && (e = e.replaceAll(/[^\dA-Z-]/gi, "")), r.trim && (e = e.trim()), r.customNormalizationForms)
63
- for (const a of r.customNormalizationForms)
64
- e = e.normalize(a);
84
+ let e = r.toString();
85
+ if (a.trim && (e = e.trim()), a.normalizeSpaces && (e = e.replaceAll(/\s+/g, " ")), a.replaceSpaces && (e = e.replaceAll(" ", "-")), a.removeNumbers && (e = e.replaceAll(/\d/g, "")), a.removeAccents && (e = e.replaceAll(/[ÀÁÂÃÄÅÇÈÉÊËÎÏÑÔÕÖØÙÚÛÜàáâãäåçèéêëíîïñóôõöøùúûüÿ]/g, (o) => c[o] || o), e = e.replaceAll(/[\u0300-\u036F]/g, "")), a.case ? e = u(e, a.case) : a.caseSensitive === !1 && (e = e.toLowerCase()), a.removeSpecialCharacters && (e = e.replaceAll(/[^\dA-Z-]/gi, "")), a.trim && (e = e.trim()), a.customNormalizationForms)
86
+ for (const o of a.customNormalizationForms)
87
+ e = e.normalize(o);
65
88
  return e;
66
89
  }
67
90
  export {
68
- s as normalizeString
91
+ S as normalizeString
69
92
  };
@@ -1,8 +1,16 @@
1
- import { camelCase as r } from "./camelCase.js";
2
- import { capitalize as e } from "./capitalize.js";
3
- function i(a) {
4
- return e(r(a));
1
+ import { camelCase as o } from "./camelCase.js";
2
+ import { capitalize as i } from "./capitalize.js";
3
+ function p(e) {
4
+ if (e === e.toUpperCase()) {
5
+ if (e.includes("-"))
6
+ return e.toLowerCase().split("-").map(i).join("");
7
+ if (e.includes("_"))
8
+ return e.toLowerCase().split("_").map(i).join("");
9
+ if (e.includes(" "))
10
+ return e.toLowerCase().split(" ").map(i).join("");
11
+ }
12
+ return e.includes("-") ? e.toLowerCase().split("-").map(i).join("") : e.includes("_") ? e.toLowerCase().split("_").map(i).join("") : e.includes(" ") ? e.toLowerCase().split(" ").map(i).join("") : i(o(e));
5
13
  }
6
14
  export {
7
- i as pascalCase
15
+ p as pascalCase
8
16
  };
@@ -0,0 +1,6 @@
1
+ function a(e) {
2
+ return e.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase().replace(/_+/g, "_").replace(/(^_)|(_$)/g, "");
3
+ }
4
+ export {
5
+ a as snakeCase
6
+ };
package/dist/index.js CHANGED
@@ -3,54 +3,58 @@ import { capitalize as m } from "./helpers/capitalize.js";
3
3
  import { checkAvailability as f } from "./helpers/checkAvailability.js";
4
4
  import { countryCodeToUnicodeFlag as a } from "./helpers/countryCodeToUnicodeFlag.js";
5
5
  import { debounce as l } from "./helpers/debounce.js";
6
- import { debounceCallback as n } from "./helpers/debounceCallback.js";
6
+ import { debounceCallback as c } from "./helpers/debounceCallback.js";
7
7
  import { debounceId as d } from "./helpers/debounceId.js";
8
8
  import { formatCurrency as b } from "./helpers/formatCurrency.js";
9
- import { formatDate as C } from "./helpers/formatDate.js";
9
+ import { formatDate as g } from "./helpers/formatDate.js";
10
10
  import { formatNumber as S } from "./helpers/formatNumber.js";
11
- import { getCountryFlagUrl as F } from "./helpers/getCountryFlagUrl.js";
12
- import { getErrorMessage as T } from "./helpers/getErrorMessage.js";
13
- import { IdleTimeout as k } from "./helpers/idleTimeout.js";
11
+ import { getCountryFlagUrl as k } from "./helpers/getCountryFlagUrl.js";
12
+ import { getErrorMessage as I } from "./helpers/getErrorMessage.js";
13
+ import { IdleTimeout as U } from "./helpers/idleTimeout.js";
14
14
  import { isClient as w } from "./helpers/isClient.js";
15
15
  import { isEqual as A } from "./helpers/isEqual.js";
16
16
  import { isServer as M } from "./helpers/isServer.js";
17
17
  import { isStandaloneMode as D } from "./helpers/isStandaloneMode.js";
18
- import { normalizeString as N } from "./helpers/normalizeString.js";
19
- import { pascalCase as j } from "./helpers/pascalCase.js";
20
- import { ScriptLoader as G } from "./helpers/scriptLoader.js";
21
- import { sleep as J } from "./helpers/sleep.js";
22
- import { Swipe as O } from "./helpers/swipeHandler.js";
23
- import { TextareaAutogrow as Q } from "./helpers/TextareaAutogrow.js";
24
- import { throttle as W } from "./helpers/throttle.js";
25
- import { throttleId as Y } from "./helpers/throttleId.js";
26
- import { truthyFilter as _ } from "./helpers/truthyFilter.js";
27
- import { UserVisibility as rr } from "./helpers/userVisibility.js";
18
+ import { kebabCase as N } from "./helpers/kebabCase.js";
19
+ import { normalizeString as j } from "./helpers/normalizeString.js";
20
+ import { pascalCase as G } from "./helpers/pascalCase.js";
21
+ import { ScriptLoader as J } from "./helpers/scriptLoader.js";
22
+ import { sleep as O } from "./helpers/sleep.js";
23
+ import { snakeCase as Q } from "./helpers/snakeCase.js";
24
+ import { Swipe as W } from "./helpers/swipeHandler.js";
25
+ import { TextareaAutogrow as Y } from "./helpers/TextareaAutogrow.js";
26
+ import { throttle as _ } from "./helpers/throttle.js";
27
+ import { throttleId as rr } from "./helpers/throttleId.js";
28
+ import { truthyFilter as er } from "./helpers/truthyFilter.js";
29
+ import { UserVisibility as mr } from "./helpers/userVisibility.js";
28
30
  export {
29
- k as IdleTimeout,
30
- G as ScriptLoader,
31
- O as Swipe,
32
- Q as TextareaAutogrow,
33
- rr as UserVisibility,
31
+ U as IdleTimeout,
32
+ J as ScriptLoader,
33
+ W as Swipe,
34
+ Y as TextareaAutogrow,
35
+ mr as UserVisibility,
34
36
  e as camelCase,
35
37
  m as capitalize,
36
38
  f as checkAvailability,
37
39
  a as countryCodeToUnicodeFlag,
38
40
  l as debounce,
39
- n as debounceCallback,
41
+ c as debounceCallback,
40
42
  d as debounceId,
41
43
  b as formatCurrency,
42
- C as formatDate,
44
+ g as formatDate,
43
45
  S as formatNumber,
44
- F as getCountryFlagUrl,
45
- T as getErrorMessage,
46
+ k as getCountryFlagUrl,
47
+ I as getErrorMessage,
46
48
  w as isClient,
47
49
  A as isEqual,
48
50
  M as isServer,
49
51
  D as isStandaloneMode,
50
- N as normalizeString,
51
- j as pascalCase,
52
- J as sleep,
53
- W as throttle,
54
- Y as throttleId,
55
- _ as truthyFilter
52
+ N as kebabCase,
53
+ j as normalizeString,
54
+ G as pascalCase,
55
+ O as sleep,
56
+ Q as snakeCase,
57
+ _ as throttle,
58
+ rr as throttleId,
59
+ er as truthyFilter
56
60
  };
@@ -15,10 +15,12 @@ export * from './isClient';
15
15
  export * from './isEqual';
16
16
  export * from './isServer';
17
17
  export * from './isStandaloneMode';
18
+ export * from './kebabCase';
18
19
  export * from './normalizeString';
19
20
  export * from './pascalCase';
20
21
  export * from './scriptLoader';
21
22
  export * from './sleep';
23
+ export * from './snakeCase';
22
24
  export * from './swipeHandler';
23
25
  export * from './TextareaAutogrow';
24
26
  export * from './throttle';
@@ -0,0 +1 @@
1
+ export declare function kebabCase(str: string): string;
@@ -1,3 +1,4 @@
1
+ export type CaseFormat = 'kebab-case' | 'camelCase' | 'PascalCase' | 'snake_case' | 'lowercase' | 'UPPERCASE';
1
2
  export interface NormalizeStringOptions {
2
3
  /**
3
4
  * Remove accents from the string
@@ -36,6 +37,11 @@ export interface NormalizeStringOptions {
36
37
  * @default false
37
38
  */
38
39
  removeNumbers?: boolean;
40
+ /**
41
+ * Convert the output to a specific case format
42
+ * @default undefined (keeps original case, respects caseSensitive option)
43
+ */
44
+ case?: CaseFormat;
39
45
  /**
40
46
  * Normalize the string with custom normalization forms
41
47
  * @default ['NFC', 'NFKD']
@@ -0,0 +1 @@
1
+ export declare function snakeCase(str: string): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maz-ui/utils",
3
3
  "type": "module",
4
- "version": "4.0.0-beta.24",
4
+ "version": "4.0.0-beta.27",
5
5
  "description": "Utils of maz-ui for JavaScript/TypeScript users",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",
@@ -54,8 +54,8 @@
54
54
  "build": "vite build",
55
55
  "dev": "vite build --watch",
56
56
  "typecheck": "tsc --noEmit --skipLibCheck",
57
- "lint": "eslint .",
58
- "lint:fix": "eslint . --fix",
57
+ "lint": "cross-env NODE_ENV=production eslint .",
58
+ "lint:fix": "pnpm lint --fix",
59
59
  "pre-commit": "lint-staged",
60
60
  "test:unit": "vitest run",
61
61
  "test:unit:watch": "vitest watch",
@@ -65,7 +65,7 @@
65
65
  "eslint-plugin-format": "^1.0.1",
66
66
  "glob": "^11.0.3",
67
67
  "libphonenumber-js": "^1.12.10",
68
- "typescript": "^5.8.3",
68
+ "typescript": "^5.9.2",
69
69
  "vite": "^7.0.6",
70
70
  "vue": "^3.5.18"
71
71
  },
@@ -74,5 +74,5 @@
74
74
  "eslint --fix"
75
75
  ]
76
76
  },
77
- "gitHead": "9ea5ccdfb15f18c4e102ef5d2cfba29bd304d38e"
77
+ "gitHead": "fc5b5e42f115cc8b7fe4d6436defb078e3f36662"
78
78
  }