ui

package
v0.111.17 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Overview

Package ui, holds components for web application

Index

Constants

View Source
const (
	AccordionBordered  = "bordered"
	AccordionGhost     = "ghost"
	AccordionSeparated = "separated"
)
View Source
const (
	// Card variants
	CardBordered = "bordered"
	CardShadowed = "shadowed"
	CardFlat     = "flat"
	CardGlass    = "glass"
)
View Source
const (
	BOOL = iota
	// BOOL_NEGATIVE
	// BOOL_ZERO
	NOT_ZERO_DATE
	ZERO_DATE
	DATES
	SELECT
)
View Source
const (
	XS = " p-1"
	SM = " p-2"
	MD = " p-3"
	ST = " p-4"
	LG = " p-5"
	XL = " p-6"
)
View Source
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"
)
View Source
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

View Source
const (
	TabsStylePills     = "pills"
	TabsStyleUnderline = "underline"
	TabsStyleBoxed     = "boxed"
	TabsStyleVertical  = "vertical"
)

Tab style constants

Variables

View Source
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

View Source
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;"}
)
View Source
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)

View Source
var BOOL_ZERO_OPTIONS = []AOption{
	{
		ID:    "",
		Value: "All",
	},
	{
		ID:    "yes",
		Value: "On",
	},
	{
		ID:    "no",
		Value: "Off",
	},
}
View Source
var Classes = func(values ...string) string {
	return Trim(strings.Join(values, " "))
}
View Source
var Flex1 = Div("flex-1")()

Flex1 creates a flex-1 div element

View Source
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)})...)
}
View Source
var Href = func(value string, target ...string) Attr {
	if len(target) > 0 {
		return Attr{Href: value, Target: target[0]}
	}

	return Attr{Href: value}
}
View Source
var ID = func(target string) Attr {
	return Attr{ID: target}
}
View Source
var IEmail = func(name string, data ...any) *TInput {
	return IText(name, data...).
		Type("email").
		Autocomplete("email").
		Placeholder("[email protected]")
}
View Source
var IPhone = func(name string, data ...any) *TInput {
	return IText(name, data...).
		Type("tel").
		Autocomplete("tel").
		Placeholder("+421").
		Pattern("\\+[0-9]{10,14}")
}
View Source
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)
	}
}
View Source
var Script = func(value ...string) string {
	return Trim(fmt.Sprintf(`<script>%s</script>`, strings.Join(value, " ")))
}
View Source
var Space = "&nbsp;"

Space represents a non-breaking space

View Source
var Src = func(alt string, target string) Attr {
	return Attr{Src: target, Alt: alt}
}
View Source
var Target = func() Attr {
	return Attr{ID: "i" + RandomString(15)}
}
View Source
var Title = func(value string) Attr {
	return Attr{Title: string(value)}
}

Functions

func Accordion

func Accordion() *accordion

Accordion creates a new accordion component

func Alert

func Alert() *alert

Alert creates a new alert component with default settings

func Badge

func Badge(attr ...Attr) *badge

func Button

func Button(attr ...Attr) *button

func Captcha

func Captcha(siteKey string, secured string) string

func Card

func Card() *card

func Collate

func Collate[T any](init *TQuery) *collate[T]

Collate constructs a new collate with sensible defaults using the provided init query. Default color scheme is blue.

func Dropdown() *dropdown

Dropdown creates a new dropdown component with default settings

func El

func El(tag string, class string, attr ...Attr) func(elements ...string) string

El creates an HTML element constructor for any tag

func ElClosed

func ElClosed(tag string, class string, attr ...Attr) string

ElClosed creates an HTML element constructor for self-closing tags

func Error

func Error(err error) string

func ErrorField

func ErrorField(err validator.FieldError) string

func ErrorForm

func ErrorForm(errs *error, translations *map[string]string) string

func FilterHiddenFields

func FilterHiddenFields(query *TQuery) string

FilterHiddenFields generates hidden form fields for filter state only. Use this when other query fields (Search, Order, etc.) are handled separately.

func Filtering

func Filtering[T any](ctx *Context, collate *collate[T], query *TQuery) string

func For

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

func Icon(css string, attr ...Attr) string

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 Icon2 added in v0.111.6

func Icon2(iconName string, extraClasses string) string

Icon2 creates an icon with additional CSS classes

func IconBasic

func IconBasic(class string, text string) string

IconBasic is kept for backward compatibility

func IconEnd

func IconEnd(css string, text string) string

func IconLeft

func IconLeft(css string, text string) string

func IconRight

func IconRight(css string, text string) string

func IconStart

func IconStart(css string, text string) string

func If

func If(cond bool, value func() string) string

func Iff

func Iff(cond bool) func(value ...string) string

func Map

func Map[T any](values []T, iter func(*T, int) string) string

func Map2

func Map2[T any](values []T, iter func(T, int) []string) string

func Normalize

func Normalize(s string) string

func NormalizeForSearch

func NormalizeForSearch(search string) string

NormalizeForSearch normalizes a search term to handle diacritics and special characters This makes searches more user-friendly by matching accented characters

func Or

func Or(cond bool, value func() string, other func() string) string

func Paging

func Paging[T any](ctx *Context, collate *collate[T], result *TCollateResult[T]) string

func PathValue

func PathValue(obj any, path string) (*reflect.Value, error)

func Print

func Print(value any) string

func ProgressBar

func ProgressBar() *progress

func ProgressWithLabel

func ProgressWithLabel(percent int) *progress

ProgressWithLabel creates a progress bar with percentage label

func QueryHiddenFields

func QueryHiddenFields(query *TQuery) string

QueryHiddenFields generates hidden form fields for preserving query state including all filter values. This ensures filter state persists across form submissions.

func RandomString

func RandomString(n ...int) string

RandomString generates a cryptographically secure random string

func RegisterSQLiteNormalize

func RegisterSQLiteNormalize(db *gorm.DB) error

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 SkeletonListN(count int) string

func SkeletonPageBlock

func SkeletonPageBlock() string

func Sorting

func Sorting[T any](ctx *Context, collate *collate[T], query *TQuery) string

func StepProgress

func StepProgress(current, total int) *stepProgress

StepProgress creates a new step progress indicator

func StepText

func StepText(current, total int, label string) *stepProgress

StepText creates a step progress with custom text label

func Tabs

func Tabs() *tabs

Tabs creates a new tabs component for tabbed navigation

func Text

func Text(text string) string

Text is a pass-through for plain text (no transformation needed in HTML mode)

func ThemeSwitcher

func ThemeSwitcher(css string) string

ThemeSwitcher renders a small button that cycles System → Light → Dark. It relies on the global setTheme(mode) provided by the server (__theme script).

func Tooltip

func Tooltip() *tooltip

Tooltip creates a new tooltip component with default settings

func Trim

func Trim(s string) string

func Variable

func Variable[T any](getter func(*T) string) func(item *T) Attr

Types

type ALabel

type ALabel struct {
	// contains filtered or unexported fields
}

func Label

func Label(target *Attr) *ALabel

func (*ALabel) Class

func (c *ALabel) Class(value ...string) *ALabel

func (*ALabel) ClassLabel

func (c *ALabel) ClassLabel(value ...string) *ALabel

func (*ALabel) Disabled

func (c *ALabel) Disabled(value bool) *ALabel

func (*ALabel) Render

func (c *ALabel) Render(text string) string

Render generates JavaScript code that creates the label element

func (*ALabel) Required

func (c *ALabel) Required(value bool) *ALabel

type AOption

type AOption struct {
	ID    string
	Value string
}

func MakeOptions

func MakeOptions(options []string) []AOption

type ARadio

type ARadio struct {
	// contains filtered or unexported fields
}

func IRadioButtons

func IRadioButtons(name string, data ...any) *ARadio

func IRadioDiv

func IRadioDiv(name string, data ...any) *ARadio

func (*ARadio) Change

func (c *ARadio) Change(action string) *ARadio

func (*ARadio) Class

func (c *ARadio) Class(value ...string) *ARadio

func (*ARadio) ClassLabel

func (c *ARadio) ClassLabel(value ...string) *ARadio

func (*ARadio) Disabled

func (c *ARadio) Disabled(value ...bool) *ARadio

func (*ARadio) Empty

func (c *ARadio) Empty() *ARadio

func (*ARadio) Error

func (c *ARadio) Error(errs *error) *ARadio

func (*ARadio) Form

func (c *ARadio) Form(form string) *ARadio

func (*ARadio) If

func (c *ARadio) If(value bool) *ARadio

func (*ARadio) Options

func (c *ARadio) Options(options []AOption) *ARadio

func (*ARadio) Placeholder

func (c *ARadio) Placeholder(value string) *ARadio

func (*ARadio) RadioPosition

func (c *ARadio) RadioPosition(class string) *ARadio

func (*ARadio) Render

func (c *ARadio) Render(text string) string

func (*ARadio) Required

func (c *ARadio) Required(value ...bool) *ARadio

type ASelect

type ASelect struct {
	// contains filtered or unexported fields
}

func ISelect

func ISelect(name string, data ...any) *ASelect

func (*ASelect) Change

func (c *ASelect) Change(action string) *ASelect

func (*ASelect) Class

func (c *ASelect) Class(value ...string) *ASelect

func (*ASelect) Disabled

func (c *ASelect) Disabled(value ...bool) *ASelect

func (*ASelect) Empty

func (c *ASelect) Empty() *ASelect

func (*ASelect) Error

func (c *ASelect) Error(errs *error) *ASelect

func (*ASelect) Form

func (c *ASelect) Form(form string) *ASelect

func (*ASelect) If

func (c *ASelect) If(value bool) *ASelect

func (*ASelect) Options

func (c *ASelect) Options(options []AOption) *ASelect

func (*ASelect) Placeholder

func (c *ASelect) Placeholder(value string) *ASelect

func (*ASelect) Render

func (c *ASelect) Render(text string) string

func (*ASelect) Required

func (c *ASelect) Required(value ...bool) *ASelect

type Action

type Action struct {
	Method *Callable
	Target Attr
	Values []any
}

type ActionType

type ActionType string
const (
	POST ActionType = "POST"
	FORM ActionType = "FORM"
)

type Actions

type Actions struct {
	Render  func(target Attr) string
	Replace func(target Attr) string
	Append  func(target Attr) string
	Prepend func(target Attr) string
	None    func() string
}

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 MakeApp

func MakeApp(defaultLanguage string) *App

func (*App) Action

func (app *App) Action(uid string, action Callable) **Callable

func (*App) Assets

func (app *App) Assets(assets embed.FS, path string, maxAge time.Duration)

func (*App) AutoRestart

func (app *App) AutoRestart(enable bool)

func (*App) Callable

func (app *App) Callable(action Callable) **Callable

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

func (app *App) Debug(enable bool)

Debug enables or disables server debug logging. When enabled, debug logs are printed with the "gsui:" prefix.

func (*App) Description

func (app *App) Description(description string)

func (*App) Favicon

func (app *App) Favicon(assets embed.FS, path string, maxAge time.Duration)

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) HTML

func (app *App) HTML(title string, class string, body ...string) string

func (*App) Handler added in v0.111.8

func (app *App) Handler() http.Handler

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

func (app *App) Layout(handler Callable)

Layout sets the persistent layout function that wraps all pages. The layout should render a content slot element with id="__content__".

func (*App) Listen

func (app *App) Listen(port string)

func (*App) Mount added in v0.111.17

func (app *App) Mount(prefix string, mux *http.ServeMux)

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

func (app *App) PWA(config PWAConfig)

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

func (app *App) Page(path string, title string, handler Callable)

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) Register

func (app *App) Register(httpMethod string, path string, method *Callable) string

func (*App) StartSweeper

func (app *App) StartSweeper()

StartSweeper launches a background goroutine to prune inactive sessions

func (*App) TestHandler

func (app *App) TestHandler() http.Handler

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

func (a Attr) Skeleton(kind ...Skeleton) string

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

func (a Attr) SkeletonComponent() string

SkeletonComponent renders a component-sized content block.

func (Attr) SkeletonDefault

func (a Attr) SkeletonDefault() string

SkeletonDefault renders three generic text lines.

func (Attr) SkeletonForm

func (a Attr) SkeletonForm() string

SkeletonForm renders a form-shaped skeleton: labels, inputs, actions.

func (Attr) SkeletonList

func (a Attr) SkeletonList(count int) string

SkeletonList renders a vertical list of generic list items (avatar + text).

func (Attr) SkeletonPage

func (a Attr) SkeletonPage() string

SkeletonPage renders a larger page-level skeleton with header and two cards.

type BodyItem

type BodyItem struct {
	Name        string `json:"name"`
	Value       string `json:"value"`
	Type        string `json:"type"`
	Filename    string `json:"filename,omitempty"`
	ContentType string `json:"content_type,omitempty"`
}

type CSS

type CSS struct {
	Orig   string
	Set    string
	Append []string
}

func (*CSS) Value

func (c *CSS) Value() string

type Callable

