frm/ui/common_templ.go

1286 lines
58 KiB
Go
Raw Permalink Normal View History

2024-11-05 16:18:04 +00:00
// Code generated by templ - DO NOT EDIT.
2025-02-13 19:45:05 +00:00
// templ: version: v0.3.833
2024-11-05 16:18:04 +00:00
package ui
//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 (
"context"
"encoding/json"
"fmt"
"github.com/acaloiaro/frm"
"github.com/acaloiaro/frm/types"
"github.com/acaloiaro/frm/ui/selector"
"slices"
"strings"
)
var loadDependenciesOnce = templ.NewOnceHandle()
2025-03-26 21:29:25 +00:00
type ToastType string
type ToastPosition string
const (
ToastPositionTop = "top"
ToastPositionBottom = "bottom"
)
const (
ToastTypeSuccess = "success"
ToastTypeWarning = "warning"
ToastTypeError = "error"
)
type ToastArgs struct {
Message string
Position string
Type ToastType
}
// Toast shows a toast message on screen
func Toast(arg ToastArgs) templ.Component {
2024-11-05 16:18:04 +00:00
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)
2025-03-27 19:14:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"toast toast-top toast-right pt-12 z-50 opacity-0\" _=\"on intersection(intersecting) transition my opacity from 0 to 1 over 500 milliseconds\n\t\tthen wait 3s\n\t\tthen transition my opacity from 1 to 0 over 500 milliseconds\">")
2025-03-26 21:29:25 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
switch arg.Type {
case ToastTypeSuccess:
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<div class=\"card rounded-md bg-base-100 shadow-lg p-2 text-white bg-primary-400\" _=\"on click add .hidden to #messages\"><span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(arg.Message)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 50, Col: 24}
}
_, 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, "</span></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
case ToastTypeWarning:
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<div class=\"card rounded-md bg-base-100 shadow-lg p-2 text-white bg-orange-400\" _=\"on click add .hidden to #messages\"><span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(arg.Message)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 57, 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, "</span></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
case ToastTypeError:
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<div class=\"card rounded-md bg-base-100 shadow-lg p-2 text-white bg-red-400\" _=\"on click add .hidden to #messages\"><span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(arg.Message)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 64, Col: 24}
}
_, 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, "</span></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
func HeroIcon(style string, name string) 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_Var5 := templ.GetChildren(ctx)
if templ_7745c5c3_Var5 == nil {
templ_7745c5c3_Var5 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<svg data-src=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("https://unpkg.com/heroicons/20/%s/%s.svg", style, name))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 71, Col: 85}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\" class=\"h-5 w-5\"></svg>")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 15:40:23 +00:00
return nil
2024-11-05 16:18:04 +00:00
})
}
2025-01-28 15:41:46 +00:00
type ButtonArgs struct {
2024-11-05 16:18:04 +00:00
Type string // button type, e.g. 'button' or 'submit'
Label string // the label to show
Classes []string // additional css classes to apply to the button
}
2025-01-28 15:41:46 +00:00
func Button(args ButtonArgs, attrs templ.Attributes) templ.Component {
2024-11-05 16:18:04 +00:00
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)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Var7 := templ.GetChildren(ctx)
if templ_7745c5c3_Var7 == nil {
templ_7745c5c3_Var7 = templ.NopComponent
2024-11-05 16:18:04 +00:00
}
ctx = templ.ClearChildren(ctx)
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var8 = []any{fmt.Sprintf("focus:outline-none disabled:cursor-not-allowed disabled:opacity-75 aria-disabled:cursor-not-allowed aria-disabled:opacity-75 flex-shrink-0 font-medium rounded-md text-sm gap-x-1.5 shadow-sm text-white dark:text-gray-900 bg-primary-500 hover:bg-primary-600 disabled:bg-primary-500 aria-disabled:bg-primary-500 dark:bg-primary-400 dark:hover:bg-primary-500 dark:disabled:bg-primary-400 dark:aria-disabled:bg-primary-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500 dark:focus-visible:outline-primary-400 inline-flex items-center px-8 md:px-4 py-2 %s", strings.Join(args.Classes, " "))}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var8...)
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "<button")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.RenderAttributes(ctx, templ_7745c5c3_Buffer, attrs)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, " class=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var8).String())
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 1, Col: 0}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\">")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templ_7745c5c3_Var7.Render(ctx, templ_7745c5c3_Buffer)
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(args.Label)
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 83, Col: 14}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</button>")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 15:40:23 +00:00
return nil
2024-11-05 16:18:04 +00:00
})
}
2025-01-28 15:41:46 +00:00
func MutedButton(args ButtonArgs, attrs templ.Attributes) templ.Component {
2024-11-05 16:18:04 +00:00
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)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Var11 := templ.GetChildren(ctx)
if templ_7745c5c3_Var11 == nil {
templ_7745c5c3_Var11 = templ.NopComponent
2024-11-05 16:18:04 +00:00
}
ctx = templ.ClearChildren(ctx)
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var12 = []any{fmt.Sprintf("btn btn-sm text-black text-md bg-gray-50 focus:outline-none disabled:cursor-not-allowed disabled:opacity-75 aria-disabled:cursor-not-allowed aria-disabled:opacity-75 flex-shrink-0 font-medium rounded-md gap-x-1.5 shadow-sm dark:text-gray-900 bg-gray-100 hover:bg-gray-200 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500 dark:focus-visible:outline-primary-400 inline-flex items-center px-8 md:px-4 py-2 %s", strings.Join(args.Classes, " "))}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var12...)
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<div")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ.RenderAttributes(ctx, templ_7745c5c3_Buffer, attrs)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " class=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var12).String())
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 1, Col: 0}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "\">")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templ_7745c5c3_Var11.Render(ctx, templ_7745c5c3_Buffer)
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(args.Label)
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 90, Col: 14}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</div>")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 15:40:23 +00:00
return nil
2024-11-05 16:18:04 +00:00
})
}
// SafePath returns mountpoint-aware SafeURL paths for the given path
func SafePath(ctx context.Context, path string) templ.SafeURL {
2025-01-14 15:51:29 +00:00
return templ.SafeURL(frm.CollectorPath(ctx, path))
2024-11-05 16:18:04 +00:00
}
type LabeledCheckboxArgs struct {
Label string // label value
Name string // field name attribute
Title string // field title attribute
ID string // field id attribute
Checked bool // value is checked
Required bool // field is required
Tooltip string // text tooltip
Hyperscript string // hyperscript associated with element
}
// LabeledCheckbox is a checkbox element with a label
func LabeledCheckbox(args LabeledCheckboxArgs) templ.Component {
2024-11-05 16:18:04 +00:00
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)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Var15 := templ.GetChildren(ctx)
if templ_7745c5c3_Var15 == nil {
templ_7745c5c3_Var15 = templ.NopComponent
2024-11-05 16:18:04 +00:00
}
ctx = templ.ClearChildren(ctx)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<label class=\"fieldset-label\"><input id=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var16 string
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(args.ID)
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 114, Col: 15}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\" name=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var17 string
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(args.Name)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 115, Col: 19}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "\" type=\"checkbox\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if args.Checked {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, " checked=\"checked\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if args.Required {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, " required")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, " class=\"checkbox\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if args.Hyperscript != "" {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, " _=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var18 string
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(args.Hyperscript)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 125, Col: 24}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "> <span class=\"pl-3\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var19 string
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(args.Label)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 128, Col: 33}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "</span> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if args.Tooltip != "" {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "<div class=\"tooltip tooltip-left px-3\" data-tip=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var20 string
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(args.Tooltip)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 130, Col: 65}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "\"><svg data-src=\"https://unpkg.com/heroicons/20/solid/question-mark-circle.svg\" class=\"inline-block h-5 w-5 text-success\"></svg></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "</label>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
type LabeledSelectorArgs struct {
Label string // label value
LabelClass string // CSS class(es) for label
Name string // field name attribute
Title string // field title attribute
ID string // field id attribute
Options []selector.Option // seletor options
Required bool // field is required
Multiple bool // allow multiple
EditItems bool
Placeholder string
SearchDisabled bool
SelectionChangeEvent string // the event fired when a selection changes
}
// LabeledSelector is a selector with a label
func LabeledSelector(args LabeledSelectorArgs) 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)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Var21 := templ.GetChildren(ctx)
if templ_7745c5c3_Var21 == nil {
templ_7745c5c3_Var21 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var22 = []any{fmt.Sprintf("flex flex-col h-fit w-full input input-bordered flex px-0 %s", args.LabelClass)}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var22...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "<label class=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var23 string
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var22).String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 1, Col: 0}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "\"><span class=\"inline-flex h-full group-[.label-group]:min-w-48 bg-primary-100 items-center rounded-tl-lg rounded-tr-lg px-3\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var24 string
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(args.Label)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 160, Col: 138}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "</span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = selector.Selector(selector.SelectArgs{
Name: args.Name,
LabelClass: "rounded-tr-lg rounded-tl-lg",
ID: args.ID,
EditItems: args.EditItems,
Options: args.Options,
Multiple: args.Multiple,
Required: args.Required,
Placeholder: args.Placeholder,
SearchDisabled: args.SearchDisabled,
SelectionChangeEvent: args.SelectionChangeEvent,
}).Render(ctx, templ_7745c5c3_Buffer)
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "</label>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
type LabeledTextInputArgs struct {
Label string // label value
LabelClass string // CSS class for label
Name string // field name attribute
Title string // field title attribute
ID string // field id attribute
Placeholder string // field placeholder attribute
Value string // field value attribute
Required bool // field is required
Tooltip string // text tooltip
Hyperscript string // hyperscript associated with element
}
// LabeledTextInput is a text input with the label inside of it
func LabeledTextInput(args LabeledTextInputArgs) 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)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Var25 := templ.GetChildren(ctx)
if templ_7745c5c3_Var25 == nil {
templ_7745c5c3_Var25 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var26 = []any{fmt.Sprintf("flex flex-col h-fit w-full %s", args.LabelClass)}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var26...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "<label class=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var27 string
templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var26).String())
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 1, Col: 0}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "\"><span class=\"inline-flex h-full w-full group-[.label-group]:min-w-48 bg-primary-100 rounded-tr-lg rounded-tl-lg items-center px-3\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var28 string
templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(args.Label)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 193, Col: 15}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if !args.Required {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "<span class=\"badge badge-info bg-slate-100 mx-3\">Optional</span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "</span><div class=\"flex items-center\"><input class=\"bg-slate-100 w-full border-0 rounded-br-lg rounded-bl-lg\" type=\"text\" name=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var29 string
templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(args.Name)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 202, Col: 20}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if args.ID != "" {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, " id=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var30 string
templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(args.ID)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 204, Col: 17}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if args.Placeholder != "" {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, " placeholder=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var31 string
templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(args.Placeholder)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 207, Col: 35}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if args.Value != "" {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, " value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var32 string
templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(args.Value)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 210, Col: 23}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if args.Required {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, " required")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, " class=\"border-0\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if args.Hyperscript != "" {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, " _=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var33 string
templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(args.Hyperscript)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 217, Col: 25}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if args.Tooltip != "" {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, "<div class=\"tooltip tooltip-left px-3 py-3\" data-tip=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var34 string
templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(args.Tooltip)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 222, Col: 70}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 54, "\"><svg data-src=\"https://unpkg.com/heroicons/20/solid/question-mark-circle.svg\" class=\"inline-block h-5 w-5 text-success\"></svg></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "</label>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
type FieldsetArgs struct {
Label string // the label of the field set
}
func FieldSet(args FieldsetArgs) 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)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Var35 := templ.GetChildren(ctx)
if templ_7745c5c3_Var35 == nil {
templ_7745c5c3_Var35 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "<fieldset class=\"fieldset flex flex-col gap-2 p-4 bg-base-100 border border-base-300 rounded-box w-full\"><legend class=\"fieldset-legend\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var36 string
templ_7745c5c3_Var36, templ_7745c5c3_Err = templ.JoinStringErrs(args.Label)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 238, Col: 46}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var36))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "</legend>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templ_7745c5c3_Var35.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 58, "</fieldset>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// head simply provides the <head> element
func Head(pageTitle string) 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)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Var37 := templ.GetChildren(ctx)
if templ_7745c5c3_Var37 == nil {
templ_7745c5c3_Var37 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, "<head><title>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var38 string
templ_7745c5c3_Var38, templ_7745c5c3_Err = templ.JoinStringErrs(pageTitle)
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 246, Col: 20}
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var38))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 60, "</title><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Var39 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
2024-11-05 16:18:04 +00:00
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)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "<link href=\"")
2025-01-22 19:38:53 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var40 string
templ_7745c5c3_Var40, templ_7745c5c3_Err = templ.JoinStringErrs(frm.CollectorPath(ctx, "/static/css/styles.css"))
2025-01-22 19:38:53 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 250, Col: 64}
2025-01-22 19:38:53 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var40))
2025-01-22 19:38:53 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 62, "\" rel=\"stylesheet\"><link rel=\"stylesheet\" href=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var41 string
templ_7745c5c3_Var41, templ_7745c5c3_Err = templ.JoinStringErrs(frm.CollectorPath(ctx, "/static/css/choices.min.css"))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 251, Col: 86}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var41))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 63, "\" nonce=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var42 string
templ_7745c5c3_Var42, templ_7745c5c3_Err = templ.JoinStringErrs(templ.GetNonce(ctx))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 251, Col: 116}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var42))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "\"><script type=\"text/javascript\" src=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var43 string
templ_7745c5c3_Var43, templ_7745c5c3_Err = templ.JoinStringErrs(frm.CollectorPath(ctx, "/static/js/htmx.js"))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 252, Col: 84}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var43))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, "\" nonce=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var44 string
templ_7745c5c3_Var44, templ_7745c5c3_Err = templ.JoinStringErrs(templ.GetNonce(ctx))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 252, Col: 114}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var44))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, "\"></script> <script type=\"text/javascript\" src=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var45 string
templ_7745c5c3_Var45, templ_7745c5c3_Err = templ.JoinStringErrs(frm.CollectorPath(ctx, "/static/js/htmx-response-targets.js"))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 253, Col: 101}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var45))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, "\" nonce=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var46 string
templ_7745c5c3_Var46, templ_7745c5c3_Err = templ.JoinStringErrs(templ.GetNonce(ctx))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 253, Col: 131}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var46))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, "\"></script> <script type=\"text/javascript\" src=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var47 string
templ_7745c5c3_Var47, templ_7745c5c3_Err = templ.JoinStringErrs(frm.CollectorPath(ctx, "/static/js/hyperscript.js"))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 254, Col: 91}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var47))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 69, "\" nonce=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var48 string
templ_7745c5c3_Var48, templ_7745c5c3_Err = templ.JoinStringErrs(templ.GetNonce(ctx))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 254, Col: 121}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var48))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, "\"></script> <script ytpe=\"text/javascript\" src=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var49 string
templ_7745c5c3_Var49, templ_7745c5c3_Err = templ.JoinStringErrs(frm.CollectorPath(ctx, "/static/js/choices.min.js"))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 255, Col: 91}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var49))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, "\" nonce=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var50 string
templ_7745c5c3_Var50, templ_7745c5c3_Err = templ.JoinStringErrs(templ.GetNonce(ctx))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 255, Col: 121}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var50))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 72, "\"></script> <script type=\"text/javascript\" src=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var51 string
templ_7745c5c3_Var51, templ_7745c5c3_Err = templ.JoinStringErrs(frm.CollectorPath(ctx, "/static/js/svg-loader.min.js"))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 256, Col: 94}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var51))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 73, "\" nonce=\"")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var52 string
templ_7745c5c3_Var52, templ_7745c5c3_Err = templ.JoinStringErrs(templ.GetNonce(ctx))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 256, Col: 124}
2024-11-05 16:18:04 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var52))
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 74, "\" async></script> <script type=\"text/javascript\" src=\"")
2025-01-23 19:28:24 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var53 string
templ_7745c5c3_Var53, templ_7745c5c3_Err = templ.JoinStringErrs(frm.CollectorPath(ctx, "/static/js/Sortable.min.js"))
2025-01-23 19:28:24 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 257, Col: 92}
2025-01-23 19:28:24 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var53))
2025-01-23 19:28:24 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 75, "\" nonce=\"")
2025-01-23 19:28:24 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var54 string
templ_7745c5c3_Var54, templ_7745c5c3_Err = templ.JoinStringErrs(templ.GetNonce(ctx))
2025-01-23 19:28:24 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 257, Col: 122}
2025-01-23 19:28:24 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var54))
2025-01-23 19:28:24 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 76, "\"></script> <script type=\"text/javascript\">\n\t\t\t\thtmx.onLoad(function(content) {\n\t\t\t\t var sortables = content.querySelectorAll(\".sortable\");\n\t\t\t\t for (var i = 0; i < sortables.length; i++) {\n\t\t\t\t var sortable = sortables[i];\n\t\t\t\t var sortableInstance = new Sortable(sortable, {\n\t\t\t\t animation: 150,\n\t\t\t\t\t\t draggable: \".sortme\",\n\t\t\t\t onMove: function (evt) {\n\t\t\t\t return evt.related.className.indexOf('htmx-indicator') === -1;\n\t\t\t\t },\n\t\t\t\t onEnd: function (evt) {\n\t\t\t\t this.option(\"disabled\", true);\n\t\t\t\t }\n\t\t\t\t });\n\t\t\t\t // Re-enable sorting on the `htmx:afterSwap` event\n\t\t\t\t sortable.addEventListener(\"htmx:afterSwap\", function() {\n\t\t\t\t sortableInstance.option(\"disabled\", false);\n\t\t\t\t });\n\t\t\t\t }\n\t\t\t\t})\n\n\t\t\t\t// formValueChanged handles changes to user input in form fields\n\t\t\t\tfunction formValueChanged(fieldID, newValue) {\n\t\t\t\t\tvar formMetadata = JSON.parse(document.getElementById('form-metadata').getAttribute(\"data-data\"));\n\t\t\t\t\tif (formMetadata == null) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\t// collect the fields that have logic monitoring the changed field \n\t\t\t\t\tvar watchingFields = Object.values(formMetadata.form.fields).filter(function(field) {\n\t\t\t\t\t\treturn field.logic != null && fieldID === field.logic.target_field_id\n\t\t\t\t\t});\n\n\t\t\t\t\t// no fields watch the one that changed\n\t\t\t\t\tif (watchingFields.length == 0) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tvar fieldElement = document.getElementById(fieldID)\n\t\t\t\t\tfor (i in watchingFields) {\n\t\t\t\t\t\tlet watchingField = watchingFields[i]\n\t\t\t\t\t\tlet match = false\n\t\t\t\t\t\tvar watcherFieldElement = document.getElementById(watchingField.id) // the actual element watching the field\n\t\t\t\t\t\t// radio form elements such as \"single choice\" elements cannot get gotten by ID because they are\n\t\t\t\t\t\t// radio button in a form group, all sharing a \"name\" attribute, rather than having one unique id\n\t\t\t\t\t\t// like other input elements. Thus, when we cannot get a watching field by ID, we must be able to get it by\n\t\t\t\t\t\t// name.\n\t\t\t\t\t\tif (watcherFieldElement == null) {\n\t\t\t\t\t\t\tradioFormElements = document.getElementsByName(watchingField.id)\n\t\t\t\t\t\t\tif (radioFormElements.length > 0) {\n\t\t\t\t\t\t\t\twatcherFieldElement = radioFormElements[0]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvar watcherFieldContainerID = `field-container-${watchingField.id}` // the DOM element that contains the watching field\n\t\t\t\t\t\tlogic = watchingField.logic\n\n\t\t\t\t\t\t// check whether the new value is coming from a Choices.js field, in which case the new value\n\t\t\t\t\t\t// is the array of chosen values, joined by commas, otherwise newValue is used as it was passed in\n\t\t\t\t\t\tif (fieldElement != null && fieldElement._choices != null) {\n\t\t\t\t\t\t\t// Choics.getValue() returns scalar for single selects and array for multi. Use Array.of\n\t\t\t\t\t\t\t// to treat everything it returns as an array\n\t\t\t\t\t\t\tnewValue = Array.of(fieldElement._choices.getValue(true)).join(',')\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// find if _any_ trigger values match the new value\n\t\t\t\t\t\tswitch (logic.field_comparator) {\n\t\t\t\t\t\t\tcase 'equal':\n\t\t\t\t\t\t\t\tmatch = watchingField.logic.trigger_values.every(val => newValue.localeCompare(val, 'en', {sensitivity: \"base\"}) == 0)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'contains':\n\t\t\t\t\t\t\t\tmatch = watchingField.logic.trigger_values.some(val => newValue.toLowerCase().includes(val.toLowerCase()))\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'not':\n\t\t\t\t\t\t\t\tmatch = watchingField.logic.trigger_values.some(val => newValue.toLowerCase() !== val.toLowerCase())\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t/
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 15:40:23 +00:00
return nil
2024-11-05 16:18:04 +00:00
})
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = loadDependenciesOnce.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var39), templ_7745c5c3_Buffer)
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 77, "</head>")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 15:40:23 +00:00
return nil
2024-11-05 16:18:04 +00:00
})
}
func footer() 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)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Var55 := templ.GetChildren(ctx)
if templ_7745c5c3_Var55 == nil {
templ_7745c5c3_Var55 = templ.NopComponent
2024-11-05 16:18:04 +00:00
}
ctx = templ.ClearChildren(ctx)
2025-01-25 15:40:23 +00:00
return nil
2024-11-05 16:18:04 +00:00
})
}
// App is the primary app with all chrome
func App(pageTitle string) 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)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Var56 := templ.GetChildren(ctx)
if templ_7745c5c3_Var56 == nil {
templ_7745c5c3_Var56 = templ.NopComponent
2024-11-05 16:18:04 +00:00
}
ctx = templ.ClearChildren(ctx)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 78, "<!doctype html><html lang=\"eng\">")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-28 15:41:46 +00:00
templ_7745c5c3_Err = Head(pageTitle).Render(ctx, templ_7745c5c3_Buffer)
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 79, "<body><div id=\"messages\"></div><main>")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templ_7745c5c3_Var56.Render(ctx, templ_7745c5c3_Buffer)
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 80, "</main>")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = footer().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 81, "</body></html>")
2024-11-05 16:18:04 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-01-25 15:40:23 +00:00
return nil
2024-11-05 16:18:04 +00:00
})
}
2025-01-28 15:41:46 +00:00
// FormUrl returns form builder URLs for the given form and additional path arguments
func FormUrl[T string | templ.SafeURL](ctx context.Context, form frm.Form, path ...string) T {
p := ""
if len(path) == 1 {
p = path[0]
}
return T(F("%s%s", frm.BuilderPathForm(ctx, form.ID), p))
}
// FieldOptionsAsSelectorOptions returns all of a field's FieldOptions as selector.Options
func FieldOptionsAsSelectorOptions(form frm.Form, field types.FormField) (options []selector.Option) {
for _, option := range field.Options {
selected := false
for _, f := range form.Fields {
if f.Logic == nil || f.Logic.TriggerValues == nil || len(f.Logic.TriggerValues) == 0 {
continue
}
2025-02-18 21:25:01 +00:00
if f.Logic != nil && slices.Contains(f.Logic.TriggerValues, option.ID.String()) {
2025-01-28 15:41:46 +00:00
selected = true
2024-11-05 16:18:04 +00:00
}
}
2025-01-28 15:41:46 +00:00
options = append(options, selector.Option{
ID: option.ID,
Label: option.Label,
Value: option.ID.String(),
Order: option.Order,
2025-01-28 15:41:46 +00:00
Selected: selected,
})
}
return
2024-11-05 16:18:04 +00:00
}
2025-01-30 19:04:48 +00:00
func ValidationErrors(errs types.ValidationErrors) 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)
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Var57 := templ.GetChildren(ctx)
if templ_7745c5c3_Var57 == nil {
templ_7745c5c3_Var57 = templ.NopComponent
2025-01-30 19:04:48 +00:00
}
ctx = templ.ClearChildren(ctx)
if len(errs) > 0 {
for fieldID, err := range errs {
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 82, "<div id=\"")
2025-01-30 19:04:48 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var58 string
templ_7745c5c3_Var58, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("errors-%s", fieldID))
2025-01-30 19:04:48 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 423, Col: 46}
2025-01-30 19:04:48 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var58))
2025-01-30 19:04:48 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 83, "\" data-hx-swap-oob=\"true\" class=\"flex flex-col gap-3 py-3\"><p class=\"text-red-500\">")
2025-01-30 19:04:48 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
var templ_7745c5c3_Var59 string
templ_7745c5c3_Var59, templ_7745c5c3_Err = templ.JoinStringErrs(err.Error())
2025-01-30 19:04:48 +00:00
if templ_7745c5c3_Err != nil {
2025-03-26 21:29:25 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/common.templ`, Line: 425, Col: 18}
2025-01-30 19:04:48 +00:00
}
2025-03-26 21:29:25 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var59))
2025-01-30 19:04:48 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2025-03-26 21:29:25 +00:00
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 84, "</p></div>")
2025-01-30 19:04:48 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
}
return nil
})
}
2024-11-05 16:18:04 +00:00
// ViewerMetdata contains data needed by the viewer component. It is rendered to JSON and accessed via Javascript.
type ViewerMetadata struct {
Form frm.Form `json:"form"`
}
func (v ViewerMetadata) JSON() string {
b, err := json.Marshal(v)
if err != nil {
return "{}"
}
return string(b)
}
2025-01-28 15:41:46 +00:00
// F formats strings; shorthand for fmt.Sprintf
func F(s string, args ...any) string {
return fmt.Sprintf(s, args...)
}
2024-11-05 16:18:04 +00:00
var _ = templruntime.GeneratedTemplate