@desource/phone-mask-nuxt 1.2.0 β 1.3.1
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/CHANGELOG.md +52 -0
- package/README.md +129 -23
- package/dist/module.d.mts +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +12 -3
- package/dist/runtime/shared.d.ts +2 -1
- package/dist/runtime/shared.js +2 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# @desource/phone-mask-nuxt
|
|
2
2
|
|
|
3
|
+
## 1.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Core Upgrades:
|
|
8
|
+
- Sync country masks with google-libphonenumber (πΈπ° Slovakia updates)
|
|
9
|
+
|
|
10
|
+
- Updated dependencies []:
|
|
11
|
+
- @desource/phone-mask-vue@1.3.1
|
|
12
|
+
|
|
13
|
+
## 1.3.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- Core Upgrades:
|
|
18
|
+
- Improved process keydown event handler for browser autocomplete cases
|
|
19
|
+
|
|
20
|
+
- Vue Upgrades:
|
|
21
|
+
- Added new `@desource/phone-mask-vue/core` subpath export (direct core helpers re-export)
|
|
22
|
+
- Root `PMaskHelpers` facade removed from index (helpers now via `/core` to reduce bundle size impact for Vue users)
|
|
23
|
+
- Added `id` and `name` props on `PhoneInput`, passed to underlying `<input>` element for better form integration and accessibility
|
|
24
|
+
- Added autofill style normalization (`-webkit-autofill` / `-moz-autofill`) for better visual consistency
|
|
25
|
+
|
|
26
|
+
- React Upgrades:
|
|
27
|
+
- Added new `@desource/phone-mask-react/core` subpath export (direct core helpers re-export)
|
|
28
|
+
- Root `PMaskHelpers` facade removed from index (helpers now via `/core` to reduce bundle size impact for React users)
|
|
29
|
+
- Added `id` and `name` props on `PhoneInput`, passed to underlying `<input>` element for better form integration and accessibility
|
|
30
|
+
- Added autofill style normalization (`-webkit-autofill` / `-moz-autofill`) for better visual consistency
|
|
31
|
+
- `useCountrySelector`, `useClipboard` internals stabilized (deps/callback consistency improvements)
|
|
32
|
+
- `usePhoneMask` callback dependency tuning for better stability
|
|
33
|
+
|
|
34
|
+
- Svelte Upgrades:
|
|
35
|
+
- Added new `@desource/phone-mask-svelte/core` subpath export (direct core helpers re-export)
|
|
36
|
+
- Root `PMaskHelpers` facade removed from index (helpers now via `/core` to reduce bundle size impact for Svelte users)
|
|
37
|
+
- Added `id` and `name` props on `PhoneInput`, passed to underlying `<input>` element for better form integration and accessibility
|
|
38
|
+
- Added autofill style normalization (`-webkit-autofill` / `-moz-autofill`) for better visual consistency
|
|
39
|
+
|
|
40
|
+
- Nuxt Upgrades:
|
|
41
|
+
- Module options expanded and clarified:
|
|
42
|
+
- `types` (default `true`): auto-import types from packages for TypeScript users
|
|
43
|
+
- `helpers` (default `false`): auto-import core helpers for direct usage in Nuxt apps (optional due to potential bundle size impact)
|
|
44
|
+
- new: `composable` (default `false`): auto-import Vue composable for custom phone mask logic (optional for users who only need more custom solution than the provided component/directive)
|
|
45
|
+
- Default auto-imports now focus on component/directive/types; helpers/composable are opt-in
|
|
46
|
+
- Runtime shared exports updated:
|
|
47
|
+
- `usePhoneMask` (composable) is now a separate export from `phoneMaskDirective` and `PhoneInput` component for more flexible usage patterns
|
|
48
|
+
- `PMaskHelpers` sourced via `@desource/phone-mask-vue/core` for better tree-shaking and bundle size control
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- Updated dependencies []:
|
|
53
|
+
- @desource/phone-mask-vue@1.3.0
|
|
54
|
+
|
|
3
55
|
## 1.2.0
|
|
4
56
|
|
|
5
57
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Drop-in Nuxt module with auto-imports, SSR support, and zero configuration.
|
|
|
10
10
|
## β¨ Features
|
|
11
11
|
|
|
12
12
|
- π― **Zero Config** β Works out of the box
|
|
13
|
-
- π **Auto-imports** β
|
|
13
|
+
- π **Auto-imports** β Component, directive, and types by default
|
|
14
14
|
- π **SSR Compatible** β Server-side rendering ready
|
|
15
15
|
- π¨ **Styleable** β Bring your own styles or use defaults
|
|
16
16
|
- π§ **TypeScript** β Fully typed
|
|
@@ -36,7 +36,8 @@ export default defineNuxtConfig({
|
|
|
36
36
|
});
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
That's it! The component and
|
|
39
|
+
That's it! The component, directive, and related mask types are now auto-imported.
|
|
40
|
+
You can additionally enable helper/composable auto-imports via module options.
|
|
40
41
|
|
|
41
42
|
## π Usage
|
|
42
43
|
|
|
@@ -109,6 +110,91 @@ const handleChange = (nextPhone: PMaskPhoneNumber) => {
|
|
|
109
110
|
</script>
|
|
110
111
|
```
|
|
111
112
|
|
|
113
|
+
### SSR + Auto-imports in Practice
|
|
114
|
+
|
|
115
|
+
`@desource/phone-mask-nuxt` is SSR-safe: the module config is evaluated on server, while the UI component is registered in client mode.
|
|
116
|
+
|
|
117
|
+
```vue
|
|
118
|
+
<script setup lang="ts">
|
|
119
|
+
const phone = ref('');
|
|
120
|
+
const valid = ref(false);
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<template>
|
|
124
|
+
<!-- Auto-imported: no explicit component import required -->
|
|
125
|
+
<PhoneInput id="phone" name="phone" v-model="phone" country="US" @validation-change="valid = $event" />
|
|
126
|
+
|
|
127
|
+
<p v-if="valid">β Ready to submit</p>
|
|
128
|
+
</template>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Backend Payload (Raw Digits)
|
|
132
|
+
|
|
133
|
+
```vue
|
|
134
|
+
<script setup lang="ts">
|
|
135
|
+
import type { PMaskPhoneNumber } from '#imports';
|
|
136
|
+
|
|
137
|
+
const phoneDigits = ref('');
|
|
138
|
+
|
|
139
|
+
const handlePhoneChange = async (phone: PMaskPhoneNumber) => {
|
|
140
|
+
await $fetch('/api/profile/phone', {
|
|
141
|
+
method: 'POST',
|
|
142
|
+
body: {
|
|
143
|
+
phoneDigits: phone.digits, // unformatted value for backend
|
|
144
|
+
phoneFull: phone.full // optional full number with country code
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
</script>
|
|
149
|
+
|
|
150
|
+
<template>
|
|
151
|
+
<PhoneInput v-model="phoneDigits" country="US" @change="handlePhoneChange" />
|
|
152
|
+
</template>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Auto-importing Helpers + Composable
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
// nuxt.config.ts
|
|
159
|
+
export default defineNuxtConfig({
|
|
160
|
+
modules: ['@desource/phone-mask-nuxt'],
|
|
161
|
+
phoneMask: {
|
|
162
|
+
// Disable auto-imported styles, component, and directive if you don't need them
|
|
163
|
+
css: false,
|
|
164
|
+
component: false,
|
|
165
|
+
directive: false,
|
|
166
|
+
// And enable only needed auto-imports
|
|
167
|
+
helpers: true,
|
|
168
|
+
composable: true
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Then use them directly in SFCs without manual imports:
|
|
174
|
+
|
|
175
|
+
```vue
|
|
176
|
+
<script setup lang="ts">
|
|
177
|
+
const value = ref('');
|
|
178
|
+
const selectedCountry = ref('US');
|
|
179
|
+
|
|
180
|
+
const { inputRef, setCountry } = usePhoneMask({
|
|
181
|
+
value,
|
|
182
|
+
onChange: (digits) => (value.value = digits),
|
|
183
|
+
country: selectedCountry
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const setGermany = () => {
|
|
187
|
+
setCountry('DE');
|
|
188
|
+
};
|
|
189
|
+
</script>
|
|
190
|
+
|
|
191
|
+
<template>
|
|
192
|
+
<input ref="inputRef" type="tel" />
|
|
193
|
+
<button @click="setGermany">Use Germany</button>
|
|
194
|
+
<p>Code for DE: {{ PMaskHelpers.MasksMap.DE.code }}</p>
|
|
195
|
+
</template>
|
|
196
|
+
```
|
|
197
|
+
|
|
112
198
|
## βοΈ Configuration
|
|
113
199
|
|
|
114
200
|
### Module Options
|
|
@@ -129,8 +215,26 @@ export default defineNuxtConfig({
|
|
|
129
215
|
// Register v-phone-mask directive
|
|
130
216
|
directive: true, // Default: true
|
|
131
217
|
|
|
132
|
-
// Register
|
|
133
|
-
|
|
218
|
+
// Register mask-related TypeScript types
|
|
219
|
+
types: true, // Default: true
|
|
220
|
+
|
|
221
|
+
// Register shared helper namespace + directive helper
|
|
222
|
+
helpers: false, // Default: false
|
|
223
|
+
|
|
224
|
+
// Register usePhoneMask composable
|
|
225
|
+
composable: false // Default: false
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Enable Helpers and Composable Auto-imports
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
export default defineNuxtConfig({
|
|
234
|
+
modules: ['@desource/phone-mask-nuxt'],
|
|
235
|
+
phoneMask: {
|
|
236
|
+
helpers: true,
|
|
237
|
+
composable: true
|
|
134
238
|
}
|
|
135
239
|
});
|
|
136
240
|
```
|
|
@@ -243,7 +347,7 @@ export const useUserStore = defineStore('user', {
|
|
|
243
347
|
|
|
244
348
|
actions: {
|
|
245
349
|
setPhoneDigits(phone: string) {
|
|
246
|
-
this.
|
|
350
|
+
this.phoneDigits = phone;
|
|
247
351
|
},
|
|
248
352
|
|
|
249
353
|
setCountry(id: string) {
|
|
@@ -324,7 +428,7 @@ const phone = ref('');
|
|
|
324
428
|
|
|
325
429
|
## π― Auto-imports
|
|
326
430
|
|
|
327
|
-
|
|
431
|
+
By default (without extra options), Nuxt auto-imports:
|
|
328
432
|
|
|
329
433
|
### Components
|
|
330
434
|
|
|
@@ -334,22 +438,23 @@ The following are automatically imported (until disabled in nuxt.config.ts):
|
|
|
334
438
|
|
|
335
439
|
- `vPhoneMask` β Phone mask directive
|
|
336
440
|
|
|
337
|
-
###
|
|
441
|
+
### Types
|
|
442
|
+
|
|
443
|
+
- `PCountryKey`
|
|
444
|
+
- `PMaskBase`, `PMaskBaseMap`
|
|
445
|
+
- `PMask`, `PMaskMap`
|
|
446
|
+
- `PMaskWithFlag`, `PMaskWithFlagMap`
|
|
447
|
+
- `PMaskFull`, `PMaskFullMap`
|
|
448
|
+
- `PMaskPhoneNumber`
|
|
338
449
|
|
|
339
|
-
|
|
340
|
-
- `PMaskHelpers` β Utility functions for phone masks like:
|
|
341
|
-
- `getFlagEmoji`
|
|
342
|
-
- `countPlaceholders`
|
|
343
|
-
- `formatDigitsWithMap`
|
|
344
|
-
- `pickMaskVariant`
|
|
345
|
-
- `removeCountryCodePrefix`
|
|
346
|
-
- And more...
|
|
450
|
+
Enable `phoneMask.helpers: true` to auto-import:
|
|
347
451
|
|
|
348
|
-
|
|
452
|
+
- `vPhoneMaskSetCountry` β Programmatically set country for directive
|
|
453
|
+
- `PMaskHelpers` β Utility functions from `@desource/phone-mask-vue/core`
|
|
349
454
|
|
|
350
|
-
|
|
455
|
+
Enable `phoneMask.composable: true` to auto-import:
|
|
351
456
|
|
|
352
|
-
|
|
457
|
+
- `usePhoneMask`
|
|
353
458
|
|
|
354
459
|
## π Migration from Vue Plugin
|
|
355
460
|
|
|
@@ -378,11 +483,12 @@ No changes needed in your components!
|
|
|
378
483
|
|
|
379
484
|
## π¦ What's Included
|
|
380
485
|
|
|
381
|
-
- `PhoneInput` component (auto-imported)
|
|
382
|
-
- `vPhoneMask` directive (auto-imported)
|
|
383
|
-
-
|
|
384
|
-
-
|
|
385
|
-
-
|
|
486
|
+
- `PhoneInput` component (auto-imported by default)
|
|
487
|
+
- `vPhoneMask` directive (auto-imported by default)
|
|
488
|
+
- Mask-related TypeScript types (auto-imported by default)
|
|
489
|
+
- Default styles (auto-imported by default, can be disabled)
|
|
490
|
+
- `vPhoneMaskSetCountry` and `PMaskHelpers` (optional via `phoneMask.helpers`)
|
|
491
|
+
- `usePhoneMask` (optional via `phoneMask.composable`)
|
|
386
492
|
|
|
387
493
|
## π Related
|
|
388
494
|
|
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -12,7 +12,9 @@ const module$1 = defineNuxtModule({
|
|
|
12
12
|
css: true,
|
|
13
13
|
component: true,
|
|
14
14
|
directive: true,
|
|
15
|
-
|
|
15
|
+
types: true,
|
|
16
|
+
helpers: false,
|
|
17
|
+
composable: false
|
|
16
18
|
},
|
|
17
19
|
async setup(options, nuxt) {
|
|
18
20
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -26,12 +28,19 @@ const module$1 = defineNuxtModule({
|
|
|
26
28
|
addPlugin(resolve(runtimeDir, "plugin.phone-mask"));
|
|
27
29
|
}
|
|
28
30
|
});
|
|
31
|
+
const shared = resolve(runtimeDir, "shared");
|
|
29
32
|
if (options.helpers) {
|
|
30
|
-
const shared = resolve(runtimeDir, "shared");
|
|
31
33
|
addImports([
|
|
32
34
|
{ name: "vPhoneMaskSetCountry", from: shared },
|
|
33
35
|
{ name: "PMaskHelpers", from: shared },
|
|
34
|
-
{ name: "vPhoneMask", from: shared }
|
|
36
|
+
{ name: "vPhoneMask", from: shared }
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
if (options.composable) {
|
|
40
|
+
addImports({ name: "usePhoneMask", from: shared });
|
|
41
|
+
}
|
|
42
|
+
if (options.types) {
|
|
43
|
+
addImports([
|
|
35
44
|
{ name: "PCountryKey", from: shared, type: true },
|
|
36
45
|
{ name: "PMaskBase", from: shared, type: true },
|
|
37
46
|
{ name: "PMaskBaseMap", from: shared, type: true },
|
package/dist/runtime/shared.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * as PMaskHelpers from '@desource/phone-mask-vue/core';
|
|
2
|
+
export { vPhoneMaskSetCountry, vPhoneMask, usePhoneMask, type PCountryKey, type PMaskBase, type PMaskBaseMap, type PMask, type PMaskMap, type PMaskWithFlag, type PMaskWithFlagMap, type PMaskFull, type PMaskFullMap, type PMaskPhoneNumber } from '@desource/phone-mask-vue';
|
package/dist/runtime/shared.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@desource/phone-mask-nuxt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "π― Zero-config Nuxt module for international phone masking. Powered by @desource/phone-mask with Google libphonenumber sync.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"vue": "^3.4.33"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@desource/phone-mask-vue": "1.
|
|
57
|
+
"@desource/phone-mask-vue": "1.3.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@nuxt/kit": "^4.4.2",
|
|
61
61
|
"@nuxt/module-builder": "^1.0.2",
|
|
62
|
-
"@nuxt/test-utils": "^4.0.
|
|
62
|
+
"@nuxt/test-utils": "^4.0.2",
|
|
63
63
|
"nuxt": "^4.4.2",
|
|
64
64
|
"vite": "7.3.1",
|
|
65
|
-
"vue": "^3.5.
|
|
65
|
+
"vue": "^3.5.33"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"dev:prepare": "nuxt prepare",
|