Mixins / foldkit-mixins-ui

PasswordInput

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

export * as PasswordInput from './passwordInput.js'

In the guides

Members

PasswordInput.capsLockOf

function · packages/mixins-ui/src/passwordInput.ts:69

function capsLockOf(
  key: string,
  modifiers: KeyboardModifiers,
): Option.Option<boolean>

What a key says of Caps Lock: a letter in the case Shift did not ask for means it is on, the other case that it is off, and any other key nothing. Fold it over the flag the application keeps, so a key typed before the hint is drawn still counts.

PasswordInput.controls

function · packages/mixins-ui/src/passwordInput.ts:130

function controls<Outer>(
  model: Model,
  onMessage: (message: Message) => Outer,
): {
  visible: boolean
  onToggle: Outer
  capsLock: { on: boolean; onKey: (reading: Option.Option<boolean>) => Outer }
}

The view's visible, onToggle and capsLock for a placed Model: PasswordInput.view({ id, label, value, onInput, ...PasswordInput.controls(model, onMessage) }, h).

PasswordInput.init

function · packages/mixins-ui/src/passwordInput.ts:107

function init(options?: { readonly visible?: boolean | undefined }): Model

Hidden, with Caps Lock off, unless visible says otherwise.

PasswordInput.Message

const · packages/mixins-ui/src/passwordInput.ts:98

const Message: MessageUnion<{
  readonly Toggled: {}
  readonly ReadCapsLock: { readonly reading: Schema.Option<Schema.Boolean> }
}>

PasswordInput.Model

const · packages/mixins-ui/src/passwordInput.ts:95

const Model: Schema.Struct<{
  readonly visible: Schema.Boolean
  readonly capsLock: Schema.Boolean
}>

Whether the password shows as text, and whether Caps Lock is on: what the field itself keeps.

PasswordInput.PasswordInputSlots

const · packages/mixins-ui/src/passwordInput.ts:30

const PasswordInputSlots: Slots.Contract<{ readonly input: Slot.UnnamedSlot<Capability.Capability<"TextInput", readonly [Capability.Capability<"Focusable", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>]>, readonly [Event.EventToken<"input">, Event.EventToken<"keydown">], readonly [Attr.AttrToken<"aria-invalid">, Attr.AttrToken<"disabled">, Attr.AttrToken<"value">], readonly Slot.RequirementName[], boolean>; readonly toggle: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly [Attr.AttrToken<"aria-label">, Attr.AttrToken<"aria-pressed">, Attr.AttrToken<"disabled">], readonly Slot.RequirementName[], boolean>; readonly description: 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 strength: 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 requirements: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Sl …;

A password field with a toggle that shows the password as text, Zag's password input: the toggle is a button outside the form's submission, named for what it does and aria-pressed while the text shows, as the APG's toggle button keeps its name and changes its state. The text and whether it shows are the application's, as are the three aids a new password wants: a strength Meter, a list of requirements each met or not, and a hint while Caps Lock is on, each read with the input.

PasswordInput.PasswordInputView

interface · packages/mixins-ui/src/passwordInput.ts:139

interface PasswordInputView<Message> extends Adornments {
  readonly id: string
  readonly label: string
  readonly value: string
  readonly onInput: OnInput<NoInfer<Message>>
  readonly visible: boolean
  readonly onToggle: NoInfer<Message>
  readonly autocomplete?: 'current-password' | 'new-password' | undefined
  readonly labelAside?: Html | undefined
  readonly words?: Partial<PasswordInputWords> | undefined
  readonly description?: string | undefined
  readonly placeholder?: string | undefined
  readonly invalid?: boolean | undefined
  readonly disabled?: boolean | undefined
  readonly name?: string | undefined
  readonly required?: boolean | undefined
  readonly strength?: Html | undefined
  readonly requirements?: ReadonlyArray<Requirement> | undefined
  readonly capsLock?:
    | {
        readonly on: boolean
        readonly onKey: (reading: Option.Option<boolean>) => NoInfer<Message>
      }
    | undefined
  readonly style?: NamedStyle<typeof PasswordInputSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
  readonly attributes?:
    | {
        readonly [K in keyof typeof PasswordInputSlots]?: SlotAttributes<
          NoInfer<Message>
        >
      }
    | undefined
}

PasswordInput.PasswordInputWords

interface · packages/mixins-ui/src/passwordInput.ts:75

interface PasswordInputWords {
  readonly toggle: string
  readonly capsLock: string
  readonly met: string
  readonly unmet: string
}

What the field draws that is no one use's content.

PasswordInput.Requirement

interface · packages/mixins-ui/src/passwordInput.ts:58

interface Requirement {
  readonly label: string
  readonly met: boolean
}

One rule a new password must keep, and whether the text keeps it.

PasswordInput.update

function · packages/mixins-ui/src/passwordInput.ts:113

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

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

PasswordInput.view

function · packages/mixins-ui/src/passwordInput.ts:196

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

PasswordInput.words

const · packages/mixins-ui/src/passwordInput.ts:87

const words = { toggle, capsLock, met, unmet }

The defaults, in English.