svelte-tel-input 3.1.0 → 3.2.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.
Files changed (37) hide show
  1. package/README.md +31 -30
  2. package/{assets → dist/assets}/allCountry.d.ts +1 -1
  3. package/dist/assets/index.d.ts +1 -0
  4. package/dist/assets/index.js +1 -0
  5. package/dist/assets/regions.d.ts +1 -0
  6. package/dist/assets/regions.js +43 -0
  7. package/dist/assets/telTypes.d.ts +5 -0
  8. package/dist/assets/telTypes.js +16 -0
  9. package/{components → dist/components}/Input/TelInput.svelte +4 -4
  10. package/{components → dist/components}/Input/TelInput.svelte.d.ts +1 -1
  11. package/dist/index.d.ts +4 -0
  12. package/dist/index.js +4 -0
  13. package/{stores → dist/stores}/index.d.ts +2 -1
  14. package/{utils → dist/utils}/directives/clickOutsideAction.d.ts +1 -1
  15. package/dist/utils/directives/clickOutsideAction.js +18 -0
  16. package/dist/utils/directives/focusAction.d.ts +8 -0
  17. package/dist/utils/directives/focusAction.js +71 -0
  18. package/{utils → dist/utils}/directives/telInputAction.js +1 -1
  19. package/{utils → dist/utils}/helpers.d.ts +1 -1
  20. package/dist/utils/index.d.ts +4 -0
  21. package/dist/utils/index.js +4 -0
  22. package/dist/utils/typeCheck.d.ts +1 -0
  23. package/dist/utils/typeCheck.js +3 -0
  24. package/package.json +85 -35
  25. package/CHANGELOG.md +0 -396
  26. package/assets/index.d.ts +0 -1
  27. package/assets/index.js +0 -1
  28. package/index.d.ts +0 -5
  29. package/index.js +0 -5
  30. package/utils/directives/clickOutsideAction.js +0 -9
  31. /package/{assets → dist/assets}/allCountry.js +0 -0
  32. /package/{assets → dist/assets}/flags_responsive.png +0 -0
  33. /package/{stores → dist/stores}/index.js +0 -0
  34. /package/{styles → dist/styles}/flags.css +0 -0
  35. /package/{types → dist/types}/index.d.ts +0 -0
  36. /package/{utils → dist/utils}/directives/telInputAction.d.ts +0 -0
  37. /package/{utils → dist/utils}/helpers.js +0 -0
package/README.md CHANGED
@@ -20,11 +20,11 @@ npm install --save svelte-tel-input
20
20
 
21
21
  ## Features
22
22
 
23
- - Parse and validate phone number.You can store one exact format (`E164`), no matter how users type their phone numbers.
24
- - Format (specified to its country), to make it more readable.
25
- - Prevent non-digits typing into the input, except the leading `+` sign (and `space` optionally).
26
- - Handle copy-pasted phone numbers, it's sanitize non-digit characters except the leading `+` sign (and `space` optionally).
27
- - Automatic placeholder generation for the selected country.
23
+ - Parse and validate phone number.You can store one exact format (`E164`), no matter how users type their phone numbers.
24
+ - Format (specified to its country), to make it more readable.
25
+ - Prevent non-digits typing into the input, except the leading `+` sign (and `space` optionally).
26
+ - Handle copy-pasted phone numbers, it's sanitize non-digit characters except the leading `+` sign (and `space` optionally).
27
+ - Automatic placeholder generation for the selected country.
28
28
 
29
29
  ## Usage
30
30
 
@@ -163,30 +163,30 @@ The default export of the library is the main TelInput component. It has the fol
163
163
 
164
164
  ## Caveats
165
165
 
166
- - In order to reset `value` and/or `country` from outside (you must pass (or set if you binded) `null` for the property) have some side-effects:
166
+ - In order to reset `value` and/or `country` from outside (you must pass (or set if you binded) `null` for the property) have some side-effects:
167
167
 
168
- - Reseting the `value` will set (keep the `country` as is):
169
- - `detailedValue` to `null`
170
- - dispatch `updateDetailedValue` event
171
- - Reseting the `country` will set:
172
- - `value` to `null`
173
- - `detailedValue` to `null`
174
- - `valid` to `true` if `invalidateOnCountryChange` config option is false (_@default false_). Otherwise it will be `false`.
175
- - and dispatch `updateValid`, `updateValue` `updateDetailedValue` events
176
- - Reseting both `value` and `country` will set:
177
- - `valid` to `true`
178
- - `detailedValue` to `null`;
168
+ - Reseting the `value` will set (keep the `country` as is):
169
+ - `detailedValue` to `null`
170
+ - dispatch `updateDetailedValue` event
171
+ - Reseting the `country` will set:
172
+ - `value` to `null`
173
+ - `detailedValue` to `null`
174
+ - `valid` to `true` if `invalidateOnCountryChange` config option is false (_@default false_). Otherwise it will be `false`.
175
+ - and dispatch `updateValid`, `updateValue` `updateDetailedValue` events
176
+ - Reseting both `value` and `country` will set:
177
+ - `valid` to `true`
178
+ - `detailedValue` to `null`;
179
179
 
