svelte-tel-input 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 +12 -0
- package/components/Input/TelInput.svelte +7 -2
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/package.json +14 -14
- package/components/Input/inputParserTest.spec.d.ts +0 -1
- package/components/Input/inputParserTest.spec.js +0 -36
- package/components/Input/testnumbers.json +0 -80
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# svelte-tel-input
|
|
2
2
|
|
|
3
|
+
## 1.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- chore: extend method exports ([#139](https://github.com/gyurielf/svelte-tel-input/pull/139))
|
|
8
|
+
|
|
9
|
+
## 1.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- fix: validation on select all and delete ([#137](https://github.com/gyurielf/svelte-tel-input/pull/137))
|
|
14
|
+
|
|
3
15
|
## 1.2.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -12,6 +12,8 @@ export let disabled = false;
|
|
|
12
12
|
let inputValue = value;
|
|
13
13
|
let prevCountry = country;
|
|
14
14
|
const handleInputAction = (value2) => {
|
|
15
|
+
if (disabled)
|
|
16
|
+
return;
|
|
15
17
|
handleParsePhoneNumber(value2, country);
|
|
16
18
|
};
|
|
17
19
|
const updateCountry = (countryCode) => {
|
|
@@ -20,7 +22,7 @@ const updateCountry = (countryCode) => {
|
|
|
20
22
|
return country;
|
|
21
23
|
};
|
|
22
24
|
const handleParsePhoneNumber = (input, currCountry = null) => {
|
|
23
|
-
if (input) {
|
|
25
|
+
if (input !== null) {
|
|
24
26
|
const numberHasCountry = getCountryForPartialE164Number(input);
|
|
25
27
|
if (numberHasCountry && numberHasCountry !== prevCountry) {
|
|
26
28
|
updateCountry(numberHasCountry);
|
|
@@ -54,9 +56,12 @@ const handleParsePhoneNumber = (input, currCountry = null) => {
|
|
|
54
56
|
if (currCountry !== prevCountry) {
|
|
55
57
|
value = null;
|
|
56
58
|
inputValue = "";
|
|
57
|
-
valid =
|
|
59
|
+
valid = false;
|
|
60
|
+
parsedTelInput = null;
|
|
58
61
|
}
|
|
59
62
|
prevCountry = currCountry;
|
|
63
|
+
dispatch("valid", valid);
|
|
64
|
+
dispatch("parseInput", parsedTelInput);
|
|
60
65
|
}
|
|
61
66
|
};
|
|
62
67
|
const initialize = () => {
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default } from './components/Input/TelInput.svelte';
|
|
2
|
-
export { getCurrentCountry, isSelected, inputParser, inspectAllowedChars } from './utils/helpers';
|
|
2
|
+
export { getCurrentCountry, isSelected, inputParser, inspectAllowedChars, normalizeTelInput, getCountryForPartialE164Number } from './utils/helpers';
|
|
3
|
+
export { parsePhoneNumberWithError } from 'libphonenumber-js/max';
|
|
3
4
|
export { clickOutsideAction } from './utils/directives/clickOutsideAction';
|
|
4
5
|
export { normalizedCountries } from './assets';
|
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default } from './components/Input/TelInput.svelte';
|
|
2
|
-
export { getCurrentCountry, isSelected, inputParser, inspectAllowedChars } from './utils/helpers';
|
|
2
|
+
export { getCurrentCountry, isSelected, inputParser, inspectAllowedChars, normalizeTelInput, getCountryForPartialE164Number } from './utils/helpers';
|
|
3
|
+
export { parsePhoneNumberWithError } from 'libphonenumber-js/max';
|
|
3
4
|
export { clickOutsideAction } from './utils/directives/clickOutsideAction';
|
|
4
5
|
export { normalizedCountries } from './assets';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-tel-input",
|
|
3
3
|
"description": "svelte-tel-input",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/gyurielf/svelte-tel-input.git"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"pnpm": ">= 7"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"libphonenumber-js": "^1.10.
|
|
25
|
+
"libphonenumber-js": "^1.10.21",
|
|
26
26
|
"svelte": "^3.55.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"@changesets/get-github-info": "^0.5.2",
|
|
31
31
|
"@changesets/types": "^5.2.1",
|
|
32
32
|
"@macfja/svelte-persistent-store": "^2.2.1",
|
|
33
|
-
"@playwright/test": "^1.
|
|
33
|
+
"@playwright/test": "^1.31.2",
|
|
34
34
|
"@sveltejs/adapter-static": "^2.0.1",
|
|
35
|
-
"@sveltejs/kit": "^1.
|
|
35
|
+
"@sveltejs/kit": "^1.11.0",
|
|
36
36
|
"@sveltejs/package": "^1.0.2",
|
|
37
37
|
"@testing-library/svelte": "^3.2.2",
|
|
38
38
|
"@testing-library/user-event": "^14.4.3",
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
40
|
-
"@typescript-eslint/parser": "^5.
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
|
40
|
+
"@typescript-eslint/parser": "^5.54.1",
|
|
41
41
|
"autoprefixer": "^10.4.13",
|
|
42
42
|
"cssnano": "^5.1.15",
|
|
43
43
|
"dotenv": "^16.0.3",
|
|
44
|
-
"edit-package-json": "^0.8.
|
|
45
|
-
"eslint": "^8.
|
|
46
|
-
"eslint-config-prettier": "^8.
|
|
44
|
+
"edit-package-json": "^0.8.9",
|
|
45
|
+
"eslint": "^8.35.0",
|
|
46
|
+
"eslint-config-prettier": "^8.7.0",
|
|
47
47
|
"eslint-plugin-svelte3": "^4.0.0",
|
|
48
48
|
"husky": "^8.0.3",
|
|
49
49
|
"jsdom": "^21.1.0",
|
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
"postcss": "^8.4.21",
|
|
52
52
|
"prettier": "^2.8.4",
|
|
53
53
|
"prettier-plugin-svelte": "^2.9.0",
|
|
54
|
-
"schema-dts": "^1.1.
|
|
55
|
-
"svelte-check": "^3.0
|
|
56
|
-
"svelte2tsx": "^0.6.
|
|
54
|
+
"schema-dts": "^1.1.2",
|
|
55
|
+
"svelte-check": "^3.1.0",
|
|
56
|
+
"svelte2tsx": "^0.6.3",
|
|
57
57
|
"tailwindcss": "^3.2.7",
|
|
58
58
|
"tslib": "^2.5.0",
|
|
59
59
|
"typescript": "^4.9.5",
|
|
60
|
-
"vite": "^4.1.
|
|
61
|
-
"vitest": "^0.
|
|
60
|
+
"vite": "^4.1.4",
|
|
61
|
+
"vitest": "^0.29.2"
|
|
62
62
|
},
|
|
63
63
|
"type": "module",
|
|
64
64
|
"license": "MIT",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { inputParser, inspectAllowedChars } from '../../utils/helpers';
|
|
2
|
-
import { describe, it, expect } from 'vitest';
|
|
3
|
-
describe('Hello.svelte', () => {
|
|
4
|
-
it('Input should be eleminate leters and special chars, and resul should be trimmed.', () => {
|
|
5
|
-
const testValue = '+36 30 1aS 34 .9 ';
|
|
6
|
-
const resut = inputParser(testValue, {
|
|
7
|
-
allowSpaces: true,
|
|
8
|
-
parseCharacter: inspectAllowedChars
|
|
9
|
-
});
|
|
10
|
-
expect(resut).toStrictEqual('+36 30 1 34 9 ');
|
|
11
|
-
});
|
|
12
|
-
it('Input should be eleminate leters and special chars, and resul should be untrimmed.', () => {
|
|
13
|
-
const testValue = '+36 30 1aS 34 .9 ';
|
|
14
|
-
const resut = inputParser(testValue, {
|
|
15
|
-
allowSpaces: true,
|
|
16
|
-
parseCharacter: inspectAllowedChars
|
|
17
|
-
});
|
|
18
|
-
expect(resut).toStrictEqual('+36 30 1 34 9 ');
|
|
19
|
-
});
|
|
20
|
-
it('Trimmed input with spaces', () => {
|
|
21
|
-
const testValue = '+36 30 1a3 45 67';
|
|
22
|
-
const resut = inputParser(testValue, {
|
|
23
|
-
allowSpaces: true,
|
|
24
|
-
parseCharacter: inspectAllowedChars
|
|
25
|
-
});
|
|
26
|
-
expect(resut).toStrictEqual('+36 30 13 45 67');
|
|
27
|
-
});
|
|
28
|
-
it('Perfect input without spaces', () => {
|
|
29
|
-
const testValue = '+36a301234567';
|
|
30
|
-
const resut = inputParser(testValue, {
|
|
31
|
-
allowSpaces: false,
|
|
32
|
-
parseCharacter: inspectAllowedChars
|
|
33
|
-
});
|
|
34
|
-
expect(resut).toStrictEqual('+36301234567');
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"numbers": [
|
|
3
|
-
{
|
|
4
|
-
"number": "+12023041258",
|
|
5
|
-
"country": "US"
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
"number": "+442079460196",
|
|
9
|
-
"country": "UK"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"number": "+611300654321",
|
|
13
|
-
"country": "AU"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"number": "+33178965432",
|
|
17
|
-
"country": "FR"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"number": "+919167299896",
|
|
21
|
-
"country": "IN"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"number": "+525512341234",
|
|
25
|
-
"country": "MX"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"number": "+81303121212",
|
|
29
|
-
"country": "JP"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"number": "+551130405060",
|
|
33
|
-
"country": "BR"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"number": "+862155555555",
|
|
37
|
-
"country": "CN"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"number": "+97225555555",
|
|
41
|
-
"country": "IL"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"number": "+12023041258",
|
|
45
|
-
"country": "CA"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"number": "+12023041258",
|
|
49
|
-
"country": "DE"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"number": "+12023041258",
|
|
53
|
-
"country": "RU"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"number": "+12023041258",
|
|
57
|
-
"country": "IT"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"number": "+12023041258",
|
|
61
|
-
"country": "ES"
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"number": "+12023041258",
|
|
65
|
-
"country": "SE"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"number": "+12023041258",
|
|
69
|
-
"country": "CH"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"number": "+12023041258",
|
|
73
|
-
"country": "DK"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"number": "+12023041258",
|
|
77
|
-
"country": "NO"
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
}
|