forms

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	HeaderLevelHeader          = 0
	HeaderLevelSubheader       = 1
	HeaderLevelSubsubheader    = 2
	HeaderLevelSubsubsubheader = 3
)
View Source
const (
	DateTimeLocalInputTimeFormat = "2006-01-02T15:04"
)

Variables

View Source
var (
	ErrRequired = errors.New("Required")
	ErrTooShort = errors.New("Too short")
	ErrTooLong  = errors.New("Too long")
)

Functions

func Add added in v0.2.2

func Add[T Child](container ChildAdder, child T) T

func ErrorStr added in v0.3.2

func ErrorStr(err error) string

func JoinNames added in v0.2.0

func JoinNames(path ...string) string

func SplitName added in v0.2.0

func SplitName(name string) []string

func StatusCode added in v0.2.2

func StatusCode(isSaving bool) int

func Validate added in v0.2.2

func Validate[T, R any](errs ErrorSet, key string, value T, f func(value T, reqs R) (T, error), reqs R) T

func ValidateString added in v0.2.2

func ValidateString(s string, reqs StringRequirements) (string, error)

Types

type AnyBinding

type AnyBinding interface {
	Init(errs ErrorSite)
}

type Binding

type Binding[T any] struct {
	Getter     func() T
	Setter     func(value T) error
	Validators []Validator[T]
	ErrSite    ErrorSite
	Child      AnyBinding
}

func AnyCast added in v0.2.2

func AnyCast[T any](b *Binding[any]) *Binding[T]

func AnyCastZeroToNil added in v0.2.2

func AnyCastZeroToNil[T comparable](b *Binding[any]) *Binding[T]

func BindField added in v0.2.2

func BindField[T, S any](b *Binding[S], field func(src *S) *T) *Binding[T]

func BindJSONObjectKeyWithDefault added in v0.2.2

func BindJSONObjectKeyWithDefault[T any](m map[string]any, key string, defaultValue T) *Binding[T]

func BindMapKey added in v0.2.0

func BindMapKey[T any, K comparable](m map[K]T, key K) *Binding[T]

func BindMapKeyDeletingZeros added in v0.2.2

func BindMapKeyDeletingZeros[T comparable, K comparable](m map[K]T, key K) *Binding[T]

func BindMapKeyWithDefault added in v0.2.2

func BindMapKeyWithDefault[T any, K comparable](m map[K]T, key K, defaultValue T) *Binding[T]

func BindNot added in v0.2.0

func BindNot(b *Binding[bool]) *Binding[bool]

func BindSliceContainsEl added in v0.2.0

func BindSliceContainsEl[T comparable](b *Binding[[]T], el T) *Binding[bool]

func BindSliceEmptyOrSingle added in v0.2.0

func BindSliceEmptyOrSingle[T comparable](b *Binding[[]T], emptyValue T) *Binding[T]

func BindUniqueList added in v0.3.7

func BindUniqueList[T comparable](b *Binding[[]T]) *Binding[[]T]

func Const

func Const[T any](value T) *Binding[T]

func Convert

func Convert[T, S any](b *Binding[S], stringer func(S) T, convert func(T) (S, error)) *Binding[T]

func ConvertStringFields added in v0.2.2

func ConvertStringFields(b *Binding[[]string], sep rune) *Binding[string]

func ConvertStringifiedFields added in v0.3.2

func ConvertStringifiedFields[T any](b *Binding[[]T], sep rune, stringify func(T) string, parse func(s string) (T, error)) *Binding[string]

func ConvertStringifiedList added in v0.3.2

func ConvertStringifiedList[T any](source *Binding[[]T], stringify func(T) string, parse func(s string) (T, error)) *Binding[[]string]

func Int64AsString added in v0.2.0

func Int64AsString(b *Binding[int64], opts ...any) *Binding[string]

func IntAsString added in v0.2.0

func IntAsString(b *Binding[int], opts ...any) *Binding[string]

func Var

func Var[T any](ptr *T) *Binding[T]

func (*Binding[T]) AsString

func (b *Binding[T]) AsString(stringer func(T) string, convert func(string) (T, error)) *Binding[string]

func (*Binding[T]) EnumBindings

func (b *Binding[T]) EnumBindings(f func(AnyBinding))

EnumBindings in Binding simplifies implementation of Processors that embed a Binding.

