Mixins / foldkit-mixins-ui

TagsInput

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

export * as TagsInput from './tagsInput.js'

In the guides

Members

TagsInput.configure

function · packages/mixins-ui/src/tagsInput.ts:343

function configure<const Names extends string = never>(
  config: Presets<TagsInputPreset, Names>,
): {
  readonly view: <Outer>(
    options: TagsInputView<Outer> & PresetOption<Names>,
    h: HtmlBuilder<Outer>,
  ) => Html
}

The application's own TagsInput: base for every use, presets chosen at a use with preset, and the call over both. mixins concatenate in that order and words merge word by word; any other option given at the call replaces the preset's.

TagsInput.conflict

function · packages/mixins-ui/src/tagsInput.ts:417

function conflict<Outer>(
  routes: ReadonlyArray<Route<Outer>>,
  input?: Partial<OwnKeysInput<Outer>>,
): Option.Option<Diagnostic>

The mixins:key-conflict that drawing the input with routes would throw, or none: the application's routes against the input's own and against each other. delimiter is the Model's (default ,) and direction the view's.

TagsInput.init

function · packages/mixins-ui/src/tagsInput.ts:129

function init(options: {
  readonly id: string
  readonly tags?: ReadonlyArray<string> | undefined
  readonly delimiter?: string | undefined
  readonly max?: number | undefined
}): Model

TagsInput.Message

const · packages/mixins-ui/src/tagsInput.ts:105

const Message: MessageUnion<{
  readonly Typed: {
    readonly text: Schema.String
    readonly drawn: Schema.Number
  }
  readonly Committed: {}
  readonly BackspacedEmpty: {}
  readonly Removed: { readonly tag: Schema.String }
  readonly FocusMoved: { readonly chip: Schema.OptionFromNullOr<Schema.String> }
  readonly CompletedFocus: {}
}>

TagsInput.Model

const · packages/mixins-ui/src/tagsInput.ts:75

const Model: Schema.Struct<{
  readonly id: Schema.String
  readonly tags: Schema.$Array<Schema.String>
  readonly draft: Schema.String
  readonly delimiter: Schema.String
  readonly max: Schema.OptionFromNullOr<Schema.Number>
  readonly refusal: Schema.OptionFromNullOr<
    TaggedUnion<{
      readonly Repeat: { readonly tag: Schema.String }
      readonly Empty: {}
      readonly Full: { readonly max: Schema.Number }
    }>
  >
  readonly refusals: Schema.Number
  readonly commits: Schema.Number
  readonly chip: Schema.OptionFromNullOr<Schema.String>
  readonly added: Schema.$Array<Schema.String>
}>

TagsInput.Refusal

const · packages/mixins-ui/src/tagsInput.ts:65

const Refusal: TaggedUnion<{
  readonly Repeat: { readonly tag: Schema.String }
  readonly Empty: {}
  readonly Full: { readonly max: Schema.Number }
}>

Why the last commit added nothing, or not all of the draft.

TagsInput.Route

type · packages/mixins-ui/src/tagsInput.ts:276

type Route<Message> = Behaviors.Keys.Route<Model, Message>

TagsInput.TagsInputPreset

type · packages/mixins-ui/src/tagsInput.ts:332

type TagsInputPreset = Pick<
  TagsInputView<never>,
  'style' | 'placeholder' | 'addOnBlur' | 'direction' | 'words'
> & {
  readonly mixins?: MixinList<never>
}

What a TagsInput is given once: its look and each option that holds no Message.

TagsInput.TagsInputSlots

const · packages/mixins-ui/src/tagsInput.ts:43

const TagsInputSlots: 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 control: 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 list: 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 tag: 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 remove: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", read …;

A field of tags, Zag's tags input: the tags as a list of chips, each with a remove button, and a text input for the next one. Enter or the delimiter adds the draft, split at the delimiter and trimmed, refusing empty parts, tags already there and tags past max; Backspace on an empty draft removes the last tag at once. A refusal is shown: the message slot, a polite status region drawn always, says why, and the control shakes once (not under reduced motion). The tags and the draft are a small Model of this module's, which the application keeps and folds with update; Typed carries the drawing it read the text from, so a frame behind the keys loses no draft.

The chips are one tab stop. ArrowLeft and ArrowRight move among them (and ArrowRight past the last returns to the input), Home and End go to the ends, Backspace and Delete remove the focused one, and ArrowLeft in the input at the start of its text enters the last. Text keys stay the browser's.

TagsInput.TagsInputView

interface · packages/mixins-ui/src/tagsInput.ts:300

interface TagsInputView<Message> {
  readonly model: Model
  readonly onMessage: (message: typeof Message.Type) => NoInfer<Message>
  readonly label: string
  readonly placeholder?: string | undefined
  readonly name?: string | undefined
  readonly disabled?: boolean | undefined
  readonly addOnBlur?: boolean | undefined
  readonly direction?: 'ltr' | 'rtl' | undefined
  readonly routes?: ReadonlyArray<Route<NoInfer<Message>>> | undefined
  readonly words?: Partial<TagsInputWords> | undefined
  readonly style?: NamedStyle<typeof TagsInputSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

TagsInput.TagsInputWords

interface · packages/mixins-ui/src/tagsInput.ts:278

interface TagsInputWords {
  readonly remove: string
  readonly mark: string
  readonly repeat: string
  readonly empty: string
  readonly full: string
}

TagsInput.update

function · packages/mixins-ui/src/tagsInput.ts:200

function update(model: Model, message: Message): Return<Model, Message>

The field after message; the same Model when nothing changes.

TagsInput.view

function · packages/mixins-ui/src/tagsInput.ts:434

function view<Outer>(options: TagsInputView<Outer>, h: HtmlBuilder<Outer>): Html

TagsInput.words

const · packages/mixins-ui/src/tagsInput.ts:292

const words = { remove, mark, repeat, empty, full }

The defaults, in English: text with {blanks}, as the other widgets' words.