458 lines
16 KiB
Go
458 lines
16 KiB
Go
// Code generated by templ - DO NOT EDIT.
|
|
|
|
// templ: version: v0.3.977
|
|
// Code generated by wa-generator. DO NOT EDIT.
|
|
|
|
// Source: Web Awesome wa-split-panel
|
|
|
|
package wa
|
|
|
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
|
|
|
import "github.com/a-h/templ"
|
|
import templruntime "github.com/a-h/templ/runtime"
|
|
|
|
import (
|
|
"github.com/a-h/templ"
|
|
)
|
|
|
|
// Split panels display two adjacent panels, allowing the user to reposition them.
|
|
//
|
|
// Web Awesome component: <wa-split-panel>
|
|
|
|
// SplitPanelProps holds all properties for the wa-split-panel component
|
|
type SplitPanelProps struct {
|
|
// The current position of the divider from the primary panel's edge as a percentage 0-100. Defaults to 50% of the
|
|
Position float64 `attr:"position"`
|
|
// The current position of the divider from the primary panel's edge in pixels.
|
|
PositionInPixels float64 `attr:"position-in-pixels"`
|
|
// Sets the split panel's orientation.
|
|
// Valid values: "horizontal", "vertical"
|
|
Orientation string `attr:"orientation"`
|
|
// Disables resizing. Note that the position may still change as a result of resizing the host element.
|
|
Disabled bool `attr:"disabled"`
|
|
// If no primary panel is designated, both panels will resize proportionally when the host element is resized. If a
|
|
// Valid values: "start", "end"
|
|
Primary string `attr:"primary"`
|
|
// One or more space-separated values at which the divider should snap. Values can be in pixels or percentages, e.g.
|
|
Snap string `attr:"snap"`
|
|
// How close the divider must be to a snap point until snapping occurs.
|
|
SnapThreshold float64 `attr:"snap-threshold"`
|
|
|
|
// Events
|
|
// Emitted when the divider's position changes.
|
|
OnReposition string `attr:"x-on:wa-reposition"`
|
|
|
|
// Slots contains named slot content
|
|
Slots SplitPanelSlots
|
|
|
|
// Attrs contains additional HTML attributes
|
|
Attrs templ.Attributes
|
|
}
|
|
|
|
// SplitPanelSlots holds named slot content for the component
|
|
type SplitPanelSlots struct {
|
|
// Content to place in the start panel.
|
|
Start templ.Component
|
|
// Content to place in the end panel.
|
|
End templ.Component
|
|
// The divider. Useful for slotting in a custom icon that renders as a handle.
|
|
Divider templ.Component
|
|
}
|
|
|
|
// SplitPanelBuilder provides a fluent API for constructing SplitPanelProps
|
|
type SplitPanelBuilder struct {
|
|
props SplitPanelProps
|
|
}
|
|
|
|
// NewSplitPanel creates a new builder for wa-split-panel
|
|
func NewSplitPanel() *SplitPanelBuilder {
|
|
return &SplitPanelBuilder{}
|
|
}
|
|
|
|
// Position sets the position attribute
|
|
// The current position of the divider from the primary panel's edge as a percentage 0-100. Defaults to 50% of the
|
|
func (b *SplitPanelBuilder) Position(v float64) *SplitPanelBuilder {
|
|
b.props.Position = v
|
|
return b
|
|
}
|
|
|
|
// PositionInPixels sets the position-in-pixels attribute
|
|
// The current position of the divider from the primary panel's edge in pixels.
|
|
func (b *SplitPanelBuilder) PositionInPixels(v float64) *SplitPanelBuilder {
|
|
b.props.PositionInPixels = v
|
|
return b
|
|
}
|
|
|
|
// Orientation sets the orientation attribute
|
|
// Sets the split panel's orientation.
|
|
func (b *SplitPanelBuilder) Orientation(v string) *SplitPanelBuilder {
|
|
b.props.Orientation = v
|
|
return b
|
|
}
|
|
|
|
// Disabled sets the disabled attribute
|
|
// Disables resizing. Note that the position may still change as a result of resizing the host element.
|
|
func (b *SplitPanelBuilder) Disabled(v bool) *SplitPanelBuilder {
|
|
b.props.Disabled = v
|
|
return b
|
|
}
|
|
|
|
// Primary sets the primary attribute
|
|
// If no primary panel is designated, both panels will resize proportionally when the host element is resized. If a
|
|
func (b *SplitPanelBuilder) Primary(v string) *SplitPanelBuilder {
|
|
b.props.Primary = v
|
|
return b
|
|
}
|
|
|
|
// Snap sets the snap attribute
|
|
// One or more space-separated values at which the divider should snap. Values can be in pixels or percentages, e.g.
|
|
func (b *SplitPanelBuilder) Snap(v string) *SplitPanelBuilder {
|
|
b.props.Snap = v
|
|
return b
|
|
}
|
|
|
|
// SnapThreshold sets the snap-threshold attribute
|
|
// How close the divider must be to a snap point until snapping occurs.
|
|
func (b *SplitPanelBuilder) SnapThreshold(v float64) *SplitPanelBuilder {
|
|
b.props.SnapThreshold = v
|
|
return b
|
|
}
|
|
|
|
// OnReposition sets the handler for wa-reposition event
|
|
// Emitted when the divider's position changes.
|
|
func (b *SplitPanelBuilder) OnReposition(handler string) *SplitPanelBuilder {
|
|
b.props.OnReposition = handler
|
|
return b
|
|
}
|
|
|
|
// StartSlot sets the start slot content
|
|
// Content to place in the start panel.
|
|
func (b *SplitPanelBuilder) StartSlot(c templ.Component) *SplitPanelBuilder {
|
|
b.props.Slots.Start = c
|
|
return b
|
|
}
|
|
|
|
// EndSlot sets the end slot content
|
|
// Content to place in the end panel.
|
|
func (b *SplitPanelBuilder) EndSlot(c templ.Component) *SplitPanelBuilder {
|
|
b.props.Slots.End = c
|
|
return b
|
|
}
|
|
|
|
// DividerSlot sets the divider slot content
|
|
// The divider. Useful for slotting in a custom icon that renders as a handle.
|
|
func (b *SplitPanelBuilder) DividerSlot(c templ.Component) *SplitPanelBuilder {
|
|
b.props.Slots.Divider = c
|
|
return b
|
|
}
|
|
|
|
// Attr adds a custom HTML attribute
|
|
func (b *SplitPanelBuilder) Attr(name, value string) *SplitPanelBuilder {
|
|
if b.props.Attrs == nil {
|
|
b.props.Attrs = templ.Attributes{}
|
|
}
|
|
b.props.Attrs[name] = value
|
|
return b
|
|
}
|
|
|
|
// Attrs merges multiple attributes
|
|
func (b *SplitPanelBuilder) Attrs(attrs templ.Attributes) *SplitPanelBuilder {
|
|
if b.props.Attrs == nil {
|
|
b.props.Attrs = templ.Attributes{}
|
|
}
|
|
for k, v := range attrs {
|
|
b.props.Attrs[k] = v
|
|
}
|
|
return b
|
|
}
|
|
|
|
// Props returns the built properties
|
|
func (b *SplitPanelBuilder) Props() SplitPanelProps {
|
|
return b.props
|
|
}
|
|
|
|
// Build returns the props (alias for Props for semantic clarity)
|
|
func (b *SplitPanelBuilder) Build() SplitPanelProps {
|
|
return b.props
|
|
}
|
|
|
|
// SplitPanel renders the wa-split-panel component
|
|
func SplitPanel(props SplitPanelProps) templ.Component {
|
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
return templ_7745c5c3_CtxErr
|
|
}
|
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
if !templ_7745c5c3_IsBuffer {
|
|
defer func() {
|
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err == nil {
|
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
}
|
|
}()
|
|
}
|
|
ctx = templ.InitializeContext(ctx)
|
|
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
|
if templ_7745c5c3_Var1 == nil {
|
|
templ_7745c5c3_Var1 = templ.NopComponent
|
|
}
|
|
ctx = templ.ClearChildren(ctx)
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<wa-split-panel")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
if props.Position != 0 {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " position=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var2 string
|
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.Position))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/split-panel.templ`, Line: 175, Col: 49}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.PositionInPixels != 0 {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " position-in-pixels=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var3 string
|
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.PositionInPixels))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/split-panel.templ`, Line: 178, Col: 67}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.Orientation != "" {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " orientation=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var4 string
|
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(props.Orientation)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/split-panel.templ`, Line: 181, Col: 34}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.Disabled {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, " disabled")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.Primary != "" {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " primary=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var5 string
|
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(props.Primary)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/split-panel.templ`, Line: 187, Col: 26}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.Snap != "" {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " snap=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var6 string
|
|
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(props.Snap)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/split-panel.templ`, Line: 190, Col: 20}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.SnapThreshold != 0 {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " snap-threshold=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var7 string
|
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(templ.Sprintf("%v", props.SnapThreshold))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/split-panel.templ`, Line: 193, Col: 60}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.OnReposition != "" {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " x-on:wa-reposition=\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
var templ_7745c5c3_Var8 string
|
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnReposition)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/split-panel.templ`, Line: 196, Col: 42}
|
|
}
|
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "\"")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
templ_7745c5c3_Err = templ.RenderAttributes(ctx, templ_7745c5c3_Buffer, props.Attrs)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, ">")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
if props.Slots.Start != nil {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<div slot=\"start\">")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = props.Slots.Start.Render(ctx, templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</div>")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.Slots.End != nil {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<div slot=\"end\">")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = props.Slots.End.Render(ctx, templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</div>")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
if props.Slots.Divider != nil {
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<div slot=\"divider\">")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = props.Slots.Divider.Render(ctx, templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</div>")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
}
|
|
templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</wa-split-panel>")
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// SplitPanelFunc renders with a builder function for inline configuration
|
|
func SplitPanelFunc(fn func(*SplitPanelBuilder)) templ.Component {
|
|
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
|
return templ_7745c5c3_CtxErr
|
|
}
|
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
if !templ_7745c5c3_IsBuffer {
|
|
defer func() {
|
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err == nil {
|
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
}
|
|
}()
|
|
}
|
|
ctx = templ.InitializeContext(ctx)
|
|
templ_7745c5c3_Var9 := templ.GetChildren(ctx)
|
|
if templ_7745c5c3_Var9 == nil {
|
|
templ_7745c5c3_Var9 = templ.NopComponent
|
|
}
|
|
ctx = templ.ClearChildren(ctx)
|
|
b := NewSplitPanel()
|
|
fn(b)
|
|
templ_7745c5c3_Var10 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
|
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
if !templ_7745c5c3_IsBuffer {
|
|
defer func() {
|
|
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err == nil {
|
|
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
}
|
|
}()
|
|
}
|
|
ctx = templ.InitializeContext(ctx)
|
|
templ_7745c5c3_Err = templ_7745c5c3_Var9.Render(ctx, templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
return nil
|
|
})
|
|
templ_7745c5c3_Err = SplitPanel(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var10), templ_7745c5c3_Buffer)
|
|
if templ_7745c5c3_Err != nil {
|
|
return templ_7745c5c3_Err
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
var _ = templruntime.GeneratedTemplate
|