intl-tel-input 27.2.1 → 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.
@@ -36,6 +36,8 @@
36
36
  // State
37
37
  let inputElement: HTMLInputElement | undefined = $state();
38
38
  let instance: Iti | undefined = $state();
39
+ // Classes the plugin adds directly to the input (e.g. iti__tel-input)
40
+ let pluginInputClasses = $state("");
39
41
  let lastEmittedNumber: string | undefined = $state();
40
42
  let lastEmittedCountry: string | undefined = $state();
41
43
  let lastEmittedValidity: boolean | undefined = $state();
@@ -117,6 +119,7 @@
117
119
  onMount(() => {
118
120
  if (inputElement) {
119
121
  instance = intlTelInput(inputElement, initOptions as SomeOptions);
122
+ pluginInputClasses = inputElement.className;
120
123
  if (disabled) instance.setDisabled(disabled);
121
124
  if (readonly) instance.setReadonly(readonly);
122
125
 
@@ -171,9 +174,11 @@
171
174
  }
172
175
  });
173
176
 
174
- // 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).
175
180
  $effect(() => {
176
- if (!hasInitialized || !instance) {
181
+ if (!hasInitialized || !instance || value === undefined) {
177
182
  return;
178
183
  }
179
184
  const next = value ?? "";
@@ -209,6 +214,8 @@
209
214
  for (const [key, val] of Object.entries(props)) {
210
215
  if (ignoredInputProps.has(key)) {
211
216
  warnInputProp(key);
217
+ } else if (key === "class") {
218
+ rest[key] = `${pluginInputClasses} ${val}`;
212
219
  } else {
213
220
  rest[key] = val;
214
221
  }