intl-tel-input 25.13.3 → 25.14.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-tel-input",
3
- "version": "25.13.3",
3
+ "version": "25.14.0",
4
4
  "description": "A JavaScript plugin for entering and validating international telephone numbers",
5
5
  "keywords": [
6
6
  "international",
@@ -21,6 +21,7 @@
21
21
  "react",
22
22
  "vue",
23
23
  "angular",
24
+ "svelte",
24
25
  "component",
25
26
  "typescript"
26
27
  ],
@@ -32,6 +33,7 @@
32
33
  "@angular/core": "^19.1.4",
33
34
  "@angular/forms": "^19.1.4",
34
35
  "@angular/platform-browser": "^19.1.4",
36
+ "@sveltejs/vite-plugin-svelte": "^5.0.3",
35
37
  "@babel/plugin-transform-modules-commonjs": "^7.25.7",
36
38
  "@babel/preset-typescript": "^7.27.1",
37
39
  "@playwright/test": "^1.47.2",
@@ -76,6 +78,7 @@
76
78
  "react-dom": "^18.3.1",
77
79
  "sass": "^1.83.1",
78
80
  "sharp": "^0.33.5",
81
+ "svelte": "^5.16.0",
79
82
  "time-grunt": "^2.0.0",
80
83
  "ts-node": "^10.9.2",
81
84
  "typescript": "^5.5.3",
@@ -88,6 +91,7 @@
88
91
  "react/build/*",
89
92
  "vue/build/*",
90
93
  "angular/build/*",
94
+ "svelte/build/*",
91
95
  "CHANGELOG.md",
92
96
  "LICENSE",
93
97
  "package.json",
@@ -117,9 +121,11 @@
117
121
  "build:react": "grunt build:react",
118
122
  "build:vue": "grunt build:vue",
119
123
  "build:angular": "grunt build:angular",
124
+ "build:svelte": "grunt build:svelte",
120
125
  "build:ci": "grunt build:ci",
121
126
  "prepublishOnly": "grunt build",
122
- "vue:demo": "vite --config vue/demo/validation/vite.config.js"
127
+ "vue:demo": "vite --config vue/demo/validation/vite.config.js",
128
+ "svelte:demo": "vite --config svelte/demo/validation/vite.config.mjs"
123
129
  },
124
130
  "style": "build/css/intlTelInput.css",
125
131
  "main": "./build/js/intlTelInput.js",
@@ -165,6 +171,12 @@
165
171
  "import": "./angular/build/IntlTelInputWithUtils.js",
166
172
  "default": "./angular/build/IntlTelInputWithUtils.js"
167
173
  },
174
+ "./svelte": {
175
+ "import": "./svelte/build/IntlTelInput.mjs"
176
+ },
177
+ "./svelteWithUtils": {
178
+ "import": "./svelte/build/IntlTelInputWithUtils.mjs"
179
+ },
168
180
  "./i18n": {
169
181
  "types": "./build/js/intlTelInput.d.ts",
170
182
  "import": "./build/js/i18n/index.js",
package/react/README.md CHANGED
@@ -30,7 +30,7 @@ import "intl-tel-input/styles";
30
30
  See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/react/demo/validation/ValidationApp.tsx) for a more fleshed-out example of how to handle validation.
31
31
 
32
32
  ## Utils Script
33
- A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize), then you can just import IntlTelInput from `"intl-tel-input/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.3/build/js/utils.js"`.
33
+ A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize), then you can just import IntlTelInput from `"intl-tel-input/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.14.0/build/js/utils.js"`.
34
34
 
35
35
  ## Props
36
36
  Here's a list of all of the current props you can pass to the IntlTelInput React component.
@@ -4106,7 +4106,7 @@ var intlTelInput = Object.assign(
4106
4106
  attachUtils,
4107
4107
  startedLoadingUtilsScript: false,
4108
4108
  startedLoadingAutoCountry: false,
4109
- version: "25.13.3"
4109
+ version: "25.14.0"
4110
4110
  }
4111
4111
  );
4112
4112
  var intl_tel_input_default = intlTelInput;
@@ -4070,7 +4070,7 @@ var intlTelInput = Object.assign(
4070
4070
  attachUtils,
4071
4071
  startedLoadingUtilsScript: false,
4072
4072
  startedLoadingAutoCountry: false,
4073
- version: "25.13.3"
4073
+ version: "25.14.0"
4074
4074
  }
4075
4075
  );
4076
4076
  var intl_tel_input_default = intlTelInput;
@@ -4106,7 +4106,7 @@ var intlTelInput = Object.assign(
4106
4106
  attachUtils,
4107
4107
  startedLoadingUtilsScript: false,
4108
4108
  startedLoadingAutoCountry: false,
4109
- version: "25.13.3"
4109
+ version: "25.14.0"
4110
4110
  }
4111
4111
  );
4112
4112
  var intl_tel_input_default = intlTelInput;
