m3e/chip
chip provides Lustre support for the M3E Chip components
Types
Behaviour controls the behavior of an assist or suggestion chip
pub type Behaviour {
Normal
Reset
Submit
}
Constructors
-
Normal -
Reset -
Submit
Chip provides expressive, accessible chip components for actions, input, filtering, and suggestions
- label: text on the chip
- behaviour: behaviour of an Assist or Suggestion chip
- interaction: whether the Chip is enabled or disabled
- form_submission: handles this element’s role in form submission
- icon: associated Icon
- removability: whether the chip can be removed
- selection: whether the chip is selected or not
- type_: the type of Chip
- variant: variant of the chip
pub opaque type Chip(msg)
Config holds the configuration for a Chip
pub type Config(msg) {
Config(
label: String,
behaviour: Behaviour,
interaction: types.Interaction,
form_submission: option.Option(form_submission.FormSubmission),
icon: option.Option(icon.Icon(msg)),
removability: Removability,
selection: types.SelectionState,
type_: Type,
variant: Variant,
)
}
Constructors
-
Config( label: String, behaviour: Behaviour, interaction: types.Interaction, form_submission: option.Option(form_submission.FormSubmission), icon: option.Option(icon.Icon(msg)), removability: Removability, selection: types.SelectionState, type_: Type, variant: Variant, )
Removability specifies if a chip can be removed
pub type Removability {
Removable
Permanent
}
Constructors
-
Removable -
Permanent
Slot gives type-safe names to each of the defined HTML named slots
pub type Slot {
AssistIcon
ChipIcon
ChipTrailingIcon
FilterIcon
FilterTrailingIcon
InputAvatar
InputIcon
InputRemoveIcon
InputSetInput
SuggestionIcon
}
Constructors
-
AssistIcon -
ChipIcon -
ChipTrailingIcon -
FilterIcon -
FilterTrailingIcon -
InputAvatar -
InputIcon -
InputRemoveIcon -
InputSetInput -
SuggestionIcon
Type of chip
pub type Type {
Assist
Filter
Information
Input
Suggestion
}
Constructors
-
Assist -
Filter -
Information -
Input -
Suggestion
Values
pub fn behaviour(c: Chip(msg), behaviour: Behaviour) -> Chip(msg)
behaviour sets the behaviour field
pub const default_behaviour: Behaviour
pub fn default_config() -> Config(msg)
default_config creates a new Config with default values
pub const default_removability: Removability
pub const default_type: Type
pub fn disabled(
c: Chip(msg),
interaction: types.Interaction,
) -> Chip(msg)
disabled sets the interaction field
pub fn form(
c: Chip(msg),
form_submission: option.Option(form_submission.FormSubmission),
) -> Chip(msg)
form sets the form_submission field when the chip is used in a form
pub fn information(label: String) -> Chip(msg)
information creates a basic Information Chip
pub fn removable(
c: Chip(msg),
removability: Removability,
) -> Chip(msg)
removable sets the removability field
pub fn render(
c: Chip(msg),
attributes: List(attribute.Attribute(msg)),
children: List(element.Element(msg)),
) -> element.Element(msg)
render creates a Lustre Element from a Chip
Parameters:
- c: a Chip
- attributes: any extra attributes, e.g. an event
- children: a list of child elements
pub fn render_config(
config: Config(msg),
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 selected(
c: Chip(msg),
selection: types.SelectionState,
) -> Chip(msg)
selected sets the selection field
pub fn slot(s: Slot) -> attribute.Attribute(msg)
slot creates a Lustre ‘slot’ Attribute(msg) for a Slot
pub fn suggestion(label: String) -> Chip(msg)
suggestion creates a basic Suggestion Chip