@innertia-solutions/innertia-nuxt 0.1.79 → 0.1.80

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.
@@ -65,6 +65,9 @@ const initHsSelect = async () => {
65
65
  return
66
66
  }
67
67
  if (HSSelect.getInstance?.(el)) return
68
+ // HSSelect toma el valor inicial de el.value: si las <option> llegaron después
69
+ // del binding :value, el nativo puede haber quedado en ''. Se re-aplica.
70
+ el.value = props.modelValue === null || props.modelValue === undefined ? '' : String(props.modelValue)
68
71
  try {
69
72
  new HSSelect(el)
70
73
  } catch (e) {
@@ -99,6 +102,28 @@ watch(
99
102
  },
100
103
  )
101
104
 
105
+ /**
106
+ * Si el valor llega o cambia desde afuera después del mount (ej. formulario de
107
+ * edición que hidrata con datos async), HSSelect conserva el valor con que se
108
+ * inicializó y el toggle sigue mostrando la opción vacía. Se lo empuja con setValue.
109
+ * Cuando el cambio viene del propio usuario, el valor ya coincide y no hace nada.
110
+ */
111
+ watch(
112
+ () => props.modelValue,
113
+ async (val) => {
114
+ await nextTick()
115
+ const el = selectRef.value
116
+ const inst = el && (window as any).HSSelect?.getInstance?.(el)
117
+ const next = val === null || val === undefined ? '' : String(val)
118
+ if (!inst || String(inst.value ?? '') === next) return
119
+ try {
120
+ inst.setValue(next)
121
+ } catch (e) {
122
+ console.warn('[FormsSelect] HSSelect setValue falló:', e)
123
+ }
124
+ },
125
+ )
126
+
102
127
  const handleChange = (e: Event) => {
103
128
  const val = (e.target as HTMLSelectElement).value
104
129
  emit('update:modelValue', val || null)
@@ -131,7 +156,10 @@ const handleChange = (e: Event) => {
131
156
  </button>
132
157
  </div>
133
158
 
134
- <!-- Select (HSSelect) -->
159
+ <!-- Select (HSSelect). OJO: el <select> nativo NO puede llevar la clase
160
+ "hs-select": HSSelect.destroy() borra el primer ".hs-select" del
161
+ contenedor, que sería el nativo en vez del wrapper (se perdía el select
162
+ al re-inicializar por cambio de options). -->
135
163
  <ClientOnly v-else>
136
164
  <template #fallback>
137
165
  <div class="innertia-field bg-surface animate-pulse" />
@@ -140,7 +168,7 @@ const handleChange = (e: Event) => {
140
168
  <div :class="['relative', error ? 'select-error' : '']">
141
169
  <select
142
170
  ref="selectRef"
143
- class="hs-select w-full"
171
+ class="innertia-select-native w-full"
144
172
  :value="modelValue ?? ''"
145
173
  :disabled="disabled"
146
174
  :data-hs-select="hsConfig"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innertia-solutions/innertia-nuxt",
3
- "version": "0.1.79",
3
+ "version": "0.1.80",
4
4
  "description": "Innertia Solutions — Nuxt layer unificada: core, auth, multitenancy, theme y app contexts",
5
5
  "keywords": [
6
6
  "nuxt",