component Alert { outputs { dismiss(payload: { sourceEvent?: Event; [key: string]: string | number | boolean | null | object }) action(payload: { sourceEvent?: Event; [key: string]: string | number | boolean | null | object }) } props { size: string = "default" color: string = "info" variant: string = "soft" class: string = "" radius: string = "md" shadow: string = "sm" title: string = "Alert" description: string = "" items: unknown[] = [] actions: unknown[] = [] showIcon: boolean = false icon: string = "" dismissible: boolean = false dismissLabel: string = "Dismiss alert" role: string = "alert" live: string = "polite" linkLabel: string = "" linkHref: string = "" actionLabel: string = "" actionHref: string = "" compact: boolean = false } state visible: boolean = true functions { client 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) } client function dismissAlert(sourceEvent) { visible = false dispatchAlertEvent(sourceEvent, "dismiss", null) } client 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}
} }