@@ -4070,7 +4070,7 @@ var intlTelInput = Object.assign(
4070
4070
  attachUtils,
4071
4071
  startedLoadingUtilsScript: false,
4072
4072
  startedLoadingAutoCountry: false,
4073
- version: "25.13.3"
4073
+ version: "25.14.0"
4074
4074
  }
4075
4075
  );
4076
4076
  var intl_tel_input_default = intlTelInput;
@@ -0,0 +1,79 @@
1
+ # IntlTelInput Svelte Component
2
+ A Svelte 5 component wrapper for the [intl-tel-input](https://github.com/jackocnr/intl-tel-input) JavaScript plugin. View the [source code](https://github.com/jackocnr/intl-tel-input/blob/master/svelte/src/intl-tel-input/IntlTelInput.svelte).
3
+
4
+ ## Table of Contents
5
+ - [Demo](#demo)
6
+ - [Getting Started](#getting-started)
7
+ - [Props](#props)
8
+ - [Events](#events)
9
+ - [Accessing Instance Methods](#accessing-instance-methods)
10
+ - [Accessing Static Methods](#accessing-static-methods)
11
+
12
+ ## Demo
13
+ Try it for yourself by downloading the project and running `npm install` and then `npm run svelte:demo` and then copy the given URL into your browser.
14
+
15
+ ## Getting Started
16
+ ```svelte
17
+ <script>
18
+ import IntlTelInput from "intl-tel-input/svelteWithUtils";
19
+ import "intl-tel-input/styles";
20
+ </script>
21
+
22
+ <IntlTelInput
23
+ options={{ initialCountry: 'us' }}
24
+ />
25
+ ```
26
+
27
+ See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/svelte/demo/validation/App.svelte) for a more fleshed-out example of how to handle validation. Make sure to change the path in the `package.json` script to the correct demo if you're running it locally e.g.:
28
+
29
+ ```
30
+ "svelte:demo": "vite --config svelte/demo/[demo variant]/vite.config.mjs"
31
+ ```
32
+
33
+ A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/svelteWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/svelte"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@25.14.0/build/js/utils.js"`.
34
+
35
+ ## Props
36
+ Here's a list of all of the current props you can pass to the IntlTelInput Svelte component.
37
+
38
+ **disabled**
39
+ Type: `Boolean`, Default: `false`
40
+ Sets the disabled attribute of both the telephone input and selected country button. *Note: we recommend using this instead of `inputProps.disabled`.*
41
+
42
+ **inputProps**
43
+ Type: `Object`
44
+ The props to pass to the input element e.g. `id`, `class`, `placeholder`, `required` etc. *Note: we recommend using the separate `disabled` prop instead of `inputProps.disabled`.*
45
+
46
+ **options**
47
+ Type: `Object`
48
+ An object containing the [initialisation options](https://github.com/jackocnr/intl-tel-input?tab=readme-ov-file#initialisation-options) to pass to the plugin. You can use these exactly the same way as with the main JavaScript plugin.
49
+
50
+ **value**
51
+ Type: `String`
52
+ The initial value to put in the input. This will get auto-formatted on init (according to `formatOnDisplay` initialisation option). IntlTelInput is an uncontrolled input, and so will ignore any changes to this value.
53
+
54
+ ## Events
55
+ Here's a list of all of the current event handlers you can pass to the IntlTelInput Svelte component.
56
+
57
+ **onChangeCountry**
58
+ Type: `Function`
59
+ A handler to be called when the selected country changes. It will be passed the new country iso2 code e.g. "gb" for UK.
60
+
61
+ **onChangeErrorCode**
62
+ Type: `Function`
63
+ A handler to be called when the number validation error changes. It will be passed the new error code (or `null`).
64
+
65
+ **onChangeNumber**
66
+ Type: `Function`
67
+ A handler to be called when the number changes. It will be passed the new number.
68
+
69
+ **onChangeValidity**
70
+ Type: `Function`
71
+ A handler to be called when the number validity changes e.g. to true/false. It will be passed the new isValid boolean.
72
+
73
+ ## Accessing Instance Methods
74
+
75
+ You can access all of the plugin's [instance methods](https://github.com/jackocnr/intl-tel-input/blob/master/README.md#instance-methods) (`setNumber`, `setCountry`, `setPlaceholderNumberType` etc) by passing a ref into the IntlTelInput component (using `bind:this`), and then calling the `getInstance()` method e.g. `ref.getInstance().setNumber(...);`. See the [Set Number demo](https://github.com/jackocnr/intl-tel-input/blob/master/svelte/demo/set-number/App.svelte) for a full example. You can also access the input DOM element via: `ref.getInput()`.
76
+
77
+ ## Accessing Static Methods
78
+
79
+ You can access all of the plugin's [static methods](https://github.com/jackocnr/intl-tel-input/blob/master/README.md#static-methods) by importing `intlTelInput` from the core package e.g. `import intlTelInput from "intl-tel-input"` (note the lower case "i" in "intlTelInput"). You can then use this as you would with the main plugin e.g. `intlTelInput.getCountryData()` or `intlTelInput.utils.numberType` etc.