intl-tel-input 26.9.2 → 27.0.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/angular/README.md +1 -1
- package/angular/dist/IntlTelInput.d.ts +97 -0
- package/angular/dist/IntlTelInput.js +4812 -0
- package/angular/dist/IntlTelInputWithUtils.d.ts +3 -0
- package/angular/{build → dist}/IntlTelInputWithUtils.js +2342 -2096
- package/{build → dist}/css/demo.css +1 -1
- package/dist/css/intlTelInput-no-assets.css +1 -0
- package/dist/css/intlTelInput-no-assets.min.css +1 -0
- package/dist/css/intlTelInput.css +1 -0
- package/dist/css/intlTelInput.min.css +1 -0
- package/dist/img/flags.png +0 -0
- package/dist/img/flags.webp +0 -0
- package/dist/img/flags@2x.png +0 -0
- package/dist/img/flags@2x.webp +0 -0
- package/dist/js/data.d.ts +1616 -0
- package/{build → dist}/js/data.js +5 -17
- package/dist/js/data.min.js +7 -0
- package/dist/js/data.mjs +1708 -0
- package/{build/js/i18n/ar/index.js → dist/js/i18n/ar.js} +1 -0
- package/{build/js/i18n/bg/index.js → dist/js/i18n/bg.js} +1 -0
- package/{build/js/i18n/bn/index.js → dist/js/i18n/bn.js} +1 -0
- package/{build/js/i18n/bs/index.js → dist/js/i18n/bs.js} +1 -0
- package/{build/js/i18n/ca/index.js → dist/js/i18n/ca.js} +1 -0
- package/{build/js/i18n/cs/index.js → dist/js/i18n/cs.js} +1 -0
- package/{build/js/i18n/da/index.js → dist/js/i18n/da.js} +1 -0
- package/{build/js/i18n/de/index.js → dist/js/i18n/de.js} +1 -0
- package/{build/js/i18n/el/index.js → dist/js/i18n/el.js} +1 -0
- package/{build/js/i18n/en/index.js → dist/js/i18n/en.js} +3 -2
- package/{build/js/i18n/es/index.js → dist/js/i18n/es.js} +1 -0
- package/{build/js/i18n/et/index.js → dist/js/i18n/et.js} +1 -0
- package/{build/js/i18n/fa/index.js → dist/js/i18n/fa.js} +1 -0
- package/{build/js/i18n/fi/index.js → dist/js/i18n/fi.js} +1 -0
- package/{build/js/i18n/fr/index.js → dist/js/i18n/fr.js} +1 -0
- package/{build/js/i18n/hi/index.js → dist/js/i18n/hi.js} +1 -0
- package/{build/js/i18n/hr/index.js → dist/js/i18n/hr.js} +1 -0
- package/{build/js/i18n/hu/index.js → dist/js/i18n/hu.js} +1 -0
- package/{build/js/i18n/id/index.js → dist/js/i18n/id.js} +1 -0
- package/{build → dist}/js/i18n/index.js +1 -0
- package/{build/js/i18n/it/index.js → dist/js/i18n/it.js} +1 -0
- package/{build/js/i18n/ja/index.js → dist/js/i18n/ja.js} +1 -0
- package/{build/js/i18n/kn/index.js → dist/js/i18n/kn.js} +1 -0
- package/{build/js/i18n/ko/index.js → dist/js/i18n/ko.js} +1 -0
- package/{build/js/i18n/lt/index.js → dist/js/i18n/lt.js} +1 -0
- package/{build/js/i18n/mr/index.js → dist/js/i18n/mr.js} +1 -0
- package/{build/js/i18n/nl/index.js → dist/js/i18n/nl.js} +1 -0
- package/{build/js/i18n/no/index.js → dist/js/i18n/no.js} +1 -0
- package/{build/js/i18n/pl/index.js → dist/js/i18n/pl.js} +1 -0
- package/{build/js/i18n/pt/index.js → dist/js/i18n/pt.js} +1 -0
- package/{build/js/i18n/ro/index.js → dist/js/i18n/ro.js} +1 -0
- package/{build/js/i18n/ru/index.js → dist/js/i18n/ru.js} +1 -0
- package/{build/js/i18n/sk/index.js → dist/js/i18n/sk.js} +1 -0
- package/{build/js/i18n/sl/index.js → dist/js/i18n/sl.js} +1 -0
- package/{build/js/i18n/sq/index.js → dist/js/i18n/sq.js} +1 -0
- package/{build/js/i18n/sr/index.js → dist/js/i18n/sr.js} +1 -0
- package/{build/js/i18n/sv/index.js → dist/js/i18n/sv.js} +1 -0
- package/{build/js/i18n/te/index.js → dist/js/i18n/te.js} +1 -0
- package/{build/js/i18n/th/index.js → dist/js/i18n/th.js} +1 -0
- package/{build/js/i18n/tr/index.js → dist/js/i18n/tr.js} +1 -0
- package/dist/js/i18n/types.js +1 -0
- package/{build/js/i18n/uk/index.js → dist/js/i18n/uk.js} +1 -0
- package/{build/js/i18n/ur/index.js → dist/js/i18n/ur.js} +1 -0
- package/{build/js/i18n/uz/index.js → dist/js/i18n/uz.js} +1 -0
- package/{build/js/i18n/vi/index.js → dist/js/i18n/vi.js} +1 -0
- package/{build/js/i18n/zh-hk/index.js → dist/js/i18n/zh-hk.js} +1 -0
- package/{build/js/i18n/zh/index.js → dist/js/i18n/zh.js} +1 -0
- package/dist/js/i18n.d.ts +1697 -0
- package/dist/js/intlTelInput.d.ts +1773 -0
- package/{build → dist}/js/intlTelInput.js +228 -215
- package/dist/js/intlTelInput.min.js +25 -0
- package/{react/build/IntlTelInput.cjs → dist/js/intlTelInput.mjs} +230 -340
- package/{build → dist}/js/intlTelInputWithUtils.js +531 -498
- package/dist/js/intlTelInputWithUtils.min.js +25 -0
- package/{react/build/IntlTelInputWithUtils.cjs → dist/js/intlTelInputWithUtils.mjs} +530 -621
- package/{build → dist}/js/utils.js +46 -47
- package/package.json +122 -122
- package/react/README.md +1 -1
- package/react/dist/IntlTelInput.d.ts +20 -0
- package/react/{build → dist}/IntlTelInput.js +274 -255
- package/react/dist/IntlTelInputWithUtils.d.ts +4 -0
- package/react/{build → dist}/IntlTelInputWithUtils.js +580 -542
- package/svelte/README.md +1 -1
- package/svelte/src/IntlTelInput.svelte +199 -0
- package/svelte/src/IntlTelInputWithUtils.svelte +15 -0
- package/svelte/src/shims.d.ts +4 -0
- package/vue/README.md +1 -1
- package/vue/dist/IntlTelInput-D7r449B2.js +2577 -0
- package/vue/dist/IntlTelInput.js +5 -0
- package/vue/dist/IntlTelInputWithUtils.js +49385 -0
- package/vue/dist/src/IntlTelInput.vue.d.ts +35 -0
- package/vue/dist/src/index.d.ts +4 -0
- package/vue/dist/src/indexWithUtils.d.ts +3 -0
- package/angular/build/IntlTelInput.js +0 -4501
- package/angular/build/types/intl-tel-input/angular.d.ts +0 -65
- package/angular/build/types/intl-tel-input/angularWithUtils.d.ts +0 -65
- package/angular/build/types/intl-tel-input/data.d.ts +0 -20
- package/angular/build/types/intl-tel-input/i18n/ar/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/bg/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/bn/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/bs/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ca/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/cs/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/da/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/de/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/el/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/en/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/es/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/et/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/fa/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/fi/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/fr/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/hi/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/hr/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/hu/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/id/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/index.d.ts +0 -45
- package/angular/build/types/intl-tel-input/i18n/it/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ja/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/kn/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ko/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/lt/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/mr/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/nl/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/no/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/pl/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/pt/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ro/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ru/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/sk/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/sl/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/sq/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/sr/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/sv/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/te/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/th/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/tr/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/types.d.ts +0 -10
- package/angular/build/types/intl-tel-input/i18n/uk/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/ur/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/uz/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/vi/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/zh/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/i18n/zh-hk/index.d.ts +0 -3
- package/angular/build/types/intl-tel-input/intlTelInputWithUtils.d.ts +0 -2
- package/angular/build/types/intl-tel-input/utils.d.ts +0 -2
- package/angular/build/types/intl-tel-input.d.ts +0 -46
- package/angular/build/types/modules/constants.d.ts +0 -94
- package/angular/build/types/modules/core/countrySearch.d.ts +0 -17
- package/angular/build/types/modules/core/icons.d.ts +0 -11
- package/angular/build/types/modules/core/numerals.d.ts +0 -7
- package/angular/build/types/modules/core/options.d.ts +0 -8
- package/angular/build/types/modules/core/ui.d.ts +0 -30
- package/angular/build/types/modules/data/country-data.d.ts +0 -12
- package/angular/build/types/modules/data/intl-regionless.d.ts +0 -2
- package/angular/build/types/modules/data/nanp-regionless.d.ts +0 -2
- package/angular/build/types/modules/format/caret.d.ts +0 -1
- package/angular/build/types/modules/format/formatting.d.ts +0 -3
- package/angular/build/types/modules/types/events.d.ts +0 -10
- package/angular/build/types/modules/types/forEachInstanceArgsMap.d.ts +0 -6
- package/angular/build/types/modules/types/public-api.d.ts +0 -65
- package/angular/build/types/modules/utils/dom.d.ts +0 -6
- package/angular/build/types/modules/utils/isAndroid.d.ts +0 -1
- package/angular/build/types/modules/utils/string.d.ts +0 -2
- package/build/css/intlTelInput-no-assets.css +0 -1323
- package/build/css/intlTelInput-no-assets.min.css +0 -1
- package/build/css/intlTelInput.css +0 -1327
- package/build/css/intlTelInput.min.css +0 -1
- package/build/img/flags.png +0 -0
- package/build/img/flags.webp +0 -0
- package/build/img/flags@2x.png +0 -0
- package/build/img/flags@2x.webp +0 -0
- package/build/js/data.min.js +0 -20
- package/build/js/i18n/types.js +0 -0
- package/build/js/intlTelInput.d.ts +0 -671
- package/build/js/intlTelInput.min.js +0 -38
- package/build/js/intlTelInputWithUtils.min.js +0 -38
- package/index.js +0 -1
- package/react/build/IntlTelInput.d.ts +0 -721
- package/svelte/build/IntlTelInput.mjs +0 -5294
- package/svelte/build/IntlTelInputWithUtils.mjs +0 -11381
- package/vue/build/IntlTelInput.vue.d.ts +0 -34
- package/vue/build/IntlTelInputWithUtils.vue.d.ts +0 -34
- package/vue/build/exports/IntlTelInput.d.ts +0 -3
- package/vue/build/exports/IntlTelInput.mjs +0 -86
- package/vue/build/exports/IntlTelInputWithUtils.d.ts +0 -3
- package/vue/build/exports/IntlTelInputWithUtils.mjs +0 -6173
- package/vue/build/intl-tel-input/data.d.ts +0 -20
- package/vue/build/intl-tel-input/i18n/ar/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/bg/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/bn/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/bs/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ca/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/cs/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/da/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/de/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/el/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/en/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/es/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/et/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/fa/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/fi/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/fr/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/hi/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/hr/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/hu/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/id/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/index.d.ts +0 -45
- package/vue/build/intl-tel-input/i18n/it/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ja/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/kn/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ko/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/lt/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/mr/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/nl/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/no/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/pl/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/pt/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ro/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ru/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/sk/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/sl/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/sq/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/sr/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/sv/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/te/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/th/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/tr/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/types.d.ts +0 -10
- package/vue/build/intl-tel-input/i18n/uk/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/ur/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/uz/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/vi/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/zh/index.d.ts +0 -3
- package/vue/build/intl-tel-input/i18n/zh-hk/index.d.ts +0 -3
- package/vue/build/intl-tel-input/intlTelInputWithUtils.d.ts +0 -2
- package/vue/build/intl-tel-input-MeSkUgHd.mjs +0 -3438
- package/vue/build/intl-tel-input.d.ts +0 -46
- package/vue/build/modules/constants.d.ts +0 -94
- package/vue/build/modules/core/countrySearch.d.ts +0 -17
- package/vue/build/modules/core/icons.d.ts +0 -11
- package/vue/build/modules/core/numerals.d.ts +0 -7
- package/vue/build/modules/core/options.d.ts +0 -8
- package/vue/build/modules/core/ui.d.ts +0 -30
- package/vue/build/modules/data/country-data.d.ts +0 -12
- package/vue/build/modules/data/intl-regionless.d.ts +0 -2
- package/vue/build/modules/data/nanp-regionless.d.ts +0 -2
- package/vue/build/modules/format/caret.d.ts +0 -1
- package/vue/build/modules/format/formatting.d.ts +0 -3
- package/vue/build/modules/types/events.d.ts +0 -10
- package/vue/build/modules/types/forEachInstanceArgsMap.d.ts +0 -6
- package/vue/build/modules/types/public-api.d.ts +0 -65
- package/vue/build/modules/utils/dom.d.ts +0 -6
- package/vue/build/modules/utils/isAndroid.d.ts +0 -1
- package/vue/build/modules/utils/string.d.ts +0 -2
package/svelte/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# IntlTelInput Svelte Component
|
|
2
2
|
|
|
3
|
-
A Svelte 5 component 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/
|
|
3
|
+
A Svelte 5 component 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/IntlTelInput.svelte).
|
|
4
4
|
|
|
5
5
|
[Explore docs »](https://intl-tel-input.com/docs/svelte-component)
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import intlTelInput, { type Iti } from "intl-tel-input";
|
|
3
|
+
export { intlTelInput };
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import type { SomeOptions } from "intl-tel-input";
|
|
8
|
+
import { onMount, onDestroy } from "svelte";
|
|
9
|
+
|
|
10
|
+
type Props = SomeOptions & {
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
readonly?: boolean;
|
|
13
|
+
inputProps?: Record<string, unknown>;
|
|
14
|
+
initialValue?: string;
|
|
15
|
+
value?: string | null;
|
|
16
|
+
usePreciseValidation?: boolean;
|
|
17
|
+
onChangeNumber?: (number: string) => void;
|
|
18
|
+
onChangeCountry?: (country: string) => void;
|
|
19
|
+
onChangeValidity?: (valid: boolean) => void;
|
|
20
|
+
onChangeErrorCode?: (errorCode: number | null) => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Props
|
|
24
|
+
let {
|
|
25
|
+
disabled = false,
|
|
26
|
+
readonly = false,
|
|
27
|
+
inputProps = {},
|
|
28
|
+
usePreciseValidation = false,
|
|
29
|
+
initialValue = "",
|
|
30
|
+
value = undefined,
|
|
31
|
+
onChangeNumber,
|
|
32
|
+
onChangeCountry,
|
|
33
|
+
onChangeValidity,
|
|
34
|
+
onChangeErrorCode,
|
|
35
|
+
...initOptions
|
|
36
|
+
} = $props() as Props;
|
|
37
|
+
|
|
38
|
+
// State
|
|
39
|
+
let inputElement: HTMLInputElement | undefined = $state();
|
|
40
|
+
let instance: Iti | undefined = $state();
|
|
41
|
+
let lastEmittedNumber: string | undefined = $state();
|
|
42
|
+
let lastEmittedCountry: string | undefined = $state();
|
|
43
|
+
let lastEmittedValidity: boolean | undefined = $state();
|
|
44
|
+
let lastEmittedErrorCode: number | null | undefined = $state();
|
|
45
|
+
let hasInitialized = $state(false);
|
|
46
|
+
|
|
47
|
+
// Validation helper
|
|
48
|
+
const isValid = (): boolean | null => {
|
|
49
|
+
if (!instance) return null;
|
|
50
|
+
return usePreciseValidation
|
|
51
|
+
? instance.isValidNumberPrecise()
|
|
52
|
+
: instance.isValidNumber();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Update handlers
|
|
56
|
+
const updateValidity = () => {
|
|
57
|
+
if (!instance) return;
|
|
58
|
+
const isCurrentlyValid = isValid();
|
|
59
|
+
if (isCurrentlyValid === null) return;
|
|
60
|
+
|
|
61
|
+
const valid = !!isCurrentlyValid;
|
|
62
|
+
const errorCode = valid ? null : instance.getValidationError();
|
|
63
|
+
|
|
64
|
+
if (valid !== lastEmittedValidity) {
|
|
65
|
+
lastEmittedValidity = valid;
|
|
66
|
+
onChangeValidity?.(valid);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (errorCode !== lastEmittedErrorCode) {
|
|
70
|
+
lastEmittedErrorCode = errorCode;
|
|
71
|
+
onChangeErrorCode?.(errorCode);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const updateValue = () => {
|
|
76
|
+
if (!instance?.isActive()) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const number = instance.getNumber() ?? "";
|
|
80
|
+
if (number !== lastEmittedNumber) {
|
|
81
|
+
lastEmittedNumber = number;
|
|
82
|
+
onChangeNumber?.(number);
|
|
83
|
+
}
|
|
84
|
+
updateValidity();
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const updateCountry = () => {
|
|
88
|
+
if (!instance?.isActive()) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const country = instance.getSelectedCountryData()?.iso2 ?? "";
|
|
92
|
+
if (country !== lastEmittedCountry) {
|
|
93
|
+
lastEmittedCountry = country;
|
|
94
|
+
onChangeCountry?.(country);
|
|
95
|
+
}
|
|
96
|
+
updateValue();
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Lifecycle
|
|
100
|
+
onMount(() => {
|
|
101
|
+
if (inputElement) {
|
|
102
|
+
instance = intlTelInput(inputElement, initOptions as SomeOptions);
|
|
103
|
+
inputElement.addEventListener("countrychange", updateCountry);
|
|
104
|
+
if (disabled) instance.setDisabled(disabled);
|
|
105
|
+
if (readonly) instance.setReadonly(readonly);
|
|
106
|
+
|
|
107
|
+
lastEmittedCountry = instance.getSelectedCountryData()?.iso2 ?? "";
|
|
108
|
+
hasInitialized = true;
|
|
109
|
+
|
|
110
|
+
// wait for utils to load before calling methods that require it (getNumber, setNumber, isValidNumber, etc.)
|
|
111
|
+
instance.promise.then(() => {
|
|
112
|
+
if (!instance?.isActive()) return;
|
|
113
|
+
if (initialValue) instance.setNumber(initialValue);
|
|
114
|
+
lastEmittedNumber = instance.getNumber() ?? "";
|
|
115
|
+
const initialValid = isValid();
|
|
116
|
+
if (initialValid !== null) {
|
|
117
|
+
lastEmittedValidity = !!initialValid;
|
|
118
|
+
lastEmittedErrorCode = initialValid ? null : instance.getValidationError();
|
|
119
|
+
}
|
|
120
|
+
// update all state values now that initialisation has finished (updateCountry calls updateValue which calls updateValidity)
|
|
121
|
+
updateCountry();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
onDestroy(() => {
|
|
127
|
+
if (inputElement) {
|
|
128
|
+
inputElement.removeEventListener("countrychange", updateCountry);
|
|
129
|
+
}
|
|
130
|
+
instance?.destroy();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Watch disabled prop changes (only after initialization)
|
|
134
|
+
$effect(() => {
|
|
135
|
+
if (hasInitialized && instance) {
|
|
136
|
+
instance.setDisabled(disabled);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Watch readonly prop changes (only after initialization)
|
|
141
|
+
$effect(() => {
|
|
142
|
+
if (hasInitialized && instance) {
|
|
143
|
+
instance.setReadonly(readonly);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Watch value prop changes (only after initialization)
|
|
148
|
+
$effect(() => {
|
|
149
|
+
if (!hasInitialized || !instance) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const next = value ?? "";
|
|
153
|
+
// wait for utils to load before calling methods that require it
|
|
154
|
+
instance.promise.then(() => {
|
|
155
|
+
if (!instance?.isActive()) return;
|
|
156
|
+
const currentCanonical = instance.getNumber() ?? "";
|
|
157
|
+
const isFocused = document.activeElement === inputElement;
|
|
158
|
+
if (isFocused || currentCanonical === next) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
instance.setNumber(next);
|
|
162
|
+
updateValidity();
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Expose instance and input for parent access
|
|
167
|
+
export function getInstance(): Iti | undefined {
|
|
168
|
+
return instance;
|
|
169
|
+
}
|
|
170
|
+
export function getInput(): HTMLInputElement | undefined {
|
|
171
|
+
return inputElement;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const warnInputProp = (prop: string): void => {
|
|
175
|
+
console.warn(`intl-tel-input: ignoring inputProps.${prop} - see docs for more info.`);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const ignoredInputProps = new Set(["type", "value", "disabled", "readonly", "oninput"]);
|
|
179
|
+
|
|
180
|
+
const sanitizeInputProps = (props: Record<string, unknown>) => {
|
|
181
|
+
const rest: Record<string, unknown> = {};
|
|
182
|
+
for (const [key, val] of Object.entries(props)) {
|
|
183
|
+
if (ignoredInputProps.has(key)) {
|
|
184
|
+
warnInputProp(key);
|
|
185
|
+
} else {
|
|
186
|
+
rest[key] = val;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return rest;
|
|
190
|
+
};
|
|
191
|
+
</script>
|
|
192
|
+
|
|
193
|
+
<!-- inputProps must come first, so cannot override the other required props -->
|
|
194
|
+
<input
|
|
195
|
+
{...sanitizeInputProps(inputProps)}
|
|
196
|
+
bind:this={inputElement}
|
|
197
|
+
type="tel"
|
|
198
|
+
oninput={updateValue}
|
|
199
|
+
/>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import intlTelInput from "intl-tel-input";
|
|
3
|
+
import utils from "intl-tel-input/utils";
|
|
4
|
+
intlTelInput.utils = utils as typeof intlTelInput.utils;
|
|
5
|
+
export { intlTelInput };
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import IntlTelInput from "./IntlTelInput.svelte";
|
|
10
|
+
import type { ComponentProps } from "svelte";
|
|
11
|
+
|
|
12
|
+
let { ...props }: ComponentProps<IntlTelInput> = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<IntlTelInput {...props} />
|
package/vue/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# IntlTelInput Vue Component
|
|
2
2
|
|
|
3
|
-
A Vue component 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/vue/src/
|
|
3
|
+
A Vue component 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/vue/src/IntlTelInput.vue).
|
|
4
4
|
|
|
5
5
|
[Explore docs »](https://intl-tel-input.com/docs/vue-component)
|