@maz-ui/utils 4.0.0-beta.3 → 4.0.0-beta.35
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 +181 -0
- package/dist/{utils → helpers}/getBrowserLocale.js +1 -1
- package/dist/helpers/getErrorMessage.js +6 -0
- package/dist/helpers/index.js +60 -0
- package/dist/helpers/isServer.js +6 -0
- package/dist/{utils → helpers}/isStandaloneMode.js +2 -2
- package/dist/helpers/kebabCase.js +6 -0
- package/dist/helpers/normalizeString.js +92 -0
- package/dist/helpers/pascalCase.js +16 -0
- package/dist/{utils → helpers}/scriptLoader.js +9 -9
- package/dist/helpers/snakeCase.js +6 -0
- package/dist/index.js +54 -48
- package/dist/types/{utils → helpers}/TextareaAutogrow.d.ts +0 -1
- package/dist/types/{formatters → helpers}/camelCase.d.ts +0 -1
- package/dist/types/{formatters → helpers}/capitalize.d.ts +0 -1
- package/dist/types/{utils → helpers}/checkAvailability.d.ts +0 -1
- package/dist/types/{utils → helpers}/countryCodeToUnicodeFlag.d.ts +0 -1
- package/dist/types/{utils → helpers}/debounce.d.ts +0 -1
- package/dist/types/{utils → helpers}/debounceCallback.d.ts +0 -1
- package/dist/types/{utils → helpers}/debounceId.d.ts +0 -1
- package/dist/types/{utils → helpers}/fetchLocaleIp.d.ts +0 -1
- package/dist/types/{formatters → helpers}/formatCurrency.d.ts +0 -1
- package/dist/types/{formatters → helpers}/formatDate.d.ts +0 -1
- package/dist/types/{formatters → helpers}/formatNumber.d.ts +0 -1
- package/dist/types/{formatters → helpers}/formatPhoneNumber.d.ts +0 -1
- package/dist/types/{utils → helpers}/getBrowserLocale.d.ts +0 -1
- package/dist/types/{utils → helpers}/getCountryFlagUrl.d.ts +0 -1
- package/dist/types/helpers/getErrorMessage.d.ts +1 -0
- package/dist/types/{utils → helpers}/idleTimeout.d.ts +0 -1
- package/dist/types/{utils → helpers}/index.d.ts +9 -1
- package/dist/types/{utils → helpers}/isClient.d.ts +0 -1
- package/dist/types/{utils → helpers}/isEqual.d.ts +0 -1
- package/dist/types/{utils → helpers}/isServer.d.ts +0 -1
- package/dist/types/{utils → helpers}/isStandaloneMode.d.ts +0 -1
- package/dist/types/helpers/kebabCase.d.ts +1 -0
- package/dist/types/{utils → helpers}/normalizeString.d.ts +6 -1
- package/dist/types/{formatters → helpers}/pascalCase.d.ts +0 -1
- package/dist/types/{utils → helpers}/scriptLoader.d.ts +1 -2
- package/dist/types/{utils → helpers}/sleep.d.ts +0 -1
- package/dist/types/helpers/snakeCase.d.ts +1 -0
- package/dist/types/{utils → helpers}/swipeHandler.d.ts +0 -1
- package/dist/types/{utils → helpers}/throttle.d.ts +0 -1
- package/dist/types/{utils → helpers}/throttleId.d.ts +0 -1
- package/dist/types/{utils → helpers}/truthyFilter.d.ts +0 -1
- package/dist/types/{utils → helpers}/userVisibility.d.ts +0 -1
- package/dist/types/index.d.ts +1 -3
- package/dist/types/ts-helpers/DeepKeyOf.d.ts +0 -1
- package/dist/types/ts-helpers/DeepPartial.d.ts +0 -1
- package/dist/types/ts-helpers/FlattenObjectKeys.d.ts +0 -1
- package/dist/types/ts-helpers/GenericInstanceType.d.ts +15 -0
- package/dist/types/ts-helpers/InferMaybeRef.d.ts +0 -1
- package/dist/types/ts-helpers/index.d.ts +1 -1
- package/package.json +25 -34
- package/dist/formatters/index.js +0 -14
- package/dist/formatters/pascalCase.js +0 -8
- package/dist/types/formatters/camelCase.d.ts.map +0 -1
- package/dist/types/formatters/capitalize.d.ts.map +0 -1
- package/dist/types/formatters/formatCurrency.d.ts.map +0 -1
- package/dist/types/formatters/formatDate.d.ts.map +0 -1
- package/dist/types/formatters/formatNumber.d.ts.map +0 -1
- package/dist/types/formatters/formatPhoneNumber.d.ts.map +0 -1
- package/dist/types/formatters/index.d.ts +0 -7
- package/dist/types/formatters/index.d.ts.map +0 -1
- package/dist/types/formatters/pascalCase.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/ts-helpers/DeepKeyOf.d.ts.map +0 -1
- package/dist/types/ts-helpers/DeepPartial.d.ts.map +0 -1
- package/dist/types/ts-helpers/FlattenObjectKeys.d.ts.map +0 -1
- package/dist/types/ts-helpers/InferMaybeRef.d.ts.map +0 -1
- package/dist/types/ts-helpers/index.d.ts.map +0 -1
- package/dist/types/utils/TextareaAutogrow.d.ts.map +0 -1
- package/dist/types/utils/checkAvailability.d.ts.map +0 -1
- package/dist/types/utils/countryCodeToUnicodeFlag.d.ts.map +0 -1
- package/dist/types/utils/debounce.d.ts.map +0 -1
- package/dist/types/utils/debounceCallback.d.ts.map +0 -1
- package/dist/types/utils/debounceId.d.ts.map +0 -1
- package/dist/types/utils/fetchLocaleIp.d.ts.map +0 -1
- package/dist/types/utils/getBrowserLocale.d.ts.map +0 -1
- package/dist/types/utils/getCountryFlagUrl.d.ts.map +0 -1
- package/dist/types/utils/idleTimeout.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/types/utils/isClient.d.ts.map +0 -1
- package/dist/types/utils/isEqual.d.ts.map +0 -1
- package/dist/types/utils/isServer.d.ts.map +0 -1
- package/dist/types/utils/isStandaloneMode.d.ts.map +0 -1
- package/dist/types/utils/normalizeString.d.ts.map +0 -1
- package/dist/types/utils/scriptLoader.d.ts.map +0 -1
- package/dist/types/utils/sleep.d.ts.map +0 -1
- package/dist/types/utils/swipeHandler.d.ts.map +0 -1
- package/dist/types/utils/throttle.d.ts.map +0 -1
- package/dist/types/utils/throttleId.d.ts.map +0 -1
- package/dist/types/utils/truthyFilter.d.ts.map +0 -1
- package/dist/types/utils/userVisibility.d.ts.map +0 -1
- package/dist/utils/index.js +0 -42
- package/dist/utils/isServer.js +0 -6
- package/dist/utils/normalizeString.js +0 -69
- /package/dist/{utils → helpers}/TextareaAutogrow.js +0 -0
- /package/dist/{formatters → helpers}/camelCase.js +0 -0
- /package/dist/{formatters → helpers}/capitalize.js +0 -0
- /package/dist/{utils → helpers}/checkAvailability.js +0 -0
- /package/dist/{utils → helpers}/countryCodeToUnicodeFlag.js +0 -0
- /package/dist/{utils → helpers}/debounce.js +0 -0
- /package/dist/{utils → helpers}/debounceCallback.js +0 -0
- /package/dist/{utils → helpers}/debounceId.js +0 -0
- /package/dist/{utils → helpers}/fetchLocaleIp.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/{utils → helpers}/getCountryFlagUrl.js +0 -0
- /package/dist/{utils → helpers}/idleTimeout.js +0 -0
- /package/dist/{utils → helpers}/isClient.js +0 -0
- /package/dist/{utils → helpers}/isEqual.js +0 -0
- /package/dist/{utils → helpers}/sleep.js +0 -0
- /package/dist/{utils → helpers}/swipeHandler.js +0 -0
- /package/dist/{utils → helpers}/throttle.js +0 -0
- /package/dist/{utils → helpers}/throttleId.js +0 -0
- /package/dist/{utils → helpers}/truthyFilter.js +0 -0
- /package/dist/{utils → helpers}/userVisibility.js +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# @maz-ui/utils
|
|
2
|
+
|
|
3
|
+
JavaScript/TypeScript utility functions for the Maz-UI ecosystem - String manipulation, date formatting, debouncing, throttling, and more.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @maz-ui/utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **String utilities** - Case conversion, normalization, and manipulation
|
|
14
|
+
- **Date and number formatting** - Localized formatting with internationalization support
|
|
15
|
+
- **Performance utilities** - Debouncing, throttling, and optimization helpers
|
|
16
|
+
- **Browser utilities** - Client/server detection, user visibility, and environment checks
|
|
17
|
+
- **TypeScript helpers** - Advanced type utilities for better type safety
|
|
18
|
+
- **Phone number formatting** - International phone number utilities
|
|
19
|
+
- **Currency formatting** - Multi-currency formatting support
|
|
20
|
+
- **Validation utilities** - Deep equality checks and data validation
|
|
21
|
+
- **DOM utilities** - Script loading, textarea autogrow, and swipe handling
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Basic Import
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { camelCase, debounce, formatDate } from '@maz-ui/utils'
|
|
29
|
+
|
|
30
|
+
// String utilities
|
|
31
|
+
const camelCased = camelCase('hello-world') // 'helloWorld'
|
|
32
|
+
|
|
33
|
+
// Date formatting
|
|
34
|
+
const formatted = formatDate(new Date(), 'en-US') // '12/25/2023'
|
|
35
|
+
|
|
36
|
+
// Performance utilities
|
|
37
|
+
const debouncedFn = debounce(() => console.log('Called!'), 300)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Modular Imports
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// Import TypeScript helpers
|
|
44
|
+
import type { DeepPartial } from '@maz-ui/utils/ts-helpers/DeepPartial'
|
|
45
|
+
// Import specific helpers
|
|
46
|
+
import { camelCase } from '@maz-ui/utils/helpers/camelCase'
|
|
47
|
+
import { debounce } from '@maz-ui/utils/helpers/debounce'
|
|
48
|
+
import { formatDate } from '@maz-ui/utils/helpers/formatDate'
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Available Utilities
|
|
52
|
+
|
|
53
|
+
### String Utilities
|
|
54
|
+
|
|
55
|
+
- **camelCase** - Convert strings to camelCase
|
|
56
|
+
- **capitalize** - Capitalize first letter of strings
|
|
57
|
+
- **kebabCase** - Convert strings to kebab-case
|
|
58
|
+
- **pascalCase** - Convert strings to PascalCase
|
|
59
|
+
- **snakeCase** - Convert strings to snake_case
|
|
60
|
+
- **normalizeString** - Normalize strings for comparison
|
|
61
|
+
|
|
62
|
+
### Date and Number Formatting
|
|
63
|
+
|
|
64
|
+
- **formatDate** - Format dates with locale support
|
|
65
|
+
- **formatNumber** - Format numbers with locale support
|
|
66
|
+
- **formatCurrency** - Format currency values with locale support
|
|
67
|
+
|
|
68
|
+
### Performance Utilities
|
|
69
|
+
|
|
70
|
+
- **debounce** - Debounce function calls
|
|
71
|
+
- **debounceCallback** - Debounce with callback support
|
|
72
|
+
- **debounceId** - Debounce with unique identifiers
|
|
73
|
+
- **throttle** - Throttle function calls
|
|
74
|
+
- **throttleId** - Throttle with unique identifiers
|
|
75
|
+
|
|
76
|
+
### Browser and Environment
|
|
77
|
+
|
|
78
|
+
- **isClient** - Check if running in client environment
|
|
79
|
+
- **isServer** - Check if running in server environment
|
|
80
|
+
- **isStandaloneMode** - Check if app is in standalone mode
|
|
81
|
+
- **userVisibility** - Track user visibility state
|
|
82
|
+
- **getBrowserLocale** - Get browser locale settings
|
|
83
|
+
|
|
84
|
+
### Validation and Comparison
|
|
85
|
+
|
|
86
|
+
- **isEqual** - Deep equality comparison
|
|
87
|
+
- **checkAvailability** - Check resource availability
|
|
88
|
+
- **truthyFilter** - Filter truthy values from arrays
|
|
89
|
+
|
|
90
|
+
### DOM and UI Utilities
|
|
91
|
+
|
|
92
|
+
- **scriptLoader** - Dynamic script loading
|
|
93
|
+
- **TextareaAutogrow** - Automatic textarea height adjustment
|
|
94
|
+
- **swipeHandler** - Touch swipe gesture handling
|
|
95
|
+
- **idleTimeout** - Idle state management
|
|
96
|
+
|
|
97
|
+
### Phone and Location
|
|
98
|
+
|
|
99
|
+
- **formatPhoneNumber** - Format international phone numbers
|
|
100
|
+
- **countryCodeToUnicodeFlag** - Convert country codes to flag emojis
|
|
101
|
+
- **getCountryFlagUrl** - Get country flag image URLs
|
|
102
|
+
- **fetchLocaleIp** - Fetch user locale from IP
|
|
103
|
+
|
|
104
|
+
### Utility Functions
|
|
105
|
+
|
|
106
|
+
- **sleep** - Promise-based delay utility
|
|
107
|
+
- **getErrorMessage** - Extract error messages safely
|
|
108
|
+
|
|
109
|
+
## TypeScript Helpers
|
|
110
|
+
|
|
111
|
+
Advanced type utilities for enhanced TypeScript development:
|
|
112
|
+
|
|
113
|
+
- **DeepPartial<T>** - Make all properties optional recursively
|
|
114
|
+
- **DeepKeyOf<T>** - Get all nested keys of an object type
|
|
115
|
+
- **FlattenObjectKeys<T>** - Flatten object keys to dot notation
|
|
116
|
+
- **GenericInstanceType<T>** - Extract instance type from constructor
|
|
117
|
+
- **InferMaybeRef<T>** - Infer type from Vue ref or regular value
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import type { DeepKeyOf, DeepPartial } from '@maz-ui/utils'
|
|
121
|
+
|
|
122
|
+
interface User {
|
|
123
|
+
profile: {
|
|
124
|
+
name: string
|
|
125
|
+
email: string
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
type PartialUser = DeepPartial<User> // All properties optional
|
|
130
|
+
type UserKeys = DeepKeyOf<User> // 'profile' | 'profile.name' | 'profile.email'
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Performance Examples
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import { debounce, throttle } from '@maz-ui/utils'
|
|
137
|
+
|
|
138
|
+
// Debounce search input
|
|
139
|
+
const debouncedSearch = debounce((query: string) => {
|
|
140
|
+
performSearch(query)
|
|
141
|
+
}, 300)
|
|
142
|
+
|
|
143
|
+
// Throttle scroll events
|
|
144
|
+
const throttledScroll = throttle(() => {
|
|
145
|
+
updateScrollPosition()
|
|
146
|
+
}, 16)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Formatting Examples
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { formatCurrency, formatDate, formatPhoneNumber } from '@maz-ui/utils'
|
|
153
|
+
|
|
154
|
+
// Currency formatting
|
|
155
|
+
const price = formatCurrency(1234.56, 'USD', 'en-US') // '$1,234.56'
|
|
156
|
+
|
|
157
|
+
// Date formatting
|
|
158
|
+
const date = formatDate(new Date(), 'fr-FR') // '25/12/2023'
|
|
159
|
+
|
|
160
|
+
// Phone formatting
|
|
161
|
+
const phone = formatPhoneNumber('+33123456789', 'international')
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Requirements
|
|
165
|
+
|
|
166
|
+
- Node.js >= 18.0.0
|
|
167
|
+
- TypeScript support included
|
|
168
|
+
- Tree-shakeable for optimal bundle size
|
|
169
|
+
|
|
170
|
+
## Contributing
|
|
171
|
+
|
|
172
|
+
Contributions are welcome! Please ensure:
|
|
173
|
+
|
|
174
|
+
- New utilities follow existing patterns
|
|
175
|
+
- TypeScript types are properly defined
|
|
176
|
+
- Unit tests are included
|
|
177
|
+
- Documentation is updated accordingly
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
MIT License - see LICENSE file for details.
|
|
@@ -0,0 +1,60 @@
|
|
|
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";
|
|
30
|
+
export {
|
|
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
|
|
60
|
+
};
|
|
@@ -2,8 +2,8 @@ import { isClient as t } from "./isClient.js";
|
|
|
2
2
|
function e() {
|
|
3
3
|
if (!t())
|
|
4
4
|
return !1;
|
|
5
|
-
const
|
|
6
|
-
return
|
|
5
|
+
const a = navigator, n = globalThis.matchMedia("(display-mode: standalone)").matches;
|
|
6
|
+
return a.standalone || n;
|
|
7
7
|
}
|
|
8
8
|
export {
|
|
9
9
|
e as isStandaloneMode
|
|
@@ -0,0 +1,92 @@
|
|
|
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 = {
|
|
6
|
+
removeAccents: !0,
|
|
7
|
+
caseSensitive: !1,
|
|
8
|
+
replaceSpaces: !0,
|
|
9
|
+
removeSpecialCharacters: !1,
|
|
10
|
+
trim: !0,
|
|
11
|
+
normalizeSpaces: !0,
|
|
12
|
+
removeNumbers: !1,
|
|
13
|
+
case: void 0,
|
|
14
|
+
customNormalizationForms: ["NFC", "NFKD"]
|
|
15
|
+
};
|
|
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 = {
|
|
36
|
+
À: "A",
|
|
37
|
+
Á: "A",
|
|
38
|
+
Â: "A",
|
|
39
|
+
Ã: "A",
|
|
40
|
+
Ä: "A",
|
|
41
|
+
Å: "A",
|
|
42
|
+
à: "a",
|
|
43
|
+
á: "a",
|
|
44
|
+
â: "a",
|
|
45
|
+
ã: "a",
|
|
46
|
+
ä: "a",
|
|
47
|
+
å: "a",
|
|
48
|
+
È: "E",
|
|
49
|
+
É: "E",
|
|
50
|
+
Ê: "E",
|
|
51
|
+
Ë: "E",
|
|
52
|
+
è: "e",
|
|
53
|
+
é: "e",
|
|
54
|
+
ê: "e",
|
|
55
|
+
ë: "e",
|
|
56
|
+
Î: "I",
|
|
57
|
+
Ï: "I",
|
|
58
|
+
í: "I",
|
|
59
|
+
î: "i",
|
|
60
|
+
ï: "i",
|
|
61
|
+
Ô: "O",
|
|
62
|
+
Õ: "O",
|
|
63
|
+
Ö: "O",
|
|
64
|
+
Ø: "O",
|
|
65
|
+
ô: "o",
|
|
66
|
+
õ: "o",
|
|
67
|
+
ö: "o",
|
|
68
|
+
ø: "o",
|
|
69
|
+
Ù: "U",
|
|
70
|
+
Ú: "U",
|
|
71
|
+
Û: "U",
|
|
72
|
+
Ü: "U",
|
|
73
|
+
ù: "u",
|
|
74
|
+
ú: "u",
|
|
75
|
+
û: "u",
|
|
76
|
+
ü: "u",
|
|
77
|
+
Ç: "C",
|
|
78
|
+
ç: "c",
|
|
79
|
+
ÿ: "y",
|
|
80
|
+
Ñ: "N",
|
|
81
|
+
ñ: "n",
|
|
82
|
+
ó: "o"
|
|
83
|
+
};
|
|
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);
|
|
88
|
+
return e;
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
S as normalizeString
|
|
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
|
+
};
|
|
@@ -5,33 +5,33 @@ class s {
|
|
|
5
5
|
async;
|
|
6
6
|
defer;
|
|
7
7
|
identifier;
|
|
8
|
-
constructor({ src: e, identifier: t, once:
|
|
9
|
-
if (typeof window > "u")
|
|
8
|
+
constructor({ src: e, identifier: t, once: o = !0, async: r = !0, defer: i = !0 }) {
|
|
9
|
+
if (typeof globalThis.window > "u")
|
|
10
10
|
throw new TypeError("[ScriptLoader]: Is supported only on browser side");
|
|
11
11
|
if (!e)
|
|
12
12
|
throw new Error('[ScriptLoader]: You should provide the attribut "src"');
|
|
13
13
|
if (!t)
|
|
14
14
|
throw new Error('[ScriptLoader]: You should provide the attribut "identifier"');
|
|
15
|
-
this.src = e, this.identifier = t, this.once =
|
|
15
|
+
this.src = e, this.identifier = t, this.once = o, this.async = r, this.defer = i;
|
|
16
16
|
}
|
|
17
17
|
removeTag(e) {
|
|
18
18
|
typeof e == "string" ? document.head.querySelector(`[data-identifier="${e}"]`)?.remove() : e.remove();
|
|
19
19
|
}
|
|
20
20
|
load() {
|
|
21
|
-
const e =
|
|
21
|
+
const e = globalThis, t = document.head.querySelectorAll(`[data-identifier="${this.identifier}"]`);
|
|
22
22
|
if (this.once && e[this.identifier] && t.length > 0)
|
|
23
23
|
return this.script = e[this.identifier], Promise.resolve(this.script);
|
|
24
24
|
if (!this.once && t.length > 0)
|
|
25
|
-
for (const
|
|
26
|
-
this.removeTag(
|
|
25
|
+
for (const o of t)
|
|
26
|
+
this.removeTag(o);
|
|
27
27
|
return this.injectScript();
|
|
28
28
|
}
|
|
29
29
|
injectScript() {
|
|
30
|
-
const e =
|
|
31
|
-
return new Promise((t,
|
|
30
|
+
const e = globalThis;
|
|
31
|
+
return new Promise((t, o) => {
|
|
32
32
|
try {
|
|
33
33
|
const r = document.createElement("script");
|
|
34
|
-
r.src = this.src, r.async = this.async, r.defer = this.defer, r.dataset.identifier = this.identifier, r.addEventListener("error", (i) =>
|
|
34
|
+
r.src = this.src, r.async = this.async, r.defer = this.defer, r.dataset.identifier = this.identifier, r.addEventListener("error", (i) => o(new Error(`[ScriptLoader](injectScript) ${i.message}`))), r.addEventListener("load", (i) => (this.script = i, e[this.identifier] = i, t(i))), document.head.append(r);
|
|
35
35
|
} catch (r) {
|
|
36
36
|
throw new Error(`[ScriptLoader](init) ${r}`);
|
|
37
37
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,54 +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 { IdleTimeout as
|
|
14
|
-
import { isClient as w } from "./
|
|
15
|
-
import { isEqual as A } from "./
|
|
16
|
-
import { isServer as
|
|
17
|
-
import { isStandaloneMode as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
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
|
+
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";
|
|
27
30
|
export {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
U as IdleTimeout,
|
|
32
|
+
J as ScriptLoader,
|
|
33
|
+
W as Swipe,
|
|
34
|
+
Y as TextareaAutogrow,
|
|
35
|
+
mr as UserVisibility,
|
|
33
36
|
e as camelCase,
|
|
34
37
|
m as capitalize,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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,
|
|
44
48
|
w as isClient,
|
|
45
49
|
A as isEqual,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
N as
|
|
49
|
-
|
|
50
|
-
G as
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
54
60
|
};
|
|
@@ -4,4 +4,3 @@ type AsyncFunction<T, Args extends unknown[]> = (...args: Args) => T | Promise<T
|
|
|
4
4
|
*/
|
|
5
5
|
export declare function debounceId<T, Args extends unknown[]>(identifier: string, func: AsyncFunction<T, Args>, delay: number): (...args: Args) => Promise<T>;
|
|
6
6
|
export {};
|
|
7
|
-
//# sourceMappingURL=debounceId.d.ts.map
|
|
@@ -6,4 +6,3 @@ declare const _supportedCodes: readonly ["ad", "ae", "af", "ag", "ai", "al", "am
|
|
|
6
6
|
type SupportedCodes = typeof _supportedCodes[number];
|
|
7
7
|
export declare function getCountryFlagUrl(countryIsoCode: SupportedCodes | string, size?: Size): string | undefined;
|
|
8
8
|
export {};
|
|
9
|
-
//# sourceMappingURL=getCountryFlagUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getErrorMessage(error: unknown): string;
|