import AdvancedSelect from "@wrnexus/ui/components/AdvancedSelect.wrn" import ComboBox from "@wrnexus/ui/components/Combobox.wrn" // Component event test page. Route: /test // // Events bubble from the exact ComboBox or AdvancedSelect that emitted them. // The
below listens once for every child component, while the first // ComboBox also demonstrates a listener attached directly to one component. page Test { layout = "public" state teams = [{ value: "design", label: "Design", description: "Product and visual design", icon: "icon-[lucide--palette]" }, { value: "engineering", label: "Engineering", description: "Platform engineering", icon: "icon-[lucide--code-2]" }, { value: "growth", label: "Growth", description: "Marketing and customer growth", icon: "icon-[lucide--trending-up]" }, { value: "support", label: "Support", description: "Customer operations", icon: "icon-[lucide--life-buoy]" }] state eventName = "No event yet" state eventSource = "Interact with a component" state eventPayload = "{}" state selectedTeam = "" seo { title = "Component event test" description = "Test ComboBox and AdvancedSelect events on one WRN page." canonical = "/test" } functions { function handleComponentEvent(event) { eventName = event.type eventSource = event.target.getAttribute("data-field") || event.detail.component eventPayload = JSON.stringify(event.detail, null, 2) } function handleTeamSelect(event) { selectedTeam = event.detail.value } } view {
WRN component events

ComboBox and AdvancedSelect event test

This page contains multiple component instances. Every component has a unique id and data-field, so the event source is always identifiable.

Direct listener

Team ComboBox

Its @select listener updates the selected-team text below. The delegated section listener also receives the event.

Selected team: {selectedTeam || "None"}
Second instance

Reviewer ComboBox

This is another ComboBox on the same page. Its events remain distinguishable through data-field="reviewer-combobox".

Multiple selection

Project teams

AdvancedSelect emits the same event names. Multiple values are available through event.detail.values.

} style { .test-hero { display: grid; max-width: 52rem; gap: 0.75rem; margin-block: 3rem 2rem; } .test-hero > span, .test-card__type, .event-monitor span { color: var(--wrn-color-primary); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; } .test-hero h1, .test-card h2, .test-hero p, .test-card p { margin: 0; } .test-hero p, .test-card p { color: var(--wrn-color-muted); line-height: 1.65; } .test-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 4rem; } .test-card, .event-monitor { display: grid; align-content: start; gap: 1rem; padding: clamp(1rem, 3vw, 1.5rem); border: 1px solid var(--wrn-color-border); border-radius: var(--wrn-radius-lg); background: var(--wrn-color-surface); box-shadow: var(--wrn-shadow-1); } .test-selection { color: var(--wrn-color-muted); font-size: 0.82rem; } .event-monitor { position: sticky; bottom: 1rem; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); background: color-mix(in srgb, var(--wrn-color-surface) 94%, var(--wrn-color-primary)); } .event-monitor > div { display: grid; gap: 0.35rem; } .event-monitor pre { grid-column: 1 / -1; max-height: 18rem; overflow: auto; margin: 0; padding: 1rem; border-radius: var(--wrn-radius-md); background: var(--wrn-color-bg); font-size: 0.75rem; line-height: 1.65; white-space: pre-wrap; } @media (max-width: 760px) { .test-grid { grid-template-columns: 1fr; } .event-monitor { grid-template-columns: 1fr; } .event-monitor pre { grid-column: auto; } } } }