Mixins / foldkit-mixins-ui

InputCopy

namespace · packages/mixins-ui/src/inputCopy.ts:1

export * as InputCopy from './inputCopy.js'

In the guides

Members

InputCopy.Copy

const · packages/mixins-ui/src/inputCopy.ts:28

const Copy: Command.CommandDefinitionWithArgs<
  'InputCopy.Copy',
  { text: Schema.String },
  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.InputCopySlots

const · packages/mixins-ui/src/inputCopy.ts:18

const InputCopySlots: Slots.Contract<{ readonly root: 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 label: 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 group: 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 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 status: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capabil …;

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, and clears it, on a timer or the next edit. 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.

InputCopy.InputCopyView

interface · packages/mixins-ui/src/inputCopy.ts:34

interface InputCopyView<Message> {
  readonly id: string
  readonly label: string
  readonly value: string
  readonly copied: boolean
  readonly onCopy: NoInfer<Message>
  readonly copyLabel?: string | undefined
  readonly copiedLabel?: string | undefined
  readonly style?: NamedStyle<typeof InputCopySlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

InputCopy.view

function · packages/mixins-ui/src/inputCopy.ts:53

function view<Message>(
  options: InputCopyView<Message>,
  h: HtmlBuilder<Message>,
): Html