m3e/form_field

form_field provides Lustre support for the M3E Form Field component

Types

Config holds the configuration for a FormField

pub type Config {
  Config(
    float_label: FloatLabel,
    required_marker: RequiredMarkerVisibility,
    hide_subscript: HideSubscript,
    variant: Variant,
  )
}

Constructors

When a form field’s control is empty, the label is presented over the control instead of above. This behavior can be changed using the float-label attribute

pub type FloatLabel {
  Always
  Auto
}

Constructors

  • Always
  • Auto

FormField is a container for form controls that applies Material Design styling and behavior. Supported controls include: input, select, textarea, and m3e-input-chip-set

Fields:

  • float_label: Specifies whether the label should float always or only when necessary
  • required_marker: Whether the required marker should be hidden
  • hide_subscript: Whether subscript content is hidden
  • variant: The appearance variant of the field
pub opaque type FormField

Hint labels are additional descriptive text that appear in a field’s subscript

pub type HideSubscript {
  AlwaysHide
  AutoHide
  NeverHide
}

Constructors

  • AlwaysHide
  • AutoHide
  • NeverHide

RequiredMarkerVisibility specifies if the required marker should be hidden or shown

pub type RequiredMarkerVisibility {
  ShowRequiredMarker
  HideRequiredMarker
}

Constructors

  • ShowRequiredMarker
  • HideRequiredMarker

Slot gives type-safe names to each of the defined HTML named slots

pub type Slot {
  Error
  Hint
  Prefix
  PrefixText
  Suffix
  SuffixText
}

Constructors

  • Error
  • Hint
  • Prefix
  • PrefixText
  • Suffix
  • SuffixText

Variant is the appearance variant of the field

pub type Variant {
  Filled
  Outlined
}

Constructors

  • Filled
  • Outlined

Values

pub fn default_config() -> Config

default_config creates a new Config with default values

pub const default_float_label: FloatLabel
pub const default_hide_subscript: HideSubscript
pub const default_variant: Variant
pub fn float_label(
  f: FormField,
  float_label: FloatLabel,
) -> FormField

float_label sets the float_label field

pub fn from_config(c: Config) -> FormField

from_config creates a FormField from a Config record

pub fn hide_required_marker(
  f: FormField,
  visibility: RequiredMarkerVisibility,
) -> FormField

hide_required_marker sets the required_marker field

pub fn hide_subscript(
  f: FormField,
  hide_subscript: HideSubscript,
) -> FormField

hide_subscript sets the hide_subscript field

pub fn new() -> FormField

new creates a FormField with default values

pub fn render(
  f: FormField,
  attributes: List(attribute.Attribute(msg)),
  children: List(element.Element(msg)),
) -> element.Element(msg)

render creates a Lustre Element from a FormField

Parameters:

  • f: a FormField
  • attributes: a list of additional attributes
  • children: a list of child Elements
pub fn render_config(
  config: Config,
  attributes: List(attribute.Attribute(msg)),
  children: List(element.Element(msg)),
) -> element.Element(msg)

render_config creates a Lustre Element directly from a Config

pub fn slot(s: Slot) -> attribute.Attribute(msg)

slot creates a Lustre ‘slot’ Attribute(msg) for a Slot

pub fn variant(f: FormField, variant: Variant) -> FormField

variant sets the variant field

Search Document