intl-tel-input 27.2.0 → 27.3.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.
@@ -6,6 +6,7 @@
6
6
  <script lang="ts">
7
7
  // Resolves to IntlTelInput.svelte.d.ts (the type declaration file for this component).
8
8
  import type { Props } from "./IntlTelInput.svelte";
9
+ import type { SomeOptions } from "intl-tel-input";
9
10
  import { onMount, onDestroy } from "svelte";
10
11
 
11
12
  // Props
@@ -35,6 +36,8 @@
35
36
  // State
36
37
  let inputElement: HTMLInputElement | undefined = $state();
37
38
  let instance: Iti | undefined = $state();
39
+ // Classes the plugin adds directly to the input (e.g. iti__tel-input)
40
+ let pluginInputClasses = $state("");
38
41
  let lastEmittedNumber: string | undefined = $state();
39
42
  let lastEmittedCountry: string | undefined = $state();
40
43
  let lastEmittedValidity: boolean | undefined = $state();
@@ -116,6 +119,7 @@
116
119
  onMount(() => {
117
120
  if (inputElement) {
118
121
  instance = intlTelInput(inputElement, initOptions as SomeOptions);
122
+ pluginInputClasses = inputElement.className;
119
123
  if (disabled) instance.setDisabled(disabled);
120
124
  if (readonly) instance.setReadonly(readonly);
121
125
 
@@ -170,9 +174,11 @@
170
174
  }
171
175
  });
172
176
 
173
- // Watch value prop changes (only after initialization)
177
+ // Watch value prop changes (only after initialization).
178
+ // If value is undefined, the component is uncontrolled — do not touch the input
179
+ // (otherwise we would clobber any initialValue with an empty string on mount).
174
180
  $effect(() => {
175
- if (!hasInitialized || !instance) {
181
+ if (!hasInitialized || !instance || value === undefined) {
176
182
  return;
177
183
  }
178
184
  const next = value ?? "";
@@ -208,6 +214,8 @@
208
214
  for (const [key, val] of Object.entries(props)) {
209
215
  if (ignoredInputProps.has(key)) {
210
216
  warnInputProp(key);
217
+ } else if (key === "class") {
218
+ rest[key] = `${pluginInputClasses} ${val}`;
211
219
  } else {
212
220
  rest[key] = val;
213
221
  }