180
- - Let's assume you pass a `US` `E164` number, which can be a partial `E164`, but long enough to determine the country and you pass `DE` country directly. The country will be updated to `US`, which is determined from the `E164` in this example. If the `E164` is not long enough to determine its country, then the country will stay what you passed to the component (`DE`).
180
+ - Let's assume you pass a `US` `E164` number, which can be a partial `E164`, but long enough to determine the country and you pass `DE` country directly. The country will be updated to `US`, which is determined from the `E164` in this example. If the `E164` is not long enough to determine its country, then the country will stay what you passed to the component (`DE`).
181
181
 
182
182
  <p align="right">(<a href="#readme-top">back to top</a>)</p>
183
183
 
184
184
  ## Goals
185
185
 
186
- - Solve the problem that a users can enter the same phone number in different formats.
187
- - Storing a phone number in a standard format, that can be indexable and searchable in any database.
188
- - Should be accessible for the the browser. Eg. for a `<a href="tel+36201234567 />`.
189
- - The stored phone number format can be useable for any SMS gateway(e.g for 2FA) and if somebody can call the number from anywhere, it should work.
186
+ - Solve the problem that a users can enter the same phone number in different formats.
187
+ - Storing a phone number in a standard format, that can be indexable and searchable in any database.
188
+ - Should be accessible for the the browser. Eg. for a `<a href="tel+36201234567 />`.
189
+ - The stored phone number format can be useable for any SMS gateway(e.g for 2FA) and if somebody can call the number from anywhere, it should work.
190
190
 
191
191
  ## Dependencies
192
192
 
@@ -206,14 +206,15 @@ The default export of the library is the main TelInput component. It has the fol
206
206
 
207
207
  ## Roadmap
208
208
 
209
- - [x] Add Changelog
210
- - [x] Add CI/CD
211
- - [x] Integrate libphonenumber
212
- - [x] Implement parser
213
- - [x] Add basics docs and examples
214
- - [x] Add advanced examples
215
- - [x] Generate placeholders autimatically
216
- - [ ] Improve A11Y
209
+ - [x] Add Changelog
210
+ - [x] Add CI/CD
211
+ - [x] Integrate libphonenumber
212
+ - [x] Implement parser
213
+ - [x] Add basics docs and examples
214
+ - [x] Add advanced examples
215
+ - [x] Generate placeholders autimatically
216
+ - [x] Move to monorepo
217
+ - [ ] Improve A11Y
217
218
 
218
219
  See the [open issues](https://github.com/gyurielf/svelte-tel-input/issues) for a list of proposed features (and known issues).
219
220
 
@@ -1,2 +1,2 @@
1
- import type { Country } from '../types';
1
+ import type { Country } from '../types/index.js';
2
2
  export declare const normalizedCountries: Country[];
@@ -0,0 +1 @@
1
+ export { normalizedCountries } from './allCountry.js';
@@ -0,0 +1 @@
1
+ export { normalizedCountries } from './allCountry.js';
@@ -0,0 +1 @@
1
+ export declare const rawRegions: (string | number | string[])[][];
@@ -0,0 +1,43 @@
1
+ // Country model:
2
+ // [
3
+ // Country name,
4
+ // Regions,
5
+ // iso2 code,
6
+ // International dial code,
7
+ // Format (if available),
8
+ // Order priority (if >1 country with same dial code),
9
+ // Area codes (if >1 country with same dial code)
10
+ // ]
11
+ //
12
+ // Regions:
13
+ // ['america', 'europe', 'asia', 'oceania', 'africa']
14
+ //
15
+ // Sub-regions:
16
+ // ['north-america', 'south-america', 'central-america', 'carribean',
17
+ // 'eu-union', 'ex-ussr', 'ex-yugos', 'baltic', 'middle-east', 'north-africa']
18
+ export const rawRegions = [
19
+ ['American Samoa', ['oceania'], 'as', '1684'],
20
+ ['Anguilla', ['america', 'carribean'], 'ai', '1264'],
21
+ ['Bermuda', ['america', 'north-america'], 'bm', '1441'],
22
+ ['British Virgin Islands', ['america', 'carribean'], 'vg', '1284'],
23
+ ['Cayman Islands', ['america', 'carribean'], 'ky', '1345'],
24
+ ['Cook Islands', ['oceania'], 'ck', '682'],
25
+ ['Falkland Islands', ['america', 'south-america'], 'fk', '500'],
26
+ ['Faroe Islands', ['europe'], 'fo', '298'],
27
+ ['Gibraltar', ['europe'], 'gi', '350'],
28
+ ['Greenland', ['america'], 'gl', '299'],
29
+ ['Jersey', ['europe', 'eu-union'], 'je', '44', '.... ......'],
30
+ ['Montserrat', ['america', 'carribean'], 'ms', '1664'],
31
+ ['Niue', ['asia'], 'nu', '683'],
32
+ ['Norfolk Island', ['oceania'], 'nf', '672'],
33
+ ['Northern Mariana Islands', ['oceania'], 'mp', '1670'],
34
+ ['Saint Barthélemy', ['america', 'carribean'], 'bl', '590', '', 1],
35
+ ['Saint Helena', ['africa'], 'sh', '290'],
36
+ ['Saint Martin', ['america', 'carribean'], 'mf', '590', '', 2],
37
+ ['Saint Pierre and Miquelon', ['america', 'north-america'], 'pm', '508'],
38
+ ['Sint Maarten', ['america', 'carribean'], 'sx', '1721'],
39
+ ['Tokelau', ['oceania'], 'tk', '690'],
40
+ ['Turks and Caicos Islands', ['america', 'carribean'], 'tc', '1649'],
41
+ ['U.S. Virgin Islands', ['america', 'carribean'], 'vi', '1340'],
42
+ ['Wallis and Futuna', ['oceania'], 'wf', '681']
43
+ ];
@@ -0,0 +1,5 @@
1
+ export declare const telTypes: {
2
+ id: string;
3
+ value: string;
4
+ label: string;
5
+ }[];
@@ -0,0 +1,16 @@
1
+ import { capitalize } from '../utils/index.js';
2
+ export const telTypes = [
3
+ 'PREMIUM_RATE',
4
+ 'TOLL_FREE',
5
+ 'SHARED_COST',
6
+ 'VOIP',
7
+ 'PERSONAL_NUMBER',
8
+ 'PAGER',
9
+ 'UAN',
10
+ 'VOICEMAIL',
11
+ 'FIXED_LINE_OR_MOBILE',
12
+ 'FIXED_LINE',
13
+ 'MOBILE'
14
+ ].map((el) => {
15
+ return { id: el, value: el, label: capitalize(el.split('_').join(' ')) };
16
+ });
@@ -1,12 +1,12 @@
1
1
  <script>import { createEventDispatcher, onMount } from "svelte";
2
2
  import { parsePhoneNumberWithError, ParseError } from "libphonenumber-js/max";
3
- import { telInputAction } from "../../utils/directives/telInputAction";
4
3
  import {
5
4
  normalizeTelInput,
6
5
  getCountryForPartialE164Number,
7
- generatePlaceholder
8
- } from "../../utils/helpers";
9
- import { watcher } from "../../stores";
6
+ generatePlaceholder,
7
+ telInputAction
8
+ } from "../../utils/index.js";
9
+ import { watcher } from "../../stores/index.js";
10
10
  const dispatch = createEventDispatcher();
