Documentation
¶
Index ¶
- type Base
- func (b *Base) AddAttribute(key, value string)
- func (b *Base) Children() []dom.Component
- func (b *Base) FieldName() string
- func (b *Base) GetID() string
- func (b *Base) GetOptions() []fmt.KeyValue
- func (b *Base) GetPlaceholder() string
- func (b *Base) GetSelectedValue() string
- func (b *Base) GetSkipValidation() bool
- func (b *Base) GetTitle() string
- func (b *Base) GetValue() string
- func (b *Base) GetValues() []string
- func (b *Base) HTMLName() string
- func (b *Base) HandlerName() string
- func (b *Base) InitBase(parentID, name, htmlName string, aliases ...string)
- func (b *Base) Matches(fieldName string) bool
- func (b *Base) RenderHTML() string
- func (b *Base) RenderInput() string
- func (b *Base) SetAliases(aliases ...string)
- func (b *Base) SetID(id string)
- func (b *Base) SetOptions(opts ...fmt.KeyValue)
- func (b *Base) SetPlaceholder(ph string)
- func (b *Base) SetSkipValidation(skip bool)
- func (b *Base) SetTitle(title string)
- func (b *Base) SetValues(v ...string)
- func (b *Base) ValidateField(value string) error
- type Input
- func Address(parentID, name string) Input
- func Checkbox(parentID, name string) Input
- func Datalist(parentID, name string) Input
- func Date(parentID, name string) Input
- func Email(parentID, name string) Input
- func Filepath(parentID, name string) Input
- func Gender(parentID, name string) Input
- func Hour(parentID, name string) Input
- func IP(parentID, name string) Input
- func Number(parentID, name string) Input
- func Password(parentID, name string) Input
- func Phone(parentID, name string) Input
- func Radio(parentID, name string) Input
- func Rut(parentID, name string) Input
- func Select(parentID, name string) Input
- func Text(parentID, name string) Input
- func Textarea(parentID, name string) Input
- type Permitted
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct {
Values []string // Multiple values support (for select/checkbox/etc)
Options []fmt.KeyValue // Multiple options for select/checkbox/etc
Placeholder string
Title string
Required bool // HTML required attribute
Disabled bool // HTML disabled attribute
Readonly bool // HTML readonly attribute
SkipValidation bool // Whether to skip validation for this input
Attributes []fmt.KeyValue
Permitted // anonymous embed: promotes Letters, Numbers, Validate(), etc.
// contains filtered or unexported fields
}
Base contains common logic and fields (State) for all inputs. It is intended to be embedded in concrete input structs.
func (*Base) AddAttribute ¶
AddAttribute adds a custom attribute to the input.
func (*Base) GetOptions ¶
GetOptions returns all options.
func (*Base) GetPlaceholder ¶
GetPlaceholder returns the input placeholder.
func (*Base) GetSelectedValue ¶
GetSelectedValue returns the first value in Values, or empty if none.
func (*Base) GetSkipValidation ¶
GetSkipValidation returns whether to skip validation.
func (*Base) HandlerName ¶ added in v0.0.4
HandlerName returns the component's unique identifier. Deprecated: use GetID instead.
func (*Base) Matches ¶
Matches checks if the given field name matches this input's htmlName, name or aliases.
func (*Base) RenderHTML ¶ added in v0.0.12
RenderHTML renders the input to HTML.
func (*Base) RenderInput ¶
RenderInput generates the standard HTML tag for the input.
func (*Base) SetAliases ¶
SetAliases sets the field name aliases for matching.
func (*Base) SetOptions ¶
SetOptions sets multiple options (for select/checkbox/etc).
func (*Base) SetPlaceholder ¶
SetPlaceholder sets the input placeholder.
func (*Base) SetSkipValidation ¶
SetSkipValidation sets whether to skip validation for this input.
func (*Base) ValidateField ¶ added in v0.0.24
ValidateField validates the input value using the embedded Permitted rules. Override this method in specific input structs for custom validation.
type Input ¶
type Input interface {
dom.Component // Includes GetID(), SetID(), RenderHTML(), Children()
HTMLName() string // Standard HTML5 type (e.g., "text", "email")
FieldName() string // Struct field name (without parent prefix)
ValidateField(value string) error // Self-contained validation logic
Clone(parentID, name string) Input // Creates a new instance with given parentID and name
}
Input interface defines the behavior for all form input types. It embeds dom.Component to ensure compatibility with the tinywasm/dom ecosystem.
func Gender ¶
Gender creates a new Gender input instance with default Male/Female options. It is a semantic wrapper around Radio.
type Permitted ¶
type Permitted struct {
Letters bool
Tilde bool
Numbers bool
BreakLine bool // line breaks allowed
WhiteSpaces bool // white spaces allowed
Tabulation bool // tabulation allowed
TextNotAllowed []string // text not allowed eg: "hola" not allowed
Characters []rune // other special characters eg: '\','/','@'
Minimum int // min characters eg 2 "lo" ok default 0 no defined
Maximum int // max characters eg 1 "l" ok default 0 no defined
ExtraValidation func(string) error
StartWith *Permitted // characters allowed at the beginning
}