widgets

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: GPL-2.0 Imports: 29 Imported by: 3

Documentation

Overview

templ: version: v0.3.1020

Index

Constants

View Source
const (
	DateWidgetTypeDate     DateWidgetType = "date"
	DateWidgetTypeDateTime DateWidgetType = "datetime-local"

	DateWidgetDateFormat        = "2006-01-02"
	DateWidgetDateTimeFormat    = "2006-01-02T15:04"
	DateWidgetDateTimeSecFormat = "2006-01-02T15:04:05"
)

Variables

This section is empty.

Functions

func ErrorListComponent

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

func HelpTextComponent

func HelpTextComponent(forElem, helpText string, attrs ...templ.Attributes) templ.Component

func LabelComponent

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

Types

type BaseWidget

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

func NewBaseWidget

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

func (*BaseWidget) BindField added in v1.7.2

func (b *BaseWidget) BindField(f Field)

func (*BaseWidget) Field added in v1.7.2

func (b *BaseWidget) Field() Field

func (*BaseWidget) FormType added in v1.6.7

func (b *BaseWidget) FormType() string

func (*BaseWidget) GetContextData

func (b *BaseWidget) GetContextData(c context.Context, 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(ctx context.Context, w io.Writer, id, name string, value interface{}, attrs map[string]string) error

func (*BaseWidget) RenderWithErrors

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

func (*BaseWidget) SetAttrs

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

func (*BaseWidget) Validate added in v1.6.7

func (b *BaseWidget) Validate(ctx context.Context, value interface{}) []error

func (*BaseWidget) ValueFromDataDict

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

func (*BaseWidget) ValueOmittedFromData

func (b *BaseWidget) ValueOmittedFromData(ctx context.Context, 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

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 Field added in v1.7.2

type Field = forms.Field

type FileObject added in v1.6.8

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

type FileWidget

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

func (*FileWidget) GetContextData added in v1.7.2

func (f *FileWidget) GetContextData(c context.Context, id, name string, value interface{}, attrs map[string]string) ctx.Context

func (*FileWidget) Render added in v1.7.2

func (f *FileWidget) Render(ctx context.Context, w io.Writer, id string, name string, value interface{}, attrs map[string]string) error

func (*FileWidget) Validate added in v1.7.2

func (f *FileWidget) Validate(ctx context.Context, value interface{}) []error

func (*FileWidget) ValueFromDataDict

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

func (*FileWidget) ValueOmittedFromData

func (f *FileWidget) ValueOmittedFromData(ctx context.Context, 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 = forms.FormValueConverter

type FormValueGetter

type FormValueGetter = forms.FormValueGetter

type FormValueOmitter

type FormValueOmitter = forms.FormValueOmitter

type FormValuer

type FormValuer = forms.FormValuer

type MultiWidget added in v1.7.2

type MultiWidget struct {
	BaseWidget
	Widgets *orderedmap.OrderedMap[string, Widget]
}

func NewMultiWidget added in v1.7.2

func NewMultiWidget(attrs map[string]string) *MultiWidget

func (*MultiWidget) AddWidget added in v1.7.2

func (b *MultiWidget) AddWidget(name string, widget Widget)

func (*MultiWidget) GetContextData added in v1.7.2

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

func (*MultiWidget) Media added in v1.7.2

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

func (*MultiWidget) Render added in v1.7.2

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

func (*MultiWidget) RenderWithErrors added in v1.7.2

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

func (*MultiWidget) Validate added in v1.7.2

func (b *MultiWidget) Validate(ctx context.Context, value interface{}) []error

func (*MultiWidget) ValueFromDataDict added in v1.7.2

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

func (*MultiWidget) ValueOmittedFromData added in v1.7.2

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

func (*MultiWidget) ValueToForm added in v1.7.2

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

func (*MultiWidget) ValueToGo added in v1.7.2

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

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 = forms.Option

func NewOption

func NewOption(name, label, value string) Option

type Widget

type Widget = forms.Widget

func NewBooleanInput

func NewBooleanInput(attrs map[string]string) 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, allowedMimeTypes []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 NewPasswordInput

func NewPasswordInput(attrs map[string]string) Widget

func NewTextInput

func NewTextInput(attrs map[string]string) Widget

func NewTextarea

func NewTextarea(attrs map[string]string) Widget

type WrappedOption added in v1.6.9

type WrappedOption struct {
	Option
	Selected bool
}

func WrapOptions added in v1.6.9

func WrapOptions(options []Option, selectedValues []string) []WrappedOption

func (*WrappedOption) Label added in v1.6.9

func (w *WrappedOption) Label() string

func (*WrappedOption) Value added in v1.6.9

func (w *WrappedOption) Value() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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