component Alert { props { size = "default" color = "info" variant = "soft" class = "" radius = "md" shadow = "sm" title = "Alert" description = "" items = [] actions = [] showIcon = false icon = "" dismissible = false dismissLabel = "Dismiss alert" role = "alert" live = "polite" linkLabel = "" linkHref = "" actionLabel = "" actionHref = "" compact = false @event dismiss = function @event action = function } state visible = true functions { function dispatchAlertEvent(sourceEvent, eventName, action, root, customEvent) { root = sourceEvent.currentTarget.closest("[data-wrn-alert]") if (!root) { return } customEvent = document.createEvent("CustomEvent") customEvent.initCustomEvent(eventName, true, false, { component: "Alert", title: title, color: color, variant: variant, action: action }) root.dispatchEvent(customEvent) } function dismissAlert(sourceEvent) { visible = false dispatchAlertEvent(sourceEvent, "dismiss", null) } function selectAction(sourceEvent, action) { dispatchAlertEvent(sourceEvent, "action", action) } } view {
{#if showIcon} {/if}
{#if title}{title}{/if} {#if description}

{description}

{/if} {#if items.length > 0} {/if} {#if actions.length > 0 || actionLabel || linkLabel}
{#each actions as item} {item.label} {/each} {#if actionLabel} {actionLabel} {/if} {#if linkLabel} {linkLabel} {/if}
{/if}
{#if dismissible} {/if}
} }