svelte-tel-input 3.4.1 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  Svelte Tel Input is distributed via [npm](https://www.npmjs.com/package/svelte-tel-input).
16
16
 
17
17
  ```bash
18
- npm install --save svelte-tel-input
18
+ npm install svelte-tel-input
19
19
  ```
20
20
 
21
21
  ## Features
@@ -6,7 +6,6 @@ import {
6
6
  generatePlaceholder,
7
7
  telInputAction
8
8
  } from "../../utils/index.js";
9
- import { watcher } from "../../stores/index.js";
10
9
  const dispatch = createEventDispatcher();
11
10
  const defaultOptions = {
12
11
  autoPlaceholder: true,
@@ -25,10 +24,11 @@ export let readonly = null;
25
24
  export let required = null;
26
25
  export let size = null;
27
26
  export let value;
28
- export let country;
27
+ export let country = void 0;
29
28
  export let detailedValue = null;
30
29
  export let valid = true;
31
30
  export let options = defaultOptions;
31
+ export let el = void 0;
32
32
  let inputValue = value;
33
33
  let prevCountry = country;
34
34
  const combinedOptions = {
@@ -103,14 +103,13 @@ const handleParsePhoneNumber = (rawInput, currCountry = null) => {
103
103
  }
104
104
  };
105
105
  let countryWatchInitRun = true;
106
- const countryChangeWatchFunction = () => {
106
+ const countryChangeWatchFunction = (current) => {
107
107
  if (!countryWatchInitRun) {
108
- handleParsePhoneNumber(null, country);
108
+ handleParsePhoneNumber(null, current);
109
109
  }
110
110
  countryWatchInitRun = false;
111
111
  };
112
- const countryChangeWatch = watcher(null, countryChangeWatchFunction);
113
- $: $countryChangeWatch = country;
112
+ $: countryChangeWatchFunction(country);
114
113
  $: getPlaceholder = combinedOptions.autoPlaceholder && country ? generatePlaceholder(country, {
115
114
  format: combinedOptions.format,
116
115
  spaces: combinedOptions.spaces
@@ -137,6 +136,8 @@ onMount(() => {
137
136
  </script>
138
137
 
139
138
  <input
139
+ {...$$restProps}
140
+ bind:this={el}
140
141
  {autocomplete}
141
142
  class={classes}
142
143
  {disabled}
@@ -2,20 +2,22 @@ import { SvelteComponentTyped } from "svelte";
2
2
  import type { DetailedValue, CountryCode, E164Number, TelInputOptions } from '../../types';
3
3
  declare const __propDef: {
4
4
  props: {
5
+ [x: string]: any;
5
6
  autocomplete?: string | null;
6
- /** You can set the classes of the input field*/ class?: string;
7
- /** You can disable the component and set the disabled attribute of the input field */ disabled?: boolean;
8
- /** You can set the id attribute of the input field */ id?: string;
9
- /** You can set the name attribute of the input field */ name?: string | null;
10
- /** It will overwrite the autoPlaceholder ! */ placeholder?: string | null;
11
- /** You can set the readonly attribute of the input field */ readonly?: boolean | null;
12
- /** Set the required attribute on the input element */ required?: boolean | null;
13
- /** You can set the size attribute of the input field */ size?: number | null;
14
- /** The core value of the input, this is the only one what you can store. It's an E164 phone number.*/ value: E164Number | null;
15
- /** It's accept any Country Code Alpha-2 (ISO 3166) */ country: CountryCode | null;
16
- /** Detailed parse of the E164 phone number */ detailedValue?: Partial<DetailedValue> | null;
17
- /** Validity of the input based on the config settings.*/ valid?: boolean;
18
- /** You can turn on and off certain features by this object */ options?: TelInputOptions;
7
+ class?: string;
8
+ disabled?: boolean;
9
+ id?: string;
10
+ name?: string | null;
11
+ placeholder?: string | null;
12
+ readonly?: boolean | null;
13
+ required?: boolean | null;
14
+ size?: number | null;
15
+ value: E164Number | null;
16
+ country?: CountryCode | null | undefined;
17
+ detailedValue?: Partial<DetailedValue> | null;
18
+ valid?: boolean;
19
+ options?: TelInputOptions;
20
+ el?: HTMLInputElement | undefined;
19
21
  updateValue?: (newValue: string | E164Number | null, newCountry?: CountryCode | null) => void;
20
22
  };
21
23
  events: {
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.4.1",
4
+ "version": "3.5.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/gyurielf/svelte-tel-input.git"
@@ -1,4 +0,0 @@
1
- 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?: import("svelte/store").Invalidator<string | null> | undefined) => import("svelte/store").Unsubscriber;
3
- set: (value: string | null) => void;
4
- };
@@ -1,14 +0,0 @@
1
- import { writable } from 'svelte/store';
2
- // Watch variable changes.
3
- export const watcher = (initialValue, watchFunction) => {
4
- const { subscribe, update } = writable(initialValue);
5
- return {
6
- subscribe,
7
- set: (value) => {
8
- update((oldvalue) => {
9
- watchFunction(oldvalue, value);
10
- return value;
11
- });
12
- }
13
- };
14
- };