@intl-tel-input/svelte 29.1.3 → 29.2.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 +12 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intl-tel-input/svelte",
|
|
3
|
-
"version": "29.1
|
|
3
|
+
"version": "29.2.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": "^29.1
|
|
28
|
+
"intl-tel-input": "^29.2.1"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"svelte": "^5.0.0"
|
package/src/IntlTelInput.svelte
CHANGED
|
@@ -118,8 +118,16 @@
|
|
|
118
118
|
// Lifecycle
|
|
119
119
|
onMount(() => {
|
|
120
120
|
if (inputElement) {
|
|
121
|
+
//* Record only the classes the library itself adds during init (iti__tel-input, plus any
|
|
122
|
+
//* classNames.input), by diffing the class list across the call. Capturing the whole className
|
|
123
|
+
//* would also scoop up any inputProps.class already rendered, which would then be re-applied on
|
|
124
|
+
//* every subsequent render - so a changed inputProps.class would leave the old value behind,
|
|
125
|
+
//* and an unchanged one would be duplicated.
|
|
126
|
+
const classesBeforeInit = new Set(inputElement.classList);
|
|
121
127
|
instance = intlTelInput(inputElement, initOptions as SomeOptions);
|
|
122
|
-
libraryInputClasses = inputElement.
|
|
128
|
+
libraryInputClasses = Array.from(inputElement.classList)
|
|
129
|
+
.filter((className) => !classesBeforeInit.has(className))
|
|
130
|
+
.join(" ");
|
|
123
131
|
if (disabled) instance.setDisabled(disabled);
|
|
124
132
|
if (readonly) instance.setReadonly(readonly);
|
|
125
133
|
|
|
@@ -215,7 +223,9 @@
|
|
|
215
223
|
if (ignoredInputProps.has(key)) {
|
|
216
224
|
warnInputProp(key);
|
|
217
225
|
} else if (key === "class") {
|
|
218
|
-
|
|
226
|
+
// Re-apply the library's own classes alongside the consumer's, as Svelte owns the attribute
|
|
227
|
+
// (filter out empties so we never emit a stray "undefined" class or leading whitespace)
|
|
228
|
+
rest[key] = [libraryInputClasses, val].filter(Boolean).join(" ");
|
|
219
229
|
} else {
|
|
220
230
|
rest[key] = val;
|
|
221
231
|
}
|