@intl-tel-input/svelte 28.1.0 → 29.0.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/package.json +2 -2
- package/src/IntlTelInput.svelte +10 -10
- package/src/IntlTelInput.svelte.d.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intl-tel-input/svelte",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "29.0.1",
|
|
4
4
|
"description": "A Svelte component for intl-tel-input, for entering, formatting, and validating international telephone numbers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"intl-tel-input": "^
|
|
28
|
+
"intl-tel-input": "^29.0.1"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"svelte": "^5.0.0"
|
package/src/IntlTelInput.svelte
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
onChangeCountry,
|
|
22
22
|
onChangeValidity,
|
|
23
23
|
onChangeErrorCode,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
onOpenCountrySelector,
|
|
25
|
+
onCloseCountrySelector,
|
|
26
26
|
onStrictReject,
|
|
27
27
|
...initOptions
|
|
28
28
|
} = $props() as Props;
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
if (!instance?.isActive()) {
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
const country = instance.
|
|
103
|
+
const country = instance.getSelectedCountry()?.iso2 ?? "";
|
|
104
104
|
if (country !== lastEmittedCountry) {
|
|
105
105
|
lastEmittedCountry = country;
|
|
106
106
|
onChangeCountry?.(country);
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
updateValue();
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
-
const
|
|
112
|
-
const
|
|
111
|
+
const handleOpenCountrySelector = (): void => onOpenCountrySelector?.();
|
|
112
|
+
const handleCloseCountrySelector = (): void => onCloseCountrySelector?.();
|
|
113
113
|
const handleStrictReject = (e: Event): void => {
|
|
114
114
|
const { source, rejectedInput, reason } = (e as CustomEvent<StrictRejectDetail>).detail;
|
|
115
115
|
onStrictReject?.(source, rejectedInput, reason);
|
|
@@ -123,11 +123,11 @@
|
|
|
123
123
|
if (disabled) instance.setDisabled(disabled);
|
|
124
124
|
if (readonly) instance.setReadonly(readonly);
|
|
125
125
|
|
|
126
|
-
inputElement.addEventListener("open:
|
|
127
|
-
inputElement.addEventListener("close:
|
|
126
|
+
inputElement.addEventListener("open:countryselector", handleOpenCountrySelector);
|
|
127
|
+
inputElement.addEventListener("close:countryselector", handleCloseCountrySelector);
|
|
128
128
|
inputElement.addEventListener("strict:reject", handleStrictReject);
|
|
129
129
|
|
|
130
|
-
lastEmittedCountry = instance.
|
|
130
|
+
lastEmittedCountry = instance.getSelectedCountry()?.iso2 ?? "";
|
|
131
131
|
hasInitialized = true;
|
|
132
132
|
|
|
133
133
|
// wait for utils to load before calling methods that require it (getNumber, setNumber, isValidNumber, etc.)
|
|
@@ -153,8 +153,8 @@
|
|
|
153
153
|
|
|
154
154
|
onDestroy(() => {
|
|
155
155
|
if (inputElement) {
|
|
156
|
-
inputElement.removeEventListener("open:
|
|
157
|
-
inputElement.removeEventListener("close:
|
|
156
|
+
inputElement.removeEventListener("open:countryselector", handleOpenCountrySelector);
|
|
157
|
+
inputElement.removeEventListener("close:countryselector", handleCloseCountrySelector);
|
|
158
158
|
inputElement.removeEventListener("strict:reject", handleStrictReject);
|
|
159
159
|
}
|
|
160
160
|
instance?.destroy();
|
|
@@ -18,8 +18,8 @@ export type Props = SomeOptions & {
|
|
|
18
18
|
onChangeCountry?: (iso2: string) => void;
|
|
19
19
|
onChangeValidity?: (isValid: boolean) => void;
|
|
20
20
|
onChangeErrorCode?: (errorCode: ValidationError | null) => void;
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
onOpenCountrySelector?: () => void;
|
|
22
|
+
onCloseCountrySelector?: () => void;
|
|
23
23
|
onStrictReject?: (source: StrictRejectSource, rejectedInput: string, reason: StrictRejectReason) => void;
|
|
24
24
|
};
|
|
25
25
|
|