|
7 | 7 | generatePlaceholder,
|
8 | 8 | telInputAction
|
9 | 9 | } from '$lib/utils/index.js';
|
10 |
| - import { watcher } from '$lib/stores/index.js'; |
11 | 10 | import type { DetailedValue, CountryCode, E164Number, TelInputOptions } from '$lib/types';
|
12 | 11 |
|
13 | 12 | const dispatch = createEventDispatcher<{
|
|
47 | 46 | /** The core value of the input, this is the only one what you can store. It's an E164 phone number.*/
|
48 | 47 | export let value: E164Number | null;
|
49 | 48 | /** It's accept any Country Code Alpha-2 (ISO 3166) */
|
50 |
| - export let country: CountryCode | null; |
| 49 | + export let country: CountryCode | null | undefined = undefined; |
51 | 50 | /** Detailed parse of the E164 phone number */
|
52 | 51 | export let detailedValue: Partial<DetailedValue> | null = null;
|
53 | 52 | /** Validity of the input based on the config settings.*/
|
|
150 | 149 |
|
151 | 150 | // Watch user's country change.
|
152 | 151 | let countryWatchInitRun = true;
|
153 |
| - const countryChangeWatchFunction = () => { |
| 152 | + const countryChangeWatchFunction = (current: CountryCode | null | undefined) => { |
154 | 153 | if (!countryWatchInitRun) {
|
155 |
| - handleParsePhoneNumber(null, country); |
| 154 | + handleParsePhoneNumber(null, current); |
156 | 155 | }
|
157 | 156 | countryWatchInitRun = false;
|
158 | 157 | };
|
159 |
| - const countryChangeWatch = watcher(null, countryChangeWatchFunction); |
160 |
| - $: $countryChangeWatch = country; |
| 158 | +
|
| 159 | + $: countryChangeWatchFunction(country); |
161 | 160 |
|
162 | 161 | // Generate placeholder based on the autoPlaceholder option
|
163 | 162 | $: getPlaceholder =
|
|
0 commit comments