svelte-tel-input 3.0.1 → 3.2.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.
Files changed (39) hide show
  1. package/LICENSE.md +1 -21
  2. package/README.md +1 -219
  3. package/{assets → dist/assets}/allCountry.d.ts +1 -1
  4. package/dist/assets/index.d.ts +1 -0
  5. package/dist/assets/index.js +1 -0
  6. package/dist/assets/regions.d.ts +1 -0
  7. package/dist/assets/regions.js +43 -0
  8. package/dist/assets/telTypes.d.ts +5 -0
  9. package/dist/assets/telTypes.js +16 -0
  10. package/{components → dist/components}/Input/TelInput.svelte +15 -9
  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/dist/utils/directives/telInputAction.d.ts +13 -0
  19. package/{utils → dist/utils}/directives/telInputAction.js +8 -3
  20. package/{utils → dist/utils}/helpers.d.ts +1 -1
  21. package/dist/utils/index.d.ts +4 -0
  22. package/dist/utils/index.js +4 -0
  23. package/dist/utils/typeCheck.d.ts +1 -0
  24. package/dist/utils/typeCheck.js +3 -0
  25. package/package.json +86 -36
  26. package/CHANGELOG.md +0 -376
  27. package/assets/index.d.ts +0 -1
  28. package/assets/index.js +0 -1
  29. package/index.d.ts +0 -5
  30. package/index.js +0 -5
  31. package/utils/directives/clickOutsideAction.js +0 -9
  32. package/utils/directives/telInputAction.d.ts +0 -6
  33. /package/{assets → dist/assets}/allCountry.js +0 -0
  34. /package/{assets → dist/assets}/flags_responsive.png +0 -0
  35. /package/{components → dist/components}/Input/TelInput.svelte.d.ts +0 -0
  36. /package/{stores → dist/stores}/index.js +0 -0
  37. /package/{styles → dist/styles}/flags.css +0 -0
  38. /package/{types → dist/types}/index.d.ts +0 -0
  39. /package/{utils → dist/utils}/helpers.js +0 -0
package/LICENSE.md CHANGED
@@ -1,21 +1 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2022 - Present Gyorgy Kallai, Budapest, Hungary.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ ../../LICENSE.md
package/README.md CHANGED
@@ -1,219 +1 @@
1
- <a name="readme-top"></a>
2
-
3
- [![npm version](https://badge.fury.io/js/svelte-tel-input.svg)](https://badge.fury.io/js/svelte-tel-input)
4
-
5
- # Svelte Tel Input
6
-
7
- > Lightweight svelte tel/phone input standardizer.
8
-
9
- <img src="https://raw.githubusercontent.com/gyurielf/svelte-tel-input/main/static/demo.gif" width="600px" align="center">
10
-
11
- 🔥 Check it out live [here](https://svelte-tel-input.vercel.app/)
12
-
13
- ## Installation
14
-
15
- Svelte Tel Input is distributed via [npm](https://www.npmjs.com/package/svelte-tel-input).
16
-
17
- ```bash
18
- npm install --save svelte-tel-input
19
- ```
20
-
21
- ## Features
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.
28
-
29
- ## Usage
30
-
31
- ### Advanced
32
-
33
- _Snippet would be too long_ - [REPL](https://stackblitz.com/edit/svelte-tel-input-repl-1jfaar?file=README.md) (StackBlitz)
34
-
35
- ### Basic
36
-
37
- [REPL](https://stackblitz.com/edit/svelte-tel-input-repl?file=README.md) (StackBlitz)
38
-
39
- ```html
40
- <script lang="ts">
41
- import { TelInput, normalizedCountries } from 'svelte-tel-input';
42
- import type { DetailedValue, CountryCode, E164Number } from 'svelte-tel-input/types';
43
-
44
- // Any Country Code Alpha-2 (ISO 3166)
45
- let selectedCountry: CountryCode | null = 'HU';
46
-
47
- // You must use E164 number format. It's guarantee the parsing and storing consistency.
48
- let value: E164Number | null = '+36301234567';
49
-
50
- // Validity
51
- let valid = true;
52
-
53
- // Optional - Extended details about the parsed phone number
54
- let detailedValue: DetailedValue | null = null;
55
- </script>
56
-
57
- <div class="wrapper">
58
- <select
59
- class="country-select {!valid && 'invalid'}"
60
- aria-label="Default select example"
61
- name="Country"
62
- bind:value={selectedCountry}
63
- >
64
- <option value={null} hidden={selectedCountry !== null}>Please select</option>
65
- {#each normalizedCountries as country (country.id)}
66
- <option
67
- value={country.iso2}
68
- selected={country.iso2 === selectedCountry}
69
- aria-selected={country.iso2 === selectedCountry}
70
- >
71
- {country.iso2} (+{country.dialCode})
72
- </option>
73
- {/each}
74
- </select>
75
- <TelInput bind:country={selectedCountry} bind:value bind:valid bind:detailedValue class="basic-tel-input {!isValid && 'invalid'}" />
76
- </div>
77
-
78
- <style>
79
- .wrapper :global(.basic-tel-input) {
80
- height: 32px;
81
- padding-left: 12px;
82
- padding-right: 12px;
83
- border-radius: 6px;
84
- border: 1px solid;
85
- outline: none;
86
- }
87
-
88
- .wrapper :global(.country-select) {
89
- height: 36px;
90
- padding-left: 12px;
91
- padding-right: 12px;
92
- border-radius: 6px;
93
- border: 1px solid;
94
- outline: none;
95
- }
96
-
97
- .wrapper :global(.invalid) {
98
- border-color: red;
99
- }
100
- </style>
101
- ```
102
-
103
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
104
-
105
- ## Props
106
-
107
- The default export of the library is the main TelInput component. It has the following props:
108
-
109
- | Property name | Type | Default Value | Usage |
110
- | ------------- | ---------------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
111
- | value | `E164Number \| null` | `null` | [E164](https://en.wikipedia.org/wiki/E.164) is the international format of phone.numbers. This is the main entry point to store and/or load an existent phone number. |
112
- | country | `CountryCode \| null` | `null` | It's accept any Country Code Alpha-2 (ISO 3166). You can set manually (e.g: by the user via a select). The parser will inspect the entered phone number and if it detect a valid country calling code, then it's automatically set the country to according to the detected country calling code. E.g: `+36` -> `HU` |
113
- | disabled | `boolean` | `false` | It's block the parser and prevent entering input. You must handle its styling on your own. |
114
- | valid | `boolean` | `true` | Indicates whether the entered tel number validity. |
115
- | detailedValue | `DetailedValue \|null` | `null` | All of the formatted results of the tel input. |
116
- | class | `string` | `` | You can pass down any classname to the component |
117
- | required | `boolean \| null` | `null` | Set the required attribute on the input element |
118
- | options | `TelInputOptions` | check below | Allow or disallow spaces in the input field |
119
-
120
- Config options:
121
-
122
- ```javascript
123
- {
124
- // Generates country specific placeholder for the selected country.
125
- autoPlaceholder: true,
126
- // Allow or disallow spaces in the input field
127
- spaces: true,
128
- // If you have a parsed phone number and you change country manually from outside, then it's set the `valid` prop to false.
129
- invalidateOnCountryChange: false
130
- }
131
- ```
132
-
133
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
134
-
135
- ## Dispatched Events
136
-
137
- The default export of the library is the main TelInput component. It has the following props:
138
-
139
- | Event name | Type |
140
- | ------------------- | ---------------------- |
141
- | updateValue | `E164Number \| null` |
142
- | updateDetailedValue | `DetailedValue \|null` |
143
- | updateCountry | `CountryCode \| null` |
144
- | updateValid | `boolean` |
145
- | parseError | `string` |
146
-
147
- ## Use case of the event driven behavior
148
-
149
- ```typescript
150
- <script lang="ts">
151
- // Imports, etc....
152
- let value: E164Number | null = null;
153
- const yourHandler = (e: CustomEvent<E164Number | null>) => {
154
- value = e.detail //
155
- // do stuff...
156
- };
157
- </script>
158
-
159
- <TelInput value={cachedValue ?? value} on:updateValue={yourHandler} ... />
160
- ```
161
-
162
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
163
-
164
- ## Caveats
165
-
166
- - In order to reset the component from outside, you must pass (or set if you binded) `null` for both the `value` and `country` properties.
167
- - 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`).
168
-
169
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
170
-
171
- ## Goals
172
-
173
- - Solve the problem that a users can enter the same phone number in different formats.
174
- - Storing a phone number in a standard format, that can be indexable and searchable in any database.
175
- - Should be accessible for the the browser. Eg. for a `<a href="tel+36201234567 />`.
176
- - 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.
177
-
178
- ## Dependencies
179
-
180
- [svelte](https://svelte.dev/)
181
-
182
- [libphonenumber-js](https://gitlab.com/catamphetamine/libphonenumber-js)
183
-
184
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
185
-
186
- ## Changelog
187
-
188
- | Package | Changelog |
189
- | ------------------------------ | ------------------------- |
190
- | [@gyurielf/svelte-tel-input]() | [Changelog](CHANGELOG.md) |
191
-
192
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
193
-
194
- ## Roadmap
195
-
196
- - [x] Add Changelog
197
- - [x] Add CI/CD
198
- - [x] Integrate libphonenumber
199
- - [x] Implement parser
200
- - [x] Add basics docs and examples
201
- - [x] Add advanced examples
202
- - [x] Generate placeholders autimatically
203
- - [ ] Improve A11Y
204
-
205
- See the [open issues](https://github.com/gyurielf/svelte-tel-input/issues) for a list of proposed features (and known issues).
206
-
207
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
208
-
209
- ## Support
210
-
211
- <a href="https://www.buymeacoffee.com/gyurielf" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
212
-
213
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
214
-
215
- ## License
216
-
217
- Distributed under the MIT License. See `LICENSE.md` for more information.
218
-
219
- <p align="right">(<a href="#readme-top">back to top</a>)</p>
1
+ ../../README.md
@@ -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,
@@ -62,13 +62,11 @@ const handleParsePhoneNumber = (input, currCountry = null) => {
62
62
  if (detailedValue?.isValid && combinedOptions.spaces && detailedValue?.formatOriginal) {
63
63
  if (inputValue === detailedValue?.formatOriginal) {
64
64
  inputValue = null;
65
- inputValue = "";
66
65
  }
67
66
  inputValue = detailedValue?.formatOriginal;
68
67
  } else if (detailedValue?.isValid && detailedValue?.nationalNumber) {
69
68
  if (inputValue === detailedValue?.nationalNumber) {
70
69
  inputValue = null;
71
- inputValue = "";
72
70
  }
73
71
  inputValue = detailedValue?.nationalNumber;
74
72
  }
@@ -84,7 +82,6 @@ const handleParsePhoneNumber = (input, currCountry = null) => {
84
82
  value = null;
85
83
  if (inputValue !== null || inputValue !== "") {
86
84
  inputValue = null;
87
- inputValue = "";
88
85
  }
89
86
  detailedValue = null;
90
87
  dispatch("updateValid", valid);
@@ -99,7 +96,6 @@ const handleParsePhoneNumber = (input, currCountry = null) => {
99
96
  dispatch("updateValid", valid);
100
97
  dispatch("updateDetailedValue", detailedValue);
101
98
  inputValue = null;
102
- inputValue = "";
103
99
  }
104
100
  };
105
101
  let countryWatchInitRun = true;
@@ -114,6 +110,12 @@ $:
114
110
  $countryChangeWatch = country;
115
111
  $:
116
112
  getPlaceholder = combinedOptions.autoPlaceholder ? country ? generatePlaceholder(country) : null : placeholder;
113
+ $:
114
+ if (value === null && inputValue !== null && detailedValue !== null) {
115
+ inputValue = null;
116
+ detailedValue = null;
117
+ dispatch("updateDetailedValue", detailedValue);
118
+ }
117
119
  const initialize = () => {
118
120
  if (value && country) {
119
121
  handleParsePhoneNumber(value, country);
@@ -149,5 +151,9 @@ onMount(() => {
149
151
  on:keyup
150
152
  on:paste
151
153
  on:click
152
- use:telInputAction={{ handler: handleInputAction, spaces: combinedOptions.spaces }}
154
+ use:telInputAction={{
155
+ handler: handleInputAction,
156
+ spaces: combinedOptions.spaces,
157
+ value
158
+ }}
153
159
  />
@@ -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
@@ -0,0 +1,13 @@
1
+ import type { E164Number } from 'libphonenumber-js';
2
+ export declare const telInputAction: (node: HTMLInputElement, { handler, spaces }: {
3
+ handler: (val: string) => void;
4
+ spaces: boolean;
5
+ value: E164Number | null;
6
+ }) => {
7
+ update(params: {
8
+ handler: (val: string) => void;
9
+ spaces: boolean;
10
+ value: E164Number | null;
11
+ }): void;
12
+ destroy(): void;
13
+ };
@@ -1,9 +1,9 @@
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)) {
5
- const value = event.target.value;
6
- const formattedInput = inputParser(value, {
5
+ const currentValue = event.target.value;
6
+ const formattedInput = inputParser(currentValue, {
7
7
  parseCharacter: inspectAllowedChars,
8
8
  allowSpaces: spaces
9
9
  });
@@ -13,6 +13,11 @@ export const telInputAction = (node, { handler, spaces }) => {
13
13
  };
14
14
  node.addEventListener('input', onInput, true);
15
15
  return {
16
+ update(params) {
17
+ if (params.value === null || params.value === '') {
18
+ node.value = '';
19
+ }
20
+ },
16
21
  destroy() {
17
22
  node.removeEventListener('input', onInput, true);
18
23
  }
@@ -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.0.1",
4
+ "version": "3.2.0",
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.59.11",
40
- "@typescript-eslint/parser": "^5.59.11",
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
- "dotenv": "^16.3.0",
44
- "edit-package-json": "^0.8.14",
45
- "eslint": "^8.43.0",
48
+ "dotenv": "^16.3.1",
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,376 +0,0 @@
1
- # svelte-tel-input
2
-
3
- ## 3.0.1
4
-
5
- ### Patch Changes
6
-
7
- - chore: update readme with advanced example REPL ([#162](https://github.com/gyurielf/svelte-tel-input/pull/162))
8
-
9
- - fix: auto country update after manual country change ([#162](https://github.com/gyurielf/svelte-tel-input/pull/162))
10
-
11
- ## 3.0.0
12
-
13
- ### Major Changes
14
-
15
- - breaking: rename `parsedTelInput` property: ([#156](https://github.com/gyurielf/svelte-tel-input/pull/156))
16
- `parsedTelInput` is `detailedValue` from now.
17
-
18
- ```diff
19
- -<TelInput bind:parsedTelInput ... />;
20
- +<TelInput bind:detailedValue ... />;
21
- ```
22
-
23
- breaking: rename dispatched events:
24
- `parseInput` is splitted to two (`updateValue` and `updateDetailedValue` ) event.
25
- `valid` is `updateValid` from now.
26
-
27
- ```diff
28
- -<TelInput on:parseInput={...} on:valid={...} ... />;
29
- +<TelInput on:updateValue={...} on:updateDetailedValue={...} on:updateValid={...} on:updateCountry={...} ... />;
30
- ```
31
-
32
- breaking: rename `NormalizedTelNumber` type to `DetailedValue`:
33
-
34
- ```diff
35
- -import type { NormalizedTelNumber } from 'svelte-tel-input/types';
36
- +import type { DetailedValue } from 'svelte-tel-input/types';
37
- ```
38
-
39
- feat: new event added: `updateCountry`
40
-
41
- ```html
42
- <TelInput on:updateCountry="{...}" ... />;
43
- ```
44
-
45
- feat: now the component is fully supports the event driven behavior. So you don't have to bind properties.
46
-
47
- ```diff
48
- -<TelInput bind:value ... />;
49
- +<TelInput value={yourValue} ... />;
50
- ```
51
-
52
- ## 2.1.1
53
-
54
- ### Patch Changes
55
-
56
- - fix: US flag is now more representative ([#154](https://github.com/gyurielf/svelte-tel-input/pull/154))
57
-
58
- ## 2.1.0
59
-
60
- ### Minor Changes
61
-
62
- - feat: support event driven behavior ([#150](https://github.com/gyurielf/svelte-tel-input/pull/150))
63
-
64
- ## 2.0.1
65
-
66
- ### Patch Changes
67
-
68
- - fix: component export ([#147](https://github.com/gyurielf/svelte-tel-input/pull/147))
69
-
70
- ## 2.0.0
71
-
72
- ### Major Changes
73
-
74
- - 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))
75
-
76
- ### Minor Changes
77
-
78
- - 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))
79
-
80
- - feat: autoPlaceholder feature added, it generates placeholder for each country. ([#143](https://github.com/gyurielf/svelte-tel-input/pull/143))
81
-
82
- ### Patch Changes
83
-
84
- - chore: update deps, re-generate package-lock.json ([#143](https://github.com/gyurielf/svelte-tel-input/pull/143))
85
-
86
- - 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))
87
-
88
- ## 1.3.2
89
-
90
- ### Patch Changes
91
-
92
- - chore: export ParseError class ([#141](https://github.com/gyurielf/svelte-tel-input/pull/141))
93
-
94
- ## 1.3.1
95
-
96
- ### Patch Changes
97
-
98
- - chore: extend method exports ([#139](https://github.com/gyurielf/svelte-tel-input/pull/139))
99
-
100
- ## 1.3.0
101
-
102
- ### Minor Changes
103
-
104
- - fix: validation on select all and delete ([#137](https://github.com/gyurielf/svelte-tel-input/pull/137))
105
-
106
- ## 1.2.0
107
-
108
- ### Minor Changes
109
-
110
- - fix: improved validation ([#132](https://github.com/gyurielf/svelte-tel-input/pull/132))
111
-
112
- ## 1.1.3
113
-
114
- ### Patch Changes
115
-
116
- - fix: make parsedTelInput prop optional ([#129](https://github.com/gyurielf/svelte-tel-input/pull/129))
117
-
118
- ## 1.1.2
119
-
120
- ### Patch Changes
121
-
122
- - feat: seo improvement and deps update ([#127](https://github.com/gyurielf/svelte-tel-input/pull/127))
123
-
124
- - fix: prevent commit to the main branch ([#127](https://github.com/gyurielf/svelte-tel-input/pull/127))
125
-
126
- ## 1.1.1
127
-
128
- ### Patch Changes
129
-
130
- - fix: advanced input handleSelect method fix ([#125](https://github.com/gyurielf/svelte-tel-input/pull/125))
131
-
132
- - fix: modify style export in package.json and in post-build.js ([#125](https://github.com/gyurielf/svelte-tel-input/pull/125))
133
-
134
- - fix: set flags assets import relative in flags.css ([#125](https://github.com/gyurielf/svelte-tel-input/pull/125))
135
-
136
- ## 1.1.0
137
-
138
- ### Minor Changes
139
-
140
- - feat: vitests and e2e (playwright) added ([#123](https://github.com/gyurielf/svelte-tel-input/pull/123))
141
-
142
- - chore: remove unnecessary dependencies ([#123](https://github.com/gyurielf/svelte-tel-input/pull/123))
143
-
144
- ## 1.0.2
145
-
146
- ### Patch Changes
147
-
148
- - chore: extend REPL example ([#119](https://github.com/gyurielf/svelte-tel-input/pull/119))
149
-
150
- - chore: polish readme ([#119](https://github.com/gyurielf/svelte-tel-input/pull/119))
151
-
152
- - chore: update dependencies ([#119](https://github.com/gyurielf/svelte-tel-input/pull/119))
153
-
154
- ## 1.0.1
155
-
156
- ### Patch Changes
157
-
158
- - fix: remove types field right before packaging ([#116](https://github.com/gyurielf/svelte-tel-input/pull/116))
159
-
160
- ## 1.0.0
161
-
162
- ### Major Changes
163
-
164
- - feat: prevent typing non-tel input characters into the input field. ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
165
-
166
- - fix: now you can use value prop as a single entry ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
167
-
168
- - feat: support monorepos ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
169
-
170
- - feat: sanitize pasted E164 number ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
171
-
172
- - 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))
173
-
174
- - fix: clear input on manual country change ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
175
-
176
- ### Minor Changes
177
-
178
- - chore: tweak types ([#108](https://github.com/gyurielf/svelte-tel-input/pull/108))
179
-
180
- ## 0.14.2
181
-
182
- ### Patch Changes
183
-
184
- - update something ([#105](https://github.com/gyurielf/svelte-tel-input/pull/105))
185
-
186
- ## 0.14.1
187
-
188
- ### Patch Changes
189
-
190
- - chore: export tests ([#100](https://github.com/gyurielf/svelte-tel-input/pull/100))
191
-
192
- ## 0.14.0
193
-
194
- ### Minor Changes
195
-
196
- - Prevent circular import ([#98](https://github.com/gyurielf/svelte-tel-input/pull/98))
197
-
198
- ## 0.13.1
199
-
200
- ### Patch Changes
201
-
202
- - chore: simplify part one ([#94](https://github.com/gyurielf/svelte-tel-input/pull/94))
203
-
204
- ## 0.13.0
205
-
206
- ### Minor Changes
207
-
208
- - Simplify structure ([#91](https://github.com/gyurielf/svelte-tel-input/pull/91))
209
-
210
- ## 0.12.0
211
-
212
- ### Minor Changes
213
-
214
- - feat: Update exports to make the package as simple to use as possible. ([#85](https://github.com/gyurielf/svelte-tel-input/pull/85))
215
-
216
- ## 0.11.1
217
-
218
- ### Patch Changes
219
-
220
- - Update readme and prepare to 1.0 ([#79](https://github.com/gyurielf/svelte-tel-input/pull/79))
221
-
222
- ## 0.11.0
223
-
224
- ### Minor Changes
225
-
226
- - feat: dark mode, example page enhancemet ([#76](https://github.com/gyurielf/svelte-tel-input/pull/76))
227
-
228
- ## 0.10.0
229
-
230
- ### Minor Changes
231
-
232
- - refactor: components and views ([#74](https://github.com/gyurielf/svelte-tel-input/pull/74))
233
-
234
- ## 0.9.0
235
-
236
- ### Minor Changes
237
-
238
- - feat: masking/formatting and parsing extends ([#72](https://github.com/gyurielf/svelte-tel-input/pull/72))
239
-
240
- ## 0.8.0
241
-
242
- ### Minor Changes
243
-
244
- - feat: example improvements, extend functionality ([#70](https://github.com/gyurielf/svelte-tel-input/pull/70))
245
-
246
- ## 0.7.0
247
-
248
- ### Minor Changes
249
-
250
- - feat: example page payload feature, parsing improvements" ([#68](https://github.com/gyurielf/svelte-tel-input/pull/68))
251
-
252
- ## 0.6.5
253
-
254
- ### Patch Changes
255
-
256
- - fix: add changeset ([#61](https://github.com/gyurielf/svelte-tel-input/pull/61))
257
-
258
- ## 0.6.4
259
-
260
- ### Patch Changes
261
-
262
- - chore: update to vite 3 ([#58](https://github.com/gyurielf/svelte-tel-input/pull/58))
263
-
264
- ## 0.6.3
265
-
266
- ### Patch Changes
267
-
268
- - update dependencies ([#56](https://github.com/gyurielf/svelte-tel-input/pull/56))
269
-
270
- ## 0.6.2
271
-
272
- ### Patch Changes
273
-
274
- - Update readme & update packages ([#54](https://github.com/gyurielf/svelte-tel-input/pull/54))
275
-
276
- ## 0.6.1
277
-
278
- ### Patch Changes
279
-
280
- - Readme update ([#52](https://github.com/gyurielf/svelte-tel-input/pull/52))
281
-
282
- ## 0.6.0
283
-
284
- ### Minor Changes
285
-
286
- - feat: example page preparations & extend functionality (part 1) ([#50](https://github.com/gyurielf/svelte-tel-input/pull/50))
287
-
288
- ## 0.5.1
289
-
290
- ### Patch Changes
291
-
292
- - chore: update packages and resolve breaking changes ([#46](https://github.com/gyurielf/svelte-tel-input/pull/46))
293
-
294
- ## 0.5.0
295
-
296
- ### Minor Changes
297
-
298
- - feat: prepare github pages deployment ([#43](https://github.com/gyurielf/svelte-tel-input/pull/43))
299
-
300
- * feat: implement selects and input ([#43](https://github.com/gyurielf/svelte-tel-input/pull/43))
301
-
302
- - feat: basic stores created ([#43](https://github.com/gyurielf/svelte-tel-input/pull/43))
303
-
304
- ## 0.4.2
305
-
306
- ### Patch Changes
307
-
308
- - fix: fix readme ([#41](https://github.com/gyurielf/svelte-tel-input/pull/41))
309
-
310
- ## 0.4.1
311
-
312
- ### Patch Changes
313
-
314
- - fix: readme fix ([#39](https://github.com/gyurielf/svelte-tel-input/pull/39))
315
-
316
- ## 0.4.0
317
-
318
- ### Minor Changes
319
-
320
- - fix: rework ci
321
-
322
- ### Patch Changes
323
-
324
- - fix: minor ci fix ([#34](https://github.com/gyurielf/svelte-tel-input/pull/34))
325
-
326
- * fix: fix ci again ([#35](https://github.com/gyurielf/svelte-tel-input/pull/35))
327
-
328
- - fix: last ci fix for today ([#36](https://github.com/gyurielf/svelte-tel-input/pull/36))
329
-
330
- * fix: ci fixxx ([#33](https://github.com/gyurielf/svelte-tel-input/pull/33))
331
-
332
- - something 1 ([#37](https://github.com/gyurielf/svelte-tel-input/pull/37))
333
-
334
- * fix: ci extend 321 ([#32](https://github.com/gyurielf/svelte-tel-input/pull/32))
335
-
336
- ## 0.3.2
337
-
338
- ### Patch Changes
339
-
340
- - feat: add MIT license ([#29](https://github.com/gyurielf/svelte-tel-input/pull/29))
341
-
342
- * fix: fix readme deps ([#29](https://github.com/gyurielf/svelte-tel-input/pull/29))
343
-
344
- ## 0.3.1
345
-
346
- ### Patch Changes
347
-
348
- - fix: lets check with different folder structure ([#25](https://github.com/gyurielf/svelte-tel-input/pull/25))
349
-
350
- ## 0.3.0
351
-
352
- ### Minor Changes
353
-
354
- - fix: ci modifications ([#22](https://github.com/gyurielf/svelte-tel-input/pull/22))
355
-
356
- ## 0.2.0
357
-
358
- ### Minor Changes
359
-
360
- - remove unused packages, cleanup, fix ci ([#19](https://github.com/gyurielf/svelte-tel-input/pull/19))
361
-
362
- * fix: another CI fix ([#20](https://github.com/gyurielf/svelte-tel-input/pull/20))
363
-
364
- ## 0.1.0
365
-
366
- ### Minor Changes
367
-
368
- - test_1
369
-
370
- ### Patch Changes
371
-
372
- - szo
373
-
374
- * test 2
375
-
376
- - 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
- };
@@ -1,6 +0,0 @@
1
- export declare const telInputAction: (node: HTMLInputElement, { handler, spaces }: {
2
- handler: (val: string) => void;
3
- spaces: boolean;
4
- }) => {
5
- destroy(): void;
6
- };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes