InputCopy.Copy# const · packages/mixins-ui/src/inputCopy.ts:37
const Copy: Command . CommandDefinitionWithArgs <
'InputCopy.Copy' ,
{ text: Schema . String },
Effect . Effect <
| { readonly _tag: 'Copied' }
| { readonly _tag: 'CopyFailed' ; readonly message: string },
never ,
never
>
> Puts text on the clipboard; a refusal or no clipboard yields CopyFailed, never a throw.
InputCopy.init# function · packages/mixins-ui/src/inputCopy.ts:68
function init ( options?: { readonly resetAfter?: number | undefined }) : Model Not copied yet; resetAfter defaults to 2000 milliseconds.
const · packages/mixins-ui/src/inputCopy.ts:25
const InputCopySlots: Slots . Contract <{ readonly input: Slot . UnnamedSlot < Capability . Capability < "Focusable" , readonly [Capability . Capability < "Interactive" , readonly [Capability . Capability < "Base" , readonly []> ]> ]>, readonly Slot . EventName [], readonly [Attr . AttrToken < "value" > ], readonly Slot . RequirementName [], boolean >; readonly button: Slot . UnnamedSlot < Capability . Capability < "Interactive" , readonly [Capability . Capability < "Base" , readonly []> ]>, readonly [Event . EventToken < "click" > ], readonly Slot . AttributeName [], readonly Slot . RequirementName [], boolean >; readonly buttonText: Slot . UnnamedSlot < Capability . Capability < "Container" , readonly [Capability . Capability < "Interactive" , readonly [Capability . Capability < "Base" , readonly []> ]> ]>, readonly Slot . EventName [], readonly Slot . AttributeName [], readonly Slot . RequirementName [], boolean >; readonly status: Slot . UnnamedSlot < Capability . Capability < "Container" , readonly [Capability . Capability < "Interactive" , readonly [Capability . Capability < "Base" , readonly []> ]> ]>, readonly Slot . EventName [], readonly [Attr . AttrToken < "role" > ], readonly Slot . RequirementName [], boolean >; readonly group: Slot . UnnamedSlot < Capability . Capability < "Container" , readonly [Capability . Capability < "Interactive" , readonly [Capability . Capability < "Base" , readonly []> ]> ]>, readonly [], readonly [], readonly [], false >; readonly start: Slot . UnnamedSlot < Capability . Capability < "Container" , readonly [Capability . Capability < "Interactive" , readonly [Capability . Capability < "Base" , readonly []> ]> ]>, readonly [], r …;A read-only field showing a value beside a copy button, Zag's clipboard.
The view holds no state: the button sends onCopy, the application's
update returns Copy with the value, and the ClipboardMessage it
yields (Copied or CopyFailed, from foldkit-primitives/dom ) is where
the application sets the copied flag it passes back. To have it go back
to "Copy" on its own, keep this module's Model and fold Copied into it
with update, which answers with Reset after the Model's resetAfter.
Copied, the button reads "Copied" and a polite
status region, drawn always so it is in place before it speaks, says so:
a screen reader does not reliably announce a focused button's new name.
interface · packages/mixins-ui/src/inputCopy.ts:126
interface InputCopyView < Message > extends Adornments {
readonly id: string
readonly label: string
readonly value: string
readonly copied: boolean
readonly failed?: boolean | undefined
readonly onCopy: NoInfer < Message >
readonly words?: Partial < InputCopyWords > | undefined
readonly copyContent?: Html | undefined
readonly style?: NamedStyle < typeof InputCopySlots> | undefined
readonly mixins?: MixinList < Message > | undefined
} interface · packages/mixins-ui/src/inputCopy.ts:114
interface InputCopyWords {
readonly copy: string
readonly copied: string
readonly failed: string
} InputCopy.Message# const · packages/mixins-ui/src/inputCopy.ts:57
const Message: MessageUnion <{
readonly Copied: {}
readonly Failed: {}
readonly ElapsedReset: { readonly copy: Schema . Number }
}> InputCopy.Model# const · packages/mixins-ui/src/inputCopy.ts:47
const Model: Schema . Struct <{
readonly copied: Schema . Boolean
readonly failed: Schema . Boolean
readonly copies: Schema . Number
readonly resetAfter: Schema . Number
}> Whether the value shows as copied, and for how long. copies stamps each
copy, so a reset begun by an earlier one does not cut a later one short.
InputCopy.Reset# const · packages/mixins-ui/src/inputCopy.ts:76
const Reset: Command . CommandDefinitionWithArgs <
'InputCopy.Reset' ,
{ ms: Schema . Number ; copy: Schema . Number },
Effect . Effect <
{ readonly _tag: 'ElapsedReset' ; readonly copy: number },
never ,
never
>
> Waits ms, then yields ElapsedReset for the copy stamped copy.
InputCopy.update# function · packages/mixins-ui/src/inputCopy.ts:84
function update ( model: Model , message: Message ) : Return < Model , Message > The field after message: copied and a Reset begun, or copied no more; the same Model when nothing changes.
InputCopy.view# function · packages/mixins-ui/src/inputCopy.ts:149
function view < Message >(
options: InputCopyView < Message >,
h: HtmlBuilder < Message >,
) : Html InputCopy.words# const · packages/mixins-ui/src/inputCopy.ts:124
const words = { copy, copied, failed } The defaults, in English.