Documentation ¶
Index ¶
- Constants
- Variables
- func Add[T Child](container ChildAdder, child T) T
- func ErrorStr(err error) string
- func JoinNames(path ...string) string
- func SplitName(name string) []string
- func StatusCode(isSaving bool) int
- func Validate[T, R any](errs ErrorSet, key string, value T, f func(value T, reqs R) (T, error), reqs R) T
- func ValidateString(s string, reqs StringRequirements) (string, error)
- type AnyBinding
- type Binding
- func AnyCast[T any](b *Binding[any]) *Binding[T]
- func AnyCastZeroToNil[T comparable](b *Binding[any]) *Binding[T]
- func BindField[T, S any](b *Binding[S], field func(src *S) *T) *Binding[T]
- func BindJSONObjectKeyWithDefault[T any](m map[string]any, key string, defaultValue T) *Binding[T]
- func BindMapKey[T any, K comparable](m map[K]T, key K) *Binding[T]
- func BindMapKeyDeletingZeros[T comparable, K comparable](m map[K]T, key K) *Binding[T]
- func BindMapKeyWithDefault[T any, K comparable](m map[K]T, key K, defaultValue T) *Binding[T]
- func BindNot(b *Binding[bool]) *Binding[bool]
- func BindSliceContainsEl[T comparable](b *Binding[[]T], el T) *Binding[bool]
- func BindSliceEmptyOrSingle[T comparable](b *Binding[[]T], emptyValue T) *Binding[T]
- func BindUniqueList[T comparable](b *Binding[[]T]) *Binding[[]T]
- func Const[T any](value T) *Binding[T]
- func Convert[T, S any](b *Binding[S], stringer func(S) T, convert func(T) (S, error)) *Binding[T]
- func ConvertStringFields(b *Binding[[]string], sep rune) *Binding[string]
- func ConvertStringifiedFields[T any](b *Binding[[]T], sep rune, stringify func(T) string, ...) *Binding[string]
- func ConvertStringifiedList[T any](source *Binding[[]T], stringify func(T) string, ...) *Binding[[]string]
- func Int64AsString(b *Binding[int64], opts ...any) *Binding[string]
- func IntAsString(b *Binding[int], opts ...any) *Binding[string]
- func Var[T any](ptr *T) *Binding[T]
- func (b *Binding[T]) AsString(stringer func(T) string, convert func(string) (T, error)) *Binding[string]
- func (b *Binding[T]) EnumBindings(f func(AnyBinding))
- func (b *Binding[T]) Init(errs ErrorSite)
- func (b *Binding[T]) Set(value T)
- func (b *Binding[T]) SetString(str string, convert func(string) (T, error))
- func (b *Binding[T]) Validate(validators ...Validator[T]) *Binding[T]
- func (b *Binding[T]) Value() T
- type Button
- type Checkbox
- type CheckboxWithLabel
- type Child
- type ChildAdder
- type ChildFlags
- type Children
- type Container
- type CustomRenderable
- type ErrorSet
- func (errs ErrorSet) Add(key string, err error)
- func (errs ErrorSet) AddMsg(key string, msg string)
- func (errs ErrorSet) FieldError(key string) error
- func (errs ErrorSet) FieldErrors(key string) []error
- func (errs ErrorSet) FieldMsg(key string) string
- func (errs ErrorSet) IsFieldInvalid(key string) bool
- func (errs ErrorSet) IsFieldValid(key string) bool
- func (errs ErrorSet) IsInvalid() bool
- func (errs ErrorSet) IsValid() bool
- type ErrorSite
- type Field
- type FileUpload
- type Form
- type FormData
- type FreeButton
- type Group
- type HTMLFragment
- type Header
- type Hidden
- type Identity
- type Image
- type InputFloat64
- type InputInt
- type InputInt64
- type InputText
- type InputTime
- type InputWellOpts
- type Item
- type ItemAction
- type Link
- type List
- func (*List[T]) DefaultTemplate() string
- func (list *List[T]) EnumChildren(f func(Child, ChildFlags))
- func (*List[T]) EnumFields(f func(name string, field *Field))
- func (list *List[T]) Finalize(state *State)
- func (list *List[T]) FullItemName(item T, index int) string
- func (list *List[T]) Process(fd *FormData)
- func (list *List[T]) RenderInto(buf *strings.Builder, r *Renderer)
- func (list *List[T]) ShouldProcessChild(data *FormData, child Child) bool
- func (list *List[T]) SplitFullItemName(fullName string) (name, typ string)
- type MultiErrorSite
- type Option
- type PreProcessor
- type Processor
- type RawMultiSelect
- type RawSelect
- type Renderable
- type RenderableImpl
- type Renderer
- func (r *Renderer) Render(item any) template.HTML
- func (r *Renderer) RenderItemInto(buf *strings.Builder, item any)
- func (r *Renderer) RenderTemplateInto(buf *strings.Builder, templ string, data any)
- func (r *Renderer) RenderWrapperTemplateInto(buf *strings.Builder, templ string, data any, raw template.HTML)
- type Select
- func (Select[T]) DefaultTemplate() string
- func (c *Select[T]) Finalize(state *State)
- func (c *Select[T]) IsHTMLValueSelected(htmlValue string) bool
- func (Select[T]) IsMultiSelect() bool
- func (c *Select[T]) OptionByHTMLValue(value string) *Option[T]
- func (c *Select[T]) OptionByModelValue(value T) *Option[T]
- func (c *Select[T]) Process(*FormData)
- type SingleErrorSite
- type SpecialValue
- type State
- func (st *State) AddField(name string, field *Field)
- func (st *State) AssignIdentity(ident *Identity)
- func (st *State) AssignSubidentity(name string, ident *Identity)
- func (st *State) Classes() map[string]string
- func (st *State) ErrorSite() ErrorSite
- func (st *State) Fin()
- func (st *State) IsReadOnly() bool
- func (st *State) LookupTemplate(templ string) string
- func (st *State) PopName()
- func (st *State) PushClass(key string, value string)
- func (st *State) PushClasses(newClasses map[string]string)
- func (st *State) PushErrorSite(errs ErrorSite)
- func (st *State) PushName(name string)
- func (st *State) PushStyle(s *Style)
- func (st *State) PushStyles(styles []*Style)
- func (st *State) PushTemplate(forTempl, useTempl string)
- func (st *State) PushTemplates(substs []Subst)
- func (st *State) TemplateStyle() TemplateStyle
- func (st *State) WithName(name string, f func())
- type StringRequirements
- type Style
- type Subst
- type TagOpts
- type Template
- type TemplateStyle
- type Templated
- type Text
- type ValidationFlags
- type Validator
- type Value
- type Wrapper
Constants ¶
View Source
const ( HeaderLevelHeader = 0 HeaderLevelSubheader = 1 HeaderLevelSubsubheader = 2 HeaderLevelSubsubsubheader = 3 )
View Source
const (
DateTimeLocalInputTimeFormat = "2006-01-02T15:04"
)
Variables ¶
Functions ¶
func Add ¶ added in v0.2.2
func Add[T Child](container ChildAdder, child T) T
func StatusCode ¶ added in v0.2.2
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 AnyCastZeroToNil ¶ added in v0.2.2
func AnyCastZeroToNil[T comparable](b *Binding[any]) *Binding[T]
func BindJSONObjectKeyWithDefault ¶ added in v0.2.2
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 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 ConvertStringFields ¶ added in v0.2.2
func ConvertStringifiedFields ¶ added in v0.3.2
func ConvertStringifiedList ¶ added in v0.3.2
func Int64AsString ¶ added in v0.2.0
func (*Binding[T]) EnumBindings ¶
func (b *Binding[T]) EnumBindings(f func(AnyBinding))
EnumBindings in Binding simplifies implementation of Processors that embed a Binding.
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) EnumBindings ¶
func (c *Button) EnumBindings(f func(AnyBinding))
func (*Button) EnumFields ¶ added in v0.2.2
type Checkbox ¶
type Checkbox struct { RenderableImpl[Checkbox] Template TemplateStyle Field TagOpts *Binding[bool] UpdateFormOnChange bool GuardOptional bool GuardIdentity Identity }
func (Checkbox) DefaultTemplate ¶
type CheckboxWithLabel ¶ added in v0.3.0
func (CheckboxWithLabel) DefaultTemplate ¶ added in v0.3.0
func (CheckboxWithLabel) DefaultTemplate() string
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) EnumChildren ¶
func (cc Children) EnumChildren(f func(Child, ChildFlags))
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) FieldError ¶ added in v0.2.2
func (ErrorSet) FieldErrors ¶ added in v0.2.2
func (ErrorSet) IsFieldInvalid ¶ added in v0.2.2
func (ErrorSet) IsFieldValid ¶ added in v0.2.2
type Field ¶
type Field struct { Identity ReadOnly bool RawFormValue string RawFormValues []string RawFormValuePresent bool }
func (*Field) EnumFields ¶
func (*Field) IsReadOnly ¶ added in v0.3.14
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) TurboFrameID ¶ added in v0.2.2
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) AddSpecial ¶ added in v0.2.2
func (*Group) EnumChildren ¶
func (group *Group) EnumChildren(f func(Child, ChildFlags))
type HTMLFragment ¶ added in v0.2.2
type HTMLFragment struct { RenderableImpl[HTMLFragment] Template TemplateStyle TagOpts Text template.HTML }
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 ¶
type Header struct { RenderableImpl[Header] Template TemplateStyle TagOpts Text string Level int }
func NewSubheader ¶ added in v0.3.0
func NewSubsubheader ¶ added in v0.3.0
func (*Header) DefaultTemplate ¶
type Hidden ¶ added in v0.2.2
type Hidden struct { RenderableImpl[Hidden] Template TemplateStyle Field TagOpts *Binding[string] }
func (Hidden) DefaultTemplate ¶ added in v0.2.2
type Image ¶
type Image struct { RenderableImpl[Image] Template TemplateStyle TagOpts Src string SafeSrc template.URL }
func (*Image) DefaultTemplate ¶
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 ¶
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 ¶
type InputTime ¶ added in v0.2.0
type InputTime struct { RenderableImpl[InputTime] Template TemplateStyle Field TagOpts *Binding[time.Time] InputWellOpts IncludeTime bool Min time.Time Max time.Time Location *time.Location }
func (InputTime) DefaultTemplate ¶ added in v0.2.0
func (*InputTime) FormattedValue ¶ added in v0.2.0
func (*InputTime) PresentationFormat ¶ added in v0.2.2
func (*InputTime) ValueFormat ¶ added in v0.2.2
type InputWellOpts ¶
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))
type ItemAction ¶ added in v0.2.2
type Link ¶
type Link struct { RenderableImpl[Link] Template TemplateStyle TagOpts Link string Text string }
func (Link) DefaultTemplate ¶
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]) 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]) FullItemName ¶ added in v0.2.0
func (*List[T]) RenderInto ¶ added in v0.2.0
func (*List[T]) ShouldProcessChild ¶ added in v0.2.2
func (*List[T]) SplitFullItemName ¶ added in v0.2.0
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 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]) IsHTMLValueSelected ¶ added in v0.3.2
func (RawSelect[T]) IsMultiSelect ¶ added in v0.3.2
type Renderable ¶
type RenderableImpl ¶ added in v0.2.2
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 ¶
func (*Renderer) RenderItemInto ¶ added in v0.2.2
func (*Renderer) RenderTemplateInto ¶
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]) IsHTMLValueSelected ¶ added in v0.3.2
func (Select[T]) IsMultiSelect ¶ added in v0.3.2
func (*Select[T]) OptionByHTMLValue ¶ added in v0.2.0
func (*Select[T]) OptionByModelValue ¶ added in v0.2.0
type SingleErrorSite ¶
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) AssignIdentity ¶
func (*State) AssignSubidentity ¶ added in v0.2.2
func (*State) IsReadOnly ¶ added in v0.3.14
func (*State) LookupTemplate ¶
func (*State) PushClasses ¶
func (*State) PushErrorSite ¶
func (*State) PushStyles ¶
func (*State) PushTemplate ¶
func (*State) PushTemplates ¶
func (*State) TemplateStyle ¶
func (st *State) TemplateStyle() TemplateStyle
type StringRequirements ¶ added in v0.2.2
type TemplateStyle ¶
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) TriggerUpdate ¶ added in v0.2.2
func (el *Text) TriggerUpdate()
type ValidationFlags ¶ added in v0.2.2
type ValidationFlags uint64
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))
Click to show internal directories.
Click to hide internal directories.