Documentation
¶
Overview ¶
templ: version: v0.3.1070
Package ui provides composable templ components, Tailwind styles and optional chart rendering. Applications retain their routes, permissions and live transport.
templ: version: v0.3.1070
Index ¶
- func Actions() templ.Component
- func Assets() fs.FS
- func Badge() templ.Component
- func Button(props ButtonProps) templ.Component
- func Dialog(props DialogProps) templ.Component
- func DialogBody() templ.Component
- func DialogHeader(props DialogHeaderProps) templ.Component
- func Field(props FieldProps) templ.Component
- func Input(props InputProps) templ.Component
- func LinkButton(props LinkButtonProps) templ.Component
- func MarshalEChartsOption(option any) (string, error)
- func MetricText(value string) string
- func PageHeader(props PageHeaderProps) templ.Component
- func Select(props SelectProps) templ.Component
- func Tab(props TabProps) templ.Component
- func Tabs(label string) templ.Component
- func VersionLabel(info versioning.Info) templ.Component
- func Widget(props WidgetProps) templ.Component
- func WidgetChart(props WidgetChartProps) templ.Component
- func WidgetData(label string) templ.Component
- func WidgetEmpty() templ.Component
- func WidgetHeader(props WidgetHeaderProps) templ.Component
- func WidgetMetric(label, value, note string) templ.Component
- func WidgetMetricFrame(props WidgetMetricProps) templ.Component
- func WidgetMetricValue(value, exact string) templ.Component
- type ButtonKind
- type ButtonProps
- type DialogHeaderProps
- type DialogProps
- type EChartsBubbleSize
- type EChartsConfig
- type EChartsConversion
- type EChartsEvents
- type EChartsFormatBinding
- type EChartsMessages
- type EChartsOption
- type EChartsTooltip
- type EChartsTooltipValue
- type EChartsValueFormat
- type FieldProps
- type InputProps
- type LinkButtonProps
- type Option
- type PageHeaderProps
- type SelectProps
- type TabProps
- type WidgetChartProps
- type WidgetElement
- type WidgetHeaderProps
- type WidgetMetricProps
- type WidgetProps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assets ¶
Assets serves ui.css, the official echarts.min.js and first-party echarts-format.js/echarts-ui.js without a repository-layout prefix. Serve with http.FileServer and http.StripPrefix at the application-owned URL. v0.6.0 removes the legacy schema adapter and compatibility bundle URL.
func Button ¶
func Button(props ButtonProps) templ.Component
func Dialog ¶
func Dialog(props DialogProps) templ.Component
Dialog supplies the native shell; apps explicitly open it and own close/focus behavior, form submission and authorization. No content is moved or fetched here.
func DialogBody ¶
func DialogHeader ¶
func DialogHeader(props DialogHeaderProps) templ.Component
func Field ¶
func Field(props FieldProps) templ.Component
func Input ¶
func Input(props InputProps) templ.Component
func LinkButton ¶
func LinkButton(props LinkButtonProps) templ.Component
func MarshalEChartsOption ¶ added in v0.6.0
MarshalEChartsOption serializes native JSON without generating JavaScript or trusting HTML. Widgets escape the result into an attribute; JS-only clients use JSON.stringify with the same native object. Runtime validation also applies.
func MetricText ¶
Format only numeric metric labels. Keep units, unavailable values, small precise costs and partial-coverage qualifiers in their original form.
func PageHeader ¶
func PageHeader(props PageHeaderProps) templ.Component
func Select ¶
func Select(props SelectProps) templ.Component
func VersionLabel ¶
func VersionLabel(info versioning.Info) templ.Component
func Widget ¶
func Widget(props WidgetProps) templ.Component
Keep the existing root element, classes and live attributes without adding a wrapper: table scrolling, semantic landmarks and DOM patch identity depend on them.
func WidgetChart ¶
func WidgetChart(props WidgetChartProps) templ.Component
The stable native ECharts host and its fallback remain siblings. Preserve the host and engine-owned children during application DOM patches; call update.
func WidgetData ¶
func WidgetEmpty ¶
func WidgetHeader ¶
func WidgetHeader(props WidgetHeaderProps) templ.Component
The children slot holds the view's actions or badges. Counts retain exact tooltips while using the same compact formatter as other numeric widgets.
func WidgetMetric ¶
func WidgetMetricFrame ¶
func WidgetMetricFrame(props WidgetMetricProps) templ.Component
func WidgetMetricValue ¶
Types ¶
type ButtonKind ¶
type ButtonKind string
const ( Primary ButtonKind = "primary" Secondary ButtonKind = "secondary" Danger ButtonKind = "danger" )
type ButtonProps ¶
type ButtonProps struct {
Type, Class string
Kind ButtonKind
Disabled bool
Attributes templ.Attributes
}
type DialogHeaderProps ¶
type DialogHeaderProps struct{ TitleID, Title, Description string }
type DialogProps ¶
type DialogProps struct {
ID, TitleID, Class string
Attributes templ.Attributes
}
type EChartsBubbleSize ¶ added in v0.6.0
type EChartsBubbleSize struct {
SeriesID string `json:"seriesId,omitempty"`
SeriesIndex *int `json:"seriesIndex,omitempty"`
Dimension int `json:"dimension"`
Min *float64 `json:"min,omitempty"`
Max *float64 `json:"max,omitempty"`
}
EChartsBubbleSize supplies the numeric dimension used by the native scatter symbolSize callback. Min/Max are accepted diameter bounds, not inferred weights.
type EChartsConfig ¶ added in v0.6.0
type EChartsConfig struct {
Locale string `json:"locale,omitempty"`
TimeZone string `json:"timeZone,omitempty"`
Formats []EChartsFormatBinding `json:"formats,omitempty"`
Tooltip []EChartsTooltip `json:"tooltip,omitempty"`
BubbleSizes []EChartsBubbleSize `json:"bubbleSizes,omitempty"`
Events EChartsEvents `json:"events,omitzero"`
Messages EChartsMessages `json:"messages,omitzero"`
Empty bool `json:"empty,omitempty"`
Loading bool `json:"loading,omitempty"`
}
EChartsConfig contains only callbacks JSON cannot encode and shared lifecycle state. Geometry, chart families and data are always native Option fields.
type EChartsConversion ¶ added in v0.6.0
type EChartsEvents ¶ added in v0.6.0
type EChartsFormatBinding ¶ added in v0.6.0
type EChartsFormatBinding struct {
Target string `json:"target"`
Format EChartsValueFormat `json:"format"`
Dimension *int `json:"dimension,omitempty"`
Compact bool `json:"compact,omitempty"`
}
EChartsFormatBinding installs a trusted callback only at a documented native formatter target. Dimension selects a vector coordinate; nil means scalar.
type EChartsMessages ¶ added in v0.6.0
type EChartsOption ¶ added in v0.6.0
EChartsOption is a native ECharts option object. Fields such as series, xAxis, yAxis, legend, grid and dataZoom use the upstream JSON contract directly. It is not a library-specific chart schema. Functions cannot be serialized.
type EChartsTooltip ¶ added in v0.6.0
type EChartsTooltip struct {
SeriesID string `json:"seriesId,omitempty"`
SeriesIndex *int `json:"seriesIndex,omitempty"`
Values []EChartsTooltipValue `json:"values"`
}
type EChartsTooltipValue ¶ added in v0.6.0
type EChartsTooltipValue struct {
Dimension *int `json:"dimension,omitempty"`
Label string `json:"label,omitempty"`
Format EChartsValueFormat `json:"format"`
}
type EChartsValueFormat ¶ added in v0.6.0
type EChartsValueFormat struct {
Unit string `json:"unit,omitempty"`
Precision *int `json:"precision,omitempty"`
Scale string `json:"scale,omitempty"`
InputUnit string `json:"inputUnit,omitempty"`
DisplayUnit string `json:"displayUnit,omitempty"`
Conversion *EChartsConversion `json:"conversion,omitempty"`
}
EChartsValueFormat describes display-only conversion; samples and bounds stay in their native input units. Unit "time" uses Locale/TimeZone, numeric units use the documented bit/byte/rate/custom conversion rules.
type FieldProps ¶
type FieldProps struct {
For, Label, Hint, Class string
Attributes templ.Attributes
}
type InputProps ¶
type InputProps struct {
ID, Name, Value, Type, Placeholder, Class string
Required, Disabled bool
Attributes templ.Attributes
}
type LinkButtonProps ¶
type LinkButtonProps struct {
Href, Class string
Kind ButtonKind
Attributes templ.Attributes
}
type PageHeaderProps ¶
type PageHeaderProps struct {
Title, Description, Class string
Attributes templ.Attributes
}
Presentation props accept server-defined attributes for HTMX and other callers. Permissions, CSRF fields and event handlers remain the application's responsibility.
type SelectProps ¶
type SelectProps struct {
ID, Name, Value, Class string
Options []Option
Required, Disabled bool
Attributes templ.Attributes
}
type TabProps ¶
type TabProps struct {
Label, Href, Class string
Active bool
Attributes templ.Attributes
}
type WidgetChartProps ¶
type WidgetChartProps struct {
ID, Label string
Option any
Config EChartsConfig
EmptyMessage, ErrorMessage, NoScriptNote string
Compact bool
}
WidgetChartProps accepts native ECharts options and safe callback/lifecycle metadata. Option may be EChartsOption, a JSON-marshallable struct or RawMessage. v0.6.0 intentionally replaces Spec; older pinned releases retain that API.
type WidgetElement ¶
type WidgetElement uint8
WidgetElement preserves the semantic containers used by existing pages. A closed set prevents callers from constructing arbitrary HTML tag names.
const ( WidgetSection WidgetElement = iota WidgetDiv WidgetAside )
type WidgetHeaderProps ¶
type WidgetMetricProps ¶
type WidgetProps ¶
type WidgetProps struct {
Element WidgetElement
Class string
Attributes templ.Attributes
}
WidgetProps contains presentation and trusted, server-defined attributes. Feature views retain responsibility for permission checks, links and data.