func (*Binding[T]) Init

func (b *Binding[T]) Init(errs ErrorSite)

func (*Binding[T]) Set

func (b *Binding[T]) Set(value T)

func (*Binding[T]) SetString

func (b *Binding[T]) SetString(str string, convert func(string) (T, error))

func (*Binding[T]) Validate

func (b *Binding[T]) Validate(validators ...Validator[T]) *Binding[T]

func (*Binding[T]) Value

func (b *Binding[T]) Value() T

type Button

type Button struct {
	RenderableImpl[Button]
	Template
	TemplateStyle
	Identity
	TagOpts
	Action     string
	FullAction string
	Activated  bool
	Title      string
	Handler    func()

	ConfirmationMessage string
}

func (Button) DefaultTemplate

func (Button) DefaultTemplate() string

func (*Button) EnumBindings

func (c *Button) EnumBindings(f func(AnyBinding))

func (*Button) EnumFields added in v0.2.2

func (c *Button) EnumFields(f func(name string, field *Field))

func (*Button) Finalize

func (c *Button) Finalize(state *State)

func (*Button) Process

func (c *Button) Process(fd *FormData)

type Checkbox

type Checkbox struct {
	RenderableImpl[Checkbox]
	Template
	TemplateStyle
	Field
	TagOpts
	*Binding[bool]
	UpdateFormOnChange bool
	GuardOptional      bool
	GuardIdentity      Identity
}

func (Checkbox) DefaultTemplate

func (Checkbox) DefaultTemplate() string

func (*Checkbox) Finalize

func (c *Checkbox) Finalize(state *State)

func (*Checkbox) Process

func (c *Checkbox) Process(data *FormData)

type CheckboxWithLabel added in v0.3.0

type CheckboxWithLabel struct {
	Checkbox
	Label any
}

func (CheckboxWithLabel) DefaultTemplate added in v0.3.0

func (CheckboxWithLabel) DefaultTemplate() string

type Child

type Child interface {
	Finalize(state *State)
}

func AsChild added in v0.2.2

func AsChild(children ...Child) Child

func RawHTML added in v0.3.8

func RawHTML(html template.HTML) Child

type ChildAdder added in v0.2.2

type ChildAdder interface {
	AddChild(c ...Child)
}

type ChildFlags added in v0.2.2

type ChildFlags uint64
const (
	ChildFlagSkipProcessing ChildFlags = 1 << iota
)

type Children

type Children []Child

func (*Children) Add added in v0.2.0

func (cc *Children) Add(c ...Child)

func (*Children) AddChild added in v0.2.2

func (cc *Children) AddChild(c ...Child)

func (Children) EnumChildren

func (cc Children) EnumChildren(f func(Child, ChildFlags))

func (Children) Finalize

func (cc Children) Finalize(state *State)

type Container

type Container interface {
	Child
	EnumChildren(f func(Child, ChildFlags))
}

type CustomRenderable added in v0.2.2

type CustomRenderable interface {
	Renderable
	RenderInto(buf *strings.Builder, r *Renderer)
}

type ErrorSet added in v0.2.2

type ErrorSet struct {
	// contains filtered or unexported fields
}

func NewErrorSet added in v0.2.2

func NewErrorSet() ErrorSet

func (ErrorSet) Add added in v0.2.2

func (errs ErrorSet) Add(key string, err error)

func (ErrorSet) AddMsg added in v0.2.2

func (errs ErrorSet) AddMsg(key string, msg string)

func (ErrorSet) FieldError added in v0.2.2

func (errs ErrorSet) FieldError(key string) error

func (ErrorSet) FieldErrors added in v0.2.2

func (errs ErrorSet) FieldErrors(key string) []error

func (ErrorSet) FieldMsg added in v0.2.2

func (errs ErrorSet) FieldMsg(key string) string

func (ErrorSet) IsFieldInvalid added in v0.2.2

func (errs ErrorSet) IsFieldInvalid(key string) bool

func (ErrorSet) IsFieldValid added in v0.2.2

func (errs ErrorSet) IsFieldValid(key string) bool

func (ErrorSet) IsInvalid added in v0.2.2

func (errs ErrorSet) IsInvalid() bool

func (ErrorSet) IsValid added in v0.2.2

func (errs ErrorSet) IsValid() bool

type ErrorSite

type ErrorSite interface {
	AddError(err error)
	NoteChildError(err error)
	Init(parent ErrorSite)
}

type Field

type Field struct {
	Identity

	ReadOnly            bool
	RawFormValue        string
	RawFormValues       []string
	RawFormValuePresent bool
}

func (*Field) EnumFields

func (field *Field) EnumFields(f func(name string, field *Field))

func (*Field) IsReadOnly added in v0.3.14

func (field *Field) IsReadOnly() bool

type FileUpload

type FileUpload[T comparable] struct {
	RenderableImpl[FileUpload[T]]
	Template
	TemplateStyle
	FileField Field
	NameField Field
	Reset     Identity
	*Binding[T]

	Required bool

	ButtonTitle string
	ButtonTag   TagOpts

	Externalize func(value T) string
	Handler     func(file *multipart.FileHeader) (T, error)
	Verify      func(raw string) (T, error)
}

func (FileUpload[T]) DefaultTemplate

func (FileUpload[T]) DefaultTemplate() string

func (*FileUpload[T]) EnumFields added in v0.2.2

func (c *FileUpload[T]) EnumFields(f func(name string, field *Field))

func (*FileUpload[T]) ExternalizedValue added in v0.3.2

func (c *FileUpload[T]) ExternalizedValue() string

func (*FileUpload[T]) Finalize

func (c *FileUpload[T]) Finalize(state *State)

func (*FileUpload[T]) Process

func (c *FileUpload[T]) Process(data *FormData)

type Form

type Form struct {
	Multipart bool
	URL       string
	ReadOnly  bool
	Group

	ID     string
	Turbo  bool
	Action string
	// contains filtered or unexported fields
}

func (*Form) Process

func (form *Form) Process(data *FormData) bool

func (*Form) ProcessRequest

func (form *Form) ProcessRequest(r *http.Request) bool

func (*Form) Render

func (form *Form) Render(r *Renderer) template.HTML

func (*Form) TurboFrameID added in v0.2.2

func (form *Form) TurboFrameID() string

type FormData

type FormData struct {
	Action string
	Values url.Values
	Files  map[string][]*multipart.FileHeader
}

type FreeButton

type FreeButton struct {
	RenderableImpl[FreeButton]
	Template
	TemplateStyle
	Field
	TagOpts
	FullAction string
	Value      string
	Title      string
}

func (FreeButton) DefaultTemplate

func (FreeButton) DefaultTemplate() string

func (*FreeButton) EnumBindings

func (c *FreeButton) EnumBindings(f func(AnyBinding))

func (*FreeButton) Finalize

func (c *FreeButton) Finalize(state *State)

type Group

type Group struct {
	RenderableImpl[Group]
	HTMLID     string
	Name       string
	Title      string
	WrapperTag TagOpts
	Styles     []*Style
	Template   string
	TemplateStyle
	Options  any
	Children Children
	Specials map[string]Child
	MultiErrorSite

	InnerHTML   template.HTML
	SpecialHTML map[string]template.HTML
	// contains filtered or unexported fields
}

func (*Group) AddChild added in v0.2.2

func (group *Group) AddChild(children ...Child)

func (*Group) AddSpecial added in v0.2.2

func (group *Group) AddSpecial(key string, children ...Child)

func (*Group) EnumChildren

func (group *Group) EnumChildren(f func(Child, ChildFlags))

func (*Group) Finalize

func (group *Group) Finalize(state *State)

func (*Group) RenderInto

func (group *Group) RenderInto(buf *strings.Builder, r *Renderer)

type HTMLFragment added in v0.2.2

func (HTMLFragment) DefaultTemplate added in v0.2.2

func (HTMLFragment) DefaultTemplate() string

func (HTMLFragment) Finalize added in v0.2.2

func (HTMLFragment) Finalize(state *State)
type Header struct {
	RenderableImpl[Header]
	Template
	TemplateStyle
	TagOpts
	Text  string
	Level int
}

func NewHeader added in v0.3.0

func NewHeader(title string) *Header

func NewSubheader added in v0.3.0

func NewSubheader(title string) *Header

func NewSubsubheader added in v0.3.0

func NewSubsubheader(title string) *Header

func (*Header) DefaultTemplate

func (h *Header) DefaultTemplate() string

func (Header) Finalize

func (Header) Finalize(state *State)

type Hidden added in v0.2.2

