@props([
'title' => 'Bloque',
'name' => 'bloque',
'required' => true,
'accept' => 'image/*',
'currentUrl' => null,
'descripcion' => null,
'imgLabel' => 'Imagen (JPG/PNG/WebP)',
'descLabel' => 'Descripción',
])
@php
$id = preg_replace('/[^a-z0-9_]/i','_', $name);
$req = filter_var($required, FILTER_VALIDATE_BOOLEAN);
@endphp
merge(['class' => 'mt-6 border rounded-lg p-4']) }}
x-data="{
previews: [],
onFileChange(e) {
// Limpia previas URLs
(this.previews||[]).forEach(u => { try{ URL.revokeObjectURL(u); }catch(_){} });
this.previews = [];
const files = Array.from(e.target.files || []);
this.previews = files.map(f => URL.createObjectURL(f));
},
clear() {
const input = $refs.file_{{ $id }};
if (input) { input.value = ''; }
(this.previews||[]).forEach(u => { try{ URL.revokeObjectURL(u); }catch(_){} });
this.previews = [];
}
}">
{{ $title }}