Files
WRNexusJS/packages/ui/components/alert.wrn
T
ClintchizandClaude Opus 5 5e65627305
Quality / quality (ubuntu-latest) (push) Failing after 13m39s
Quality / quality (windows-latest) (push) Canceled after 0s
fix(csr,ui): deliver component outputs to parent bindings
An output only reaches a parent @binding when the component calls
output.<name>(). Two separate faults meant most of the library never got
there, and both failed silently at each end.

HTML lowercases attribute names, so a parent's @sizeChange registered under
"sizechange" while the component emitted "sizeChange". The lookup missed, fell
through to a DOM dispatch, and the binding was never invoked. That made all 17
camelCase outputs undeliverable -- DataTable.pageChange and .rowClick,
Map.markerClick, ChatBubble.messageClick, LayoutSplitter.sizeChange and the
rest. invokeComponentOutput now falls back to a case-insensitive lookup, and a
csr test fails without it.

Separately, 18 components dispatched hand-built CustomEvents rather than
calling output.*. A bubbling event on the component's own root never reaches a
binding, because parent handlers live in a registry only the output proxy
reads. Card, Footer, Breadcrumb, Accordion, alert, Badge, AnnouncementBar,
AvatarGroup, ToggleCount and InputNumber now emit properly; Marquee, Map,
Timeline, List and SearchBox additionally declare the outputs they were
already firing. Dispatches on window are left alone -- that is how Toaster,
Modal and DataTable signal across component boundaries.

Verified in a browser both ways before and after: an AnnouncementBar
dispatching its own bubbling "dismiss" never reached a page-level @dismiss,
and reached it immediately once it called output.dismiss().

This corrects the audit, which called the LayoutSplitter failure "narrow and
unexplained" and read 32 dead outputs as 16 components needing a rebuild.
"Outputs work elsewhere" was an assumption; the components that worked
happened to use lowercase names and output.*. The dead-output ratchet drops
from 32 to 22, and a new test forbids the raw-CustomEvent pattern outright.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-09 01:40:39 +05:30

147 lines
4.3 KiB
Plaintext

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 {
// The output name has to be written out rather than computed: outputs are
// resolved as named properties, so a dynamic key would not reach a parent
// binding. Only two names exist here, so a branch is honest and cheap.
client function dispatchAlertEvent(sourceEvent, eventName, action, payload) {
payload = {
component: "Alert",
title: title,
color: color,
variant: variant,
action: action
}
if (eventName === "dismiss") {
output.dismiss(payload)
} else {
output.action(payload)
}
}
client function dismissAlert(sourceEvent) {
visible = false
dispatchAlertEvent(sourceEvent, "dismiss", null)
}
client function selectAction(sourceEvent, action) {
dispatchAlertEvent(sourceEvent, "action", action)
}
}
view {
<section
{...attrs}
data-wrn-alert
data-color="{color}"
data-variant="{variant}"
data-radius="{radius}"
data-shadow="{shadow}"
data-show="visible"
aria-hidden="{visible ? 'false' : 'true'}"
role="{role}"
aria-live="{live}"
class="wire-next wire-next--color-{color} wire-next--size-{size} wire-next--alert wire-next--alert-{variant} {compact ? 'wire-next--alert-compact' : ''} {class}"
>
{#if showIcon}
<span class="wire-next__alert-icon" aria-hidden="true">
{#if icon}
<span class="{icon}"></span>
{:else if color === "success"}
<span class="icon-[lucide--circle-check]"></span>
{:else if color === "danger"}
<span class="icon-[lucide--circle-x]"></span>
{:else if color === "warning"}
<span class="icon-[lucide--triangle-alert]"></span>
{:else}
<span class="icon-[lucide--info]"></span>
{/if}
</span>
{/if}
<div class="wire-next__alert-body">
{#if title}<strong class="wire-next__alert-title">{title}</strong>{/if}
{#if description}<p>{description}</p>{/if}
{#if items.length > 0}
<ul>
{#each items as item}<li>{item.label || item}</li>{/each}
</ul>
{/if}
{#if actions.length > 0 || actionLabel || linkLabel}
<div class="wire-next__alert-actions">
{#each actions as item}
<a
href="{item.href || '#'}"
data-variant="{item.variant || 'link'}"
@click="selectAction(event, item)"
>{item.label}</a>
{/each}
{#if actionLabel}
<a
href="{actionHref || '#'}"
data-variant="action"
@click="selectAction(event, { label: actionLabel, href: actionHref })"
>{actionLabel}</a>
{/if}
{#if linkLabel}
<a
href="{linkHref || '#'}"
data-variant="link"
@click="selectAction(event, { label: linkLabel, href: linkHref })"
>{linkLabel}</a>
{/if}
</div>
{/if}
</div>
{#if dismissible}
<button
type="button"
class="wire-next__alert-dismiss"
aria-label="{dismissLabel}"
@click="dismissAlert(event)"
>
<span class="icon-[lucide--x]" aria-hidden="true"></span>
</button>
{/if}
</section>
}
}