Documentation
¶
Overview ¶
Package ui, holds components for web application
Index ¶
- Constants
- Variables
- func Accordion() *accordion
- func Alert() *alert
- func Badge(attr ...Attr) *badge
- func Button(attr ...Attr) *button
- func Captcha(siteKey string, secured string) string
- func Card() *card
- func Collate[T any](init *TQuery) *collate[T]
- func Dropdown() *dropdown
- func El(tag string, class string, attr ...Attr) func(elements ...string) string
- func ElClosed(tag string, class string, attr ...Attr) string
- func Error(err error) string
- func ErrorField(err validator.FieldError) string
- func ErrorForm(errs *error, translations *map[string]string) string
- func FilterHiddenFields(query *TQuery) string
- func Filtering[T any](ctx *Context, collate *collate[T], query *TQuery) string
- func For[T any](from, to int, iter func(int) string) string
- func Header[T any](ctx *Context, collate *collate[T], query *TQuery) string
- func Icon(css string, attr ...Attr) string
- func Icon2(iconName string, extraClasses string) string
- func IconBasic(class string, text string) string
- func IconEnd(css string, text string) string
- func IconLeft(css string, text string) string
- func IconRight(css string, text string) string
- func IconStart(css string, text string) string
- func If(cond bool, value func() string) string
- func Iff(cond bool) func(value ...string) string
- func Map[T any](values []T, iter func(*T, int) string) string
- func Map2[T any](values []T, iter func(T, int) []string) string
- func Normalize(s string) string
- func NormalizeForSearch(search string) string
- func Or(cond bool, value func() string, other func() string) string
- func Paging[T any](ctx *Context, collate *collate[T], result *TCollateResult[T]) string
- func PathValue(obj any, path string) (*reflect.Value, error)
- func Print(value any) string
- func ProgressBar() *progress
- func ProgressWithLabel(percent int) *progress
- func QueryHiddenFields(query *TQuery) string
- func RandomString(n ...int) string
- func RegisterSQLiteNormalize(db *gorm.DB) error
- func SkeletonComponentBlock() string
- func SkeletonDefault() string
- func SkeletonFormBlock() string
- func SkeletonListN(count int) string
- func SkeletonPageBlock() string
- func Sorting[T any](ctx *Context, collate *collate[T], query *TQuery) string
- func StepProgress(current, total int) *stepProgress
- func StepText(current, total int, label string) *stepProgress
- func Tabs() *tabs
- func Text(text string) string
- func ThemeSwitcher(css string) string
- func Tooltip() *tooltip
- func Trim(s string) string
- func Variable[T any](getter func(*T) string) func(item *T) Attr
- type ALabel
- type AOption
- type ARadio
- func (c *ARadio) Change(action string) *ARadio
- func (c *ARadio) Class(value ...string) *ARadio
- func (c *ARadio) ClassLabel(value ...string) *ARadio
- func (c *ARadio) Disabled(value ...bool) *ARadio
- func (c *ARadio) Empty() *ARadio
- func (c *ARadio) Error(errs *error) *ARadio
- func (c *ARadio) Form(form string) *ARadio
- func (c *ARadio) If(value bool) *ARadio
- func (c *ARadio) Options(options []AOption) *ARadio
- func (c *ARadio) Placeholder(value string) *ARadio
- func (c *ARadio) RadioPosition(class string) *ARadio
- func (c *ARadio) Render(text string) string
- func (c *ARadio) Required(value ...bool) *ARadio
- type ASelect
- func (c *ASelect) Change(action string) *ASelect
- func (c *ASelect) Class(value ...string) *ASelect
- func (c *ASelect) Disabled(value ...bool) *ASelect
- func (c *ASelect) Empty() *ASelect
- func (c *ASelect) Error(errs *error) *ASelect
- func (c *ASelect) Form(form string) *ASelect
- func (c *ASelect) If(value bool) *ASelect
- func (c *ASelect) Options(options []AOption) *ASelect
- func (c *ASelect) Placeholder(value string) *ASelect
- func (c *ASelect) Render(text string) string
- func (c *ASelect) Required(value ...bool) *ASelect
- type Action
- type ActionType
- type Actions
- type App
- func (app *App) Action(uid string, action Callable) **Callable
- func (app *App) Assets(assets embed.FS, path string, maxAge time.Duration)
- func (app *App) AutoRestart(enable bool)
- func (app *App) Callable(action Callable) **Callable
- func (app *App) Custom(method string, path string, handler http.HandlerFunc)
- func (app *App) DELETE(path string, handler http.HandlerFunc)
- func (app *App) Debug(enable bool)
- func (app *App) Description(description string)
- func (app *App) Favicon(assets embed.FS, path string, maxAge time.Duration)
- func (app *App) GET(path string, handler http.HandlerFunc)
- func (app *App) HTML(title string, class string, body ...string) string
- func (app *App) Handler() http.Handler
- func (app *App) Layout(handler Callable)
- func (app *App) Listen(port string)
- func (app *App) Mount(prefix string, mux *http.ServeMux)
- func (app *App) PATCH(path string, handler http.HandlerFunc)
- func (app *App) POST(path string, handler http.HandlerFunc)
- func (app *App) PUT(path string, handler http.HandlerFunc)
- func (app *App) PWA(config PWAConfig)
- func (app *App) Page(path string, title string, handler Callable)
- func (app *App) Register(httpMethod string, path string, method *Callable) string
- func (app *App) StartSweeper()
- func (app *App) TestHandler() http.Handler
- type Attr
- func (a Attr) Append() TargetSwap
- func (a Attr) Prepend() TargetSwap
- func (a Attr) Render() TargetSwap
- func (a Attr) Replace() TargetSwap
- func (a Attr) Skeleton(kind ...Skeleton) string
- func (a Attr) SkeletonComponent() string
- func (a Attr) SkeletonDefault() string
- func (a Attr) SkeletonForm() string
- func (a Attr) SkeletonList(count int) string
- func (a Attr) SkeletonPage() string
- type BodyItem
- type CSS
- type Callable
- type Captcha2Component
- func (c *Captcha2Component) AnswerField(name string) *Captcha2Component
- func (c *Captcha2Component) AnswerFieldName() string
- func (c *Captcha2Component) Attempts(limit int) *Captcha2Component
- func (c *Captcha2Component) ClientVerifiedField(name string) *Captcha2Component
- func (c *Captcha2Component) ClientVerifiedFieldName() string
- func (c *Captcha2Component) Length(n int) *Captcha2Component
- func (c *Captcha2Component) Lifetime(d time.Duration) *Captcha2Component
- func (c *Captcha2Component) Render(ctx *Context) string
- func (c *Captcha2Component) SessionField(name string) *Captcha2Component
- func (c *Captcha2Component) SessionFieldName() string
- func (c *Captcha2Component) Validate(sessionID, answer string) (bool, error)
- func (c *Captcha2Component) ValidateRequest(r *http.Request) (bool, error)
- func (c *Captcha2Component) ValidateValues(sessionID, answer string) (bool, error)
- type Captcha3Component
- func (c *Captcha3Component) ArrangementField(name string) *Captcha3Component
- func (c *Captcha3Component) ArrangementFieldName() string
- func (c *Captcha3Component) Attempts(limit int) *Captcha3Component
- func (c *Captcha3Component) ClientVerifiedField(name string) *Captcha3Component
- func (c *Captcha3Component) ClientVerifiedFieldName() string
- func (c *Captcha3Component) Count(n int) *Captcha3Component
- func (c *Captcha3Component) Lifetime(d time.Duration) *Captcha3Component
- func (c *Captcha3Component) Render(ctx *Context) string
- func (c *Captcha3Component) SessionField(name string) *Captcha3Component
- func (c *Captcha3Component) SessionFieldName() string
- func (c *Captcha3Component) Validate(sessionID, arrangement string) (bool, error)
- func (c *Captcha3Component) ValidateRequest(r *http.Request) (bool, error)
- func (c *Captcha3Component) ValidateValues(sessionID, arrangement string) (bool, error)
- type CaptchaSession
- type CollateColors
- type Context
- func (ctx *Context) Action(uid string, action Callable) **Callable
- func (ctx *Context) AllQueryParams() map[string][]string
- func (ctx *Context) Body(output any) error
- func (ctx *Context) Call(method Callable, values ...any) Actions
- func (ctx *Context) Callable(action Callable) **Callable
- func (ctx *Context) Click(method Callable, values ...any) Submits
- func (ctx *Context) DownloadAs(file *io.Reader, contentType string, name string) error
- func (ctx *Context) Error(message string) string
- func (ctx *Context) ErrorReload(message string)
- func (ctx *Context) File(name string) (*FileUpload, error)
- func (ctx *Context) Files(name string) ([]*FileUpload, error)
- func (ctx *Context) IP() string
- func (ctx *Context) Info(message string) string
- func (ctx *Context) Load(href string) Attr
- func (ctx *Context) Patch(ts TargetSwap, html string, clear ...func())
- func (ctx *Context) PathParam(name string) string
- func (ctx *Context) Post(as ActionType, swap Swap, action *Action) string
- func (ctx *Context) QueryParam(name string) string
- func (ctx *Context) QueryParams(name string) []string
- func (ctx *Context) Redirect(href string) string
- func (ctx *Context) Reload() string
- func (ctx *Context) Render(target Attr, html string)
- func (ctx *Context) Replace(target Attr, html string)
- func (ctx *Context) Send(method Callable, values ...any) Actions
- func (ctx *Context) Session(db *gorm.DB, name string) *TSession
- func (ctx *Context) SetCSP(policy string)
- func (ctx *Context) SetCustomSecurityHeaders(options SecurityHeaderOptions)
- func (ctx *Context) SetDefaultCSP()
- func (ctx *Context) SetSecurityHeaders()
- func (ctx *Context) Submit(method Callable, values ...any) Submits
- func (ctx *Context) Success(message string) string
- func (ctx *Context) Title(title string)
- func (ctx *Context) Translate(message string, val ...any) string
- type CustomRoute
- type FileUpload
- type FormInstance
- func (f *FormInstance) Area(name string, data ...any) *TInput
- func (f *FormInstance) Button() *button
- func (f *FormInstance) Checkbox(name string, data ...any) *TInput
- func (f *FormInstance) Date(name string, data ...any) *TInput
- func (f *FormInstance) DateTime(name string, data ...any) *TInput
- func (f *FormInstance) Email(name string, data ...any) *TInput
- func (f *FormInstance) File(name string) *TFile
- func (f *FormInstance) Hidden(name string, value any, attr ...Attr) string
- func (f *FormInstance) ImageUpload(name string) *TImageUpload
- func (f *FormInstance) Number(name string, data ...any) *TInput
- func (f *FormInstance) Password(name string, data ...any) *TInput
- func (f *FormInstance) Phone(name string, data ...any) *TInput
- func (f *FormInstance) Radio(name string, data ...any) *TInput
- func (f *FormInstance) RadioButtons(name string, data ...any) *ARadio
- func (f *FormInstance) RadioDiv(name string, data ...any) *ARadio
- func (f *FormInstance) Render() string
- func (f *FormInstance) Select(name string, data ...any) *ASelect
- func (f *FormInstance) Text(name string, data ...any) *TInput
- func (f *FormInstance) Time(name string, data ...any) *TInput
- type JSCallMessage
- type JSElement
- type JSEvent
- type JSHTTPResponse
- type JSPatchMessage
- type JSPatchOp
- type JSResponseMessage
- type PWAConfig
- type PWAIcon
- type Route
- type SecurityHeaderOptions
- type Skeleton
- type Submits
- type Swap
- type TCollateResult
- type TField
- type TFile
- func (c *TFile) Accept(types string) *TFile
- func (c *TFile) Change(action string) *TFile
- func (c *TFile) Class(value ...string) *TFile
- func (c *TFile) ClassInput(value ...string) *TFile
- func (c *TFile) ClassLabel(value ...string) *TFile
- func (c *TFile) ClassZone(classes ...string) *TFile
- func (c *TFile) Disabled(value ...bool) *TFile
- func (c *TFile) Form(value string) *TFile
- func (c *TFile) GetID() string
- func (c *TFile) ID(id string) *TFile
- func (c *TFile) If(value bool) *TFile
- func (c *TFile) Multiple() *TFile
- func (c *TFile) Required(value ...bool) *TFile
- func (c *TFile) Zone(title, hint string) *TFile
- func (c *TFile) ZoneContent(html string) *TFile
- func (c *TFile) ZoneIcon(classes string) *TFile
- type TImagePreview
- type TImageUpload
- func (c *TImageUpload) Accept(types string) *TImageUpload
- func (c *TImageUpload) Change(action string) *TImageUpload
- func (c *TImageUpload) Class(value ...string) *TImageUpload
- func (c *TImageUpload) ClassInput(value ...string) *TImageUpload
- func (c *TImageUpload) ClassLabel(value ...string) *TImageUpload
- func (c *TImageUpload) ClassPreview(classes ...string) *TImageUpload
- func (c *TImageUpload) ClassZone(classes ...string) *TImageUpload
- func (c *TImageUpload) Disabled(value ...bool) *TImageUpload
- func (c *TImageUpload) Form(value string) *TImageUpload
- func (c *TImageUpload) GetID() string
- func (c *TImageUpload) ID(id string) *TImageUpload
- func (c *TImageUpload) If(value bool) *TImageUpload
- func (c *TImageUpload) MaxSize(size string) *TImageUpload
- func (c *TImageUpload) Multiple() *TImageUpload
- func (c *TImageUpload) Required(value ...bool) *TImageUpload
- func (c *TImageUpload) Zone(title, hint string) *TImageUpload
- func (c *TImageUpload) ZoneContent(html string) *TImageUpload
- func (c *TImageUpload) ZoneIcon(classes string) *TImageUpload
- type TInput
- func IArea(name string, data ...any) *TInput
- func ICheckbox(name string, data ...any) *TInput
- func IDate(name string, data ...any) *TInput
- func IDateTime(name string, data ...any) *TInput
- func INumber(name string, data ...any) *TInput
- func IPassword(name string, data ...any) *TInput
- func IRadio(name string, data ...any) *TInput
- func IText(name string, data ...any) *TInput
- func ITime(name string, data ...any) *TInput
- func IValue(attr ...Attr) *TInput
- func (c *TInput) Autocomplete(value string) *TInput
- func (c *TInput) Change(action string) *TInput
- func (c *TInput) Class(value ...string) *TInput
- func (c *TInput) ClassInput(value ...string) *TInput
- func (c *TInput) ClassLabel(value ...string) *TInput
- func (c *TInput) Click(action string) *TInput
- func (c *TInput) Dates(min time.Time, max time.Time) *TInput
- func (c *TInput) Disabled(value ...bool) *TInput
- func (c *TInput) EmptyOnDefault() *TInput
- func (c *TInput) Error(errs *error) *TInput
- func (c *TInput) Form(value string) *TInput
- func (c *TInput) Format(value string) *TInput
- func (c *TInput) If(value bool) *TInput
- func (c *TInput) Numbers(min float64, max float64, step float64) *TInput
- func (c *TInput) Pattern(value string) *TInput
- func (c *TInput) Placeholder(value string) *TInput
- func (c *TInput) Readonly(value ...bool) *TInput
- func (c *TInput) Required(value ...bool) *TInput
- func (c *TInput) Rows(value uint8) *TInput
- func (c *TInput) Size(value string) *TInput
- func (c *TInput) Type(value string) *TInput
- func (c *TInput) Value(value string) *TInput
- type TQuery
- type TSession
- type TTable
- func (t *TTable[T]) Field(slot func(item *T) string, cls string) *TTable[T]
- func (t *TTable[T]) FieldText(slot func(item *T) string, cls string) *TTable[T]
- func (t *TTable[T]) Head(value string, cls string) *TTable[T]
- func (t *TTable[T]) HeadHTML(value string, cls string) *TTable[T]
- func (t *TTable[T]) Render(data []*T) string
- func (t *TTable[T]) Row(slot func(item *T) []string, cls string) *TTable[T]
- type TTableSimple
- func (t *TTableSimple) Attr(attrs string) *TTableSimple
- func (t *TTableSimple) Class(column int, classes ...string) *TTableSimple
- func (t *TTableSimple) Empty() *TTableSimple
- func (t *TTableSimple) Field(value string, cls ...string) *TTableSimple
- func (t *TTableSimple) FieldText(value string, cls ...string) *TTableSimple
- func (t *TTableSimple) Render() string
- type TargetSwap
Constants ¶
const ( AccordionBordered = "bordered" AccordionGhost = "ghost" AccordionSeparated = "separated" )
const ( // Card variants CardBordered = "bordered" CardShadowed = "shadowed" CardFlat = "flat" CardGlass = "glass" )
const ( BOOL = iota // BOOL_NEGATIVE // BOOL_ZERO NOT_ZERO_DATE ZERO_DATE DATES SELECT )
const ( XS = " p-1" SM = " p-2" MD = " p-3" ST = " p-4" LG = " p-5" XL = " p-6" )
const ( // DISABLED = " cursor-text bg-gray-100 pointer-events-none" AREA = " cursor-pointer bg-white border border-gray-300 hover:border-blue-500 rounded block w-full" INPUT = " cursor-pointer bg-white border border-gray-300 hover:border-blue-500 rounded block w-full h-12" VALUE = " bg-white border border-gray-300 hover:border-blue-500 rounded block h-12" BTN = " cursor-pointer font-bold text-center select-none" DISABLED = " cursor-text pointer-events-none bg-gray-50 text-gray-500" Yellow = "" /* 127-byte string literal not displayed */ YellowOutline = " border border-yellow-500 text-yellow-600 hover:text-gray-700 hover:bg-yellow-500 flex items-center justify-center" Green = " bg-green-600 text-white hover:bg-green-700 checked:bg-green-600 border-gray-300 flex items-center justify-center" GreenOutline = " border border-green-500 text-green-500 hover:text-white hover:bg-green-600 flex items-center justify-center" Purple = " bg-purple-500 text-white hover:bg-purple-700 border-purple-500 flex items-center justify-center" PurpleOutline = " border border-purple-500 text-purple-500 hover:text-white hover:bg-purple-600 flex items-center justify-center" Blue = " bg-blue-800 text-white hover:bg-blue-700 border-gray-300 flex items-center justify-center" BlueOutline = " border border-blue-500 text-blue-600 hover:text-white hover:bg-blue-700 checked:bg-blue-700 flex items-center justify-center" Red = " bg-red-600 text-white hover:bg-red-800 border-gray-300 flex items-center justify-center" RedOutline = " border border-red-500 text-red-600 hover:text-white hover:bg-red-700 flex items-center justify-center" Gray = " bg-gray-600 text-white hover:bg-gray-800 focus:bg-gray-800 border-gray-300 flex items-center justify-center" GrayOutline = " border border-gray-300 text-black hover:text-white hover:bg-gray-700 flex items-center justify-center" White = " bg-white text-black hover:bg-gray-200 border-gray-200 flex items-center justify-center" WhiteOutline = " border border-white text-black hover:text-black hover:bg-white flex items-center justify-center" Black = " bg-black text-white hover:bg-gray-900 border-black flex items-center justify-center" )
const ( MaxBodySize = 10 * 1024 * 1024 // 10MB max request body MaxFieldNameLen = 256 // Max field name length MaxFieldValueLen = 1024 * 1024 // 1MB max field value MaxFieldCount = 1000 // Max number of fields )
Maximum input size limits for security
const ( TabsStylePills = "pills" TabsStyleUnderline = "underline" TabsStyleBoxed = "boxed" TabsStyleVertical = "vertical" )
Tab style constants
Variables ¶
var ( CollateBlue = CollateColors{ Button: Blue, ButtonOutline: BlueOutline, ActiveBg: "bg-blue-800", ActiveBorder: "border-blue-600", ActiveHover: "hover:bg-blue-700", } CollateGreen = CollateColors{ Button: Green, ButtonOutline: GreenOutline, ActiveBg: "bg-green-600", ActiveBorder: "border-green-600", ActiveHover: "hover:bg-green-700", } CollatePurple = CollateColors{ Button: Purple, ButtonOutline: PurpleOutline, ActiveBg: "bg-purple-500", ActiveBorder: "border-purple-500", ActiveHover: "hover:bg-purple-700", } CollateRed = CollateColors{ Button: Red, ButtonOutline: RedOutline, ActiveBg: "bg-red-600", ActiveBorder: "border-red-600", ActiveHover: "hover:bg-red-700", } CollateYellow = CollateColors{ Button: Yellow, ButtonOutline: YellowOutline, ActiveBg: "bg-yellow-400", ActiveBorder: "border-yellow-400", ActiveHover: "hover:bg-yellow-500", } CollateGray = CollateColors{ Button: Gray, ButtonOutline: GrayOutline, ActiveBg: "bg-gray-600", ActiveBorder: "border-gray-600", ActiveHover: "hover:bg-gray-700", } )
Predefined color schemes for collate components
var ( W35 = Attr{Style: "max-width: 35rem;"} W30 = Attr{Style: "max-width: 30rem;"} W25 = Attr{Style: "max-width: 25rem;"} W20 = Attr{Style: "max-width: 20rem;"} )
var ( I = func(class string, attr ...Attr) func(elements ...string) string { return El("i", class, attr...) } A = func(class string, attr ...Attr) func(elements ...string) string { return El("a", class, attr...) } P = func(class string, attr ...Attr) func(elements ...string) string { return El("p", class, attr...) } Div = func(class string, attr ...Attr) func(elements ...string) string { return El("div", class, attr...) } Span = func(class string, attr ...Attr) func(elements ...string) string { return El("span", class, attr...) } Form = func(class string, attr ...Attr) func(elements ...string) string { return El("form", class, attr...) } H1 = func(class string, attr ...Attr) func(elements ...string) string { return El("h1", class, attr...) } H2 = func(class string, attr ...Attr) func(elements ...string) string { return El("h2", class, attr...) } H3 = func(class string, attr ...Attr) func(elements ...string) string { return El("h3", class, attr...) } Textarea = func(class string, attr ...Attr) func(elements ...string) string { return El("textarea", class, attr...) } Select = func(class string, attr ...Attr) func(elements ...string) string { return El("select", class, attr...) } Option = func(class string, attr ...Attr) func(elements ...string) string { return El("option", class, attr...) } List = func(class string, attr ...Attr) func(elements ...string) string { return El("ul", class, attr...) } ListItem = func(class string, attr ...Attr) func(elements ...string) string { return El("li", class, attr...) } Canvas = func(class string, attr ...Attr) func(elements ...string) string { return El("canvas", class, attr...) } Img = func(class string, attr ...Attr) string { return ElClosed("img", class, attr...) } Input = func(class string, attr ...Attr) string { return ElClosed("input", class, attr...) } )
Primary element constructors (generate HTML)
var BOOL_ZERO_OPTIONS = []AOption{
{
ID: "",
Value: "All",
},
{
ID: "yes",
Value: "On",
},
{
ID: "no",
Value: "Off",
},
}
var Flex1 = Div("flex-1")()
Flex1 creates a flex-1 div element
var Hidden = func(name string, value any, attr ...Attr) string { return Input("hidden", append(attr, Attr{Name: name, Type: "hidden", Value: fmt.Sprintf("%v", value)})...) }
var Href = func(value string, target ...string) Attr { if len(target) > 0 { return Attr{Href: value, Target: target[0]} } return Attr{Href: value} }
var ID = func(target string) Attr { return Attr{ID: target} }
var IEmail = func(name string, data ...any) *TInput { return IText(name, data...). Type("email"). Autocomplete("email"). Placeholder("[email protected]") }
var IPhone = func(name string, data ...any) *TInput { return IText(name, data...). Type("tel"). Autocomplete("tel"). Placeholder("+421"). Pattern("\\+[0-9]{10,14}") }
var Markdown = func(css string) func(elements ...string) string { return func(elements ...string) string { md := []byte(strings.Join(elements, " ")) md = bytes.ReplaceAll(md, []byte("\t"), []byte("")) html := mdToHTML(md) return fmt.Sprintf(`<div class="markdown %s">%s</div>`, css, html) } }
var Script = func(value ...string) string { return Trim(fmt.Sprintf(`<script>%s</script>`, strings.Join(value, " "))) }
var Space = " "
Space represents a non-breaking space
var Src = func(alt string, target string) Attr { return Attr{Src: target, Alt: alt} }
var Target = func() Attr { return Attr{ID: "i" + RandomString(15)} }
var Title = func(value string) Attr { return Attr{Title: string(value)} }
Functions ¶
func Collate ¶
Collate constructs a new collate with sensible defaults using the provided init query. Default color scheme is blue.
func Dropdown ¶
func Dropdown() *dropdown
Dropdown creates a new dropdown component with default settings
func ErrorField ¶
func ErrorField(err validator.FieldError) string
func FilterHiddenFields ¶
FilterHiddenFields generates hidden form fields for filter state only. Use this when other query fields (Search, Order, etc.) are handled separately.
func Icon ¶
Icon functions for creating icon elements and layouts Icon accepts either Material Icon names (e.g., "check", "arrow_back") or Font Awesome format (e.g., "fa fa-check") For backward compatibility, Font Awesome format is automatically converted to Material Icons
func NormalizeForSearch ¶
NormalizeForSearch normalizes a search term to handle diacritics and special characters This makes searches more user-friendly by matching accented characters
func Paging ¶
func Paging[T any](ctx *Context, collate *collate[T], result *TCollateResult[T]) string
func ProgressBar ¶
func ProgressBar() *progress
func ProgressWithLabel ¶
func ProgressWithLabel(percent int) *progress
ProgressWithLabel creates a progress bar with percentage label
func QueryHiddenFields ¶
QueryHiddenFields generates hidden form fields for preserving query state including all filter values. This ensures filter state persists across form submissions.
func RandomString ¶
RandomString generates a cryptographically secure random string
func RegisterSQLiteNormalize ¶
RegisterSQLiteNormalize registers a custom SQLite function 'normalize' for diacritic removal This function should be called after establishing the database connection
func SkeletonComponentBlock ¶
func SkeletonComponentBlock() string
func SkeletonDefault ¶
func SkeletonDefault() string
func SkeletonFormBlock ¶
func SkeletonFormBlock() string
func SkeletonListN ¶
func SkeletonPageBlock ¶
func SkeletonPageBlock() string
func StepProgress ¶
func StepProgress(current, total int) *stepProgress
StepProgress creates a new step progress indicator
func ThemeSwitcher ¶
ThemeSwitcher renders a small button that cycles System → Light → Dark. It relies on the global setTheme(mode) provided by the server (__theme script).
Types ¶
type ALabel ¶
type ALabel struct {
// contains filtered or unexported fields
}
func (*ALabel) ClassLabel ¶
type AOption ¶
func MakeOptions ¶
type ARadio ¶
type ARadio struct {
// contains filtered or unexported fields
}
func IRadioButtons ¶
func (*ARadio) ClassLabel ¶
func (*ARadio) Placeholder ¶
func (*ARadio) RadioPosition ¶
type ASelect ¶
type ASelect struct {
// contains filtered or unexported fields
}
func (*ASelect) Placeholder ¶
type ActionType ¶
type ActionType string
const ( POST ActionType = "POST" FORM ActionType = "FORM" )
type App ¶
type App struct {
Lanugage string
ContentID Attr
BasePath string // URL prefix for path-prefix mounting (e.g., "/admin")
HTMLBody func(string) string
HTMLHead []string
DebugEnabled bool
// contains filtered or unexported fields
}
func (*App) AutoRestart ¶
func (*App) Custom ¶ added in v0.111.8
func (app *App) Custom(method string, path string, handler http.HandlerFunc)
Custom registers a standard http.HandlerFunc for a specific path and HTTP method. This allows integrating regular HTTP endpoints (like REST APIs) alongside g-sui pages. Custom handlers are checked before g-sui routes, so they take priority.
Example:
app.Custom("GET", "/api/health", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"status": "ok"}`))
})
app.Custom("POST", "/api/users", createUserHandler)
func (*App) DELETE ¶ added in v0.111.8
func (app *App) DELETE(path string, handler http.HandlerFunc)
DELETE registers a custom handler for DELETE requests. Shorthand for Custom("DELETE", path, handler).
func (*App) Debug ¶
Debug enables or disables server debug logging. When enabled, debug logs are printed with the "gsui:" prefix.
func (*App) Description ¶
func (*App) Favicon ¶
Favicon serves a favicon file from the embedded filesystem at /favicon.ico. The path parameter should be the path to the favicon file in the embed.FS (e.g., "assets/favicon.ico", "assets/favicon.svg"). Defaults to "favicon.ico" if not provided.
func (*App) GET ¶ added in v0.111.8
func (app *App) GET(path string, handler http.HandlerFunc)
GET registers a custom handler for GET requests. Shorthand for Custom("GET", path, handler).
func (*App) Handler ¶ added in v0.111.8
Handler returns an http.Handler that can be used in custom server configurations. This allows wrapping the g-sui handler with custom middleware or integrating with existing HTTP server setups.
Example:
app := ui.MakeApp("en")
app.Page("/", "Home", homeHandler)
app.StartSweeper()
// Use with custom server
server := &http.Server{
Addr: ":8080",
Handler: app.Handler(),
}
server.ListenAndServe()
func (*App) Layout ¶
Layout sets the persistent layout function that wraps all pages. The layout should render a content slot element with id="__content__".
func (*App) Mount ¶ added in v0.111.17
Mount registers the app's routes on an external mux under the given prefix. This enables running multiple g-sui apps on a single HTTP server.
Example:
mux := http.NewServeMux()
adminApp := ui.MakeApp("en")
adminApp.Page("/", "Admin", adminHandler)
adminApp.Mount("/admin", mux)
portalApp := ui.MakeApp("en")
portalApp.Page("/", "Portal", portalHandler)
portalApp.Mount("/portal", mux)
http.ListenAndServe(":8080", mux)
func (*App) PATCH ¶ added in v0.111.8
func (app *App) PATCH(path string, handler http.HandlerFunc)
PATCH registers a custom handler for PATCH requests. Shorthand for Custom("PATCH", path, handler).
func (*App) POST ¶ added in v0.111.8
func (app *App) POST(path string, handler http.HandlerFunc)
POST registers a custom handler for POST requests. Shorthand for Custom("POST", path, handler).
func (*App) PUT ¶ added in v0.111.8
func (app *App) PUT(path string, handler http.HandlerFunc)
PUT registers a custom handler for PUT requests. Shorthand for Custom("PUT", path, handler).
func (*App) PWA ¶
PWA enables Progressive Web App capabilities. Call this to generate manifest.webmanifest and optionally a service worker. The manifest will be served at /manifest.webmanifest The service worker will be served at /sw.js
func (*App) Page ¶
Page registers a route with a title and handler. Usage: Page("/", "Page Title", handler) Supports path parameters: Page("/vehicles/edit/{id}", "Edit Vehicle", handler)
func (*App) StartSweeper ¶
func (app *App) StartSweeper()
StartSweeper launches a background goroutine to prune inactive sessions
func (*App) TestHandler ¶
TestHandler returns an http.Handler that uses g-sui's routing logic. This is intended for testing purposes to allow test servers to use the same routing as production without starting a real HTTP server.
type Attr ¶
type Attr struct {
OnClick string
Step string
ID string
Href string
Title string
Alt string
Type string
Class string
Style string
Name string
Value string
Checked string
OnSubmit string
For string
Src string
Selected string
Pattern string
Placeholder string
Autocomplete string
OnChange string
Max string
Min string
Target string
Form string
Action string
Method string
Rows uint8
Cols uint8
Width uint8
Height uint8
Disabled bool
Required bool
Readonly bool
// Custom data attributes for component state
DataAccordion string
DataAccordionItem string
DataAccordionContent string
DataTabs string
DataTabsIndex string
DataTabsPanel string
}
func (Attr) Append ¶
func (a Attr) Append() TargetSwap
func (Attr) Prepend ¶
func (a Attr) Prepend() TargetSwap
func (Attr) Render ¶
func (a Attr) Render() TargetSwap
func (Attr) Replace ¶
func (a Attr) Replace() TargetSwap
func (Attr) Skeleton ¶
Skeleton renders a skeleton for the given target. If kind is not provided or unknown, renders the Default variant (three text lines), matching the TS implementation.
func (Attr) SkeletonComponent ¶
SkeletonComponent renders a component-sized content block.
func (Attr) SkeletonDefault ¶
SkeletonDefault renders three generic text lines.
func (Attr) SkeletonForm ¶
SkeletonForm renders a form-shaped skeleton: labels, inputs, actions.
func (Attr) SkeletonList ¶
SkeletonList renders a vertical list of generic list items (avatar + text).
func (Attr) SkeletonPage ¶
SkeletonPage renders a larger page-level skeleton with header and two cards.
type Captcha2Component ¶
type Captcha2Component struct {
// contains filtered or unexported fields
}
func Captcha2 ¶
func Captcha2(onValidated Callable) *Captcha2Component
Captcha2 constructs a configurable CAPTCHA component with built-in session storage and validation helpers. Each call to Render() creates a new challenge and stores it in the in-memory session map.
func (*Captcha2Component) AnswerField ¶
func (c *Captcha2Component) AnswerField(name string) *Captcha2Component
AnswerField sets the form field used for the user-supplied CAPTCHA answer.
func (*Captcha2Component) AnswerFieldName ¶
func (c *Captcha2Component) AnswerFieldName() string
func (*Captcha2Component) Attempts ¶
func (c *Captcha2Component) Attempts(limit int) *Captcha2Component
Attempts configures how many attempts are permitted before the session is discarded.
func (*Captcha2Component) ClientVerifiedField ¶
func (c *Captcha2Component) ClientVerifiedField(name string) *Captcha2Component
ClientVerifiedField customises the optional hidden field used for client-side hints.
func (*Captcha2Component) ClientVerifiedFieldName ¶
func (c *Captcha2Component) ClientVerifiedFieldName() string
func (*Captcha2Component) Length ¶
func (c *Captcha2Component) Length(n int) *Captcha2Component
Length configures the number of characters in the generated CAPTCHA challenge.
func (*Captcha2Component) Lifetime ¶
func (c *Captcha2Component) Lifetime(d time.Duration) *Captcha2Component
Lifetime configures how long the generated CAPTCHA session remains valid.
func (*Captcha2Component) Render ¶
func (c *Captcha2Component) Render(ctx *Context) string
func (*Captcha2Component) SessionField ¶
func (c *Captcha2Component) SessionField(name string) *Captcha2Component
SessionField sets the hidden form field used to transport the CAPTCHA session ID.
func (*Captcha2Component) SessionFieldName ¶
func (c *Captcha2Component) SessionFieldName() string
func (*Captcha2Component) Validate ¶
func (c *Captcha2Component) Validate(sessionID, answer string) (bool, error)
Validate provides a convenience alias for ValidateValues.
func (*Captcha2Component) ValidateRequest ¶
func (c *Captcha2Component) ValidateRequest(r *http.Request) (bool, error)
ValidateRequest extracts the CAPTCHA fields from an HTTP request and validates them.
func (*Captcha2Component) ValidateValues ¶
func (c *Captcha2Component) ValidateValues(sessionID, answer string) (bool, error)
ValidateValues verifies a supplied answer against a stored CAPTCHA session.
type Captcha3Component ¶
type Captcha3Component struct {
// contains filtered or unexported fields
}
Captcha3Component provides a drag-and-drop captcha experience where users rearrange characters to match the target sequence rendered inline.
func Captcha3 ¶
func Captcha3(onValidated Callable) *Captcha3Component
Captcha3 constructs a configurable CAPTCHA component featuring drag & drop reordering with a styled tile board that reflects the current arrangement.
func (*Captcha3Component) ArrangementField ¶
func (c *Captcha3Component) ArrangementField(name string) *Captcha3Component
ArrangementField overrides the hidden field storing the current character order.
func (*Captcha3Component) ArrangementFieldName ¶
func (c *Captcha3Component) ArrangementFieldName() string
ArrangementFieldName returns the configured arrangement hidden input name.
func (*Captcha3Component) Attempts ¶
func (c *Captcha3Component) Attempts(limit int) *Captcha3Component
Attempts configures how many validation attempts are permitted for the session.
func (*Captcha3Component) ClientVerifiedField ¶
func (c *Captcha3Component) ClientVerifiedField(name string) *Captcha3Component
ClientVerifiedField overrides the optional hidden flag toggled when solved client-side.
func (*Captcha3Component) ClientVerifiedFieldName ¶
func (c *Captcha3Component) ClientVerifiedFieldName() string
ClientVerifiedFieldName returns the configured client verification hidden input name.
func (*Captcha3Component) Count ¶
func (c *Captcha3Component) Count(n int) *Captcha3Component
Count configures how many characters are generated for the captcha challenge.
func (*Captcha3Component) Lifetime ¶
func (c *Captcha3Component) Lifetime(d time.Duration) *Captcha3Component
Lifetime configures how long the generated captcha session remains valid.
func (*Captcha3Component) Render ¶
func (c *Captcha3Component) Render(ctx *Context) string
Render builds the captcha markup and accompanying behaviour script.
func (*Captcha3Component) SessionField ¶
func (c *Captcha3Component) SessionField(name string) *Captcha3Component
SessionField overrides the hidden form field used to transport the session ID.
func (*Captcha3Component) SessionFieldName ¶
func (c *Captcha3Component) SessionFieldName() string
SessionFieldName returns the configured session hidden input name.
func (*Captcha3Component) Validate ¶
func (c *Captcha3Component) Validate(sessionID, arrangement string) (bool, error)
Validate offers a convenience alias for ValidateValues.
func (*Captcha3Component) ValidateRequest ¶
func (c *Captcha3Component) ValidateRequest(r *http.Request) (bool, error)
ValidateRequest extracts captcha fields from the HTTP request and validates them.
func (*Captcha3Component) ValidateValues ¶
func (c *Captcha3Component) ValidateValues(sessionID, arrangement string) (bool, error)
ValidateValues provides server-side validation by comparing stored captcha text with the supplied arrangement.
type CaptchaSession ¶
type CaptchaSession struct {
Text string
CreatedAt time.Time
Attempts int
Solved bool
ExpiresAt time.Time
MaxAttempts int
}
CaptchaSession stores server-side CAPTCHA information
type CollateColors ¶
type CollateColors struct {
Button string // Button color constant (e.g., Blue, Green)
ButtonOutline string // Outline button color constant (e.g., BlueOutline, GreenOutline)
ActiveBg string // Active state background (e.g., "bg-blue-600")
ActiveBorder string // Active state border (e.g., "border-blue-600")
ActiveHover string // Active state hover (e.g., "hover:bg-blue-700")
}
CollateColors holds all color-related CSS classes for theming collate components. Use predefined color sets (CollateBlue, CollateGreen, etc.) or create custom ones.
type Context ¶
type Context struct {
App *App
Request *http.Request
Response http.ResponseWriter
SessionID string
// contains filtered or unexported fields
}
func (*Context) AllQueryParams ¶
AllQueryParams returns all query parameters as a map.
func (*Context) DownloadAs ¶
func (*Context) ErrorReload ¶
ErrorReload shows an error toast with a Reload button.
func (*Context) File ¶ added in v0.111.1
func (ctx *Context) File(name string) (*FileUpload, error)
File returns a single uploaded file by name Returns nil if no file found with that name
func (*Context) Files ¶ added in v0.111.1
func (ctx *Context) Files(name string) ([]*FileUpload, error)
Files returns all uploaded files with the given name (for multiple file inputs)
func (*Context) Patch ¶
func (ctx *Context) Patch(ts TargetSwap, html string, clear ...func())
Patch patches using a TargetSwap descriptor (id + swap) and pushes to WS clients.
func (*Context) PathParam ¶
PathParam returns the value of a path parameter extracted from the route pattern. Returns empty string if the parameter doesn't exist.
func (*Context) QueryParam ¶
QueryParam returns the value of a query parameter from the URL. For SPA navigation, this returns params from the navigated URL. For direct requests, this falls back to ctx.Request.URL.Query(). Returns empty string if the parameter doesn't exist.
func (*Context) QueryParams ¶
QueryParams returns all values for a query parameter (for multi-value params). Returns nil if the parameter doesn't exist.
func (*Context) Redirect ¶
Redirect adds a redirect operation that will navigate to the specified URL
func (*Context) SetCustomSecurityHeaders ¶
func (ctx *Context) SetCustomSecurityHeaders(options SecurityHeaderOptions)
SetCustomSecurityHeaders allows fine-grained control over security headers
func (*Context) SetDefaultCSP ¶
func (ctx *Context) SetDefaultCSP()
SetDefaultCSP sets a restrictive CSP that allows only same-origin scripts and styles
func (*Context) SetSecurityHeaders ¶
func (ctx *Context) SetSecurityHeaders()
SetSecurityHeaders sets comprehensive security headers
type CustomRoute ¶ added in v0.111.8
type CustomRoute struct {
Method string // HTTP method (GET, POST, PUT, DELETE, etc.)
Path string // URL path
Handler http.HandlerFunc // The handler function
}
CustomRoute represents a custom HTTP handler registered with the app
type FileUpload ¶ added in v0.111.1
type FileUpload struct {
Name string // Original filename
Data []byte // File content (decoded from Base64)
ContentType string // MIME type (e.g., "image/png")
Size int // File size in bytes
}
FileUpload represents an uploaded file from a form submission
type FormInstance ¶
func FormNew ¶
func FormNew(onSubmit Attr) *FormInstance
func (*FormInstance) Button ¶
func (f *FormInstance) Button() *button
func (*FormInstance) File ¶ added in v0.111.1
func (f *FormInstance) File(name string) *TFile
func (*FormInstance) Hidden ¶
func (f *FormInstance) Hidden(name string, value any, attr ...Attr) string
func (*FormInstance) ImageUpload ¶ added in v0.111.1
func (f *FormInstance) ImageUpload(name string) *TImageUpload
func (*FormInstance) RadioButtons ¶
func (f *FormInstance) RadioButtons(name string, data ...any) *ARadio
func (*FormInstance) Render ¶
func (f *FormInstance) Render() string
type JSCallMessage ¶
type JSCallMessage struct {
Type string `json:"type"` // "call"
RID string `json:"rid"` // request ID for correlation
Act string `json:"act"` // "post" or "form"
Path string `json:"path"` // callable endpoint path
Swap string `json:"swap"` // "inline", "outline", "append", "prepend", "none"
Tgt string `json:"tgt"` // target element ID
Vals []BodyItem `json:"vals"` // values/payload
}
JSCallMessage is the WebSocket request for callable actions
type JSElement ¶
type JSElement struct {
T string `json:"t"` // tag name
A map[string]string `json:"a,omitempty"` // attributes (id, class, style, etc.)
E map[string]*JSEvent `json:"e,omitempty"` // events (click, change, submit)
C []interface{} `json:"c,omitempty"` // children (strings or JSElement objects)
}
JSElement represents a DOM element in JSON format
type JSEvent ¶
type JSEvent struct {
Act string `json:"act"` // "post", "form", or "raw"
Swap string `json:"swap,omitempty"` // "inline", "outline", "append", "prepend", "none"
Tgt string `json:"tgt,omitempty"` // target element ID
Path string `json:"path,omitempty"` // server endpoint path
Vals []BodyItem `json:"vals,omitempty"` // pre-populated values
JS string `json:"js,omitempty"` // raw JavaScript code (for act="raw")
}
JSEvent represents a declarative event handler in JSON format
type JSHTTPResponse ¶
type JSHTTPResponse struct {
El *JSElement `json:"el"` // element to render
Ops []*JSPatchOp `json:"ops,omitempty"` // additional operations (notifications, title, etc.)
}
JSHTTPResponse is the HTTP POST response format
type JSPatchMessage ¶
type JSPatchMessage struct {
Type string `json:"type"` // "patch"
Ops []*JSPatchOp `json:"ops"` // operations to apply
}
JSPatchMessage is the WebSocket patch message format
type JSPatchOp ¶
type JSPatchOp struct {
Op string `json:"op"` // "inline", "outline", "append", "prepend", "none", "notify", "title", "reload", "redirect", "download"
Tgt string `json:"tgt,omitempty"` // target element ID
El *JSElement `json:"el,omitempty"` // element to insert/replace
JS string `json:"js,omitempty"` // raw JavaScript (for backwards compatibility)
// Notification fields (when op == "notify")
Msg string `json:"msg,omitempty"` // notification message
Variant string `json:"variant,omitempty"` // "success", "error", "info", "error-reload"
// Title field (when op == "title")
Title string `json:"title,omitempty"` // page title
// Redirect field (when op == "redirect")
Href string `json:"href,omitempty"` // redirect URL
// Download fields (when op == "download")
Data string `json:"data,omitempty"` // base64-encoded file content
ContentType string `json:"content_type,omitempty"` // MIME type
Filename string `json:"filename,omitempty"` // download filename
}
JSPatchOp represents a single patch operation
type JSResponseMessage ¶
type JSResponseMessage struct {
Type string `json:"type"` // "response"
RID string `json:"rid"` // matching request ID
El *JSElement `json:"el"` // element to render
Ops []*JSPatchOp `json:"ops"` // additional operations
}
JSResponseMessage is the WebSocket response for callable actions
type PWAConfig ¶
type PWAConfig struct {
Name string `json:"name"`
ShortName string `json:"short_name"`
ID string `json:"id,omitempty"` // App ID - defaults to StartURL if empty
Description string `json:"description,omitempty"`
ThemeColor string `json:"theme_color,omitempty"`
BackgroundColor string `json:"background_color,omitempty"`
Display string `json:"display,omitempty"`
StartURL string `json:"start_url,omitempty"`
Icons []PWAIcon `json:"icons,omitempty"`
GenerateServiceWorker bool `json:"-"`
CacheAssets []string `json:"-"` // Asset URLs to pre-cache, e.g., ["/assets/style.css"]
OfflinePage string `json:"-"` // Optional offline fallback page URL
}
type SecurityHeaderOptions ¶
type TCollateResult ¶
type TFile ¶ added in v0.111.1
TFile represents a file input component
func (*TFile) Accept ¶ added in v0.111.1
Accept sets allowed file types (MIME types or extensions) Examples: "image/*", ".pdf,.doc", "image/png,image/jpeg"
func (*TFile) ClassInput ¶ added in v0.111.1
ClassInput sets the input element class
func (*TFile) ClassLabel ¶ added in v0.111.1
ClassLabel sets the label class
func (*TFile) GetID ¶ added in v0.111.1
GetID returns the file input's ID (useful for linking with ImagePreview)
func (*TFile) ID ¶ added in v0.111.1
ID sets a custom ID for the file input (useful for linking with ImagePreview) If not set, an auto-generated ID will be used
func (*TFile) ZoneContent ¶ added in v0.111.1
ZoneContent sets completely custom HTML content for zone mode (overrides icon/title/hint)
type TImagePreview ¶ added in v0.111.1
type TImagePreview struct {
// contains filtered or unexported fields
}
TImagePreview represents an image preview component for file inputs
func ImagePreview ¶ added in v0.111.1
func ImagePreview(inputID string) *TImagePreview
ImagePreview creates a new image preview component linked to a file input
func (*TImagePreview) Class ¶ added in v0.111.1
func (c *TImagePreview) Class(value ...string) *TImagePreview
Class sets the wrapper div classes
func (*TImagePreview) If ¶ added in v0.111.1
func (c *TImagePreview) If(value bool) *TImagePreview
If conditionally renders the component
func (*TImagePreview) MaxSize ¶ added in v0.111.1
func (c *TImagePreview) MaxSize(size string) *TImagePreview
MaxSize sets the maximum image dimensions
func (*TImagePreview) Multiple ¶ added in v0.111.1
func (c *TImagePreview) Multiple() *TImagePreview
Multiple enables multi-image grid layout
func (*TImagePreview) Render ¶ added in v0.111.1
func (c *TImagePreview) Render() string
Render generates the HTML and JavaScript for the image preview
type TImageUpload ¶ added in v0.111.1
type TImageUpload struct {
Render func(text string) string
// contains filtered or unexported fields
}
TImageUpload represents a combined image upload component with built-in preview It combines TFile functionality with TImagePreview for a single, image-specific component
func IImageUpload ¶ added in v0.111.1
func IImageUpload(name string) *TImageUpload
IImageUpload creates a new image upload component with default accept="image/*"
func (*TImageUpload) Accept ¶ added in v0.111.1
func (c *TImageUpload) Accept(types string) *TImageUpload
Accept sets allowed file types (MIME types or extensions) Defaults to "image/*" but can be overridden (e.g., "image/png,image/jpeg")
func (*TImageUpload) Change ¶ added in v0.111.1
func (c *TImageUpload) Change(action string) *TImageUpload
Change sets the onchange handler
func (*TImageUpload) Class ¶ added in v0.111.1
func (c *TImageUpload) Class(value ...string) *TImageUpload
Class sets the wrapper div class
func (*TImageUpload) ClassInput ¶ added in v0.111.1
func (c *TImageUpload) ClassInput(value ...string) *TImageUpload
ClassInput sets the input element class
func (*TImageUpload) ClassLabel ¶ added in v0.111.1
func (c *TImageUpload) ClassLabel(value ...string) *TImageUpload
ClassLabel sets the label class
func (*TImageUpload) ClassPreview ¶ added in v0.111.1
func (c *TImageUpload) ClassPreview(classes ...string) *TImageUpload
ClassPreview sets the preview container CSS classes
func (*TImageUpload) ClassZone ¶ added in v0.111.1
func (c *TImageUpload) ClassZone(classes ...string) *TImageUpload
ClassZone sets the zone container CSS classes
func (*TImageUpload) Disabled ¶ added in v0.111.1
func (c *TImageUpload) Disabled(value ...bool) *TImageUpload
Disabled disables the input
func (*TImageUpload) Form ¶ added in v0.111.1
func (c *TImageUpload) Form(value string) *TImageUpload
Form associates the input with a form by ID
func (*TImageUpload) GetID ¶ added in v0.111.1
func (c *TImageUpload) GetID() string
GetID returns the file input's ID
func (*TImageUpload) ID ¶ added in v0.111.1
func (c *TImageUpload) ID(id string) *TImageUpload
ID sets a custom ID for the file input
func (*TImageUpload) If ¶ added in v0.111.1
func (c *TImageUpload) If(value bool) *TImageUpload
If conditionally renders the component
func (*TImageUpload) MaxSize ¶ added in v0.111.1
func (c *TImageUpload) MaxSize(size string) *TImageUpload
MaxSize sets the maximum image dimensions for preview (e.g., "320px")
func (*TImageUpload) Multiple ¶ added in v0.111.1
func (c *TImageUpload) Multiple() *TImageUpload
Multiple allows selecting multiple files
func (*TImageUpload) Required ¶ added in v0.111.1
func (c *TImageUpload) Required(value ...bool) *TImageUpload
Required marks the field as required
func (*TImageUpload) Zone ¶ added in v0.111.1
func (c *TImageUpload) Zone(title, hint string) *TImageUpload
Zone enables dropzone mode with title and hint text
func (*TImageUpload) ZoneContent ¶ added in v0.111.1
func (c *TImageUpload) ZoneContent(html string) *TImageUpload
ZoneContent sets completely custom HTML content for zone mode (overrides icon/title/hint)
func (*TImageUpload) ZoneIcon ¶ added in v0.111.1
func (c *TImageUpload) ZoneIcon(classes string) *TImageUpload
ZoneIcon sets the icon CSS classes for zone mode
type TInput ¶
func (*TInput) Autocomplete ¶
func (*TInput) ClassInput ¶
func (*TInput) ClassLabel ¶
func (*TInput) EmptyOnDefault ¶
func (*TInput) Placeholder ¶
type TTable ¶
type TTable[T any] struct { // contains filtered or unexported fields }
func (*TTable[T]) FieldText ¶
FieldText adds a table field with automatic HTML escaping for safe text content
type TTableSimple ¶
type TTableSimple struct {
// contains filtered or unexported fields
}
func SimpleTable ¶
func SimpleTable(numColumns int, cls ...string) *TTableSimple
func (*TTableSimple) Attr ¶
func (t *TTableSimple) Attr(attrs string) *TTableSimple
func (*TTableSimple) Class ¶
func (t *TTableSimple) Class(column int, classes ...string) *TTableSimple
func (*TTableSimple) Empty ¶
func (t *TTableSimple) Empty() *TTableSimple
func (*TTableSimple) Field ¶
func (t *TTableSimple) Field(value string, cls ...string) *TTableSimple
func (*TTableSimple) FieldText ¶
func (t *TTableSimple) FieldText(value string, cls ...string) *TTableSimple
FieldText adds a field with automatic HTML escaping for safe text content
func (*TTableSimple) Render ¶
func (t *TTableSimple) Render() string
type TargetSwap ¶
TargetSwap pairs a target id with a swap strategy for convenient patch calls.