@props([ 'type' => 'info', 'title' => null, 'message' => null, 'duration' => 5200, ]) @php $type = in_array($type, ['success', 'error', 'warning', 'info'], true) ? $type : 'info'; $defaults = [ 'success' => ['title' => __('kview-ui-core::ui.toast.success'), 'icon' => 'check'], 'error' => ['title' => __('kview-ui-core::ui.toast.error'), 'icon' => 'x'], 'warning' => ['title' => __('kview-ui-core::ui.toast.warning'), 'icon' => 'alert'], 'info' => ['title' => __('kview-ui-core::ui.toast.info'), 'icon' => 'info'], ]; $durationMs = is_numeric($duration) ? max(0, (int) $duration) : 5000; $toastStyle = trim('--toast-duration: '.$durationMs.'ms; '.$attributes->get('style', '')); @endphp
except('style')->class(['ui-toast', 'ui-toast--'.$type])->merge([ 'role' => $type === 'error' ? 'alert' : 'status', 'data-ui-toast' => true, 'data-toast-duration' => $durationMs, 'style' => $toastStyle, ]) }} > {{ $title ?: $defaults[$type]['title'] }} @if ($message) {{ $message }} @endif @if ($durationMs > 0) @endif