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>
86 lines
3.4 KiB
Plaintext
86 lines
3.4 KiB
Plaintext
component SearchBox {
|
|
outputs {
|
|
search(payload: { sourceEvent?: Event; [key: string]: string | number | boolean | null | object })
|
|
clear(payload: { sourceEvent?: Event; [key: string]: string | number | boolean | null | object })
|
|
}
|
|
|
|
props {
|
|
size: string = "default"
|
|
color: string = "primary"
|
|
label: string = "Search Box"
|
|
name: string = ""
|
|
value: string = ""
|
|
placeholder: string = ""
|
|
type: string = "search"
|
|
min: string = ""
|
|
max: string = ""
|
|
step: string = ""
|
|
disabled: boolean = false
|
|
required: boolean = false
|
|
class: string = ""
|
|
}
|
|
|
|
state query = value
|
|
|
|
view {
|
|
<form
|
|
data-ui-component="SearchBox"
|
|
role="search"
|
|
class='w-full {class}'
|
|
@submit='event.preventDefault(); output.search({ value: query, name: name })'
|
|
>
|
|
<label
|
|
class="mb-2 block text-sm font-semibold text-[var(--wire-color-text)]"
|
|
class:sr-only='label === ""'
|
|
>
|
|
{label}
|
|
</label>
|
|
|
|
<div class="relative flex items-center">
|
|
<span
|
|
class="icon-[lucide--search] pointer-events-none absolute left-4 size-5 text-[var(--wire-color-input-placeholder)]"
|
|
aria-hidden="true"
|
|
></span>
|
|
|
|
<input
|
|
name='{name}'
|
|
type='{type}'
|
|
value='{query}'
|
|
placeholder='{placeholder}'
|
|
min='{min}'
|
|
max='{max}'
|
|
step='{step}'
|
|
disabled='{disabled}'
|
|
required='{required}'
|
|
autocomplete="off"
|
|
class="w-full rounded-xl border border-[var(--wire-color-input-border)] bg-[var(--wire-color-input-background)] pl-12 pr-24 text-[var(--wire-color-input-text)] outline-none transition placeholder:text-[var(--wire-color-input-placeholder)] hover:border-[var(--wire-color-input-border-hover)] focus:border-[var(--wire-color-input-border-focus)] focus:ring-2 focus:ring-[var(--wire-color-focus)] disabled:cursor-not-allowed disabled:opacity-60"
|
|
class:h-10='size === "sm"'
|
|
class:h-12='size === "default" || size === "md"'
|
|
class:h-14='size === "lg"'
|
|
@input='query = event.target.value'
|
|
@change='query = event.target.value'
|
|
/>
|
|
|
|
<button
|
|
type="button"
|
|
aria-label="Clear search"
|
|
data-show='query.length > 0 && !disabled'
|
|
class="absolute right-12 inline-flex size-8 items-center justify-center rounded-lg text-[var(--wire-color-text-muted)] transition hover:bg-[var(--wire-color-surface-soft)] hover:text-[var(--wire-color-text)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--wire-color-focus)]"
|
|
@click='query = ""; event.currentTarget.parentElement.querySelector("input")?.focus(); output.clear({ value: "", name: name })'
|
|
>
|
|
<span class="icon-[lucide--x] size-4" aria-hidden="true"></span>
|
|
</button>
|
|
|
|
<button
|
|
type="submit"
|
|
aria-label='{label || "Search"}'
|
|
disabled='{disabled}'
|
|
class="absolute right-2 inline-flex size-9 items-center justify-center rounded-lg bg-[var(--wire-color-primary)] text-[var(--wire-color-on-primary)] transition hover:bg-[var(--wire-color-primary-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--wire-color-focus)] disabled:cursor-not-allowed disabled:opacity-60"
|
|
>
|
|
<span class="icon-[lucide--arrow-right] size-4" aria-hidden="true"></span>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
}
|
|
}
|