func (Hidden) DefaultTemplate added in v0.2.2

func (Hidden) DefaultTemplate() string

func (*Hidden) Finalize added in v0.2.2

func (c *Hidden) Finalize(state *State)

func (*Hidden) Process added in v0.2.2

func (c *Hidden) Process(*FormData)

type Identity

type Identity struct {
	ID       string
	FullName string
}

type Image

type Image struct {
	RenderableImpl[Image]
	Template
	TemplateStyle
	TagOpts
	Src     string
	SafeSrc template.URL
}

func (*Image) DefaultTemplate

func (*Image) DefaultTemplate() string

func (*Image) Finalize

func (*Image) Finalize(state *State)

type InputFloat64

type InputFloat64 struct {
	RenderableImpl[InputFloat64]
	Template
	TemplateStyle
	Field
	TagOpts
	*Binding[float64]
	InputWellOpts
	Min       float64
	Max       float64
	HasMin    bool
	HasMax    bool
	Precision int
}

func (InputFloat64) DefaultTemplate

func (InputFloat64) DefaultTemplate() string

func (*InputFloat64) Finalize

func (c *InputFloat64) Finalize(state *State)

func (*InputFloat64) Process

func (c *InputFloat64) Process(*FormData)

type InputInt

type InputInt struct {
	RenderableImpl[InputInt]
	Template
	TemplateStyle
	Field
	TagOpts
	*Binding[int]
	InputWellOpts
	Min    int
	Max    int
	Step   int
	HasMin bool
	HasMax bool
}

func (InputInt) DefaultTemplate

func (InputInt) DefaultTemplate() string

func (*InputInt) Finalize

func (c *InputInt) Finalize(state *State)

func (*InputInt) Process

func (c *InputInt) Process(*FormData)

type InputInt64

type InputInt64 struct {
	RenderableImpl[InputInt64]
	Template
	TemplateStyle
	Field
	TagOpts
	*Binding[int64]
	InputWellOpts
	Min    int64
	Max    int64
	HasMin bool
	HasMax bool
	Step   int64
}

func (InputInt64) DefaultTemplate

func (InputInt64) DefaultTemplate() string

func (*InputInt64) Finalize

func (c *InputInt64) Finalize(state *State)

func (*InputInt64) Process

func (c *InputInt64) Process(*FormData)

type InputText

type InputText struct {
	RenderableImpl[InputText]
	Template
	TemplateStyle
	Field
	TagOpts
	*Binding[string]

	Required    bool
	MinLen      int
	MaxLen      int
	Placeholder string
}

func (InputText) DefaultTemplate

func (InputText) DefaultTemplate() string

func (*InputText) Finalize

func (c *InputText) Finalize(state *State)

func (*InputText) Process

func (c *InputText) Process(*FormData)

type InputTime added in v0.2.0

func (InputTime) DefaultTemplate added in v0.2.0

func (InputTime) DefaultTemplate() string

func (*InputTime) Finalize added in v0.2.0

func (c *InputTime) Finalize(state *State)

func (*InputTime) FormattedValue added in v0.2.0

func (c *InputTime) FormattedValue() string

func (*InputTime) InputType added in v0.2.2

func (c *InputTime) InputType() string

func (*InputTime) PresentationFormat added in v0.2.2

func (c *InputTime) PresentationFormat() string

func (*InputTime) Process added in v0.2.0

func (c *InputTime) Process(*FormData)

func (*InputTime) ValueFormat added in v0.2.2

func (c *InputTime) ValueFormat() string

type InputWellOpts

type InputWellOpts struct {
	LeftLabel     string
	LeftLabelTag  TagOpts
	RightLabel    string
	RightLabelTag TagOpts
}

type Item

type Item struct {
	RenderableImpl[Item]
	Name string
	Identity

	Label     string
	LabelTag  TagOpts
	Desc      string
	DescTag   TagOpts
	ItemTag   TagOpts
	ExtraArgs map[string]any
	Styles    []*Style
	Template  string
	TemplateStyle
	SingleErrorSite

	Child     Child
	Extra     Child
	InnerHTML template.HTML
	ExtraHTML template.HTML
}

func (*Item) EnumChildren

func (item *Item) EnumChildren(f func(Child, ChildFlags))

func (*Item) Finalize

func (item *Item) Finalize(state *State)

func (*Item) RenderInto

func (item *Item) RenderInto(buf *strings.Builder, r *Renderer)

type ItemAction added in v0.2.2

type ItemAction struct {
	ItemName string
	Key      string
	Remove   bool
	Save     bool
}
type Link struct {
	RenderableImpl[Link]
	Template
	TemplateStyle
	TagOpts
	Link string
	Text string
}

func (Link) DefaultTemplate

func (Link) DefaultTemplate() string

func (Link) Finalize

func (Link) Finalize(state *State)

type List added in v0.2.0

type List[T comparable] struct {
	RenderableImpl[List[T]]
	Name     string
	Template string
	TemplateStyle
	Identity
	Styles     []*Style
	WrapperTag TagOpts
	*Binding[[]T]

	MinCount int
	MaxCount int

	IsReadOnly       bool
	UseIndicesAsKeys bool

	NewItem       func(name, typ string, index int) (T, bool)
	DeleteItem    func(item T)
	ItemName      func(item T, index int) string
	ItemType      func(item T, index int) string
	RenderItem    func(item T, index int) *Group
	RenderItemPtr func(item *T, index int) *Group
	Sort          func(items []T)
	Compare       func(a, b T) int
	Empty         Child
	TopArea       func() Children
	BottomArea    func() Children
	ItemActions   map[string]func(item T, index int, action *ItemAction)

	InnerHTML template.HTML
	// contains filtered or unexported fields
}

func (*List[T]) DefaultTemplate added in v0.2.0

func (*List[T]) DefaultTemplate() string

func (*List[T]) EnumChildren added in v0.2.0

func (list *List[T]) EnumChildren(f func(Child, ChildFlags))

func (*List[T]) EnumFields added in v0.2.0

func (*List[T]) EnumFields(f func(name string, field *Field))

func (*List[T]) Finalize added in v0.2.0

func (list *List[T]) Finalize(state *State)

func (*List[T]) FullItemName added in v0.2.0

func (list *List[T]) FullItemName(item T, index int) string

func (*List[T]) Process added in v0.2.0

func (list *List[T]) Process(fd *FormData)

func (*List[T]) RenderInto added in v0.2.0

func (list *List[T]) RenderInto(buf *strings.Builder, r *Renderer)

func (*List[T]) ShouldProcessChild added in v0.2.2

func (list *List[T]) ShouldProcessChild(data *FormData, child Child) bool

func (*List[T]) SplitFullItemName added in v0.2.0

func (list *List[T]) SplitFullItemName(fullName string) (name, typ string)

type MultiErrorSite

type MultiErrorSite struct {
	Errors          []error
	ChildErrors     []error
	ParentErrorSite ErrorSite
	ErrCount        int
	CaptureErrors   bool
}

func (*MultiErrorSite) AddError

func (errs *MultiErrorSite) AddError(err error)

func (*MultiErrorSite) Init

func (errs *MultiErrorSite) Init(parent ErrorSite)

func (*MultiErrorSite) Invalid

func (errs *MultiErrorSite) Invalid() bool

func (*MultiErrorSite) NoteChildError

func (errs *MultiErrorSite) NoteChildError(err error)

type Option added in v0.2.0

type Option[T comparable] struct {
	ModelValue T
	HTMLValue  string
	Label      string
}

type PreProcessor added in v0.2.2

type PreProcessor interface {
	Processor
	PreProcess(data *FormData)
}

type Processor

type Processor interface {
	Child
	EnumFields(f func(name string, field *Field))
	EnumBindings(f func(AnyBinding))
	Process(data *FormData)
}

type RawMultiSelect added in v0.3.2

type RawMultiSelect[T comparable] struct {
	RenderableImpl[RawMultiSelect[T]]
	Template
	TemplateStyle
	Field
	TagOpts
	*Binding[[]T]

	Required           bool
	UpdateFormOnChange bool
	Options            []*Option[T]
	Stringify          func(T) string
	MissingItemLabel   func(T) string
	Parse              func(s string) (T, error)
}

func (RawMultiSelect[T]) DefaultTemplate added in v0.3.2

func (RawMultiSelect[T]) DefaultTemplate() string

func (*RawMultiSelect[T]) Finalize added in v0.3.2

func (c *RawMultiSelect[T]) Finalize(state *State)

func (*RawMultiSelect[T]) IsHTMLValueSelected added in v0.3.2