11
11
  const defaultOptions = {
12
12
  autoPlaceholder: true,
@@ -1,7 +1,7 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import type { DetailedValue, CountryCode, E164Number, TelInputOptions } from '../../types';
3
3
  declare const __propDef: {
4
- /** Set the required attribute on the input element */ props: {
4
+ props: {
5
5
  [x: string]: any;
6
6
  country: CountryCode | null;
7
7
  value: E164Number | null;
@@ -0,0 +1,4 @@
1
+ export { default as TelInput } from './components/Input/TelInput.svelte';
2
+ export { getCurrentCountry, inputParser, inspectAllowedChars, normalizeTelInput, getCountryForPartialE164Number, clickOutsideAction, isSelected } from './utils/index.js';
3
+ export { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js/max';
4
+ export { normalizedCountries } from './assets/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { default as TelInput } from './components/Input/TelInput.svelte';
2
+ export { getCurrentCountry, inputParser, inspectAllowedChars, normalizeTelInput, getCountryForPartialE164Number, clickOutsideAction, isSelected } from './utils/index.js';
3
+ export { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js/max';
4
+ export { normalizedCountries } from './assets/index.js';
@@ -1,4 +1,5 @@
1
+ /// <reference types="svelte" />
1
2
  export declare const watcher: (initialValue: string | null, watchFunction: (oldVal: string | null, newVal: string | null) => void) => {
2
- subscribe: (this: void, run: import("svelte/store").Subscriber<string | null>, invalidate?: ((value?: string | null | undefined) => void) | undefined) => import("svelte/store").Unsubscriber;
3
+ subscribe: (this: void, run: import("svelte/store").Subscriber<string | null>, invalidate?: import("svelte/store").Invalidator<string | null> | undefined) => import("svelte/store").Unsubscriber;
3
4
  set: (value: string | null) => void;
4
5
  };
@@ -1,3 +1,3 @@
1
- export declare const clickOutsideAction: (node: HTMLElement, handler: () => void) => {
1
+ export declare const clickOutsideAction: (node: HTMLElement, handler: () => void, skipPrevented?: boolean) => {
2
2
  destroy: () => void;
3
3
  };
@@ -0,0 +1,18 @@
1
+ export const clickOutsideAction = (node, handler, skipPrevented = true) => {
2
+ const handleClick = async (event) => {
3
+ if (skipPrevented) {
4
+ if (!node.contains(event.target) && !event.defaultPrevented)
5
+ handler();
6
+ }
7
+ else {
8
+ if (!node.contains(event.target))
9
+ handler();
10
+ }
11
+ };
12
+ document.addEventListener('click', handleClick, true);
13
+ return {
14
+ destroy() {
15
+ document.removeEventListener('click', handleClick, true);
16
+ }
17
+ };
18
+ };
@@ -0,0 +1,8 @@
1
+ export declare function focusable_children(node: HTMLElement): {
2
+ next: (selector: string) => void;
3
+ prev: (selector: string) => void;
4
+ update: (d: number) => void;
5
+ };
6
+ export declare function trap(node: HTMLElement): {
7
+ destroy: () => void;
8
+ };
@@ -0,0 +1,71 @@
1
+ export function focusable_children(node) {
2
+ const nodes = Array.from(node.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'));
3
+ const index = document.activeElement ? nodes.indexOf(document.activeElement) : -1;
4
+ const update = (d) => {
5
+ let i = index + d;
6
+ i += nodes.length;
7
+ i %= nodes.length;
8
+ // @ts-expect-error Element is not HTMLElement
9
+ nodes[i].focus();
10
+ };
11
+ return {
12
+ next: (selector) => {
13
+ const reordered = [...nodes.slice(index + 1), ...nodes.slice(0, index + 1)];
14
+ for (let i = 0; i < reordered.length; i += 1) {
15
+ if (!selector || reordered[i].matches(selector)) {
16
+ // @ts-expect-error Element is not HTMLElement
17
+ reordered[i].focus();
18
+ return;
19
+ }
20
+ }
21
+ },
22
+ prev: (selector) => {
23
+ const reordered = [...nodes.slice(index + 1), ...nodes.slice(0, index + 1)];
24
+ for (let i = reordered.length - 2; i >= 0; i -= 1) {
25
+ if (!selector || reordered[i].matches(selector)) {
26
+ // @ts-expect-error Element is not HTMLElement
27
+ reordered[i].focus();
28
+ return;
29
+ }
30
+ }
31
+ },
32
+ update
33
+ };
34
+ }
35
+ export function trap(node) {
36
+ const handle_keydown = (e) => {
37
+ if (e.key === 'Tab') {
38
+ e.preventDefault();
39
+ const group = focusable_children(node);
40
+ if (e.shiftKey) {
41
+ // @ts-expect-error Element is not HTMLElement
42
+ group.prev();
43
+ }
44
+ else {
45
+ // @ts-expect-error Element is not HTMLElement
46
+ group.next();
47
+ }
48
+ }
49
+ };
50
+ node.addEventListener('keydown', handle_keydown);
51
+ return {
52
+ destroy: () => {
53
+ node.removeEventListener('keydown', handle_keydown);
54
+ }
55
+ };
56
+ }
57
+ // Put onto the element, where you want to use the keyboard navigation.
58
+ // on:keydown={(e) => {
59
+ // if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
60
+ // e.preventDefault();
61
+ // const group = focusable_children(e.currentTarget);
62
+ // // when using arrow keys (as opposed to tab), don't focus buttons
63
+ // const selector = 'a, input';
64
+ // if (e.key === 'ArrowDown') {
65
+ // group.next(selector);
66
+ // } else {
67
+ // group.prev(selector);
68
+ // }
69
+ // }
70
+ // }}
71
+ // use:trap
@@ -1,4 +1,4 @@
1
- import { inspectAllowedChars, inputParser } from '../..';
1
+ import { inspectAllowedChars, inputParser } from '../../index.js';
2
2
  export const telInputAction = (node, { handler, spaces }) => {
3
3
  const onInput = (event) => {
4
4
  if (node && node.contains(event.target)) {
@@ -1,4 +1,4 @@
1
- import type { PhoneNumber, MetadataJson, Countries, E164Number, CountryCode } from '../types';
1
+ import type { PhoneNumber, MetadataJson, Countries, E164Number, CountryCode } from '../types/index.js';
2
2
  export declare const capitalize: (str: string) => string;
3
3
  export declare const getCurrentCountry: () => Promise<string | undefined>;
4
4
  export declare const isNumber: (value: number) => boolean;
@@ -0,0 +1,4 @@
1
+ export * from './helpers.js';
2
+ export * from './typeCheck.js';
3
+ export * from './directives/clickOutsideAction.js';
4
+ export * from './directives/telInputAction.js';
@@ -0,0 +1,4 @@
1
+ export * from './helpers.js';
2
+ export * from './typeCheck.js';
3
+ export * from './directives/clickOutsideAction.js';
4
+ export * from './directives/telInputAction.js';
@@ -0,0 +1 @@
1
+ export declare const isStringArray: (items: unknown) => items is string[];
@@ -0,0 +1,3 @@
1
+ export const isStringArray = (items) => {
2
+ return Array.isArray(items) && items.length > 0 && typeof items[0] === 'string';
3
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "svelte-tel-input",
3
3
  "description": "svelte-tel-input",
4
- "version": "3.1.0",
4
+ "version": "3.2.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/gyurielf/svelte-tel-input.git"
@@ -9,63 +9,113 @@
9
9
  "homepage": "https://github.com/gyurielf/svelte-tel-input#readme",
10
10
  "keywords": [
11
11
  "svelte",
12
+ "svelte kit",
13
+ "sveltekit",
12
14
  "tel input",
13
15
  "phone",
14
16
  "phone input",
17
+ "svelte phone input",
18
+ "svelte tel input",
15
19
  "intl",
16
- "intl tel input"
20
+ "intl tel input",
21
+ "svelte intl tel input"
17
22
  ],
18
23
  "engines": {
19
24
  "npm": ">= 8",
20
- "yarn": ">=2",
21
- "node": ">= 16",
22
- "pnpm": ">= 7"
25
+ "yarn": ">= 2",
26
+ "node": ">= 18",
27
+ "pnpm": ">= 8"
28
+ },
29
+ "peerDependencies": {
30
+ "libphonenumber-js": "^1.10.30",
31
+ "svelte": "^3.58.0 || ^4.0.0"
23
32
  },
24
33
  "dependencies": {
25
- "libphonenumber-js": "^1.10.36",
26
- "svelte": "^3.58.0"
34
+ "libphonenumber-js": "^1.10.37",
35
+ "svelte": "^4.0.5"
27
36
  },
28
37
  "devDependencies": {
29
- "@changesets/cli": "^2.26.1",
30
- "@changesets/get-github-info": "^0.5.2",
31
- "@changesets/types": "^5.2.1",
32
- "@macfja/svelte-persistent-store": "^2.3.0",
33
- "@playwright/test": "^1.35.1",
34
- "@sveltejs/adapter-static": "^2.0.2",
35
- "@sveltejs/kit": "^1.20.4",
36
- "@sveltejs/package": "^1.0.2",
37
- "@testing-library/svelte": "^3.2.2",
38
+ "@sveltejs/adapter-auto": "2.1.0",
39
+ "@sveltejs/kit": "^1.22.3",
40
+ "@sveltejs/package": "^2.2.0",
41
+ "@testing-library/svelte": "^4.0.3",
38
42
  "@testing-library/user-event": "^14.4.3",
39
- "@typescript-eslint/eslint-plugin": "^5.60.0",
40
- "@typescript-eslint/parser": "^5.60.0",
43
+ "@types/micromatch": "^4.0.2",
44
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
45
+ "@typescript-eslint/parser": "^6.0.0",
41
46
  "autoprefixer": "^10.4.14",
42
47
  "cssnano": "^6.0.1",
43
48
  "dotenv": "^16.3.1",
44
- "edit-package-json": "^0.8.14",
45
- "eslint": "^8.43.0",
49
+ "eslint": "^8.45.0",
46
50
  "eslint-config-prettier": "^8.8.0",
47
- "eslint-plugin-svelte3": "^4.0.0",
48
- "husky": "^8.0.3",
51
+ "eslint-plugin-import": "^2.27.5",
52
+ "eslint-plugin-svelte": "^2.32.2",
49
53
  "jsdom": "^22.1.0",
50
54
  "micromatch": "^4.0.5",
51
- "postcss": "^8.4.24",
55
+ "postcss": "^8.4.26",
52
56
  "prettier": "^2.8.8",
53
57
  "prettier-plugin-svelte": "^2.10.1",
54
- "schema-dts": "^1.1.2",
55
- "svelte-check": "^3.4.3",
56
- "svelte2tsx": "^0.6.15",
57
- "tailwindcss": "^3.3.2",
58
- "tslib": "^2.5.3",
59
- "typescript": "^5.0.4",
60
- "vite": "^4.3.9",
61
- "vitest": "^0.32.2"
58
+ "publint": "^0.1.16",
59
+ "svelte-check": "^3.4.6",
60
+ "svelte2tsx": "^0.6.19",
61
+ "tailwindcss": "^3.3.3",
62
+ "tslib": "^2.6.0",
63
+ "typescript": "^5.1.6",
64
+ "vite": "^4.4.4",
65
+ "vitest": "^0.33.0"
62
66
  },
63
67
  "type": "module",
64
68
  "license": "MIT",
69
+ "files": [
70
+ "dist"
71
+ ],
72
+ "types": "./dist/index.d.ts",
73
+ "typesVersions": {
74
+ "*": {
75
+ "types": [
76
+ "./dist/types/index.d.ts"
77
+ ],
78
+ "utils": [
79
+ "./dist/utils/index.d.ts"
80
+ ],
81
+ "assets": [
82
+ "./dist/assets/index.d.ts"
83
+ ]
84
+ }
85
+ },
65
86
  "exports": {
66
- "./package.json": "./package.json",
67
- ".": "./index.js",
68
- "./styles/flags.css": "./styles/flags.css"
87
+ ".": {
88
+ "types": "./dist/index.d.ts",
89
+ "svelte": "./dist/index.js",
90
+ "default": "./dist/index.js"
91
+ },
92
+ "./types": {
93
+ "types": "./dist/types/index.d.ts",
94
+ "default": "./dist/types/index.d.ts"
95
+ },
96
+ "./utils": {
97
+ "types": "./dist/utils/index.d.ts",
98
+ "default": "./dist/utils/index.js"
99
+ },
100
+ "./assets": {
101
+ "types": "./dist/assets/index.d.ts",
102
+ "default": "./dist/assets/index.js"
103
+ },
104
+ "./styles/flags.css": "./dist/styles/flags.css"
69
105
  },
70
- "svelte": "./index.js"
106
+ "scripts": {
107
+ "check:publint": "publint . --strict",
108
+ "eslint": "eslint --ext .js,.ts,.svelte .",
109
+ "eslint:fix": "eslint --fix",
110
+ "lint": "npm run prettier:check && npm run eslint && npm run ts && npm run svelte-check",
111
+ "lint:fix": "npm run eslint:fix && npm run prettier:fix",
112
+ "package:watch": "svelte-kit sync && svelte-package --watch",
113
+ "package": "svelte-kit sync && svelte-package && npm run check:publint",
114
+ "prettier:check": "prettier --check --plugin-search-dir=. .",
115
+ "prettier:fix": "prettier --write --plugin-search-dir=. .",
116
+ "svelte-check": "svelte-kit sync && svelte-check --ignore 'dist,build,coverage,.svelte-kit,package' --fail-on-warnings",
117
+ "sync": "svelte-kit sync",
118
+ "test": "vitest",
119
+ "ts": "tsc --noEmit"
120
+ }
71
121
  }
package/CHANGELOG.md DELETED
@@ -1,396 +0,0 @@
1
- # svelte-tel-input
2
-
3
- ## 3.1.0
4
-
5
- ### Minor Changes
6
-
7
- - feat: value can be reseted without country reset ([#165](https://github.com/gyurielf/svelte-tel-input/pull/165))
8
-
9
- - In order to reset `value` and/or `country` from outside (you must pass (or set if you binded) `null` for the property) have some side-effects:
10
-
11
- - Reseting the `value` will set (keep the `country` as is):
12
- - `detailedValue` to `null`
13
- - dispatch `updateDetailedValue` event
14
- - Reseting the `country` will set:
15
- - `value` to `null`
16
- - `detailedValue` to `null`
17
- - `valid` to `true` if `invalidateOnCountryChange` config option is false (_@default false_). Otherwise it will be `false`.
18
- - and dispatch `updateValid`, `updateValue` `updateDetailedValue` events
19
- - Reseting both `value` and `country` will set:
20
- - `valid` to `true`
21
- - `detailedValue` to `null`;
22
-
23
- ## 3.0.1
24
-
25
- ### Patch Changes
26
-
27
- - chore: update readme with advanced example REPL ([#162](https://github.com/gyurielf/svelte-tel-input/pull/162))
28
-
29
- - fix: auto country update after manual country change ([#162](https://github.com/gyurielf/svelte-tel-input/pull/162))
30
-
31
- ## 3.0.0
32
-
33
- ### Major Changes
34
-
35
- - breaking: rename `parsedTelInput` property: ([#156](https://github.com/gyurielf/svelte-tel-input/pull/156))
36
- `parsedTelInput` is `detailedValue` from now.
37
-
38
- ```diff
39
- -<TelInput bind:parsedTelInput ... />;
40
- +<TelInput bind:detailedValue ... />;
41
- ```
42
-
43
- breaking: rename dispatched events:
44
- `parseInput` is splitted to two (`updateValue` and `updateDetailedValue` ) event.
45
- `valid` is `updateValid` from now.
46
-
47
- ```diff
48
- -<TelInput on:parseInput={...} on:valid={...} ... />;
49
- +<TelInput on:updateValue={...} on:updateDetailedValue={...} on:updateValid={...} on:updateCountry={...} ... />;
50
- ```
51
-
52
- breaking: rename `NormalizedTelNumber` type to `DetailedValue`:
53
-
54
- ```diff
55
- -import type { NormalizedTelNumber } from 'svelte-tel-input/types';
56
- +import type { DetailedValue } from 'svelte-tel-input/types';
57
- ```
58
-
59
- feat: new event added: `updateCountry`
60
-
61
- ```html
62
- <TelInput on:updateCountry="{...}" ... />;
63
- ```
64
-
65
- feat: now the component is fully supports the event driven behavior. So you don't have to bind properties.
66
-
67
- ```diff
68
- -<TelInput bind:value ... />;
69
- +<TelInput value={yourValue} ... />;
70
- ```
71
-
72
- ## 2.1.1
73
-
74
- ### Patch Changes
75
-
76
- - fix: US flag is now more representative ([#154](https://github.com/gyurielf/svelte-tel-input/pull/154))
77
-
78
- ## 2.1.0
79
-
80
- ### Minor Changes
81
-
82
- - feat: support event driven behavior ([#150](https://github.com/gyurielf/svelte-tel-input/pull/150))
83
-
84
- ## 2.0.1
85
-
86
- ### Patch Changes
87
-
88
- - fix: component export ([#147](https://github.com/gyurielf/svelte-tel-input/pull/147))
89
-
90
- ## 2.0.0
91
-
92
- ### Major Changes
93
-
94
- - breaking: switch from default to named export to export TelInput component. Use named import in the future. From now Svelte >= 3.58.0 is required. ([#143](https://github.com/gyurielf/svelte-tel-input/pull/143))
95
-
96
- ### Minor Changes
97
-
98
- - feat: space config option added, it will enable or disable spaces in the input field. ([#143](https://github.com/gyurielf/svelte-tel-input/pull/143))
99
-
100
- - feat: autoPlaceholder feature added, it generates placeholder for each country. ([#143](https://github.com/gyurielf/svelte-tel-input/pull/143))
101
-
102
- ### Patch Changes
103
-
104
- - chore: update deps, re-generate package-lock.json ([#143](https://github.com/gyurielf/svelte-tel-input/pull/143))
105
-
106
- - feat: added options panel to example page to be able to try out config opts. ([#143](https://github.com/gyurielf/svelte-tel-input/pull/143))
107
-
108
- ## 1.3.2
109
-
110
- ### Patch Changes
111
-
112
- - chore: export ParseError class ([#141](https://github.com/gyurielf/svelte-tel-input/pull/141))
113
-
114
- ## 1.3.1
115
-
116
- ### Patch Changes
117
-
118
- - chore: extend method exports ([#139](https://github.com/gyurielf/svelte-tel-input/pull/139))
119
-
120
- ## 1.3.0
121
-
122
- ### Minor Changes
123
-
124
- - fix: validation on select all and delete ([#137](https://github.com/gyurielf/svelte-tel-input/pull/137))
125
-
126
- ## 1.2.0
127
-
128
- ### Minor Changes
129
-
130
- - fix: improved validation ([#132](https://github.com/gyurielf/svelte-tel-input/pull/132))
131
-
132
- ## 1.1.3
133
-
134
- ### Patch Changes
135
-
136
- - fix: make parsedTelInput prop optional ([#129](https://github.com/gyurielf/svelte-tel-input/pull/129))
137
-
138
- ## 1.1.2
139
-
140
- ### Patch Changes
141
-
142
- - feat: seo improvement and deps update ([#127](https://github.com/gyurielf/svelte-tel-input/pull/127))
143
-
144
- - fix: prevent commit to the main branch ([#127](https://github.com/gyurielf/svelte-tel-input/pull/127))
145
-
146
- ## 1.1.1
147
-
148
- ### Patch Changes
149
-
150
- - fix: advanced input handleSelect method fix ([#125](https://github.com/gyurielf/svelte-tel-input/pull/125))
151
-
152
- - fix: modify style export in package.json and in post-build.js ([#125](https://github.com/gyurielf/svelte-tel-input/pull/125))
153
-
154
- - fix: set flags assets import relative in flags.css ([#125](https://github.com/gyurielf/svelte-tel-input/pull/125))
155
-
156
- ## 1.1.0
157
-
158
- ### Minor Changes
159
-
160
- - feat: vitests and e2e (playwright) added ([#123](https://github.com/gyurielf/svelte-tel-input/pull/123))
161
-
162
- - chore: remove unnecessary dependencies ([#123](https://github.com/gyurielf/svelte-tel-input/pull/123))
163
-
164
- ## 1.0.2
165
-
166
- ### Patch Changes
167
-
168
- - chore: extend REPL example ([#119](https://github.com/gyurielf/svelte-tel-input/pull/119))
169
-
170
- - chore: polish readme ([#119](https://github.com/gyurielf/svelte-tel-input/pull/119))
171
-
172
- - chore: update dependencies ([#119](https://github.com/gyurielf/svelte-tel-input/pull/119))
173
-
174
- ## 1.0.1
175
-
176
- ### Patch Changes
177
-
178
- - fix: remove types field right before packaging ([#116](https://github.com/gyurielf/svelte-tel-input/pull/116))
179
-
180
- ## 1.0.0
181
-
182
- ### Major Changes
183
-
184
- - feat: prevent typing non-tel input characters into the input field. ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
185
-
186
- - fix: now you can use value prop as a single entry ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
187
-
188
- - feat: support monorepos ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
189
-
190
- - feat: sanitize pasted E164 number ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
191
-
192
- - feat: switch country automatically if the pasted/entered phone number contains a valid country calling code ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
193
-
194
- - fix: clear input on manual country change ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
195
-
196
- ### Minor Changes
197
-
198
- - chore: tweak types ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
199
-
200
- ## 0.14.2
201
-
202
- ### Patch Changes
203
-
204
- - update something ([#105](https://github.com/gyurielf/svelte-tel-input/pull/105))
205
-
206
- ## 0.14.1
207
-
208
- ### Patch Changes
209
-
210
- - chore: export tests ([#100](https://github.com/gyurielf/svelte-tel-input/pull/100))
211
-
212
- ## 0.14.0
213
-
214
- ### Minor Changes
215
-
216
- - Prevent circular import ([#98](https://github.com/gyurielf/svelte-tel-input/pull/98))
217
-
218
- ## 0.13.1
219
-
220
- ### Patch Changes
221
-
222
- - chore: simplify part one ([#94](https://github.com/gyurielf/svelte-tel-input/pull/94))
223
-
224
- ## 0.13.0
225
-
226
- ### Minor Changes
227
-
228
- - Simplify structure ([#91](https://github.com/gyurielf/svelte-tel-input/pull/91))
229
-
230
- ## 0.12.0
231
-
232
- ### Minor Changes
233
-
234
- - feat: Update exports to make the package as simple to use as possible. ([#85](https://github.com/gyurielf/svelte-tel-input/pull/85))
235
-
236
- ## 0.11.1
237
-
238
- ### Patch Changes
239
-
240
- - Update readme and prepare to 1.0 ([#79](https://github.com/gyurielf/svelte-tel-input/pull/79))
241
-
242
- ## 0.11.0
243
-
244
- ### Minor Changes
245
-
246
- - feat: dark mode, example page enhancemet ([#76](https://github.com/gyurielf/svelte-tel-input/pull/76))
247
-
248
- ## 0.10.0
249
-
250
- ### Minor Changes
251
-
252
- - refactor: components and views ([#74](https://github.com/gyurielf/svelte-tel-input/pull/74))
253
-
254
- ## 0.9.0
255
-
256
- ### Minor Changes
257
-
258
- - feat: masking/formatting and parsing extends ([#72](https://github.com/gyurielf/svelte-tel-input/pull/72))
259
-
260
- ## 0.8.0
261
-
262
- ### Minor Changes
263
-
264
- - feat: example improvements, extend functionality ([#70](https://github.com/gyurielf/svelte-tel-input/pull/70))
265
-
266
- ## 0.7.0
267
-
268
- ### Minor Changes
269
-
270
- - feat: example page payload feature, parsing improvements" ([#68](https://github.com/gyurielf/svelte-tel-input/pull/68))
271
-
272
- ## 0.6.5
273
-
274
- ### Patch Changes
275
-
276
- - fix: add changeset ([#61](https://github.com/gyurielf/svelte-tel-input/pull/61))
277
-
278
- ## 0.6.4
279
-
280
- ### Patch Changes
281
-
282
- - chore: update to vite 3 ([#58](https://github.com/gyurielf/svelte-tel-input/pull/58))
283
-
284
- ## 0.6.3
285
-
286
- ### Patch Changes
287
-
288
- - update dependencies ([#56](https://github.com/gyurielf/svelte-tel-input/pull/56))
289
-
290
- ## 0.6.2
291
-
292
- ### Patch Changes
293
-
294
- - Update readme & update packages ([#54](https://github.com/gyurielf/svelte-tel-input/pull/54))
295
-
296
- ## 0.6.1
297
-
298
- ### Patch Changes
299
-
300
- - Readme update ([#52](https://github.com/gyurielf/svelte-tel-input/pull/52))
301
-
302
- ## 0.6.0
303
-
304
- ### Minor Changes
305
-
306
- - feat: example page preparations & extend functionality (part 1) ([#50](https://github.com/gyurielf/svelte-tel-input/pull/50))
307
-
308
- ## 0.5.1
309
-
310
- ### Patch Changes
311
-
312
- - chore: update packages and resolve breaking changes ([#46](https://github.com/gyurielf/svelte-tel-input/pull/46))
313
-
314
- ## 0.5.0
315
-
316
- ### Minor Changes
317
-
318
- - feat: prepare github pages deployment ([#43](https://github.com/gyurielf/svelte-tel-input/pull/43))
319
-
320
- * feat: implement selects and input ([#43](https://github.com/gyurielf/svelte-tel-input/pull/43))
321
-
322
- - feat: basic stores created ([#43](https://github.com/gyurielf/svelte-tel-input/pull/43))
323
-
324
- ## 0.4.2
325
-
326
- ### Patch Changes
327
-
328
- - fix: fix readme ([#41](https://github.com/gyurielf/svelte-tel-input/pull/41))
329
-
330
- ## 0.4.1
331
-
332
- ### Patch Changes
333
-
334
- - fix: readme fix ([#39](https://github.com/gyurielf/svelte-tel-input/pull/39))
335
-
336
- ## 0.4.0
337
-
338
- ### Minor Changes
339
-
340
- - fix: rework ci
341
-
342
- ### Patch Changes
343
-
344
- - fix: minor ci fix ([#34](https://github.com/gyurielf/svelte-tel-input/pull/34))
345
-
346
- * fix: fix ci again ([#35](https://github.com/gyurielf/svelte-tel-input/pull/35))
347
-
348
- - fix: last ci fix for today ([#36](https://github.com/gyurielf/svelte-tel-input/pull/36))
349
-
350
- * fix: ci fixxx ([#33](https://github.com/gyurielf/svelte-tel-input/pull/33))
351
-
352
- - something 1 ([#37](https://github.com/gyurielf/svelte-tel-input/pull/37))
353
-
354
- * fix: ci extend 321 ([#32](https://github.com/gyurielf/svelte-tel-input/pull/32))
355
-
356
- ## 0.3.2
357
-
358
- ### Patch Changes
359
-
360
- - feat: add MIT license ([#29](https://github.com/gyurielf/svelte-tel-input/pull/29))
361
-
362
- * fix: fix readme deps ([#29](https://github.com/gyurielf/svelte-tel-input/pull/29))
363
-
364
- ## 0.3.1
365
-
366
- ### Patch Changes
367
-
368
- - fix: lets check with different folder structure ([#25](https://github.com/gyurielf/svelte-tel-input/pull/25))
369
-
370
- ## 0.3.0
371
-
372
- ### Minor Changes
373
-
374
- - fix: ci modifications ([#22](https://github.com/gyurielf/svelte-tel-input/pull/22))
375
-
376
- ## 0.2.0
377
-
378
- ### Minor Changes
379
-
380
- - remove unused packages, cleanup, fix ci ([#19](https://github.com/gyurielf/svelte-tel-input/pull/19))
381
-
382
- * fix: another CI fix ([#20](https://github.com/gyurielf/svelte-tel-input/pull/20))
383
-
384
- ## 0.1.0
385
-
386
- ### Minor Changes
387
-
388
- - test_1
389
-
390
- ### Patch Changes
391
-
392
- - szo
393
-
394
- * test 2
395
-
396
- - test3
package/assets/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { normalizedCountries } from './allCountry';
package/assets/index.js DELETED
@@ -1 +0,0 @@
1
- export { normalizedCountries } from './allCountry';
package/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export { default as TelInput } from './components/Input/TelInput.svelte';
2
- export { getCurrentCountry, isSelected, inputParser, inspectAllowedChars, normalizeTelInput, getCountryForPartialE164Number } from './utils/helpers';
3
- export { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js/max';
4
- export { clickOutsideAction } from './utils/directives/clickOutsideAction';
5
- export { normalizedCountries } from './assets';
package/index.js DELETED
@@ -1,5 +0,0 @@
1
- export { default as TelInput } from './components/Input/TelInput.svelte';
2
- export { getCurrentCountry, isSelected, inputParser, inspectAllowedChars, normalizeTelInput, getCountryForPartialE164Number } from './utils/helpers';
3
- export { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js/max';
4
- export { clickOutsideAction } from './utils/directives/clickOutsideAction';
5
- export { normalizedCountries } from './assets';
@@ -1,9 +0,0 @@
1
- export const clickOutsideAction = (node, handler) => {
2
- const onClick = (event) => node && !node.contains(event.target) && !event.defaultPrevented && handler();
3
- document.addEventListener('click', onClick, true);
4
- return {
5
- destroy() {
6
- document.removeEventListener('click', onClick, true);
7
- }
8
- };
9
- };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes