forms

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrencySymbol

func CurrencySymbol(code string) string

CurrencySymbol returns a display symbol for common ISO codes.

func JoinHTML

func JoinHTML(parts ...string) string

JoinHTML concatenates HTML fragments.

func NumberFormat

func NumberFormat(value float64, locale string, decimals int) string

NumberFormat formats value for display using locale conventions. tr: 1.234,56 — en: 1,234.56

func ParseLocalizedNumber

func ParseLocalizedNumber(raw, locale string) (float64, error)

ParseLocalizedNumber parses a user-typed number for the given locale. Accepts optional currency/percent symbols and spaces.

func RenderMarkdown

func RenderMarkdown(source string) string

RenderMarkdown converts markdown source to HTML.

func ValidateAll

func ValidateAll(fields ...Validatable) bool

ValidateAll runs Validate on every field (no early return) and reports overall success.

Types

type Attrs

type Attrs map[string]string

Attrs is a helper for building HTML attribute strings.

func (Attrs) Set

func (a Attrs) Set(key, value string) Attrs

func (Attrs) SetBool

func (a Attrs) SetBool(key string, on bool) Attrs

func (Attrs) SetInt

func (a Attrs) SetInt(key string, n int) Attrs

func (Attrs) String

func (a Attrs) String() string

type Autocomplete

type Autocomplete struct {
	BaseSelectField
	EventName string
}

Autocomplete shows suggestions for an input; selecting a suggestion sets Value. Typing filters server-side; free text remains in Query until select/commit.

func (*Autocomplete) HandleEvent

func (a *Autocomplete) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*Autocomplete) Mount

func (a *Autocomplete) Mount(_ context.Context) error

func (*Autocomplete) Name

func (a *Autocomplete) Name() string

func (*Autocomplete) RawValue

func (a *Autocomplete) RawValue() string

func (*Autocomplete) Render

func (a *Autocomplete) Render() (string, error)

func (*Autocomplete) SetRawValue

func (a *Autocomplete) SetRawValue(v string)

func (*Autocomplete) Unmount

func (a *Autocomplete) Unmount(_ context.Context) error

func (*Autocomplete) Validate

func (a *Autocomplete) Validate() bool

type AvatarUpload

type AvatarUpload struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Avatar    UploadedRef
	UploadURL string
	EventName string
	OnChange  func(ref UploadedRef)
}

AvatarUpload: pick image → optional client crop (1:1) → upload → store ref.

func (*AvatarUpload) HandleEvent

func (a *AvatarUpload) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*AvatarUpload) Mount

func (a *AvatarUpload) Mount(_ context.Context) error

func (*AvatarUpload) Name

func (a *AvatarUpload) Name() string

func (*AvatarUpload) RawValue

func (a *AvatarUpload) RawValue() string

func (*AvatarUpload) Render

func (a *AvatarUpload) Render() (string, error)

func (*AvatarUpload) SetRawValue

func (a *AvatarUpload) SetRawValue(v string)

func (*AvatarUpload) Unmount

func (a *AvatarUpload) Unmount(_ context.Context) error

func (*AvatarUpload) Validate

func (a *AvatarUpload) Validate() bool

type BaseSelectField

type BaseSelectField struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	// Items is the full source list (or last loaded page from a provider).
	Items []SelectItem
	// Filtered is the list rendered after the last server-side filter pass.
	Filtered []SelectItem

	Query       string
	Open        bool
	Value       string   // single selection
	Values      []string // multi selection (used by later controls)
	FilterMode  FilterMode
	MaxResults  int
	Placeholder string

	OnChange func(value string)
	OnQuery  func(query string)
}

BaseSelectField is shared state for searchable / multi / combobox-style controls.

func (*BaseSelectField) ApplyQuery

func (b *BaseSelectField) ApplyQuery(query string)

ApplyQuery updates Query and recomputes Filtered in Go (server-side default).

func (*BaseSelectField) EnsureFiltered

func (b *BaseSelectField) EnsureFiltered()

EnsureFiltered initializes Filtered from Items when empty (first render).

func (*BaseSelectField) SelectedLabel

func (b *BaseSelectField) SelectedLabel() string

SelectedLabel returns the label for the current single Value.

type Button

type Button struct {
	core.BaseComponent
	CommonAttrs
	Type      string
	Value     string
	Text      string
	Src       string // type=image
	Alt       string
	EventName string // g-click event
}

Button covers type=submit|button|reset|image.

func (*Button) HandleEvent

func (b *Button) HandleEvent(_ context.Context, _ string, _ map[string]any) error

func (*Button) Mount

func (b *Button) Mount(_ context.Context) error

func (*Button) Render

func (b *Button) Render() (string, error)

func (*Button) Unmount

func (b *Button) Unmount(_ context.Context) error

type CalendarDatePicker

type CalendarDatePicker struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Value       string // YYYY-MM-DD
	Min         string
	Max         string
	Open        bool
	Placeholder string
	EventName   string
	OnChange    func(value string)
}

CalendarDatePicker is a visual date picker. Month navigation is client-side (UI-only); the selected YYYY-MM-DD lives on the server.

func (*CalendarDatePicker) HandleEvent

func (c *CalendarDatePicker) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*CalendarDatePicker) Mount

func (*CalendarDatePicker) Name

func (c *CalendarDatePicker) Name() string

func (*CalendarDatePicker) RawValue

func (c *CalendarDatePicker) RawValue() string

func (*CalendarDatePicker) Render

func (c *CalendarDatePicker) Render() (string, error)

func (*CalendarDatePicker) SetRawValue

func (c *CalendarDatePicker) SetRawValue(v string)

func (*CalendarDatePicker) Unmount

func (c *CalendarDatePicker) Unmount(_ context.Context) error

func (*CalendarDatePicker) Validate

func (c *CalendarDatePicker) Validate() bool

type Cascader

type Cascader struct {
	BaseSelectField
	EventName string
	// Levels[0] is root options; deeper levels filled via LoadChildren.
	Levels []CascaderLevel
	// LoadChildren returns child items for a selected parent value at level index.
	LoadChildren func(level int, parentValue string) []SelectItem
}

Cascader loads child options when a parent value is chosen (server-driven).

func (*Cascader) HandleEvent

func (c *Cascader) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*Cascader) Mount

func (c *Cascader) Mount(_ context.Context) error

func (*Cascader) Name

func (c *Cascader) Name() string

func (*Cascader) RawValue

func (c *Cascader) RawValue() string

func (*Cascader) Render

func (c *Cascader) Render() (string, error)

func (*Cascader) SetRawValue

func (c *Cascader) SetRawValue(v string)

func (*Cascader) Unmount

func (c *Cascader) Unmount(_ context.Context) error

func (*Cascader) Validate

func (c *Cascader) Validate() bool

type CascaderLevel

type CascaderLevel struct {
	Items    []SelectItem
	Selected string
}

CascaderLevel is one column in a cascader.

type CheckboxInput

type CheckboxInput = ChoiceInput

CheckboxInput is an alias constructor helper naming for clarity in parent forms.

type ChipsInput

type ChipsInput = TagInput

ChipsInput is an alias highlighting chip presentation of TagInput / MultiSelect values.

type ChoiceInput

type ChoiceInput struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation
	Type      string // checkbox | radio
	Value     string // submitted value when checked
	Checked   bool
	EventName string
	LabelText string // optional adjacent label text (not a separate Label component)
	OnChange  func(checked bool, value string)
}

ChoiceInput covers type=checkbox|radio.

func (*ChoiceInput) HandleEvent

func (c *ChoiceInput) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*ChoiceInput) Mount

func (c *ChoiceInput) Mount(_ context.Context) error

func (*ChoiceInput) Name

func (c *ChoiceInput) Name() string

func (*ChoiceInput) RawValue

func (c *ChoiceInput) RawValue() string

func (*ChoiceInput) Render

func (c *ChoiceInput) Render() (string, error)

func (*ChoiceInput) SetRawValue

func (c *ChoiceInput) SetRawValue(v string)

func (*ChoiceInput) Unmount

func (c *ChoiceInput) Unmount(_ context.Context) error

func (*ChoiceInput) Validate

func (c *ChoiceInput) Validate() bool

type CodeEditor

type CodeEditor struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Value      string
	Language   string // e.g. javascript, go, htmlmixed
	EventName  string
	DebounceMS int
	OnChange   func(value string)
}

CodeEditor stores source text on the server; CodeMirror UI is client-side (CDN). Render is stable (seed empty); initial value via data-initial. Use data-goui-ignore.

func (*CodeEditor) HandleEvent

func (c *CodeEditor) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*CodeEditor) Mount

func (c *CodeEditor) Mount(_ context.Context) error

func (*CodeEditor) Name

func (c *CodeEditor) Name() string

func (*CodeEditor) RawValue

func (c *CodeEditor) RawValue() string

func (*CodeEditor) Render

func (c *CodeEditor) Render() (string, error)

func (*CodeEditor) SetRawValue

func (c *CodeEditor) SetRawValue(v string)

func (*CodeEditor) Unmount

func (c *CodeEditor) Unmount(_ context.Context) error

func (*CodeEditor) Validate

func (c *CodeEditor) Validate() bool

type ColorInput

type ColorInput struct {
	core.BaseComponent
	CommonAttrs
	Value     string
	EventName string
	OnChange  func(newValue string)
}

ColorInput covers type=color.

func (*ColorInput) HandleEvent

func (c *ColorInput) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*ColorInput) Mount

func (c *ColorInput) Mount(_ context.Context) error

func (*ColorInput) Name

func (c *ColorInput) Name() string

func (*ColorInput) RawValue

func (c *ColorInput) RawValue() string

func (*ColorInput) Render

func (c *ColorInput) Render() (string, error)

func (*ColorInput) SetRawValue

func (c *ColorInput) SetRawValue(v string)

func (*ColorInput) Unmount

func (c *ColorInput) Unmount(_ context.Context) error

type Combobox

type Combobox struct {
	BaseSelectField
	EventName string
	// RestrictToList when true rejects free text (Value only from Items).
	RestrictToList bool
}

Combobox is a searchable select that also accepts free-typed values.

func (*Combobox) HandleEvent

func (c *Combobox) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*Combobox) Mount

func (c *Combobox) Mount(_ context.Context) error

func (*Combobox) Name

func (c *Combobox) Name() string

func (*Combobox) RawValue

func (c *Combobox) RawValue() string

func (*Combobox) Render

func (c *Combobox) Render() (string, error)

func (*Combobox) SetRawValue

func (c *Combobox) SetRawValue(v string)

func (*Combobox) Unmount

func (c *Combobox) Unmount(_ context.Context) error

func (*Combobox) Validate

func (c *Combobox) Validate() bool

type CommonAttrs

type CommonAttrs struct {
	ID              string
	Class           string
	Title           string
	TabIndex        *int
	Spellcheck      *bool
	Draggable       *bool
	AriaLabel       string
	AriaDescribedBy string
	Autocomplete    string
	Disabled        bool
	ReadOnly        bool
	Required        bool
	Autofocus       bool
	Name            string
}

CommonAttrs holds HTML attributes shared across most form controls.

func (CommonAttrs) Apply

func (c CommonAttrs) Apply(a Attrs) Attrs

Apply exports common HTML attributes onto attrs (for subpackages).

type CurrencyInput

type CurrencyInput struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Value     float64
	Currency  string // ISO code, default TRY
	Locale    string // default "tr"
	Decimals  int    // default 2 (zero-value → 2)
	Draft     string // raw text while typing; empty → show formatted Value
	EventName string
	OnChange  func(value float64)
}

CurrencyInput stores a float64 amount; display formatting is server-side.

func (*CurrencyInput) HandleEvent

func (c *CurrencyInput) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*CurrencyInput) Mount

func (c *CurrencyInput) Mount(_ context.Context) error

func (*CurrencyInput) Name

func (c *CurrencyInput) Name() string

func (*CurrencyInput) RawValue

func (c *CurrencyInput) RawValue() string

func (*CurrencyInput) Render

func (c *CurrencyInput) Render() (string, error)

func (*CurrencyInput) SetRawValue

func (c *CurrencyInput) SetRawValue(v string)

func (*CurrencyInput) Unmount

func (c *CurrencyInput) Unmount(_ context.Context) error

func (*CurrencyInput) Validate

func (c *CurrencyInput) Validate() bool

type Datalist

type Datalist struct {
	core.BaseComponent
	CommonAttrs
	Options []DatalistOption
}

Datalist provides autocomplete suggestions for an input via list=id.

func (*Datalist) HandleEvent

func (d *Datalist) HandleEvent(_ context.Context, _ string, _ map[string]any) error

func (*Datalist) Mount

func (d *Datalist) Mount(_ context.Context) error

func (*Datalist) Render

func (d *Datalist) Render() (string, error)

func (*Datalist) Unmount

func (d *Datalist) Unmount(_ context.Context) error

type DatalistOption

type DatalistOption struct {
	Value string
	Label string
}

DatalistOption is an option inside a datalist.

type DateRangePicker

type DateRangePicker struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Start     string
	End       string
	Min       string
	Max       string
	EventName string
	OnChange  func(start, end string)
}

DateRangePicker holds start/end dates (YYYY-MM-DD) on the server.

func (*DateRangePicker) HandleEvent

func (d *DateRangePicker) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*DateRangePicker) Mount

func (d *DateRangePicker) Mount(_ context.Context) error

func (*DateRangePicker) Name

func (d *DateRangePicker) Name() string

func (*DateRangePicker) RawValue

func (d *DateRangePicker) RawValue() string

func (*DateRangePicker) Render

func (d *DateRangePicker) Render() (string, error)

func (*DateRangePicker) SetRawValue

func (d *DateRangePicker) SetRawValue(v string)

func (*DateRangePicker) Unmount

func (d *DateRangePicker) Unmount(_ context.Context) error

func (*DateRangePicker) Validate

func (d *DateRangePicker) Validate() bool

type DateTimeInput

type DateTimeInput struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation
	Type      string
	Value     string
	Min       string
	Max       string
	Step      string
	EventName string
	OnChange  func(newValue string)
}

DateTimeInput covers type=date|time|datetime-local|month|week.

func (*DateTimeInput) HandleEvent

func (d *DateTimeInput) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*DateTimeInput) Mount

func (d *DateTimeInput) Mount(_ context.Context) error

func (*DateTimeInput) Name

func (d *DateTimeInput) Name() string

func (*DateTimeInput) RawValue

func (d *DateTimeInput) RawValue() string

func (*DateTimeInput) Render

func (d *DateTimeInput) Render() (string, error)

func (*DateTimeInput) SetRawValue

func (d *DateTimeInput) SetRawValue(v string)

func (*DateTimeInput) Unmount

func (d *DateTimeInput) Unmount(_ context.Context) error

func (*DateTimeInput) Validate

func (d *DateTimeInput) Validate() bool

type DragDropUpload

type DragDropUpload struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Files      []UploadedRef
	Accept     string
	Multiple   bool
	ShowThumbs bool
	UploadURL  string
	EventName  string
	OnChange   func(files []UploadedRef)
}

DragDropUpload collects uploaded file refs (binary via /goui/upload, refs via WS).

func NewImageUpload

func NewImageUpload(name, event string) DragDropUpload

ImageUpload is a DragDropUpload preset for images with thumbnails.

func (*DragDropUpload) HandleEvent

func (d *DragDropUpload) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*DragDropUpload) Mount

func (d *DragDropUpload) Mount(_ context.Context) error

func (*DragDropUpload) Name

func (d *DragDropUpload) Name() string

func (*DragDropUpload) RawValue

func (d *DragDropUpload) RawValue() string

func (*DragDropUpload) Render

func (d *DragDropUpload) Render() (string, error)

func (*DragDropUpload) SetRawValue

func (d *DragDropUpload) SetRawValue(v string)

func (*DragDropUpload) Unmount

func (d *DragDropUpload) Unmount(_ context.Context) error

func (*DragDropUpload) Validate

func (d *DragDropUpload) Validate() bool

type DualListbox

type DualListbox struct {
	BaseSelectField
	EventName      string
	SelectedQuery  string
	SelectedFilter []SelectItem // filtered view of selected side
}

DualListbox moves items between available and selected lists (server-owned). Filtering on both sides is server-side by default (ApplyQuery / ApplySelectedQuery).

func (*DualListbox) ApplyAvailableQuery

func (d *DualListbox) ApplyAvailableQuery(query string)

ApplyAvailableQuery filters the left (available) list server-side.

func (*DualListbox) ApplySelectedQuery

func (d *DualListbox) ApplySelectedQuery(query string)

ApplySelectedQuery filters the right (selected) list server-side.

func (*DualListbox) HandleEvent

func (d *DualListbox) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*DualListbox) Mount

func (d *DualListbox) Mount(_ context.Context) error

func (*DualListbox) Name

func (d *DualListbox) Name() string

func (*DualListbox) RawValue

func (d *DualListbox) RawValue() string

func (*DualListbox) Render

func (d *DualListbox) Render() (string, error)

func (*DualListbox) SetRawValue

func (d *DualListbox) SetRawValue(v string)

func (*DualListbox) Unmount

func (d *DualListbox) Unmount(_ context.Context) error

func (*DualListbox) Validate

func (d *DualListbox) Validate() bool

type FieldValidation

type FieldValidation struct {
	Rules  []validation.Rule
	Errors []string
}

FieldValidation holds rules and translated error messages for a field.

func (*FieldValidation) ApplyErrorState

func (f *FieldValidation) ApplyErrorState(attrs Attrs, baseClass string) Attrs

ApplyErrorState marks invalid visual state on attrs (for subpackages).

func (*FieldValidation) ErrorsHTML

func (f *FieldValidation) ErrorsHTML() string

ErrorsHTML renders translated field errors (for subpackages).

func (*FieldValidation) Run

func (f *FieldValidation) Run(value string, translate func(key string, args ...any) string) bool

Run validates value and fills Errors with translated messages (for subpackages).

type FieldValue

type FieldValue interface {
	Name() string
	RawValue() string
	SetRawValue(string)
}

FieldValue is the shared value contract for form fields.

type Fieldset

type Fieldset struct {
	core.BaseComponent
	CommonAttrs
	InnerHTML string
}

Fieldset groups related controls.

func (*Fieldset) HandleEvent

func (f *Fieldset) HandleEvent(_ context.Context, _ string, _ map[string]any) error

func (*Fieldset) Mount

func (f *Fieldset) Mount(_ context.Context) error

func (*Fieldset) Render

func (f *Fieldset) Render() (string, error)

func (*Fieldset) Unmount

func (f *Fieldset) Unmount(_ context.Context) error

type FileInput

type FileInput struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation
	Accept    string
	Capture   string
	Multiple  bool
	EventName string
	OnChange  func(fileNames string)
	// Value holds last selected file name(s) for display/state (actual upload is later phase).
	Value string
}

FileInput covers type=file.

func (*FileInput) HandleEvent

func (f *FileInput) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*FileInput) Mount

func (f *FileInput) Mount(_ context.Context) error

func (*FileInput) Name

func (f *FileInput) Name() string

func (*FileInput) RawValue

func (f *FileInput) RawValue() string

func (*FileInput) Render

func (f *FileInput) Render() (string, error)

func (*FileInput) SetRawValue

func (f *FileInput) SetRawValue(v string)

func (*FileInput) Unmount

func (f *FileInput) Unmount(_ context.Context) error

func (*FileInput) Validate

func (f *FileInput) Validate() bool

type FilterMode

type FilterMode int

FilterMode controls where list filtering runs.

const (
	// FilterServer filters in Go on query events (default).
	FilterServer FilterMode = iota
	// FilterClient is allowed only for small fixed lists; server still owns selection state.
	FilterClient
)

type Form

type Form struct {
	core.BaseComponent
	CommonAttrs
	Action    string
	Method    string
	EncType   string
	InnerHTML string
	OnSubmit  string // g-submit event name
}

Form is a container for form fields.

func (*Form) HandleEvent

func (f *Form) HandleEvent(_ context.Context, _ string, _ map[string]any) error

func (*Form) Mount

func (f *Form) Mount(_ context.Context) error

func (*Form) Render

func (f *Form) Render() (string, error)

func (*Form) Unmount

func (f *Form) Unmount(_ context.Context) error

type GradientPicker

type GradientPicker struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	From      string
	To        string
	Angle     string // e.g. "135deg"
	EventName string
	OnChange  func(css string)
}

GradientPicker builds a simple CSS linear-gradient from two stops + angle.

func (*GradientPicker) CSS

func (g *GradientPicker) CSS() string

func (*GradientPicker) HandleEvent

func (g *GradientPicker) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*GradientPicker) Mount

func (g *GradientPicker) Mount(_ context.Context) error

func (*GradientPicker) Name

func (g *GradientPicker) Name() string

func (*GradientPicker) RawValue

func (g *GradientPicker) RawValue() string

func (*GradientPicker) Render

func (g *GradientPicker) Render() (string, error)

func (*GradientPicker) SetRawValue

func (g *GradientPicker) SetRawValue(v string)

func (*GradientPicker) Unmount

func (g *GradientPicker) Unmount(_ context.Context) error

func (*GradientPicker) Validate

func (g *GradientPicker) Validate() bool

type HiddenInput

type HiddenInput struct {
	core.BaseComponent
	CommonAttrs
	Value string
}

HiddenInput covers type=hidden.

func (*HiddenInput) HandleEvent

func (h *HiddenInput) HandleEvent(_ context.Context, _ string, _ map[string]any) error

func (*HiddenInput) Mount

func (h *HiddenInput) Mount(_ context.Context) error

func (*HiddenInput) Name

func (h *HiddenInput) Name() string

func (*HiddenInput) RawValue

func (h *HiddenInput) RawValue() string

func (*HiddenInput) Render

func (h *HiddenInput) Render() (string, error)

func (*HiddenInput) SetRawValue

func (h *HiddenInput) SetRawValue(v string)

func (*HiddenInput) Unmount

func (h *HiddenInput) Unmount(_ context.Context) error

type Label

type Label struct {
	core.BaseComponent
	CommonAttrs
	For  string
	Text string
}

Label associates text with a control.

func (*Label) HandleEvent

func (l *Label) HandleEvent(_ context.Context, _ string, _ map[string]any) error

func (*Label) Mount

func (l *Label) Mount(_ context.Context) error

func (*Label) Render

func (l *Label) Render() (string, error)

func (*Label) Unmount

func (l *Label) Unmount(_ context.Context) error

type Legend

type Legend struct {
	core.BaseComponent
	CommonAttrs
	Text string
}

Legend is a fieldset caption.

func (*Legend) HandleEvent

func (l *Legend) HandleEvent(_ context.Context, _ string, _ map[string]any) error

func (*Legend) Mount

func (l *Legend) Mount(_ context.Context) error

func (*Legend) Render

func (l *Legend) Render() (string, error)

func (*Legend) Unmount

func (l *Legend) Unmount(_ context.Context) error

type MarkdownEditor

type MarkdownEditor struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Value       string
	PreviewHTML string
	Rows        int
	Placeholder string
	EventName   string
	DebounceMS  int
	OnChange    func(value string)
}

MarkdownEditor is a textarea + server-rendered live preview (goldmark).

func (*MarkdownEditor) HandleEvent

func (m *MarkdownEditor) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*MarkdownEditor) Mount

func (m *MarkdownEditor) Mount(_ context.Context) error

func (*MarkdownEditor) Name

func (m *MarkdownEditor) Name() string

func (*MarkdownEditor) RawValue

func (m *MarkdownEditor) RawValue() string

func (*MarkdownEditor) Render

func (m *MarkdownEditor) Render() (string, error)

func (*MarkdownEditor) SetRawValue

func (m *MarkdownEditor) SetRawValue(v string)

func (*MarkdownEditor) Unmount

func (m *MarkdownEditor) Unmount(_ context.Context) error

func (*MarkdownEditor) Validate

func (m *MarkdownEditor) Validate() bool

type MentionTextarea

type MentionTextarea struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Value       string
	Placeholder string
	Rows        int
	Users       []MentionUser // full directory
	Filtered    []MentionUser
	Query       string // text after @
	Open        bool
	EventName   string
	OnChange    func(value string)
}

MentionTextarea is a textarea that opens an @mention suggestion list (server-filtered).

func (*MentionTextarea) HandleEvent

func (m *MentionTextarea) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*MentionTextarea) Mount

func (m *MentionTextarea) Mount(_ context.Context) error

func (*MentionTextarea) Name

func (m *MentionTextarea) Name() string

func (*MentionTextarea) RawValue

func (m *MentionTextarea) RawValue() string

func (*MentionTextarea) Render

func (m *MentionTextarea) Render() (string, error)

func (*MentionTextarea) SetRawValue

func (m *MentionTextarea) SetRawValue(v string)

func (*MentionTextarea) Unmount

func (m *MentionTextarea) Unmount(_ context.Context) error

func (*MentionTextarea) Validate

func (m *MentionTextarea) Validate() bool

type MentionUser

type MentionUser struct {
	ID    string
	Label string
}

MentionUser is one @mention candidate.

type Meter

type Meter struct {
	core.BaseComponent
	CommonAttrs
	Value   float64
	Min     float64
	Max     float64
	Low     float64
	High    float64
	Optimum float64
}

Meter represents a scalar measurement within a known range.

func (*Meter) HandleEvent

func (m *Meter) HandleEvent(_ context.Context, _ string, _ map[string]any) error

func (*Meter) Mount

func (m *Meter) Mount(_ context.Context) error

func (*Meter) Render

func (m *Meter) Render() (string, error)

func (*Meter) Unmount

func (m *Meter) Unmount(_ context.Context) error

type MultiSelect

type MultiSelect struct {
	BaseSelectField
	EventName string
}

MultiSelect allows selecting multiple values with server-side search.

func (*MultiSelect) HandleEvent

func (m *MultiSelect) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*MultiSelect) Mount

func (m *MultiSelect) Mount(_ context.Context) error

func (*MultiSelect) Name

func (m *MultiSelect) Name() string

func (*MultiSelect) RawValue

func (m *MultiSelect) RawValue() string

func (*MultiSelect) Render

func (m *MultiSelect) Render() (string, error)

func (*MultiSelect) SetRawValue

func (m *MultiSelect) SetRawValue(v string)

func (*MultiSelect) Unmount

func (m *MultiSelect) Unmount(_ context.Context) error

func (*MultiSelect) Validate

func (m *MultiSelect) Validate() bool

type NumericInput

type NumericInput struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation
	Type      string
	Value     string
	Min       string
	Max       string
	Step      string
	EventName string
	OnChange  func(newValue string)
}

NumericInput covers type=number|range.

func (*NumericInput) HandleEvent

func (n *NumericInput) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*NumericInput) Mount

func (n *NumericInput) Mount(_ context.Context) error

func (*NumericInput) Name

func (n *NumericInput) Name() string

func (*NumericInput) RawValue

func (n *NumericInput) RawValue() string

func (*NumericInput) Render

func (n *NumericInput) Render() (string, error)

func (*NumericInput) SetRawValue

func (n *NumericInput) SetRawValue(v string)

func (*NumericInput) Unmount

func (n *NumericInput) Unmount(_ context.Context) error

func (*NumericInput) Validate

func (n *NumericInput) Validate() bool

type OTPInput

type OTPInput struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Length    int // default 6
	Value     string
	Masked    bool // password-style cells (PIN)
	EventName string
	OnChange  func(value string)
}

OTPInput is N single-character boxes; combined Value lives on the server.

func (*OTPInput) HandleEvent

func (o *OTPInput) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*OTPInput) Mount

func (o *OTPInput) Mount(_ context.Context) error

func (*OTPInput) Name

func (o *OTPInput) Name() string

func (*OTPInput) RawValue

func (o *OTPInput) RawValue() string

func (*OTPInput) Render

func (o *OTPInput) Render() (string, error)

func (*OTPInput) SetRawValue

func (o *OTPInput) SetRawValue(v string)

func (*OTPInput) Unmount

func (o *OTPInput) Unmount(_ context.Context) error

func (*OTPInput) Validate

func (o *OTPInput) Validate() bool

