@use('App\Support\CharityPresenter') @use('App\Models\ColumnTooltip') @props([ 'charity', 'columns', 'borderStartKey', 'borderEndKey', 'pinLeftKey' => null, 'pinRightKeys' => [], 'barMaxima' => [], 'values' => [], 'openRows' => [], 'detailEnabled' => true, ]) @php // Columns are data, not code: each one carries a renderer (how it is drawn) // and, for everything but the name cell, an expression that Services\ // HomepageColumns has already compiled into the query. `$values` holds // those computed results for this row, keyed by column key — a new column // is a row in column_tooltips and needs no change here. $words = preg_split('/\s+/', $charity->name ?? ''); $initials = implode('', array_map( fn($w) => mb_strtoupper(mb_substr($w, 0, 1)), array_slice(array_filter($words), 0, 2) )); $rowId = $charity->id ?? $charity->registration_number ?? $charity->ein; $detailUrl = route('charity.detail', [ 'country' => strtolower($charity->country_code ?? 'us'), 'registration_number' => $charity->registration_number ?? $charity->ein, ]); $pinClass = function (string $key) use ($pinLeftKey, $pinRightKeys): string { if ($key === $pinLeftKey) return ' col-pin-l'; if (in_array($key, $pinRightKeys, true)) return ' col-pin-r'; return ''; }; @endphp {{-- `detailEnabled` is the Customizer's Features switch. When it is off there is no expander to click, so a row can only be open because it was open before the switch was thrown — treating it as closed keeps the panel from surviving its own button. --}} @php $isOpen = $detailEnabled && in_array((string) $rowId, array_map('strval', $openRows), true); @endphp