svelte-tel-input 0.4.2 → 0.5.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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # svelte-tel-input
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: prepare github pages deployment ([#43](https://github.com/gyurielf/svelte-tel-input/pull/43))
8
+
9
+ * feat: implement selects and input ([#43](https://github.com/gyurielf/svelte-tel-input/pull/43))
10
+
11
+ - feat: basic stores created ([#43](https://github.com/gyurielf/svelte-tel-input/pull/43))
12
+
3
13
  ## 0.4.2
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -6,20 +6,22 @@
6
6
 
7
7
  ## Installation
8
8
 
9
- ---
10
-
11
9
  Svelte Tel Input is distributed via [npm](https://www.npmjs.com/package/svelte-tel-input).
12
10
 
13
11
  ```sh
14
12
  yarn add svelte-tel-input
13
+ ```
15
14
 
16
- # or
17
-
15
+ ```
18
16
  npm install --save svelte-tel-input
19
17
  ```
20
18
 
21
- ---
22
-
23
19
  ## Dependencies
24
20
 
25
21
  [libphonenumber-js](https://gitlab.com/catamphetamine/libphonenumber-js)
22
+
23
+ ## Changelog
24
+
25
+ | Package | Changelog |
26
+ | ------------------------------ | ------------------------- |
27
+ | [@gyurielf/svelte-tel-input]() | [Changelog](CHANGELOG.md) |
@@ -0,0 +1,23 @@
1
+ <script >import { enteredTelInputStore } from '../../stores';
2
+ import { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js';
3
+ export let enteredTelInput;
4
+ const handleInput = (event) => {
5
+ const inputVal = event.target.value;
6
+ enteredTelInput = inputVal;
7
+ $enteredTelInputStore = inputVal;
8
+ try {
9
+ const phoneNumber = parsePhoneNumberWithError(inputVal);
10
+ }
11
+ catch (error) {
12
+ if (error instanceof ParseError) {
13
+ // Not a phone number, non-existent country, etc.
14
+ console.log(error.message);
15
+ }
16
+ else {
17
+ throw error;
18
+ }
19
+ }
20
+ };
21
+ </script>
22
+
23
+ <input class={$$props.class} type="tel" on:input={handleInput} />
@@ -0,0 +1,17 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ [x: string]: any;
5
+ enteredTelInput: string;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export declare type TelInputProps = typeof __propDef.props;
13
+ export declare type TelInputEvents = typeof __propDef.events;
14
+ export declare type TelInputSlots = typeof __propDef.slots;
15
+ export default class TelInput extends SvelteComponentTyped<TelInputProps, TelInputEvents, TelInputSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,15 @@
1
+ <script >import { selectedCountryStore } from '../../../stores';
2
+ export let selectedCountry;
3
+ const setSelectedCountry = (value) => {
4
+ selectedCountry = value;
5
+ $selectedCountryStore = value;
6
+ };
7
+ </script>
8
+
9
+ <select
10
+ name="country_select"
11
+ class="some-class {$$props.class}"
12
+ on:change={(e) => setSelectedCountry(e.currentTarget.value)}
13
+ >
14
+ <slot name="options" />
15
+ </select>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ [x: string]: any;
5
+ selectedCountry: string;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ options: {};
12
+ };
13
+ };
14
+ export declare type TelCountrySelectProps = typeof __propDef.props;
15
+ export declare type TelCountrySelectEvents = typeof __propDef.events;
16
+ export declare type TelCountrySelectSlots = typeof __propDef.slots;
17
+ export default class TelCountrySelect extends SvelteComponentTyped<TelCountrySelectProps, TelCountrySelectEvents, TelCountrySelectSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,12 @@
1
+ <script >"use strict";
2
+ let selectedTelRegion;
3
+ </script>
4
+
5
+ <select
6
+ name="region_select"
7
+ class={$$props.class}
8
+ bind:value={selectedTelRegion}
9
+ on:change={() => console.log(selectedTelRegion)}
10
+ >
11
+ <slot name="options" />
12
+ </select>
@@ -0,0 +1,18 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ [x: string]: any;
5
+ };
6
+ events: {
7
+ [evt: string]: CustomEvent<any>;
8
+ };
9
+ slots: {
10
+ options: {};
11
+ };
12
+ };
13
+ export declare type TelRegionSelectProps = typeof __propDef.props;
14
+ export declare type TelRegionSelectEvents = typeof __propDef.events;
15
+ export declare type TelRegionSelectSlots = typeof __propDef.slots;
16
+ export default class TelRegionSelect extends SvelteComponentTyped<TelRegionSelectProps, TelRegionSelectEvents, TelRegionSelectSlots> {
17
+ }
18
+ export {};
@@ -0,0 +1,4 @@
1
+ <script >export let regionOption;
2
+ </script>
3
+
4
+ <option class={$$props.class} value={regionOption.value}>{regionOption.label}</option>
@@ -0,0 +1,18 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { SelectObject } from '../../../models/interfaces/Select.interface';
3
+ declare const __propDef: {
4
+ props: {
5
+ [x: string]: any;
6
+ regionOption: SelectObject;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
13
+ export declare type TelRegionSelectOptionProps = typeof __propDef.props;
14
+ export declare type TelRegionSelectOptionEvents = typeof __propDef.events;
15
+ export declare type TelRegionSelectOptionSlots = typeof __propDef.slots;
16
+ export default class TelRegionSelectOption extends SvelteComponentTyped<TelRegionSelectOptionProps, TelRegionSelectOptionEvents, TelRegionSelectOptionSlots> {
17
+ }
18
+ export {};
@@ -0,0 +1,15 @@
1
+ <script >import { selectedTelTypeStore } from '../../../stores';
2
+ export let selectedTelType;
3
+ const setSelectedCountry = (value) => {
4
+ selectedTelType = value;
5
+ $selectedTelTypeStore = value;
6
+ };
7
+ </script>
8
+
9
+ <select
10
+ name="type_select"
11
+ class={$$props.class}
12
+ on:change={(e) => setSelectedCountry(e.currentTarget.value)}
13
+ >
14
+ <slot name="options" />
15
+ </select>
@@ -0,0 +1,20 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { SelectType } from '../../../models/types/Select.type';
3
+ declare const __propDef: {
4
+ props: {
5
+ [x: string]: any;
6
+ selectedTelType: SelectType;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {
12
+ options: {};
13
+ };
14
+ };
15
+ export declare type TelTypeSelectProps = typeof __propDef.props;
16
+ export declare type TelTypeSelectEvents = typeof __propDef.events;
17
+ export declare type TelTypeSelectSlots = typeof __propDef.slots;
18
+ export default class TelTypeSelect extends SvelteComponentTyped<TelTypeSelectProps, TelTypeSelectEvents, TelTypeSelectSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,4 @@
1
+ <script >export let typeOption;
2
+ </script>
3
+
4
+ <option class={$$props.class} value={typeOption.value}>{typeOption.label}</option>
@@ -0,0 +1,18 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { SelectObject } from '../../../models/interfaces/Select.interface';
3
+ declare const __propDef: {
4
+ props: {
5
+ [x: string]: any;
6
+ typeOption: SelectObject;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
13
+ export declare type TelTypeSelectOptionProps = typeof __propDef.props;
14
+ export declare type TelTypeSelectOptionEvents = typeof __propDef.events;
15
+ export declare type TelTypeSelectOptionSlots = typeof __propDef.slots;
16
+ export default class TelTypeSelectOption extends SvelteComponentTyped<TelTypeSelectOptionProps, TelTypeSelectOptionEvents, TelTypeSelectOptionSlots> {
17
+ }
18
+ export {};
package/index.d.ts CHANGED
@@ -1,2 +1,6 @@
1
- export { default as LazyLoad } from './components/LazyLoad/LazyLoad.svelte';
2
- export { default as PhoneInput } from './components/Input/SvelteTelInput.svelte';
1
+ export { default as TelCountrySelect } from "./components/Select/TelCountrySelect/TelCountrySelect.svelte";
2
+ export { default as TelTypeSelect } from "./components/Select/TelTypeSelect/TelTypeSelect.svelte";
3
+ export { default as TelTypeSelectOption } from "./components/Select/TelTypeSelect/TelTypeSelectOption.svelte";
4
+ export { default as TelRegionSelect } from "./components/Select/TelRegionSelect/TelRegionSelect.svelte";
5
+ export { default as TelRegionSelectOption } from "./components/Select/TelRegionSelect/TelRegionSelectOption.svelte";
6
+ export { default as TelInput } from "./components/Input/TelInput.svelte";
package/index.js CHANGED
@@ -1,2 +1,6 @@
1
- export { default as LazyLoad } from './components/LazyLoad/LazyLoad.svelte';
2
- export { default as PhoneInput } from './components/Input/SvelteTelInput.svelte';
1
+ export { default as TelCountrySelect } from './components/Select/TelCountrySelect/TelCountrySelect.svelte';
2
+ export { default as TelTypeSelect } from './components/Select/TelTypeSelect/TelTypeSelect.svelte';
3
+ export { default as TelTypeSelectOption } from './components/Select/TelTypeSelect/TelTypeSelectOption.svelte';
4
+ export { default as TelRegionSelect } from './components/Select/TelRegionSelect/TelRegionSelect.svelte';
5
+ export { default as TelRegionSelectOption } from './components/Select/TelRegionSelect/TelRegionSelectOption.svelte';
6
+ export { default as TelInput } from './components/Input/TelInput.svelte';
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.2",
4
+ "version": "0.5.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/gyurielf/svelte-tel-input.git"
@@ -17,20 +17,20 @@
17
17
  ],
18
18
  "engines": {
19
19
  "npm": ">= 7",
20
- "yarn": "please-use-npm",
20
+ "yarn": ">=2",
21
21
  "node": ">= 16"
22
22
  },
23
23
  "dependencies": {
24
24
  "libphonenumber-js": "^1.9.44"
25
25
  },
26
26
  "devDependencies": {
27
- "@babel/core": "^7.16.10",
28
- "@babel/preset-env": "^7.16.10",
27
+ "@babel/core": "^7.16.12",
28
+ "@babel/preset-env": "^7.16.11",
29
29
  "@changesets/cli": "^2.19.0",
30
30
  "@changesets/get-github-info": "^0.5.0",
31
31
  "@changesets/types": "^4.0.2",
32
32
  "@sveltejs/adapter-static": "^1.0.0-next.26",
33
- "@sveltejs/kit": "^1.0.0-next.234",
33
+ "@sveltejs/kit": "^1.0.0-next.240",
34
34
  "@testing-library/jest-dom": "^5.16.1",
35
35
  "@testing-library/svelte": "^3.0.3",
36
36
  "@types/jest": "^27.4.0",
@@ -40,7 +40,7 @@
40
40
  "babel-jest": "^27.4.6",
41
41
  "babel-loader": "^8.2.3",
42
42
  "commitizen": "^4.2.4",
43
- "cssnano": "^5.0.15",
43
+ "cssnano": "^5.0.16",
44
44
  "dotenv": "^14.2.0",
45
45
  "eslint": "^8.7.0",
46
46
  "eslint-config-prettier": "^8.3.0",
@@ -67,7 +67,7 @@
67
67
  "ts-jest": "^27.1.3",
68
68
  "tsconfig-paths-webpack-plugin": "^3.5.2",
69
69
  "tslib": "^2.3.1",
70
- "typescript": "^4.5.4"
70
+ "typescript": "^4.5.5"
71
71
  },
72
72
  "standard-version": {
73
73
  "skip": {
@@ -143,9 +143,12 @@
143
143
  "./package.json": "./package.json",
144
144
  "./assets/countries": "./assets/countries.js",
145
145
  "./assets/regions": "./assets/regions.js",
146
- "./components/Input/SvelteTelInput.svelte": "./components/Input/SvelteTelInput.svelte",
147
- "./components/Select/CountrySelect.svelte": "./components/Select/CountrySelect.svelte",
148
- "./components/Select/RegionSelect.svelte": "./components/Select/RegionSelect.svelte",
146
+ "./components/Input/TelInput.svelte": "./components/Input/TelInput.svelte",
147
+ "./components/Select/TelCountrySelect/TelCountrySelect.svelte": "./components/Select/TelCountrySelect/TelCountrySelect.svelte",
148
+ "./components/Select/TelRegionSelect/TelRegionSelect.svelte": "./components/Select/TelRegionSelect/TelRegionSelect.svelte",
149
+ "./components/Select/TelRegionSelect/TelRegionSelectOption.svelte": "./components/Select/TelRegionSelect/TelRegionSelectOption.svelte",
150
+ "./components/Select/TelTypeSelect/TelTypeSelect.svelte": "./components/Select/TelTypeSelect/TelTypeSelect.svelte",
151
+ "./components/Select/TelTypeSelect/TelTypeSelectOption.svelte": "./components/Select/TelTypeSelect/TelTypeSelectOption.svelte",
149
152
  ".": "./index.js",
150
153
  "./models/enums/PhoneType.enum": "./models/enums/PhoneType.enum.js",
151
154
  "./models/enums": "./models/enums/index.js",
@@ -155,6 +158,7 @@
155
158
  "./models/types/Select.type": "./models/types/Select.type.js",
156
159
  "./stores": "./stores/index.js",
157
160
  "./utils/directives/clickOutsideAction": "./utils/directives/clickOutsideAction.js",
161
+ "./utils/helpers": "./utils/helpers.js",
158
162
  "./utils/simulator": "./utils/simulator.js",
159
163
  "./utils/typeCheck": "./utils/typeCheck.js"
160
164
  }
package/stores/index.d.ts CHANGED
@@ -1,11 +1,17 @@
1
+ import type { Writable } from 'svelte/store';
2
+ import type { SelectType } from '../models/types/Select.type';
1
3
  export declare const booleanStore: (initial: boolean) => {
2
- isOpen: import("svelte/store").Writable<boolean>;
4
+ isOpen: Writable<boolean>;
3
5
  open: () => void;
4
6
  close: () => void;
5
7
  toggle: () => void;
6
8
  };
7
9
  export declare const statefulSwap: (initialState: boolean | null) => {
8
- transitionState: import("svelte/store").Writable<boolean | null>;
10
+ transitionState: Writable<boolean | null>;
9
11
  transitionTo: (newState: boolean | null) => void;
10
12
  onOutro: () => void;
11
13
  };
14
+ export declare const selectedCountryStore: Writable<string>;
15
+ export declare const selectedRegionStore: Writable<string>;
16
+ export declare const selectedTelTypeStore: Writable<SelectType>;
17
+ export declare const enteredTelInputStore: Writable<string>;
package/stores/index.js CHANGED
@@ -29,3 +29,9 @@ export const statefulSwap = (initialState) => {
29
29
  onOutro
30
30
  };
31
31
  };
32
+ // SELECTS
33
+ export const selectedCountryStore = writable();
34
+ export const selectedRegionStore = writable();
35
+ export const selectedTelTypeStore = writable();
36
+ // INPUT
37
+ export const enteredTelInputStore = writable();
@@ -0,0 +1 @@
1
+ export declare const capitalize: (str: string) => string;
@@ -0,0 +1,3 @@
1
+ export const capitalize = (str) => {
2
+ return (str && str[0].toUpperCase() + str.slice(1).toLowerCase()) || '';
3
+ };
@@ -1,23 +0,0 @@
1
- <script >import { parsePhoneNumberFromString } from 'libphonenumber-js';
2
- let telInputNumber;
3
- // const phoneNumber = parsePhoneNumber(' 8 (800) 555-35-35 ', 'RU');
4
- // if (phoneNumber) {
5
- // phoneNumber.country === 'RU';
6
- // phoneNumber.number === '+78005553535';
7
- // phoneNumber.isValid() === true;
8
- // // Note: `.getType()` requires `/max` metadata: see below for an explanation.
9
- // phoneNumber.getType() === 'TOLL_FREE';
10
- // }
11
- // const parse = parsePhoneNumber(telInputNumber);
12
- const handleInput = (event) => {
13
- let inputVal = event.target.value;
14
- console.log(parsePhoneNumberFromString(inputVal));
15
- };
16
- $: console.log(telInputNumber);
17
- </script>
18
-
19
- <input
20
- class="px-4 py-1 text-gray-900 rounded-full focus:outline-none"
21
- type="tel"
22
- on:input={handleInput}
23
- />
@@ -1,14 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {};
4
- events: {
5
- [evt: string]: CustomEvent<any>;
6
- };
7
- slots: {};
8
- };
9
- export declare type SvelteTelInputProps = typeof __propDef.props;
10
- export declare type SvelteTelInputEvents = typeof __propDef.events;
11
- export declare type SvelteTelInputSlots = typeof __propDef.slots;
12
- export default class SvelteTelInput extends SvelteComponentTyped<SvelteTelInputProps, SvelteTelInputEvents, SvelteTelInputSlots> {
13
- }
14
- export {};
@@ -1,14 +0,0 @@
1
- <script >import rawCountries from '../../assets/countries';
2
- let selectedCountry;
3
- </script>
4
-
5
- <select
6
- name="countrySelect"
7
- class="text-gray-700"
8
- bind:value={selectedCountry}
9
- on:change={() => console.log(selectedCountry)}
10
- >
11
- {#each rawCountries as country}
12
- <option value={country[2]}>{country[0]}</option>
13
- {/each}
14
- </select>
@@ -1,14 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {};
4
- events: {
5
- [evt: string]: CustomEvent<any>;
6
- };
7
- slots: {};
8
- };
9
- export declare type CountrySelectProps = typeof __propDef.props;
10
- export declare type CountrySelectEvents = typeof __propDef.events;
11
- export declare type CountrySelectSlots = typeof __propDef.slots;
12
- export default class CountrySelect extends SvelteComponentTyped<CountrySelectProps, CountrySelectEvents, CountrySelectSlots> {
13
- }
14
- export {};
@@ -1,14 +0,0 @@
1
- <script >import rawRegions from '../../assets/regions';
2
- let selectedRegion;
3
- </script>
4
-
5
- <select
6
- name="countrySelect"
7
- class="text-gray-700"
8
- bind:value={selectedRegion}
9
- on:change={() => console.log(selectedRegion)}
10
- >
11
- {#each rawRegions as region}
12
- <option value={region[2]}>{region[0]}</option>
13
- {/each}
14
- </select>
@@ -1,14 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {};
4
- events: {
5
- [evt: string]: CustomEvent<any>;
6
- };
7
- slots: {};
8
- };
9
- export declare type RegionSelectProps = typeof __propDef.props;
10
- export declare type RegionSelectEvents = typeof __propDef.events;
11
- export declare type RegionSelectSlots = typeof __propDef.slots;
12
- export default class RegionSelect extends SvelteComponentTyped<RegionSelectProps, RegionSelectEvents, RegionSelectSlots> {
13
- }
14
- export {};