@maz-ui/utils 4.0.0-beta.27 → 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.
Files changed (2) hide show
  1. package/README.md +181 -0
  2. package/package.json +5 -4
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.
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.27",
4
+ "version": "4.0.0-beta.35",
5
5
  "description": "Utils of maz-ui for JavaScript/TypeScript users",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",
@@ -38,7 +38,8 @@
38
38
  "module": "./dist/helpers/*.js",
39
39
  "default": "./dist/helpers/*.js"
40
40
  },
41
- "./*": "./*"
41
+ "./ts-helpers": "./dist/types/ts-helpers/index.d.ts",
42
+ "./ts-helpers/*": "./dist/types/ts-helpers/*.d.ts"
42
43
  },
43
44
  "main": "./dist/index.js",
44
45
  "types": "./dist/index.d.ts",
@@ -66,7 +67,7 @@
66
67
  "glob": "^11.0.3",
67
68
  "libphonenumber-js": "^1.12.10",
68
69
  "typescript": "^5.9.2",
69
- "vite": "^7.0.6",
70
+ "vite": "^7.1.1",
70
71
  "vue": "^3.5.18"
71
72
  },
72
73
  "lint-staged": {
@@ -74,5 +75,5 @@
74
75
  "eslint --fix"
75
76
  ]
76
77
  },
77
- "gitHead": "fc5b5e42f115cc8b7fe4d6436defb078e3f36662"
78
+ "gitHead": "c27390faa3370a981efb0bd908d712871e654f1e"
78
79
  }