@maz-ui/utils 4.0.0-beta.21 → 4.0.0-beta.25
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/dist/helpers/index.js +58 -42
- package/dist/helpers/kebabCase.js +6 -0
- package/dist/helpers/normalizeString.js +31 -8
- package/dist/helpers/pascalCase.js +16 -0
- package/dist/helpers/snakeCase.js +6 -0
- package/dist/index.js +54 -50
- package/dist/types/helpers/index.d.ts +8 -0
- package/dist/types/helpers/kebabCase.d.ts +1 -0
- package/dist/types/helpers/normalizeString.d.ts +6 -0
- package/dist/types/helpers/snakeCase.d.ts +1 -0
- package/dist/types/index.d.ts +0 -1
- package/package.json +5 -17
- package/dist/formatters/index.js +0 -14
- package/dist/formatters/pascalCase.js +0 -8
- package/dist/types/formatters/index.d.ts +0 -6
- /package/dist/{formatters → helpers}/camelCase.js +0 -0
- /package/dist/{formatters → helpers}/capitalize.js +0 -0
- /package/dist/{formatters → helpers}/formatCurrency.js +0 -0
- /package/dist/{formatters → helpers}/formatDate.js +0 -0
- /package/dist/{formatters → helpers}/formatNumber.js +0 -0
- /package/dist/{formatters → helpers}/formatPhoneNumber.js +0 -0
- /package/dist/types/{formatters → helpers}/camelCase.d.ts +0 -0
- /package/dist/types/{formatters → helpers}/capitalize.d.ts +0 -0
- /package/dist/types/{formatters → helpers}/formatCurrency.d.ts +0 -0
- /package/dist/types/{formatters → helpers}/formatDate.d.ts +0 -0
- /package/dist/types/{formatters → helpers}/formatNumber.d.ts +0 -0
- /package/dist/types/{formatters → helpers}/formatPhoneNumber.d.ts +0 -0
- /package/dist/types/{formatters → helpers}/pascalCase.d.ts +0 -0
package/dist/helpers/index.js
CHANGED
|
@@ -1,44 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
1
|
+
import { camelCase as e } from "./camelCase.js";
|
|
2
|
+
import { capitalize as m } from "./capitalize.js";
|
|
3
|
+
import { checkAvailability as f } from "./checkAvailability.js";
|
|
4
|
+
import { countryCodeToUnicodeFlag as a } from "./countryCodeToUnicodeFlag.js";
|
|
5
|
+
import { debounce as l } from "./debounce.js";
|
|
6
|
+
import { debounceCallback as c } from "./debounceCallback.js";
|
|
7
|
+
import { debounceId as d } from "./debounceId.js";
|
|
8
|
+
import { formatCurrency as b } from "./formatCurrency.js";
|
|
9
|
+
import { formatDate as g } from "./formatDate.js";
|
|
10
|
+
import { formatNumber as S } from "./formatNumber.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
|
+
import { isClient as w } from "./isClient.js";
|
|
15
|
+
import { isEqual as A } from "./isEqual.js";
|
|
16
|
+
import { isServer as M } from "./isServer.js";
|
|
17
|
+
import { isStandaloneMode as D } from "./isStandaloneMode.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";
|
|
22
30
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
e as
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
U as IdleTimeout,
|
|
32
|
+
J as ScriptLoader,
|
|
33
|
+
W as Swipe,
|
|
34
|
+
Y as TextareaAutogrow,
|
|
35
|
+
mr as UserVisibility,
|
|
36
|
+
e as camelCase,
|
|
37
|
+
m as capitalize,
|
|
38
|
+
f as checkAvailability,
|
|
39
|
+
a as countryCodeToUnicodeFlag,
|
|
40
|
+
l as debounce,
|
|
41
|
+
c as debounceCallback,
|
|
42
|
+
d as debounceId,
|
|
43
|
+
b as formatCurrency,
|
|
44
|
+
g as formatDate,
|
|
45
|
+
S as formatNumber,
|
|
46
|
+
k as getCountryFlagUrl,
|
|
47
|
+
I as getErrorMessage,
|
|
48
|
+
w as isClient,
|
|
49
|
+
A as isEqual,
|
|
50
|
+
M as isServer,
|
|
51
|
+
D as isStandaloneMode,
|
|
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
|
|
44
60
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
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
|
|
12
|
-
|
|
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 =
|
|
62
|
-
if (
|
|
63
|
-
for (const
|
|
64
|
-
e = e.normalize(
|
|
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
|
-
|
|
91
|
+
S as normalizeString
|
|
69
92
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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));
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
p as pascalCase
|
|
16
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,56 +1,60 @@
|
|
|
1
|
-
import { camelCase as e } from "./
|
|
2
|
-
import { capitalize as m } from "./
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
1
|
+
import { camelCase as e } from "./helpers/camelCase.js";
|
|
2
|
+
import { capitalize as m } from "./helpers/capitalize.js";
|
|
3
|
+
import { checkAvailability as f } from "./helpers/checkAvailability.js";
|
|
4
|
+
import { countryCodeToUnicodeFlag as a } from "./helpers/countryCodeToUnicodeFlag.js";
|
|
5
|
+
import { debounce as l } from "./helpers/debounce.js";
|
|
6
|
+
import { debounceCallback as c } from "./helpers/debounceCallback.js";
|
|
7
|
+
import { debounceId as d } from "./helpers/debounceId.js";
|
|
8
|
+
import { formatCurrency as b } from "./helpers/formatCurrency.js";
|
|
9
|
+
import { formatDate as g } from "./helpers/formatDate.js";
|
|
10
|
+
import { formatNumber as S } from "./helpers/formatNumber.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
|
+
import { isClient as w } from "./helpers/isClient.js";
|
|
15
|
+
import { isEqual as A } from "./helpers/isEqual.js";
|
|
16
|
+
import { isServer as M } from "./helpers/isServer.js";
|
|
17
|
+
import { isStandaloneMode as D } from "./helpers/isStandaloneMode.js";
|
|
18
|
+
import { kebabCase as N } from "./helpers/kebabCase.js";
|
|
19
19
|
import { normalizeString as j } from "./helpers/normalizeString.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
f as checkAvailability,
|
|
39
|
+
a as countryCodeToUnicodeFlag,
|
|
40
|
+
l as debounce,
|
|
41
|
+
c as debounceCallback,
|
|
42
|
+
d as debounceId,
|
|
43
|
+
b as formatCurrency,
|
|
44
|
+
g as formatDate,
|
|
45
|
+
S as formatNumber,
|
|
46
|
+
k as getCountryFlagUrl,
|
|
47
|
+
I as getErrorMessage,
|
|
48
|
+
w as isClient,
|
|
49
|
+
A as isEqual,
|
|
50
|
+
M as isServer,
|
|
51
|
+
D as isStandaloneMode,
|
|
52
|
+
N as kebabCase,
|
|
50
53
|
j as normalizeString,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
export * from './camelCase';
|
|
2
|
+
export * from './capitalize';
|
|
1
3
|
export * from './checkAvailability';
|
|
2
4
|
export * from './countryCodeToUnicodeFlag';
|
|
3
5
|
export * from './debounce';
|
|
4
6
|
export * from './debounceCallback';
|
|
5
7
|
export * from './debounceId';
|
|
8
|
+
export * from './formatCurrency';
|
|
9
|
+
export * from './formatDate';
|
|
10
|
+
export * from './formatNumber';
|
|
6
11
|
export * from './getCountryFlagUrl';
|
|
7
12
|
export * from './getErrorMessage';
|
|
8
13
|
export * from './idleTimeout';
|
|
@@ -10,9 +15,12 @@ export * from './isClient';
|
|
|
10
15
|
export * from './isEqual';
|
|
11
16
|
export * from './isServer';
|
|
12
17
|
export * from './isStandaloneMode';
|
|
18
|
+
export * from './kebabCase';
|
|
13
19
|
export * from './normalizeString';
|
|
20
|
+
export * from './pascalCase';
|
|
14
21
|
export * from './scriptLoader';
|
|
15
22
|
export * from './sleep';
|
|
23
|
+
export * from './snakeCase';
|
|
16
24
|
export * from './swipeHandler';
|
|
17
25
|
export * from './TextareaAutogrow';
|
|
18
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/dist/types/index.d.ts
CHANGED
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.
|
|
4
|
+
"version": "4.0.0-beta.25",
|
|
5
5
|
"description": "Utils of maz-ui for JavaScript/TypeScript users",
|
|
6
6
|
"author": "Louis Mazel <me@loicmazuel.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -32,24 +32,12 @@
|
|
|
32
32
|
"module": "./dist/helpers/index.js",
|
|
33
33
|
"default": "./dist/helpers/index.js"
|
|
34
34
|
},
|
|
35
|
-
"./formatters": {
|
|
36
|
-
"types": "./dist/types/formatters/index.d.ts",
|
|
37
|
-
"import": "./dist/formatters/index.js",
|
|
38
|
-
"module": "./dist/formatters/index.js",
|
|
39
|
-
"default": "./dist/formatters/index.js"
|
|
40
|
-
},
|
|
41
35
|
"./helpers/*": {
|
|
42
36
|
"types": "./dist/types/helpers/*.d.ts",
|
|
43
37
|
"import": "./dist/helpers/*.js",
|
|
44
38
|
"module": "./dist/helpers/*.js",
|
|
45
39
|
"default": "./dist/helpers/*.js"
|
|
46
40
|
},
|
|
47
|
-
"./formatters/*": {
|
|
48
|
-
"types": "./dist/types/formatters/*.d.ts",
|
|
49
|
-
"import": "./dist/formatters/*.js",
|
|
50
|
-
"module": "./dist/formatters/*.js",
|
|
51
|
-
"default": "./dist/formatters/*.js"
|
|
52
|
-
},
|
|
53
41
|
"./*": "./*"
|
|
54
42
|
},
|
|
55
43
|
"main": "./dist/index.js",
|
|
@@ -66,8 +54,8 @@
|
|
|
66
54
|
"build": "vite build",
|
|
67
55
|
"dev": "vite build --watch",
|
|
68
56
|
"typecheck": "tsc --noEmit --skipLibCheck",
|
|
69
|
-
"lint": "eslint .",
|
|
70
|
-
"lint:fix": "
|
|
57
|
+
"lint": "cross-env NODE_ENV=production eslint .",
|
|
58
|
+
"lint:fix": "pnpm lint --fix",
|
|
71
59
|
"pre-commit": "lint-staged",
|
|
72
60
|
"test:unit": "vitest run",
|
|
73
61
|
"test:unit:watch": "vitest watch",
|
|
@@ -77,7 +65,7 @@
|
|
|
77
65
|
"eslint-plugin-format": "^1.0.1",
|
|
78
66
|
"glob": "^11.0.3",
|
|
79
67
|
"libphonenumber-js": "^1.12.10",
|
|
80
|
-
"typescript": "^5.
|
|
68
|
+
"typescript": "^5.9.2",
|
|
81
69
|
"vite": "^7.0.6",
|
|
82
70
|
"vue": "^3.5.18"
|
|
83
71
|
},
|
|
@@ -86,5 +74,5 @@
|
|
|
86
74
|
"eslint --fix"
|
|
87
75
|
]
|
|
88
76
|
},
|
|
89
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "0173f663d5b5b821eab8757f150da3f8218cf254"
|
|
90
78
|
}
|
package/dist/formatters/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { camelCase as e } from "./camelCase.js";
|
|
2
|
-
import { capitalize as m } from "./capitalize.js";
|
|
3
|
-
import { formatCurrency as f } from "./formatCurrency.js";
|
|
4
|
-
import { formatDate as x } from "./formatDate.js";
|
|
5
|
-
import { formatNumber as l } from "./formatNumber.js";
|
|
6
|
-
import { pascalCase as C } from "./pascalCase.js";
|
|
7
|
-
export {
|
|
8
|
-
e as camelCase,
|
|
9
|
-
m as capitalize,
|
|
10
|
-
f as formatCurrency,
|
|
11
|
-
x as formatDate,
|
|
12
|
-
l as formatNumber,
|
|
13
|
-
C as pascalCase
|
|
14
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|