Files
nebula/pkg/wa/zoomable-frame_templ.go

520 lines
18 KiB
Go

// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.960
// Code generated by wa-generator. DO NOT EDIT.
// Source: Web Awesome wa-zoomable-frame
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"
)
// Zoomable frames render iframe content with zoom and interaction controls.
//
// Web Awesome component: <wa-zoomable-frame>
// ZoomableFrameProps holds all properties for the wa-zoomable-frame component
type ZoomableFrameProps struct {
// The URL of the content to display.
Src string `attr:"src"`
// Inline HTML to display.
Srcdoc string `attr:"srcdoc"`
// Allows fullscreen mode.
Allowfullscreen bool `attr:"allowfullscreen"`
// Controls iframe loading behavior.
// Valid values: "eager", "lazy"
Loading string `attr:"loading"`
// Controls referrer information.
Referrerpolicy string `attr:"referrerpolicy"`
// Security restrictions for the iframe.
Sandbox string `attr:"sandbox"`
// The current zoom of the frame, e.g. 0 = 0% and 1 = 100%.
Zoom float64 `attr:"zoom"`
// The zoom levels to step through when using zoom controls. This does not restrict programmatic changes to the zoom.
ZoomLevels string `attr:"zoom-levels"`
// Removes the zoom controls.
WithoutControls bool `attr:"without-controls"`
// Disables interaction when present.
WithoutInteraction bool `attr:"without-interaction"`
// Events
// Emitted when the internal iframe when it finishes loading.
OnLoad string `attr:"x-on:load"`
// Emitted from the internal iframe when it fails to load.
OnError string `attr:"x-on:error"`
// Slots contains named slot content
Slots ZoomableFrameSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// ZoomableFrameSlots holds named slot content for the component
type ZoomableFrameSlots struct {
// The slot that contains the zoom in icon.
ZoomInIcon templ.Component
// The slot that contains the zoom out icon.
ZoomOutIcon templ.Component
}
// ZoomableFrameBuilder provides a fluent API for constructing ZoomableFrameProps
type ZoomableFrameBuilder struct {
props ZoomableFrameProps
}
// NewZoomableFrame creates a new builder for wa-zoomable-frame
func NewZoomableFrame() *ZoomableFrameBuilder {
return &ZoomableFrameBuilder{}
}
// Src sets the src attribute
// The URL of the content to display.
func (b *ZoomableFrameBuilder) Src(v string) *ZoomableFrameBuilder {
b.props.Src = v
return b
}
// Srcdoc sets the srcdoc attribute
// Inline HTML to display.
func (b *ZoomableFrameBuilder) Srcdoc(v string) *ZoomableFrameBuilder {
b.props.Srcdoc = v
return b
}
// Allowfullscreen sets the allowfullscreen attribute
// Allows fullscreen mode.
func (b *ZoomableFrameBuilder) Allowfullscreen(v bool) *ZoomableFrameBuilder {
b.props.Allowfullscreen = v
return b
}
// Loading sets the loading attribute
// Controls iframe loading behavior.
func (b *ZoomableFrameBuilder) Loading(v string) *ZoomableFrameBuilder {
b.props.Loading = v
return b
}
// Referrerpolicy sets the referrerpolicy attribute
// Controls referrer information.
func (b *ZoomableFrameBuilder) Referrerpolicy(v string) *ZoomableFrameBuilder {
b.props.Referrerpolicy = v
return b
}
// Sandbox sets the sandbox attribute
// Security restrictions for the iframe.
func (b *ZoomableFrameBuilder) Sandbox(v string) *ZoomableFrameBuilder {
b.props.Sandbox = v
return b
}
// Zoom sets the zoom attribute
// The current zoom of the frame, e.g. 0 = 0% and 1 = 100%.
func (b *ZoomableFrameBuilder) Zoom(v float64) *ZoomableFrameBuilder {
b.props.Zoom = v
return b
}
// ZoomLevels sets the zoom-levels attribute
// The zoom levels to step through when using zoom controls. This does not restrict programmatic changes to the zoom.
func (b *ZoomableFrameBuilder) ZoomLevels(v string) *ZoomableFrameBuilder {
b.props.ZoomLevels = v
return b
}
// WithoutControls sets the without-controls attribute
// Removes the zoom controls.
func (b *ZoomableFrameBuilder) WithoutControls(v bool) *ZoomableFrameBuilder {
b.props.WithoutControls = v
return b
}
// WithoutInteraction sets the without-interaction attribute
// Disables interaction when present.
func (b *ZoomableFrameBuilder) WithoutInteraction(v bool) *ZoomableFrameBuilder {
b.props.WithoutInteraction = v
return b
}
// OnLoad sets the handler for load event
// Emitted when the internal iframe when it finishes loading.
func (b *ZoomableFrameBuilder) OnLoad(handler string) *ZoomableFrameBuilder {
b.props.OnLoad = handler
return b
}
// OnError sets the handler for error event
// Emitted from the internal iframe when it fails to load.
func (b *ZoomableFrameBuilder) OnError(handler string) *ZoomableFrameBuilder {
b.props.OnError = handler
return b
}
// ZoomInIconSlot sets the zoom-in-icon slot content
// The slot that contains the zoom in icon.
func (b *ZoomableFrameBuilder) ZoomInIconSlot(c templ.Component) *ZoomableFrameBuilder {
b.props.Slots.ZoomInIcon = c
return b
}
// ZoomOutIconSlot sets the zoom-out-icon slot content
// The slot that contains the zoom out icon.
func (b *ZoomableFrameBuilder) ZoomOutIconSlot(c templ.Component) *ZoomableFrameBuilder {
b.props.Slots.ZoomOutIcon = c
return b
}
// Attr adds a custom HTML attribute
func (b *ZoomableFrameBuilder) Attr(name, value string) *ZoomableFrameBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *ZoomableFrameBuilder) Attrs(attrs templ.Attributes) *ZoomableFrameBuilder {
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 *ZoomableFrameBuilder) Props() ZoomableFrameProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *ZoomableFrameBuilder) Build() ZoomableFrameProps {
return b.props
}
// ZoomableFrame renders the wa-zoomable-frame component
func ZoomableFrame(props ZoomableFrameProps) 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-zoomable-frame")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Src != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " src=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(props.Src)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/zoomable-frame.templ`, Line: 201, Col: 18}
}
_, 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.Srcdoc != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " srcdoc=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(props.Srcdoc)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/zoomable-frame.templ`, Line: 204, Col: 24}
}
_, 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.Allowfullscreen {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " allowfullscreen")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Loading != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " loading=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(props.Loading)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/zoomable-frame.templ`, Line: 210, Col: 26}
}
_, 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, 8, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Referrerpolicy != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " referrerpolicy=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(props.Referrerpolicy)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/zoomable-frame.templ`, Line: 213, Col: 40}
}
_, 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.Sandbox != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " sandbox=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(props.Sandbox)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/zoomable-frame.templ`, Line: 216, Col: 26}
}
_, 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.Zoom != 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " zoom=\"")
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.Zoom))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/zoomable-frame.templ`, Line: 219, Col: 41}
}
_, 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.ZoomLevels != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " zoom-levels=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(props.ZoomLevels)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/zoomable-frame.templ`, Line: 222, Col: 33}
}
_, 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
}
}
if props.WithoutControls {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " without-controls")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.WithoutInteraction {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " without-interaction")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnLoad != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, " x-on:load=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnLoad)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/zoomable-frame.templ`, Line: 231, Col: 27}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.OnError != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, " x-on:error=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(props.OnError)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/wa/zoomable-frame.templ`, Line: 234, Col: 29}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "\"")
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, 23, ">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if props.Slots.ZoomInIcon != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "<div slot=\"zoom-in-icon\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.ZoomInIcon.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if props.Slots.ZoomOutIcon != nil {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "<div slot=\"zoom-out-icon\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = props.Slots.ZoomOutIcon.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "</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, 28, "</wa-zoomable-frame>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// ZoomableFrameFunc renders with a builder function for inline configuration
func ZoomableFrameFunc(fn func(*ZoomableFrameBuilder)) 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_Var11 := templ.GetChildren(ctx)
if templ_7745c5c3_Var11 == nil {
templ_7745c5c3_Var11 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
b := NewZoomableFrame()
fn(b)
templ_7745c5c3_Var12 := 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_Var11.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = ZoomableFrame(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate