widgets

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: GPL-2.0 Imports: 20 Imported by: 0

Documentation

Overview

templ: version: v0.2.707

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorListComponent

func ErrorListComponent(forElem string, errors []error) templ.Component

func HelpTextComponent

func HelpTextComponent(forElem, helpText string) templ.Component

func LabelComponent

func LabelComponent(forElem, label, labelFor string) templ.Component

Types

type BaseWidget

type BaseWidget struct {
	Type          string
	TemplateName  string
	InputIsHidden bool
	BaseAttrs     map[string]string
}

func NewBaseWidget

func NewBaseWidget(type_ string, templateName string, attrs map[string]string) *BaseWidget

func (*BaseWidget) FormType added in v1.6.7

func (b *BaseWidget) FormType() string

func (*BaseWidget) GetContextData

func (b *BaseWidget) GetContextData(id, name string, value interface{}, attrs map[string]string) ctx.Context

func (*BaseWidget) Hide

func (b *BaseWidget) Hide(hidden bool)

func (*BaseWidget) IdForLabel

func (b *BaseWidget) IdForLabel(id string) string

func (*BaseWidget) IsHidden

func (b *BaseWidget) IsHidden() bool

func (*BaseWidget) Media

func (b *BaseWidget) Media() media.Media

func (*BaseWidget) Render

func (b *BaseWidget) Render(w io.Writer, id, name string, value interface{}, attrs map[string]string) error

func (*BaseWidget) RenderWithErrors

func (b *BaseWidget) RenderWithErrors(w io.Writer, id, name string, value interface{}, errors []error, attrs map[string]string) error

func (*BaseWidget) SetAttrs

func (b *BaseWidget) SetAttrs(attrs map[string]string)

func (*BaseWidget) Validate added in v1.6.7

func (b *BaseWidget) Validate(value interface{}) []error

func (*BaseWidget) ValueFromDataDict

func (b *BaseWidget) ValueFromDataDict(data url.Values, files map[string][]filesystem.FileHeader, name string) (interface{}, []error)

func (*BaseWidget) ValueOmittedFromData

func (b *BaseWidget) ValueOmittedFromData(data url.Values, files map[string][]filesystem.FileHeader, name string) bool

func (*BaseWidget) ValueToForm

func (b *BaseWidget) ValueToForm(value interface{}) interface{}

func (*BaseWidget) ValueToGo

func (b *BaseWidget) ValueToGo(value interface{}) (interface{}, error)

type BooleanWidget

type BooleanWidget struct {
	*BaseWidget
}

func (*BooleanWidget) ValueToForm

func (b *BooleanWidget) ValueToForm(value interface{}) interface{}

func (*BooleanWidget) ValueToGo

func (b *BooleanWidget) ValueToGo(value interface{}) (interface{}, error)

type DateWidget

type DateWidget struct {
	*BaseWidget
	DateType DateWidgetType
}

func (*DateWidget) ValueToForm

func (d *DateWidget) ValueToForm(value interface{}) interface{}

func (*DateWidget) ValueToGo

func (d *DateWidget) ValueToGo(value interface{}) (interface{}, error)

type DateWidgetType

type DateWidgetType string
const (
	DateWidgetTypeDate     DateWidgetType = "date"
	DateWidgetTypeDateTime DateWidgetType = "datetime-local"
)

type DecimalWidget added in v1.6.7

type DecimalWidget struct {
	*BaseWidget
	DecimalPlaces int
}

func (*DecimalWidget) ValueToForm added in v1.6.7

func (d *DecimalWidget) ValueToForm(value interface{}) interface{}

func (*DecimalWidget) ValueToGo added in v1.6.7

func (d *DecimalWidget) ValueToGo(value interface{}) (interface{}, error)

type FileObject added in v1.6.8

type FileObject struct {
	Name string
	File *bytes.Buffer
}

type FileWidget

type FileWidget struct {
	*BaseWidget
	Validators []func(filename string, file io.Reader) error
}

func (*FileWidget) ValueFromDataDict

func (f *FileWidget) ValueFromDataDict(data url.Values, files map[string][]filesystem.FileHeader, name string) (interface{}, []error)

func (*FileWidget) ValueOmittedFromData

func (f *FileWidget) ValueOmittedFromData(data url.Values, files map[string][]filesystem.FileHeader, name string) bool