type Callable = func(*Context) string

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

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

Count configures how many characters are generated for the captcha challenge.

func (*Captcha3Component) Lifetime

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) Action

func (ctx *Context) Action(uid string, action Callable) **Callable

func (*Context) AllQueryParams

func (ctx *Context) AllQueryParams() map[string][]string

AllQueryParams returns all query parameters as a map.

func (*Context) Body

func (ctx *Context) Body(output any) error

func (*Context) Call

func (ctx *Context) Call(method Callable, values ...any) Actions

func (*Context) Callable

func (ctx *Context) Callable(action Callable) **Callable

func (*Context) Click

func (ctx *Context) Click(method Callable, values ...any) Submits

func (*Context) DownloadAs

func (ctx *Context) DownloadAs(file *io.Reader, contentType string, name string) error

func (*Context) Error

func (ctx *Context) Error(message string) string

func (*Context) ErrorReload

func (ctx *Context) ErrorReload(message string)

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) IP

func (ctx *Context) IP() string

func (*Context) Info

func (ctx *Context) Info(message string) string

func (*Context) Load

func (ctx *Context) Load(href string) Attr

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

func (ctx *Context) PathParam(name string) string

PathParam returns the value of a path parameter extracted from the route pattern. Returns empty string if the parameter doesn't exist.

func (*Context) Post

func (ctx *Context) Post(as ActionType, swap Swap, action *Action) string

func (*Context) QueryParam

func (ctx *Context) QueryParam(name string) string

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

func (ctx *Context) QueryParams(name string) []string

QueryParams returns all values for a query parameter (for multi-value params). Returns nil if the parameter doesn't exist.

func (*Context) Redirect

func (ctx *Context) Redirect(href string) string

Redirect adds a redirect operation that will navigate to the specified URL

func (*Context) Reload

func (ctx *Context) Reload() string

Reload adds a reload operation that will reload the page on the client

func (*Context) Render

func (ctx *Context) Render(target Attr, html string)

Render renders HTML inside the given target element (replaces innerHTML).

func (*Context) Replace

func (ctx *Context) Replace(target Attr, html string)

Replace replaces the given target element with HTML (replaces outerHTML).

func (*Context) Send

func (ctx *Context) Send(method Callable, values ...any) Actions

func (*Context) Session

func (ctx *Context) Session(db *gorm.DB, name string) *TSession

func (*Context) SetCSP

func (ctx *Context) SetCSP(policy string)

SetCSP sets Content Security Policy headers to help prevent XSS attacks

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

func (*Context) Submit

func (ctx *Context) Submit(method Callable, values ...any) Submits

func (*Context) Success

func (ctx *Context) Success(message string) string

func (*Context) Title

func (ctx *Context) Title(title string)

Title updates the page title dynamically

func (*Context) Translate

func (ctx *Context) Translate(message string, val ...any) string

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

type FormInstance struct {
	FormId   string
	OnSubmit Attr
}

func FormNew

func FormNew(onSubmit Attr) *FormInstance

func (*FormInstance) Area

func (f *FormInstance) Area(name string, data ...any) *TInput

func (*FormInstance) Button

func (f *FormInstance) Button() *button

func (*FormInstance) Checkbox

func (f *FormInstance) Checkbox(name string, data ...any) *TInput

func (*FormInstance) Date

func (f *FormInstance) Date(name string, data ...any) *TInput

func (*FormInstance) DateTime

func (f *FormInstance) DateTime(name string, data ...any) *TInput

func (*FormInstance) Email

func (f *FormInstance) Email(name string, data ...any) *TInput

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) Number

func (f *FormInstance) Number(name string, data ...any) *TInput

func (*FormInstance) Password

func (f *FormInstance) Password(name string, data ...any) *TInput

func (*FormInstance) Phone

func (f *FormInstance) Phone(name string, data ...any) *TInput

func (*FormInstance) Radio

func (f *FormInstance) Radio(name string, data ...any) *TInput

func (*FormInstance) RadioButtons

func (f *FormInstance) RadioButtons(name string, data ...any) *ARadio

func (*FormInstance) RadioDiv

func (f *FormInstance) RadioDiv(name string, data ...any) *ARadio

func (*FormInstance) Render

func (f *FormInstance) Render() string

func (*FormInstance) Select

func (f *FormInstance) Select(name string, data ...any) *ASelect

func (*FormInstance) Text

func (f *FormInstance) Text(name string, data ...any) *TInput

func (*FormInstance) Time

func (f *FormInstance) Time(name string, data ...any) *TInput

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 PWAIcon

type PWAIcon struct {
	Src     string `json:"src"`
	Sizes   string `json:"sizes"`
	Type    string `json:"type"`
	Purpose string `json:"purpose,omitempty"` // "any", "maskable", or "any maskable"
}

type Route

type Route struct {
	Path       string
	Title      string
	Handler    *Callable
	Pattern    string   // original pattern like "/vehicles/edit/{id}"
	Segments   []string // split segments for matching
	ParamNames []string // names of parameters in order
	HasParams  bool     // whether this route has path parameters
}

type SecurityHeaderOptions

type SecurityHeaderOptions struct {
	CSP                string
	HSTS               string
	EnableHSTS         bool
	FrameOptions       string
	ContentTypeOptions bool
	XSSProtection      string
	ReferrerPolicy     string
	PermissionsPolicy  string
}

type Skeleton

type Skeleton string
const (
	SkeletonList      Skeleton = "list"
	SkeletonComponent Skeleton = "component"
	SkeletonPage      Skeleton = "page"
	SkeletonForm      Skeleton = "form"
)

type Submits

type Submits struct {
	Render  func(target Attr) Attr
	Replace func(target Attr) Attr
	Append  func(target Attr) Attr
	Prepend func(target Attr) Attr
	None    func() Attr
}

type Swap

type Swap string
const (
	OUTLINE Swap = "outline"
	INLINE  Swap = "inline"
	APPEND  Swap = "append"
	PREPEND Swap = "prepend"
	NONE    Swap = "none"
)

type TCollateResult

type TCollateResult[T any] struct {
	Total    int64
	Filtered int64
	Data     []T
	Query    *TQuery
}

type TField

type TField struct {
	DB    string
	Field string
	Text  string

	Value     string
	As        uint
	Condition string
	Options   []AOption

	Bool bool
	// Value string
	Dates struct {
		From time.Time
		To   time.Time
	}
}

type TFile added in v0.111.1

type TFile struct {
	Render func(text string) string
	// contains filtered or unexported fields
}

TFile represents a file input component

func IFile added in v0.111.1

func IFile(name string) *TFile

func (*TFile) Accept added in v0.111.1

func (c *TFile) Accept(types string) *TFile

Accept sets allowed file types (MIME types or extensions) Examples: "image/*", ".pdf,.doc", "image/png,image/jpeg"

func (*TFile) Change added in v0.111.1

func (c *TFile) Change(action string) *TFile

Change sets the onchange handler

func (*TFile) Class added in v0.111.1

func (c *TFile) Class(value ...string) *TFile

Class sets the wrapper div class

func (*TFile) ClassInput added in v0.111.1

func (c *TFile) ClassInput(value ...string) *TFile

ClassInput sets the input element class

func (*TFile) ClassLabel added in v0.111.1

func (c *TFile) ClassLabel(value ...string) *TFile

ClassLabel sets the label class

func (*TFile) ClassZone added in v0.111.1

func (c *TFile) ClassZone(classes ...string) *TFile

ClassZone sets the zone container CSS classes

func (*TFile) Disabled added in v0.111.1

func (c *TFile) Disabled(value ...bool) *TFile

Disabled disables the input

func (*TFile) Form added in v0.111.1

func (c *TFile) Form(value string) *TFile

Form associates the input with a form by ID

func (*TFile) GetID added in v0.111.1

func (c *TFile) GetID() string

GetID returns the file input's ID (useful for linking with ImagePreview)

func (*TFile) ID added in v0.111.1

func (c *TFile) ID(id string) *TFile

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) If added in v0.111.1

func (c *TFile) If(value bool) *TFile

If conditionally renders the component

func (*TFile) Multiple added in v0.111.1

func (c *TFile) Multiple() *TFile

Multiple allows selecting multiple files

func (*TFile) Required added in v0.111.1

func (c *TFile) Required(value ...bool) *TFile

Required marks the field as required

func (*TFile) Zone added in v0.111.1

func (c *TFile) Zone(title, hint string) *TFile

Zone enables dropzone mode with title and hint text

func (*TFile) ZoneContent added in v0.111.1

func (c *TFile) ZoneContent(html string) *TFile

ZoneContent sets completely custom HTML content for zone mode (overrides icon/title/hint)

func (*TFile) ZoneIcon added in v0.111.1

