{{-- Props: - rows: array — values del eje vertical (ej. zonas) - cols: array — values del eje horizontal (ej. sub-productos) - grid: array> — counts grid[$row][$col] = $count - title: ?string — título del card - icon: string — icono del título - row-label: string — label para columna izquierda ej. "Zona ↓ / Sub →" - row-prefix: string — prefijo decorativo (ej. "📍 ") - col-strip-prefix: ?string — prefijo a quitar de los col labels (ej. "shops_") - filter-route: ?string — route name para hacer celdas clickeables - row-param: string — query param para el filtro de row (ej. "zone") - col-param: string — query param para el filtro de col (ej. "sub_product") - hint: ?string — texto helper sobre interactividad - empty-text: string — texto cuando rows/cols están vacíos Pattern: command.blade.php líneas 259-309 (escala 0 / 1-7 / 8-14 / 15+ con opacidad dinámica) --}} @props([ 'rows' => [], 'cols' => [], 'grid' => [], 'title' => 'Heatmap', 'icon' => 'bi-grid-3x3-gap-fill', 'rowLabel' => '↓ / →', 'rowPrefix' => '📍 ', 'colStripPrefix' => null, 'filterRoute' => null, 'rowParam' => 'row', 'colParam' => 'col', 'hint' => 'Click en cualquier celda para filtrar', 'emptyText' => 'Sin datos para visualizar', ]) @if(empty($rows) || empty($cols)) {{-- silent skip si no hay datos suficientes --}} @else
@if($title)

{{ $title }}

@if($hint)
{{ $hint }}
@endif
@endif
@foreach($cols as $c) @php $label = $c; if ($colStripPrefix && str_starts_with($label, $colStripPrefix)) { $label = substr($label, strlen($colStripPrefix)); } $label = ucwords(str_replace(['_', '-'], ' ', $label)); @endphp @endforeach @foreach($rows as $r) @foreach($cols as $c) @php $count = $grid[$r][$c] ?? 0; if ($count === 0) { $bg = '#f9fafb'; $opacity = 1; $textColor = 'text-gray-400'; } else { $intensity = $count >= 15 ? 'success' : ($count >= 8 ? 'warning' : 'info'); $bg = "var(--bs-{$intensity})"; $opacity = min(1, 0.2 + ($count / 30)); $textColor = $count >= 8 ? 'text-white' : 'text-dark'; } $cellUrl = ($count > 0 && $filterRoute) ? route($filterRoute, [$rowParam => $r, $colParam => $c]) : null; @endphp @endforeach @endforeach
{{ $rowLabel }}{{ $label }}
{{ $rowPrefix }}{{ ucwords(str_replace(['_', '-'], ' ', $r)) }} @if($count > 0 && $cellUrl) {{ $count }} @elseif($count > 0) {{ $count }} @else @endif
@endif