@props([
// Either pass the record itself…
'for' => null,
// …or the registry alias + id directly (handy when the row is an array).
'type' => null,
'id' => null,
'title' => null,
// Note count for the badge. Falls back to a withCount('notes') / loaded
// relation on the record; pass it explicitly to avoid an N+1 in tables.
'count' => null,
// 'icon' for table action columns, 'link' for text-link action columns,
// 'button' for a labelled toolbar action, 'segment' for a labelled action
// sitting inside a joined toolbar group (document previews).
'variant' => 'icon',
// Icon-button footprint: 'md' (h-8) matches most tables, 'sm' (h-7) the
// tighter invoice/people rows.
'size' => 'md',
'label' => null,
])
@php
$record = $for;
$noteType = $type ?: ($record ? \App\Support\Notables::aliasFor($record) : null);
$noteId = $id ?: $record?->getKey();
if ($count === null && $record) {
$count = $record->notes_count
?? ($record->relationLoaded('notes') ? $record->notes->count() : null);
}
$count = $count === null ? null : (int) $count;
$noteTitle = $title ?: (($record && $noteType) ? \App\Support\Notables::title($noteType, $record) : '');
$noteLabel = $label ?: __('Notes');
$hint = $count ? trans_choice(':count note|:count notes', $count, ['count' => $count]) : __('Add a note');
$box = $size === 'sm' ? 'h-7 w-7' : 'h-8 w-8';
$glyph = $size === 'sm' ? 'h-3.5 w-3.5' : 'h-4 w-4';
@endphp
@if ($noteType && $noteId)
@php
$open = 'x-on:click="$dispatch(\'open-notes\', { type: '.\Illuminate\Support\Js::from($noteType).', id: '.(int) $noteId.', title: '.\Illuminate\Support\Js::from($noteTitle).' })"';
@endphp
@if ($variant === 'button')
@elseif ($variant === 'segment')
@elseif ($variant === 'link')
@else
@endif
@endif