svelte-tel-input 0.12.0 → 0.13.0
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 +6 -0
- package/assets/allCountry.d.ts +1 -1
- package/components/Input/AdvancedTelInput.svelte.d.ts +1 -1
- package/components/Input/TelInput.svelte +3 -1
- package/components/Input/TelInput.svelte.d.ts +1 -1
- package/package.json +18 -18
- package/{styles → style}/flags.css +0 -2
- package/types.d.ts +64 -0
- package/utils/helpers.d.ts +1 -5
- package/utils/helpers.js +0 -8
- package/types/enums/index.d.ts +0 -10
- package/types/enums/index.js +0 -12
- package/types/index.d.ts +0 -18
- package/types/index.js +0 -2
- package/types/interfaces/Country.interface.d.ts +0 -10
- package/types/interfaces/Country.interface.js +0 -1
- package/types/interfaces/Phone.interface.d.ts +0 -21
- package/types/interfaces/Phone.interface.js +0 -1
- package/types/interfaces/index.d.ts +0 -2
- package/types/interfaces/index.js +0 -2
- package/utils/api.d.ts +0 -28
- package/utils/api.js +0 -30
package/CHANGELOG.md
CHANGED
package/assets/allCountry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Country } from '../types
|
|
1
|
+
import type { Country } from '../types.d';
|
|
2
2
|
export declare const normalizedCountries: Country[];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script>import { watcher } from '../../stores';
|
|
2
|
-
import { PhoneNumberParseError } from '../../types';
|
|
2
|
+
import { PhoneNumberParseError } from '../../types.d';
|
|
3
|
+
// import { PhoneNumberParseError } from '../../types';
|
|
4
|
+
// import type { NormalizedTelNumber } from '../../types.d';
|
|
3
5
|
import { normalizeTelInput } from '../../utils/helpers';
|
|
4
6
|
import { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js';
|
|
5
7
|
import { onMount } from 'svelte';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type
|
|
2
|
+
import { type NormalizedTelNumber } from '../../types.d';
|
|
3
3
|
import { type CountryCode } from 'libphonenumber-js';
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-tel-input",
|
|
3
3
|
"description": "svelte-tel-input",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.13.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/gyurielf/svelte-tel-input.git"
|
|
@@ -24,50 +24,50 @@
|
|
|
24
24
|
"libphonenumber-js": "^1.10.13"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@babel/core": "^7.19.
|
|
28
|
-
"@babel/preset-env": "^7.19.
|
|
27
|
+
"@babel/core": "^7.19.3",
|
|
28
|
+
"@babel/preset-env": "^7.19.3",
|
|
29
29
|
"@changesets/cli": "^2.24.4",
|
|
30
30
|
"@changesets/get-github-info": "^0.5.1",
|
|
31
31
|
"@changesets/types": "^5.1.0",
|
|
32
32
|
"@macfja/svelte-persistent-store": "^2.1.0",
|
|
33
33
|
"@sveltejs/adapter-static": "^1.0.0-next.43",
|
|
34
|
-
"@sveltejs/kit": "^1.0.0-next.
|
|
35
|
-
"@sveltejs/package": "^1.0.0-next.
|
|
34
|
+
"@sveltejs/kit": "^1.0.0-next.504",
|
|
35
|
+
"@sveltejs/package": "^1.0.0-next.5",
|
|
36
36
|
"@testing-library/jest-dom": "^5.16.5",
|
|
37
37
|
"@testing-library/svelte": "^3.2.1",
|
|
38
|
-
"@types/jest": "^29.0.
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
40
|
-
"@typescript-eslint/parser": "^5.
|
|
41
|
-
"autoprefixer": "^10.4.
|
|
42
|
-
"babel-jest": "^29.0
|
|
38
|
+
"@types/jest": "^29.0.3",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
|
40
|
+
"@typescript-eslint/parser": "^5.38.1",
|
|
41
|
+
"autoprefixer": "^10.4.12",
|
|
42
|
+
"babel-jest": "^29.1.0",
|
|
43
43
|
"babel-loader": "^8.2.5",
|
|
44
44
|
"cssnano": "^5.1.13",
|
|
45
45
|
"dotenv": "^16.0.2",
|
|
46
|
-
"eslint": "^8.
|
|
46
|
+
"eslint": "^8.24.0",
|
|
47
47
|
"eslint-config-prettier": "^8.5.0",
|
|
48
48
|
"eslint-plugin-jest": "^27.0.4",
|
|
49
49
|
"eslint-plugin-svelte3": "^4.0.0",
|
|
50
50
|
"husky": "^8.0.1",
|
|
51
|
-
"jest": "^29.
|
|
51
|
+
"jest": "^29.1.1",
|
|
52
52
|
"jest-matchmedia-mock": "^1.1.0",
|
|
53
53
|
"micromatch": "^4.0.5",
|
|
54
54
|
"postcss": "^8.4.16",
|
|
55
55
|
"postcss-load-config": "^4.0.1",
|
|
56
56
|
"prettier": "^2.7.1",
|
|
57
|
-
"prettier-plugin-svelte": "^2.7.
|
|
57
|
+
"prettier-plugin-svelte": "^2.7.1",
|
|
58
58
|
"svelte": "^3.50.1",
|
|
59
|
-
"svelte-check": "^2.9.
|
|
59
|
+
"svelte-check": "^2.9.1",
|
|
60
60
|
"svelte-inview": "^3.0.1",
|
|
61
61
|
"svelte-jester": "^2.3.2",
|
|
62
62
|
"svelte-loader": "^3.1.3",
|
|
63
63
|
"svelte-preprocess": "^4.10.7",
|
|
64
|
-
"svelte2tsx": "^0.5.
|
|
64
|
+
"svelte2tsx": "^0.5.19",
|
|
65
65
|
"tailwindcss": "^3.1.8",
|
|
66
|
-
"ts-jest": "^29.0.
|
|
66
|
+
"ts-jest": "^29.0.2",
|
|
67
67
|
"tsconfig-paths-webpack-plugin": "^4.0.0",
|
|
68
68
|
"tslib": "^2.4.0",
|
|
69
|
-
"typescript": "^4.8.
|
|
70
|
-
"vite": "^3.1.
|
|
69
|
+
"typescript": "^4.8.4",
|
|
70
|
+
"vite": "^3.1.4"
|
|
71
71
|
},
|
|
72
72
|
"standard-version": {
|
|
73
73
|
"skip": {
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { CountryCode } from './types';
|
|
2
|
+
|
|
3
|
+
import type { PhoneNumberParseError } from './types/enums';
|
|
4
|
+
import type {
|
|
5
|
+
CountryCallingCode,
|
|
6
|
+
CountryCode,
|
|
7
|
+
E164Number,
|
|
8
|
+
NationalNumber
|
|
9
|
+
} from 'libphonenumber-js';
|
|
10
|
+
|
|
11
|
+
export interface Country {
|
|
12
|
+
id: string;
|
|
13
|
+
label: string;
|
|
14
|
+
name: string;
|
|
15
|
+
iso2: CountryCode;
|
|
16
|
+
dialCode: string | number | string[];
|
|
17
|
+
priority: string | number | string[];
|
|
18
|
+
areaCodes: string | number | string[] | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type CountrySelectEvents<T> = {
|
|
22
|
+
add: { option: T };
|
|
23
|
+
remove: { option: T };
|
|
24
|
+
same: { option: T };
|
|
25
|
+
change: {
|
|
26
|
+
option: T;
|
|
27
|
+
};
|
|
28
|
+
focus: unknown;
|
|
29
|
+
blur: unknown;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export interface PhoneNumberError {
|
|
33
|
+
isValid: false;
|
|
34
|
+
error: PhoneNumberParseError;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface NormalizedTelNumber {
|
|
38
|
+
countryCode?: CountryCode | null;
|
|
39
|
+
isValid: boolean;
|
|
40
|
+
phoneNumber: string | null;
|
|
41
|
+
countryCallingCode: CountryCallingCode | null;
|
|
42
|
+
formattedNumber: string | null;
|
|
43
|
+
formatOriginal: string | null;
|
|
44
|
+
nationalNumber: NationalNumber | null;
|
|
45
|
+
formatInternational: string | null;
|
|
46
|
+
formatNational: string | null;
|
|
47
|
+
uri: string | null;
|
|
48
|
+
e164: E164Number | null;
|
|
49
|
+
error?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type { CountryCallingCode, CountryCode, E164Number, NationalNumber };
|
|
53
|
+
|
|
54
|
+
export enum PhoneNumberParseError {
|
|
55
|
+
NOT_A_NUMBER = 'NOT_A_NUMBER',
|
|
56
|
+
INVALID_COUNTRY = 'INVALID_COUNTRY',
|
|
57
|
+
TOO_SHORT = 'TOO_SHORT',
|
|
58
|
+
TOO_LONG = 'TOO_LONG'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export enum PhoneType {
|
|
62
|
+
FIXED_LINE = 'FIXED_LINE',
|
|
63
|
+
MOBILE = 'MOBILE'
|
|
64
|
+
}
|
package/utils/helpers.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import type { NormalizedTelNumber } from '../types/interfaces/Phone.interface';
|
|
2
1
|
import type { PhoneNumber } from 'libphonenumber-js';
|
|
3
2
|
export declare const capitalize: (str: string) => string;
|
|
4
3
|
export declare const getCurrentCountry: () => Promise<string | undefined>;
|
|
5
4
|
export declare const isNumber: (value: number) => boolean;
|
|
6
5
|
export declare const normalizeTelInput: (input: PhoneNumber) => {
|
|
7
|
-
[k: string]: string | boolean | import("libphonenumber-js").
|
|
6
|
+
[k: string]: string | boolean | import("libphonenumber-js").E164Number | import("libphonenumber-js").CountryCallingCode | import("libphonenumber-js").NationalNumber | null | undefined;
|
|
8
7
|
};
|
|
9
8
|
export declare const isSelected: <T extends {
|
|
10
9
|
id: string;
|
|
11
10
|
}>(itemToSelect: T, selectedItem: T | null | undefined) => boolean;
|
|
12
|
-
export declare const jsonPrettyParser: (node: HTMLElement, data: NormalizedTelNumber | null) => {
|
|
13
|
-
destroy: () => void;
|
|
14
|
-
};
|
package/utils/helpers.js
CHANGED
|
@@ -61,11 +61,3 @@ export const isSelected = (itemToSelect, selectedItem) => {
|
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
export const jsonPrettyParser = (node, data) => {
|
|
65
|
-
data !== null && (node.innerHTML = `<code>${JSON.stringify(data, null, 2)}</code>`);
|
|
66
|
-
return {
|
|
67
|
-
destroy: () => {
|
|
68
|
-
node.remove();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
};
|
package/types/enums/index.d.ts
DELETED
package/types/enums/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export var PhoneNumberParseError;
|
|
2
|
-
(function (PhoneNumberParseError) {
|
|
3
|
-
PhoneNumberParseError["NOT_A_NUMBER"] = "NOT_A_NUMBER";
|
|
4
|
-
PhoneNumberParseError["INVALID_COUNTRY"] = "INVALID_COUNTRY";
|
|
5
|
-
PhoneNumberParseError["TOO_SHORT"] = "TOO_SHORT";
|
|
6
|
-
PhoneNumberParseError["TOO_LONG"] = "TOO_LONG";
|
|
7
|
-
})(PhoneNumberParseError || (PhoneNumberParseError = {}));
|
|
8
|
-
export var PhoneType;
|
|
9
|
-
(function (PhoneType) {
|
|
10
|
-
PhoneType["FIXED_LINE"] = "FIXED_LINE";
|
|
11
|
-
PhoneType["MOBILE"] = "MOBILE";
|
|
12
|
-
})(PhoneType || (PhoneType = {}));
|
package/types/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export * from './enums';
|
|
2
|
-
export * from './interfaces';
|
|
3
|
-
export declare type CountrySelectEvents<T> = {
|
|
4
|
-
add: {
|
|
5
|
-
option: T;
|
|
6
|
-
};
|
|
7
|
-
remove: {
|
|
8
|
-
option: T;
|
|
9
|
-
};
|
|
10
|
-
same: {
|
|
11
|
-
option: T;
|
|
12
|
-
};
|
|
13
|
-
change: {
|
|
14
|
-
option: T;
|
|
15
|
-
};
|
|
16
|
-
focus: unknown;
|
|
17
|
-
blur: unknown;
|
|
18
|
-
};
|
package/types/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CountryCode } from './Phone.interface';
|
|
2
|
-
export interface Country {
|
|
3
|
-
id: string;
|
|
4
|
-
label: string;
|
|
5
|
-
name: string;
|
|
6
|
-
iso2: CountryCode;
|
|
7
|
-
dialCode: string | number | string[];
|
|
8
|
-
priority: string | number | string[];
|
|
9
|
-
areaCodes: string | number | string[] | null;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { PhoneNumberParseError } from '../enums';
|
|
2
|
-
import type { CountryCallingCode, CountryCode, E164Number, NationalNumber } from 'libphonenumber-js';
|
|
3
|
-
export interface PhoneNumberError {
|
|
4
|
-
isValid: false;
|
|
5
|
-
error: PhoneNumberParseError;
|
|
6
|
-
}
|
|
7
|
-
export interface NormalizedTelNumber {
|
|
8
|
-
countryCode?: CountryCode | null;
|
|
9
|
-
isValid: boolean;
|
|
10
|
-
phoneNumber: string | null;
|
|
11
|
-
countryCallingCode: CountryCallingCode | null;
|
|
12
|
-
formattedNumber: string | null;
|
|
13
|
-
formatOriginal: string | null;
|
|
14
|
-
nationalNumber: NationalNumber | null;
|
|
15
|
-
formatInternational: string | null;
|
|
16
|
-
formatNational: string | null;
|
|
17
|
-
uri: string | null;
|
|
18
|
-
e164: E164Number | null;
|
|
19
|
-
error?: string;
|
|
20
|
-
}
|
|
21
|
-
export type { CountryCallingCode, CountryCode, E164Number, NationalNumber };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/utils/api.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export declare const get: (base: string, path: string) => Promise<{
|
|
2
|
-
response: Response;
|
|
3
|
-
json?: undefined;
|
|
4
|
-
} | {
|
|
5
|
-
response: Response;
|
|
6
|
-
json: Record<string, unknown>;
|
|
7
|
-
}>;
|
|
8
|
-
export declare const del: (base: string, path: string, data?: unknown) => Promise<{
|
|
9
|
-
response: Response;
|
|
10
|
-
json?: undefined;
|
|
11
|
-
} | {
|
|
12
|
-
response: Response;
|
|
13
|
-
json: Record<string, unknown>;
|
|
14
|
-
}>;
|
|
15
|
-
export declare const post: (base: string, path: string, data?: unknown) => Promise<{
|
|
16
|
-
response: Response;
|
|
17
|
-
json?: undefined;
|
|
18
|
-
} | {
|
|
19
|
-
response: Response;
|
|
20
|
-
json: Record<string, unknown>;
|
|
21
|
-
}>;
|
|
22
|
-
export declare const put: (base: string, path: string, data?: unknown) => Promise<{
|
|
23
|
-
response: Response;
|
|
24
|
-
json?: undefined;
|
|
25
|
-
} | {
|
|
26
|
-
response: Response;
|
|
27
|
-
json: Record<string, unknown>;
|
|
28
|
-
}>;
|
package/utils/api.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const send = async ({ method, path, data, base }) => {
|
|
2
|
-
const opts = { method, headers: {}, credentials: 'include' };
|
|
3
|
-
if (data) {
|
|
4
|
-
opts.headers && (opts.headers['content-type'] = 'application/json');
|
|
5
|
-
opts.body = JSON.stringify(data);
|
|
6
|
-
}
|
|
7
|
-
const fullPath = encodeURI(`${base}${path}`);
|
|
8
|
-
const response = await fetch(fullPath, opts);
|
|
9
|
-
if (response.status === 204) {
|
|
10
|
-
return { response };
|
|
11
|
-
}
|
|
12
|
-
if (response.headers.get('content-type') === 'application/json') {
|
|
13
|
-
const json = await response.json();
|
|
14
|
-
return { response, json };
|
|
15
|
-
}
|
|
16
|
-
return { response };
|
|
17
|
-
};
|
|
18
|
-
// Shortcut methods
|
|
19
|
-
export const get = (base, path) => {
|
|
20
|
-
return send({ method: 'GET', path, base });
|
|
21
|
-
};
|
|
22
|
-
export const del = (base, path, data) => {
|
|
23
|
-
return send({ method: 'DELETE', path, data, base });
|
|
24
|
-
};
|
|
25
|
-
export const post = (base, path, data) => {
|
|
26
|
-
return send({ method: 'POST', path, data, base });
|
|
27
|
-
};
|
|
28
|
-
export const put = (base, path, data) => {
|
|
29
|
-
return send({ method: 'PUT', path, data, base });
|
|
30
|
-
};
|