pkg

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean(inputHTML string) string

func FieldsToMap

func FieldsToMap(fields []DataField) map[string]DataField

func GetInValidation

func GetInValidation(v string) string

func Normalize

func Normalize(inputHtml string) string

func RemoveClass

func RemoveClass(inputHTML string) string

Types

type Choice

type Choice struct {
	Group   string
	Label   string
	Value   string
	Checked bool
}

func (*Choice) IsSelected

func (c *Choice) IsSelected(x any) bool

func (*Choice) L

func (c *Choice) L() string

func (*Choice) Val

func (c *Choice) Val() string

type DataField

type DataField struct {
	Name    string
	Kind    string
	SubKind string
	// https://stackoverflow.com/questions/3518002/how-can-i-set-the-default-value-for-an-html-select-element
	Choices    []Choice
	Multi      bool
	Value      any
	Validation string
	Optional   bool
	// Replace by Map, every validator might have it's own message
	ErrorMessage string
}

func FieldGenerator

func FieldGenerator(obj interface{}) []DataField

func (DataField) Val

func (f DataField) Val() any

type ElementOpts added in v0.1.8

type ElementOpts struct {
	Placeholder string
	Id          string
	Label       string
	Description string
	Choices     []Choice
	Groups      map[string]string
	SubLayout   *FormLayout
}

type FormElement

type FormElement struct {
	Kind        string
	Name        string
	Label       string
	Description string
	Config      ElementOpts
}

type FormLayout

type FormLayout struct {
	Theme TailwindTheme
	// contains filtered or unexported fields
}

func NewFormLayout

func NewFormLayout() *FormLayout

func (*FormLayout) Add

func (f *FormLayout) Add(name string, label string, config ...OptFunc) *FormLayout

func (*FormLayout) AddGroup

func (f *FormLayout) AddGroup(name string,
	label string,
	description string,
	layout func(f *FormLayout),
) *FormLayout

func (*FormLayout) AddHeader

func (f *FormLayout) AddHeader(name string) *FormLayout

func (*FormLayout) AddHidden added in v0.1.8

func (f *FormLayout) AddHidden(name string) *FormLayout

func (*FormLayout) RenderForm

func (f *FormLayout) RenderForm(data any) string

func (*FormLayout) RenderFormWithErrors added in v0.1.8

func (f *FormLayout) RenderFormWithErrors(data any, errors map[string]string) string

func (*FormLayout) RenderView

func (f *FormLayout) RenderView(data any) string

type OptFunc added in v0.1.8

type OptFunc func(config *ElementOpts)

func WithChoices added in v0.1.8

func WithChoices(choices []Choice) OptFunc

func WithDescription added in v0.1.8

func WithDescription(description string) OptFunc

func WithGroups added in v0.1.8

func WithGroups(groups map[string]string) OptFunc

func WithId added in v0.1.8

func WithId(id string) OptFunc

func WithPlaceholder added in v0.1.8

func WithPlaceholder(placeholder string) OptFunc

type Selection

type Selection struct {
	Value          int
	PossibleValues []int
	Default        int
}

type Tag

type Tag struct {
	Validation   *string
	ErrorMessage *string
	Choices      []Choice
}

func ParseTag

func ParseTag(tag string) Tag

type TailwindTheme added in v0.1.5

type TailwindTheme struct {
}

type Theme added in v0.1.5

type Theme interface {
	// contains filtered or unexported methods
}

type ValidationData added in v0.1.8

type ValidationData struct {
	Optional bool
	Min      Option[int]
	Max      Option[int]
	Subtype  Option[string]
}

func GetValidation added in v0.1.8

func GetValidation(v DataField) ValidationData

func GetValidations added in v0.1.8

func GetValidations(v []DataField) []ValidationData

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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