// Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-mutation-observer package wa import ( "github.com/a-h/templ" ) // The Mutation Observer component offers a thin, declarative interface to the MutationObserver API. // // Web Awesome component: // MutationObserverProps holds all properties for the wa-mutation-observer component type MutationObserverProps struct { // Watches for changes to attributes. To watch only specific attributes, separate them by a space, e.g. Attr string `attr:"attr"` // Indicates whether or not the attribute's previous value should be recorded when monitoring changes. AttrOldValue bool `attr:"attr-old-value"` // Watches for changes to the character data contained within the node. CharData bool `attr:"char-data"` // Indicates whether or not the previous value of the node's text should be recorded. CharDataOldValue bool `attr:"char-data-old-value"` // Watches for the addition or removal of new child nodes. ChildList bool `attr:"child-list"` // Disables the observer. Disabled bool `attr:"disabled"` // Events // Emitted when a mutation occurs. OnMutation string `attr:"x-on:wa-mutation"` // Slots contains named slot content Slots MutationObserverSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // MutationObserverBuilder provides a fluent API for constructing MutationObserverProps type MutationObserverBuilder struct { props MutationObserverProps } // NewMutationObserver creates a new builder for wa-mutation-observer func NewMutationObserver() *MutationObserverBuilder { return &MutationObserverBuilder{} } // Attr sets the attr attribute // Watches for changes to attributes. To watch only specific attributes, separate them by a space, e.g. func (b *MutationObserverBuilder) Attr(v string) *MutationObserverBuilder { b.props.Attr = v return b } // AttrOldValue sets the attr-old-value attribute // Indicates whether or not the attribute's previous value should be recorded when monitoring changes. func (b *MutationObserverBuilder) AttrOldValue(v bool) *MutationObserverBuilder { b.props.AttrOldValue = v return b } // CharData sets the char-data attribute // Watches for changes to the character data contained within the node. func (b *MutationObserverBuilder) CharData(v bool) *MutationObserverBuilder { b.props.CharData = v return b } // CharDataOldValue sets the char-data-old-value attribute // Indicates whether or not the previous value of the node's text should be recorded. func (b *MutationObserverBuilder) CharDataOldValue(v bool) *MutationObserverBuilder { b.props.CharDataOldValue = v return b } // ChildList sets the child-list attribute // Watches for the addition or removal of new child nodes. func (b *MutationObserverBuilder) ChildList(v bool) *MutationObserverBuilder { b.props.ChildList = v return b } // Disabled sets the disabled attribute // Disables the observer. func (b *MutationObserverBuilder) Disabled(v bool) *MutationObserverBuilder { b.props.Disabled = v return b } // OnMutation sets the handler for wa-mutation event // Emitted when a mutation occurs. func (b *MutationObserverBuilder) OnMutation(handler string) *MutationObserverBuilder { b.props.OnMutation = handler return b } // Attr adds a custom HTML attribute func (b *MutationObserverBuilder) Attr(name, value string) *MutationObserverBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *MutationObserverBuilder) Attrs(attrs templ.Attributes) *MutationObserverBuilder { 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 *MutationObserverBuilder) Props() MutationObserverProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *MutationObserverBuilder) Build() MutationObserverProps { return b.props } // MutationObserver renders the wa-mutation-observer component templ MutationObserver(props MutationObserverProps) { { children... } } // MutationObserverFunc renders with a builder function for inline configuration templ MutationObserverFunc(fn func(*MutationObserverBuilder)) { {{ b := NewMutationObserver(); fn(b) }} @MutationObserver(b.Props()) { { children... } } }