[ @sdxc/ui/mixins ]
attachmentTrigger
Turns an Attachment.Trigger's whole card into a single activation target, following its href or opening the <dialog> its commandfor names.
import { attachmentTrigger } from "@sdxc/ui/mixins";Usage
Makes an Attachment.Trigger's whole card activatable as a link or dialog
trigger through the same href/commandfor attributes resolveAction
reads; an aria-disabled="true" host ignores every activation, and nested controls keep answering their own click, tap, and keypress independently.
Signature
attachmentTrigger(): MixinDescriptor<HTMLElement>Returns a mixin descriptor for an Attachment.Trigger's mix prop.
Examples
<Attachment.Trigger href="/files/quarterly-report.pdf" mix={attachmentTrigger()}>
<Attachment state="done">
<Attachment.Media><FileTextIcon aria-hidden /></Attachment.Media>
<Attachment.Content>
<Attachment.Title>quarterly-report.pdf</Attachment.Title>
</Attachment.Content>
<Attachment.Actions>
<Attachment.Action aria-label={t("attachment.download")}>
<DownloadIcon />
</Attachment.Action>
</Attachment.Actions>
</Attachment>
</Attachment.Trigger><Attachment.Trigger commandfor="quarterly-report-preview" mix={attachmentTrigger()}>
<Attachment state="done">
<Attachment.Media><FileTextIcon aria-hidden /></Attachment.Media>
<Attachment.Content>
<Attachment.Title>quarterly-report.pdf</Attachment.Title>
</Attachment.Content>
</Attachment>
</Attachment.Trigger>
<Dialog id="quarterly-report-preview">...</Dialog>Used with it
The events, constants and types its module publishes, each imported from @sdxc/ui/mixins too.
AttachmentTriggerEvent
Dispatched on an Attachment.Trigger host by attachmentTrigger
right before it follows a link or opens a dialog, so a consumer can react
— log analytics, swap in a custom viewer — or cancel it with preventDefault() to stop the default effect.
new AttachmentTriggerEvent(href: string | null)| Property | Type | Description |
|---|---|---|
href | readonly string | null | The href this activation is about to follow, or null when it opens a dialog instead. |