func (c *TFile) ZoneIcon(classes string) *TFile

ZoneIcon sets the icon CSS classes for zone mode

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

type TInput struct {
	Render func(text string) string
	// contains filtered or unexported fields
}

func IArea

func IArea(name string, data ...any) *TInput

func ICheckbox

func ICheckbox(name string, data ...any) *TInput

func IDate

func IDate(name string, data ...any) *TInput

func IDateTime

func IDateTime(name string, data ...any) *TInput

func INumber

func INumber(name string, data ...any) *TInput

func IPassword

func IPassword(name string, data ...any) *TInput

func IRadio

func IRadio(name string, data ...any) *TInput

func IText

func IText(name string, data ...any) *TInput

func ITime

func ITime(name string, data ...any) *TInput

func IValue

func IValue(attr ...Attr) *TInput

func (*TInput) Autocomplete

func (c *TInput) Autocomplete(value string) *TInput

func (*TInput) Change

func (c *TInput) Change(action string) *TInput

func (*TInput) Class

func (c *TInput) Class(value ...string) *TInput

func (*TInput) ClassInput

func (c *TInput) ClassInput(value ...string) *TInput

func (*TInput) ClassLabel

func (c *TInput) ClassLabel(value ...string) *TInput

func (*TInput) Click

func (c *TInput) Click(action string) *TInput

func (*TInput) Dates

func (c *TInput) Dates(min time.Time, max time.Time) *TInput

func (*TInput) Disabled

func (c *TInput) Disabled(value ...bool) *TInput

func (*TInput) EmptyOnDefault

func (c *TInput) EmptyOnDefault() *TInput

func (*TInput) Error

func (c *TInput) Error(errs *error) *TInput

func (*TInput) Form

func (c *TInput) Form(value string) *TInput

func (*TInput) Format

func (c *TInput) Format(value string) *TInput

func (*TInput) If

func (c *TInput) If(value bool) *TInput

func (*TInput) Numbers

func (c *TInput) Numbers(min float64, max float64, step float64) *TInput

func (*TInput) Pattern

func (c *TInput) Pattern(value string) *TInput

func (*TInput) Placeholder

func (c *TInput) Placeholder(value string) *TInput

func (*TInput) Readonly

func (c *TInput) Readonly(value ...bool) *TInput

func (*TInput) Required

func (c *TInput) Required(value ...bool) *TInput

func (*TInput) Rows

func (c *TInput) Rows(value uint8) *TInput

func (*TInput) Size

func (c *TInput) Size(value string) *TInput

func (*TInput) Type

func (c *TInput) Type(value string) *TInput

func (*TInput) Value

func (c *TInput) Value(value string) *TInput

type TQuery

type TQuery struct {
	Limit        int64
	Offset       int64
	Order        string
	PendingOrder string // Pending sort order that will be applied on "Apply" click
	Search       string
	Filter       []TField
}

type TSession

type TSession struct {
	DB        *gorm.DB `gorm:"-"`
	SessionID string
	Name      string
	Data      datatypes.JSON
}

func (*TSession) Load

func (session *TSession) Load(data any)

func (*TSession) Save

func (session *TSession) Save(output any)

func (TSession) TableName

func (TSession) TableName() string

type TTable

type TTable[T any] struct {
	// contains filtered or unexported fields
}

func NewTable

func NewTable[T any](cls string) *TTable[T]

func Table

func Table[T any](cls string) *TTable[T]

func (*TTable[T]) Field

func (t *TTable[T]) Field(slot func(item *T) string, cls string) *TTable[T]

func (*TTable[T]) FieldText

func (t *TTable[T]) FieldText(slot func(item *T) string, cls string) *TTable[T]

FieldText adds a table field with automatic HTML escaping for safe text content

func (*TTable[T]) Head

func (t *TTable[T]) Head(value string, cls string) *TTable[T]

func (*TTable[T]) HeadHTML

func (t *TTable[T]) HeadHTML(value string, cls string) *TTable[T]

HeadHTML adds a table header with raw HTML content (use with caution)

func (*TTable[T]) Render

func (t *TTable[T]) Render(data []*T) string

func (*TTable[T]) Row

func (t *TTable[T]) Row(slot func(item *T) []string, cls string) *TTable[T]

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

type TargetSwap struct {
	ID   string
	Swap Swap
}

TargetSwap pairs a target id with a swap strategy for convenient patch calls.

Jump to

Keyboard shortcuts

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