func (*FileWidget) ValueToForm

func (f *FileWidget) ValueToForm(value interface{}) interface{}

type FormOption

type FormOption struct {
	OptLabel string
	OptValue string
}

func (*FormOption) Label

func (o *FormOption) Label() string

func (*FormOption) Value

func (o *FormOption) Value() string

type FormValueConverter

type FormValueConverter interface {
	// Convert the forms' string value to the appropriate GO type.
	ValueToGo(value interface{}) (interface{}, error)

	// Convert the GO type to the forms' string value.
	ValueToForm(value interface{}) interface{}
}

type FormValueGetter

type FormValueGetter interface {
	// Get the value from the provided data.
	ValueFromDataDict(data url.Values, files map[string][]filesystem.FileHeader, name string) (interface{}, []error)
}

type FormValueOmitter

type FormValueOmitter interface {
	// Check if the value is omitted from the data provided.
	ValueOmittedFromData(data url.Values, files map[string][]filesystem.FileHeader, name string) bool
}

type FormValuer

type FormValuer interface {
	FormValueConverter
	FormValueOmitter
	FormValueGetter
}

type NumberType

type NumberType interface {
	constraints.Integer | constraints.Float
}

type NumberWidget

type NumberWidget[T NumberType] struct {
	*BaseWidget
}

func (*NumberWidget[T]) ValueToForm

func (n *NumberWidget[T]) ValueToForm(value interface{}) interface{}

func (*NumberWidget[T]) ValueToGo

func (n *NumberWidget[T]) ValueToGo(value interface{}) (interface{}, error)

type Option

type Option interface {
	Label() string
	Value() string
}

func NewOption

func NewOption(name, label, value string) Option

type OptionsWidget

type OptionsWidget struct {
	*BaseWidget
	Choices      func() []Option
	IncludeBlank bool
	BlankLabel   string
}

func (*OptionsWidget) GetContextData

func (o *OptionsWidget) GetContextData(id, name string, value interface{}, attrs map[string]string) ctx.Context

func (*OptionsWidget) Render

func (b *OptionsWidget) Render(w io.Writer, id, name string, value interface{}, attrs map[string]string) error

func (*OptionsWidget) RenderWithErrors

func (b *OptionsWidget) RenderWithErrors(w io.Writer, id, name string, value interface{}, errors []error, attrs map[string]string) error

func (*OptionsWidget) Validate added in v1.6.7

func (o *OptionsWidget) Validate(value interface{}) []error

type Widget

type Widget interface {
	IsHidden() bool
	Hide(hidden bool)
	FormType() string
	SetAttrs(attrs map[string]string)
	IdForLabel(id string) string
	GetContextData(id, name string, value interface{}, attrs map[string]string) ctx.Context
	RenderWithErrors(w io.Writer, id, name string, value interface{}, errors []error, attrs map[string]string) error
	Render(w io.Writer, id, name string, value interface{}, attrs map[string]string) error
	Validate(value interface{}) []error

	FormValuer
	media.MediaDefiner
}

func NewBooleanInput

func NewBooleanInput(attrs map[string]string) Widget

func NewCheckboxInput

func NewCheckboxInput(attrs map[string]string, choices func() []Option) Widget

func NewDateInput

func NewDateInput(attrs map[string]string, t DateWidgetType) Widget

func NewDecimalInput added in v1.6.7

func NewDecimalInput(attrs map[string]string, decimalPlaces int) Widget

func NewEmailInput

func NewEmailInput(attrs map[string]string) Widget

func NewFileInput

func NewFileInput(attrs map[string]string, validators ...func(filename string, file io.Reader) error) Widget

func NewHiddenInput

func NewHiddenInput(attrs map[string]string) Widget

func NewNumberInput

func NewNumberInput[T NumberType](attrs map[string]string) Widget

func NewOptionWidget

func NewOptionWidget(type_ string, templateName string, attrs map[string]string, choices func() []Option) Widget

func NewPasswordInput

func NewPasswordInput(attrs map[string]string) Widget

func NewRadioInput

func NewRadioInput(attrs map[string]string, choices func() []Option) Widget

func NewSelectInput

func NewSelectInput(attrs map[string]string, choices func() []Option) Widget

func NewTextInput

func NewTextInput(attrs map[string]string) Widget

func NewTextarea

func NewTextarea(attrs map[string]string) Widget

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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