grav-svelte 0.1.249 → 0.1.250

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.
@@ -58,6 +58,24 @@
58
58
  { value: "+32", label: "🇧🇪 +32" },
59
59
  ];
60
60
 
61
+ // Hidratar el estado interno desde un valor entrante (edición / prellenado).
62
+ // DEBE correr antes del bloque reactivo de abajo: de lo contrario ese bloque
63
+ // sobrescribiría valueVar con el dial code por defecto al montar.
64
+ const valorInicial =
65
+ valueVar || (phoneNumber ? (dialCode || defaultDialCode) + phoneNumber : "");
66
+ if (valorInicial) {
67
+ const dialCodes = [...new Set(countries.map((c) => c.value))].sort(
68
+ (a, b) => b.length - a.length
69
+ );
70
+ const codigo = dialCodes.find((c) => valorInicial.startsWith(c));
71
+ if (codigo) {
72
+ selectedDialCode = codigo;
73
+ internalPhoneNumber = valorInicial.slice(codigo.length).replace(/\D/g, "");
74
+ } else {
75
+ internalPhoneNumber = valorInicial.replace(/\D/g, "");
76
+ }
77
+ }
78
+
61
79
  // Update all exported values reactively
62
80
  $: {
63
81
  const cleanNumber = internalPhoneNumber.replace(/\D/g, "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grav-svelte",
3
- "version": "0.1.249",
3
+ "version": "0.1.250",
4
4
  "description": "A collection of Svelte components",
5
5
  "license": "MIT",
6
6
  "scripts": {