func (c *RawMultiSelect[T]) IsHTMLValueSelected(htmlValue string) bool

func (RawMultiSelect[T]) IsMultiSelect added in v0.3.2

func (RawMultiSelect[T]) IsMultiSelect() bool

func (*RawMultiSelect[T]) Process added in v0.3.2

func (c *RawMultiSelect[T]) Process(*FormData)

type RawSelect added in v0.3.2

type RawSelect[T comparable] struct {
	RenderableImpl[RawSelect[T]]
	Template
	TemplateStyle
	Field
	TagOpts
	*Binding[T]

	Required           bool
	UpdateFormOnChange bool
	Options            []*Option[T]
	Stringify          func(T) string
	MissingItemLabel   func(T) string
	Parse              func(s string) (T, error)
}

func (RawSelect[T]) DefaultTemplate added in v0.3.2

func (RawSelect[T]) DefaultTemplate() string

func (*RawSelect[T]) Finalize added in v0.3.2

func (c *RawSelect[T]) Finalize(state *State)

func (*RawSelect[T]) IsHTMLValueSelected added in v0.3.2

func (c *RawSelect[T]) IsHTMLValueSelected(htmlValue string) bool

func (RawSelect[T]) IsMultiSelect added in v0.3.2

func (RawSelect[T]) IsMultiSelect() bool

func (*RawSelect[T]) Process added in v0.3.2

func (c *RawSelect[T]) Process(*FormData)

type Renderable

type Renderable interface {
	Child
	BeforeRender()
	IsRenderableVisible() bool
}

type RenderableImpl added in v0.2.2

type RenderableImpl[T any] struct {
	IsHidden bool
	// contains filtered or unexported fields
}

func (*RenderableImpl[T]) BeforeRender added in v0.2.2

func (impl *RenderableImpl[T]) BeforeRender()

func (*RenderableImpl[T]) IsRenderableVisible added in v0.2.2

func (impl *RenderableImpl[T]) IsRenderableVisible() bool

func (*RenderableImpl[T]) WithUpdater added in v0.2.2

func (impl *RenderableImpl[T]) WithUpdater(f func(*T)) *T

func (*RenderableImpl[T]) WithVisibility added in v0.2.2

func (impl *RenderableImpl[T]) WithVisibility(f func() bool) *T

type Renderer

type Renderer struct {
	Exec func(w io.Writer, templateName string, data any) error
}

func (*Renderer) Render

func (r *Renderer) Render(item any) template.HTML

func (*Renderer) RenderItemInto added in v0.2.2

func (r *Renderer) RenderItemInto(buf *strings.Builder, item any)

func (*Renderer) RenderTemplateInto

func (r *Renderer) RenderTemplateInto(buf *strings.Builder, templ string, data any)

func (*Renderer) RenderWrapperTemplateInto

func (r *Renderer) RenderWrapperTemplateInto(buf *strings.Builder, templ string, data any, raw template.HTML)

type Select added in v0.2.0

type Select[T comparable] struct {
	RenderableImpl[Select[T]]
	Template
	TemplateStyle
	Field
	TagOpts
	*Binding[T]

	Required           bool
	UpdateFormOnChange bool
	Options            []*Option[T]
}

func (Select[T]) DefaultTemplate added in v0.2.0

func (Select[T]) DefaultTemplate() string

func (*Select[T]) Finalize added in v0.2.0

func (c *Select[T]) Finalize(state *State)

func (*Select[T]) IsHTMLValueSelected added in v0.3.2

func (c *Select[T]) IsHTMLValueSelected(htmlValue string) bool

func (Select[T]) IsMultiSelect added in v0.3.2

func (Select[T]) IsMultiSelect() bool

func (*Select[T]) OptionByHTMLValue added in v0.2.0

func (c *Select[T]) OptionByHTMLValue(value string) *Option[T]

func (*Select[T]) OptionByModelValue added in v0.2.0

func (c *Select[T]) OptionByModelValue(value T) *Option[T]

func (*Select[T]) Process added in v0.2.0

func (c *Select[T]) Process(*FormData)

type SingleErrorSite

type SingleErrorSite struct {
	Error           error
	ParentErrorSite ErrorSite
	ErrCount        int
}

func (*SingleErrorSite) AddError

func (errs *SingleErrorSite) AddError(err error)

func (*SingleErrorSite) ErrorStr added in v0.3.2

func (errs *SingleErrorSite) ErrorStr() string

func (*SingleErrorSite) Init

func (errs *SingleErrorSite) Init(parent ErrorSite)

func (*SingleErrorSite) Invalid

func (errs *SingleErrorSite) Invalid() bool

func (*SingleErrorSite) NoteChildError

func (errs *SingleErrorSite) NoteChildError(err error)

type SpecialValue added in v0.2.0

type SpecialValue[T comparable] struct {
	ModelValue    T
	PostbackValue string
}

type State

type State struct {
	Data *FormData
	// contains filtered or unexported fields
}

func (*State) AddField

func (st *State) AddField(name string, field *Field)

func (*State) AssignIdentity

func (st *State) AssignIdentity(ident *Identity)

func (*State) AssignSubidentity added in v0.2.2

func (st *State) AssignSubidentity(name string, ident *Identity)

func (*State) Classes

func (st *State) Classes() map[string]string

func (*State) ErrorSite

func (st *State) ErrorSite() ErrorSite

func (*State) Fin

func (st *State) Fin()

func (*State) IsReadOnly added in v0.3.14

func (st *State) IsReadOnly() bool

func (*State) LookupTemplate

func (st *State) LookupTemplate(templ string) string

func (*State) PopName added in v0.2.2

func (st *State) PopName()

func (*State) PushClass

func (st *State) PushClass(key string, value string)

func (*State) PushClasses

func (st *State) PushClasses(newClasses map[string]string)

func (*State) PushErrorSite

func (st *State) PushErrorSite(errs ErrorSite)

func (*State) PushName

func (st *State) PushName(name string)

func (*State) PushStyle

func (st *State) PushStyle(s *Style)

func (*State) PushStyles

func (st *State) PushStyles(styles []*Style)

func (*State) PushTemplate

func (st *State) PushTemplate(forTempl, useTempl string)

func (*State) PushTemplates

func (st *State) PushTemplates(substs []Subst)

func (*State) TemplateStyle

func (st *State) TemplateStyle() TemplateStyle

func (*State) WithName added in v0.2.2

func (st *State) WithName(name string, f func())

type StringRequirements added in v0.2.2

type StringRequirements struct {
	Required bool
	MinLen   int
	MaxLen   int
}

type Style

type Style struct {
	Templates []Subst
	Classes   map[string]string
}

type Subst

type Subst struct {
	For string
	Use string
}

type TagOpts

type TagOpts struct {
	Class string
	Attrs map[string]any
}

func (*TagOpts) SetAttr added in v0.2.2

func (to *TagOpts) SetAttr(name string, value any)

type Template

type Template string

func (Template) CurrentTemplate

func (t Template) CurrentTemplate() string

type TemplateStyle

type TemplateStyle struct {
	Classes map[string]string
}

func (*TemplateStyle) TemplateStylePtr

func (ts *TemplateStyle) TemplateStylePtr() *TemplateStyle

type Templated

type Templated interface {
	Renderable
	TemplateStylePtr() *TemplateStyle
	CurrentTemplate() string
	DefaultTemplate() string
}

type Text

type Text struct {
	RenderableImpl[Text]
	Template
	TemplateStyle
	TagOpts
	Text   string
	Update func(el *Text)
}

func (Text) DefaultTemplate

func (Text) DefaultTemplate() string

func (Text) Finalize

func (Text) Finalize(state *State)

func (*Text) TriggerUpdate added in v0.2.2

func (el *Text) TriggerUpdate()

type ValidationFlags added in v0.2.2

type ValidationFlags uint64

type Validator

type Validator[T any] func(value T) (T, error)

type Value

type Value struct {
	Key   string
	Value any
}

type Wrapper

type Wrapper struct {
	RenderableImpl[Wrapper]
	WrapperTag TagOpts
	Template   string
	TemplateStyle
	Child     Child
	InnerHTML template.HTML
}

func (*Wrapper) EnumChildren

func (wrapper *Wrapper) EnumChildren(f func(Child, ChildFlags))

func (*Wrapper) Finalize

func (wrapper *Wrapper) Finalize(state *State)

func (*Wrapper) RenderInto

func (wrapper *Wrapper) RenderInto(buf *strings.Builder, r *Renderer)

Jump to

Keyboard shortcuts

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