type Optgroup

type Optgroup struct {
	Label    string
	Disabled bool
	Options  []Option
}

Optgroup groups options.

type Option

type Option struct {
	Value    string
	Label    string
	Selected bool
	Disabled bool
}

Option is a select option.

type Output

type Output struct {
	core.BaseComponent
	CommonAttrs
	For   string
	Form  string
	Value string
	Text  string
}

Output displays a calculation result.

func (*Output) HandleEvent

func (o *Output) HandleEvent(_ context.Context, _ string, _ map[string]any) error

func (*Output) Mount

func (o *Output) Mount(_ context.Context) error

func (*Output) Name

func (o *Output) Name() string

func (*Output) RawValue

func (o *Output) RawValue() string

func (*Output) Render

func (o *Output) Render() (string, error)

func (*Output) SetRawValue

func (o *Output) SetRawValue(v string)

func (*Output) Unmount

func (o *Output) Unmount(_ context.Context) error

type PINInput

type PINInput = OTPInput

PINInput is an alias; set Masked: true for PIN UX.

type PasswordStrengthLevel

type PasswordStrengthLevel int

PasswordStrengthLevel is a 0–4 score (empty → weak → fair → good → strong).

const (
	StrengthEmpty PasswordStrengthLevel = iota
	StrengthWeak
	StrengthFair
	StrengthGood
	StrengthStrong
)

func PasswordStrength

func PasswordStrength(password string) PasswordStrengthLevel

PasswordStrength scores a password with simple server-side heuristics.

func (PasswordStrengthLevel) CSSClass

func (l PasswordStrengthLevel) CSSClass() string

func (PasswordStrengthLevel) LabelKey

func (l PasswordStrengthLevel) LabelKey() string

type PercentageInput

type PercentageInput struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Value     float64
	Locale    string
	Decimals  int // default 1
	Min       *float64
	Max       *float64
	Draft     string
	EventName string
	OnChange  func(value float64)
}

PercentageInput stores percentage points (e.g. 45.5 means 45,5%). Display formatting is server-side (locale-aware).

func (*PercentageInput) HandleEvent

func (p *PercentageInput) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*PercentageInput) Mount

func (p *PercentageInput) Mount(_ context.Context) error

func (*PercentageInput) Name

func (p *PercentageInput) Name() string

func (*PercentageInput) RawValue

func (p *PercentageInput) RawValue() string

func (*PercentageInput) Render

func (p *PercentageInput) Render() (string, error)

func (*PercentageInput) SetRawValue

func (p *PercentageInput) SetRawValue(v string)

func (*PercentageInput) Unmount

func (p *PercentageInput) Unmount(_ context.Context) error

func (*PercentageInput) Validate

func (p *PercentageInput) Validate() bool

type PhoneInput

type PhoneInput struct {
	CommonAttrs
	FieldValidation

	Dial   SearchableSelect
	Number TextInput
}

PhoneInput composes a dial-code SearchableSelect + national number TextInput. Not a separate control family — wiring helper for Alt-Grup F.

func NewPhoneInput

func NewPhoneInput(name string) *PhoneInput

func (*PhoneInput) HandleEvent

func (p *PhoneInput) HandleEvent(ctx context.Context, event string, payload map[string]any) error

func (*PhoneInput) Name

func (p *PhoneInput) Name() string

func (*PhoneInput) RawValue

func (p *PhoneInput) RawValue() string

func (*PhoneInput) Render

func (p *PhoneInput) Render() (string, error)

func (*PhoneInput) SetRawValue

func (p *PhoneInput) SetRawValue(v string)

func (*PhoneInput) Validate

func (p *PhoneInput) Validate() bool

type Progress

type Progress struct {
	core.BaseComponent
	CommonAttrs
	Value float64
	Max   float64
}

Progress represents task completion.

func (*Progress) HandleEvent

func (p *Progress) HandleEvent(_ context.Context, _ string, _ map[string]any) error

func (*Progress) Mount

func (p *Progress) Mount(_ context.Context) error

func (*Progress) Render

func (p *Progress) Render() (string, error)

func (*Progress) Unmount

func (p *Progress) Unmount(_ context.Context) error

type RadioInput

type RadioInput = ChoiceInput

RadioInput is an alias for radio-typed ChoiceInput.

type Rating

type Rating struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Value     int    // 0..Max
	Max       int    // default 5
	Icon      string // default ★
	EmptyIcon string // default ☆
	EventName string
	OnChange  func(value int)
}

Rating is an N-star (or custom icon) control; selection lives on the server.

func (*Rating) HandleEvent

func (r *Rating) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*Rating) Mount

func (r *Rating) Mount(_ context.Context) error

func (*Rating) Name

func (r *Rating) Name() string

func (*Rating) RawValue

func (r *Rating) RawValue() string

func (*Rating) Render

func (r *Rating) Render() (string, error)

func (*Rating) SetRawValue

func (r *Rating) SetRawValue(v string)

func (*Rating) Unmount

func (r *Rating) Unmount(_ context.Context) error

func (*Rating) Validate

func (r *Rating) Validate() bool

type RichTextEditor

type RichTextEditor struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Value      string // HTML
	EventName  string
	DebounceMS int
	OnChange   func(value string)
}

RichTextEditor stores HTML content on the server; Quill UI is client-side (CDN). Render output is intentionally stable (no live Value in the DOM) so patches do not remount Quill; use data-goui-ignore + ErrSkipRender on sync events.

func (*RichTextEditor) HandleEvent

func (r *RichTextEditor) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*RichTextEditor) Mount

func (r *RichTextEditor) Mount(_ context.Context) error

func (*RichTextEditor) Name

func (r *RichTextEditor) Name() string

func (*RichTextEditor) RawValue

func (r *RichTextEditor) RawValue() string

func (*RichTextEditor) Render

func (r *RichTextEditor) Render() (string, error)

func (*RichTextEditor) SetRawValue

func (r *RichTextEditor) SetRawValue(v string)

func (*RichTextEditor) Unmount

func (r *RichTextEditor) Unmount(_ context.Context) error

func (*RichTextEditor) Validate

func (r *RichTextEditor) Validate() bool

type SearchableSelect

type SearchableSelect struct {
	BaseSelectField
	EventName string // prefix for events, e.g. "city" → city.query / city.select
}

SearchableSelect is a single-select control with server-side search filtering.

func NewCountryPicker

func NewCountryPicker(name, event string) SearchableSelect

NewCountryPicker returns a SearchableSelect preloaded with CountryItems.

func NewCurrencyPicker

func NewCurrencyPicker(name, event string) SearchableSelect

NewCurrencyPicker returns a SearchableSelect preloaded with CurrencyItems.

func NewEmojiPicker

func NewEmojiPicker(name, event string) SearchableSelect

func NewFontPicker

func NewFontPicker(name, event string) SearchableSelect

func NewIconPicker

func NewIconPicker(name, event string) SearchableSelect

func NewLanguagePicker

func NewLanguagePicker(name, event string) SearchableSelect

NewLanguagePicker returns a SearchableSelect preloaded with LanguageItems.

func NewTimezonePicker

func NewTimezonePicker(name, event string) SearchableSelect

NewTimezonePicker returns a SearchableSelect preloaded with TimezoneItems.

func (*SearchableSelect) HandleEvent

func (s *SearchableSelect) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*SearchableSelect) Mount

func (s *SearchableSelect) Mount(_ context.Context) error

func (*SearchableSelect) Name

func (s *SearchableSelect) Name() string

func (*SearchableSelect) RawValue

func (s *SearchableSelect) RawValue() string

func (*SearchableSelect) Render

func (s *SearchableSelect) Render() (string, error)

func (*SearchableSelect) SetRawValue

func (s *SearchableSelect) SetRawValue(v string)

func (*SearchableSelect) Unmount

func (s *SearchableSelect) Unmount(_ context.Context) error

func (*SearchableSelect) Validate

func (s *SearchableSelect) Validate() bool

type Select

type Select struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation
	Value     string
	Multiple  bool
	Size      int
	Options   []Option
	Groups    []Optgroup
	EventName string
	OnChange  func(newValue string)
}

Select is a dropdown control.

func (*Select) HandleEvent

func (s *Select) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*Select) Mount

func (s *Select) Mount(_ context.Context) error

func (*Select) Name

func (s *Select) Name() string

func (*Select) RawValue

func (s *Select) RawValue() string

func (*Select) Render

func (s *Select) Render() (string, error)

func (*Select) SetRawValue

func (s *Select) SetRawValue(v string)

func (*Select) Unmount

func (s *Select) Unmount(_ context.Context) error

func (*Select) Validate

func (s *Select) Validate() bool

type SelectItem

type SelectItem struct {
	Value    string
	Label    string
	Disabled bool
}

SelectItem is one option in an advanced select list.

func CountryItems

func CountryItems() []SelectItem

CountryItems returns a curated ISO country list for SearchableSelect.

func CurrencyItems

func CurrencyItems() []SelectItem

CurrencyItems returns common ISO currency codes.

func DialCodeItems

func DialCodeItems() []SelectItem

DialCodeItems maps country ISO → phone dial code for PhoneInput.

func EmojiItems

func EmojiItems() []SelectItem

EmojiItems curated emoji set for SearchableSelect.

func FilterItems

func FilterItems(items []SelectItem, query string, limit int) []SelectItem

FilterItems performs case-insensitive substring match on label/value (server-side).

func FontItems

func FontItems() []SelectItem

FontItems common web-safe / system font stacks.

func IconItems

func IconItems() []SelectItem

IconItems simple symbol icons (no icon font dependency).

func LanguageItems

func LanguageItems() []SelectItem

LanguageItems returns common language codes.

func MentionUsers

func MentionUsers() []SelectItem

MentionUsers sample @mention directory.

func TimezoneItems

func TimezoneItems() []SelectItem

TimezoneItems returns common IANA time zones.

type SignaturePad

type SignaturePad struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	File      UploadedRef
	UploadURL string
	EventName string
	OnChange  func(ref UploadedRef)
}

SignaturePad captures a drawn signature; client uploads PNG then notifies via WS.

func (*SignaturePad) HandleEvent

func (s *SignaturePad) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*SignaturePad) Mount

func (s *SignaturePad) Mount(_ context.Context) error

func (*SignaturePad) Name

func (s *SignaturePad) Name() string

func (*SignaturePad) RawValue

func (s *SignaturePad) RawValue() string

func (*SignaturePad) Render

func (s *SignaturePad) Render() (string, error)

func (*SignaturePad) SetRawValue

func (s *SignaturePad) SetRawValue(v string)

func (*SignaturePad) Unmount

func (s *SignaturePad) Unmount(_ context.Context) error

func (*SignaturePad) Validate

func (s *SignaturePad) Validate() bool

type SwatchColorPicker

type SwatchColorPicker struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Value     string // #rrggbb
	Swatches  []string
	EventName string
	OnChange  func(value string)
}

SwatchColorPicker is an advanced palette + hex field (beyond native type=color).

func (*SwatchColorPicker) HandleEvent

func (c *SwatchColorPicker) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*SwatchColorPicker) Mount

func (c *SwatchColorPicker) Mount(_ context.Context) error

func (*SwatchColorPicker) Name

func (c *SwatchColorPicker) Name() string

func (*SwatchColorPicker) RawValue

func (c *SwatchColorPicker) RawValue() string

func (*SwatchColorPicker) Render

func (c *SwatchColorPicker) Render() (string, error)

func (*SwatchColorPicker) SetRawValue

func (c *SwatchColorPicker) SetRawValue(v string)

func (*SwatchColorPicker) Unmount

func (c *SwatchColorPicker) Unmount(_ context.Context) error

func (*SwatchColorPicker) Validate

func (c *SwatchColorPicker) Validate() bool

type TagInput

type TagInput struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Values      []string
	Draft       string
	Placeholder string
	EventName   string
	OnChange    func(tags []string)
}

TagInput collects free-text tags; Values live on the server.

func (*TagInput) HandleEvent

func (t *TagInput) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*TagInput) Mount

func (t *TagInput) Mount(_ context.Context) error

func (*TagInput) Name

func (t *TagInput) Name() string

func (*TagInput) RawValue

func (t *TagInput) RawValue() string

func (*TagInput) Render

func (t *TagInput) Render() (string, error)

func (*TagInput) SetRawValue

func (t *TagInput) SetRawValue(v string)

func (*TagInput) Unmount

func (t *TagInput) Unmount(_ context.Context) error

func (*TagInput) Validate

func (t *TagInput) Validate() bool

type TextInput

type TextInput struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation
	Type          string
	Value         string
	Placeholder   string
	MinLength     int
	MaxLength     int
	Pattern       string
	Size          int
	Multiple      bool // email
	List          string
	EventName     string // g-change / g-input event name (defaults to Name)
	DebounceMS    int
	OnChange      func(newValue string)
	ShowCharCount bool
	ShowStrength  bool   // password strength meter (server-side)
	HelperText    string // hint below the field
}

TextInput covers type=text|password|email|search|tel|url.

func (*TextInput) HandleEvent

func (t *TextInput) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*TextInput) Mount

func (t *TextInput) Mount(_ context.Context) error

func (*TextInput) Name

func (t *TextInput) Name() string

func (*TextInput) RawValue

func (t *TextInput) RawValue() string

func (*TextInput) Render

func (t *TextInput) Render() (string, error)

func (*TextInput) SetRawValue

func (t *TextInput) SetRawValue(v string)

func (*TextInput) Unmount

func (t *TextInput) Unmount(_ context.Context) error

func (*TextInput) Validate

func (t *TextInput) Validate() bool

type Textarea

type Textarea struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation
	Value         string
	Placeholder   string
	Rows          int
	Cols          int
	Wrap          string
	MinLength     int
	MaxLength     int
	EventName     string
	DebounceMS    int
	OnChange      func(newValue string)
	ShowCharCount bool
	HelperText    string
}

Textarea is a multi-line text control.

func (*Textarea) HandleEvent

func (t *Textarea) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*Textarea) Mount

func (t *Textarea) Mount(_ context.Context) error

func (*Textarea) Name

func (t *Textarea) Name() string

func (*Textarea) RawValue

func (t *Textarea) RawValue() string

func (*Textarea) Render

func (t *Textarea) Render() (string, error)

func (*Textarea) SetRawValue

func (t *Textarea) SetRawValue(v string)

func (*Textarea) Unmount

func (t *Textarea) Unmount(_ context.Context) error

func (*Textarea) Validate

func (t *Textarea) Validate() bool

type TimeRangePicker

type TimeRangePicker struct {
	core.BaseComponent
	CommonAttrs
	FieldValidation

	Start     string
	End       string
	Min       string
	Max       string
	Step      string
	EventName string
	OnChange  func(start, end string)
}

TimeRangePicker holds start/end times (HH:MM) on the server.

func (*TimeRangePicker) HandleEvent

func (t *TimeRangePicker) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*TimeRangePicker) Mount

func (t *TimeRangePicker) Mount(_ context.Context) error

func (*TimeRangePicker) Name

func (t *TimeRangePicker) Name() string

func (*TimeRangePicker) RawValue

func (t *TimeRangePicker) RawValue() string

func (*TimeRangePicker) Render

func (t *TimeRangePicker) Render() (string, error)

func (*TimeRangePicker) SetRawValue

func (t *TimeRangePicker) SetRawValue(v string)

func (*TimeRangePicker) Unmount

func (t *TimeRangePicker) Unmount(_ context.Context) error

func (*TimeRangePicker) Validate

func (t *TimeRangePicker) Validate() bool

type TreeNode

type TreeNode struct {
	Value    string
	Label    string
	Disabled bool
	Children []TreeNode
}

TreeNode is a hierarchical selectable item.

type TreeSelect

type TreeSelect struct {
	BaseSelectField
	Nodes     []TreeNode
	Expanded  map[string]bool
	EventName string
}

TreeSelect selects a single node from a tree (server expands/collapses).

func (*TreeSelect) HandleEvent

func (t *TreeSelect) HandleEvent(_ context.Context, event string, payload map[string]any) error

func (*TreeSelect) Mount

func (t *TreeSelect) Mount(_ context.Context) error

func (*TreeSelect) Name

func (t *TreeSelect) Name() string

func (*TreeSelect) RawValue

func (t *TreeSelect) RawValue() string

func (*TreeSelect) Render

func (t *TreeSelect) Render() (string, error)

func (*TreeSelect) SetRawValue

func (t *TreeSelect) SetRawValue(v string)

func (*TreeSelect) Unmount

func (t *TreeSelect) Unmount(_ context.Context) error

func (*TreeSelect) Validate

func (t *TreeSelect) Validate() bool

type UploadedRef

type UploadedRef struct {
	ID          string
	Name        string
	URL         string
	ContentType string
	Size        int64
}

UploadedRef is server-side metadata after HTTP upload completes.

type Validatable

type Validatable interface {
	Validate() bool
}

Validatable is implemented by form fields that support server-side validation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL