goffeetabler/controllers/tablertypes.go
2026-05-03 01:58:18 -05:00

546 lines
14 KiB
Go

package controllers
// TablerMenuItem represents a single item in the navbar menu
type TablerMenuItem struct {
Title string `json:"title"`
TitleLong string `json:"title-long,omitempty"`
Icon string `json:"icon,omitempty"`
URL string `json:"url,omitempty"`
Badge string `json:"badge,omitempty"`
Color string `json:"color,omitempty"`
Active bool `json:"active,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Columns int `json:"columns,omitempty"`
Children []*TablerMenuItem `json:"children,omitempty"`
}
// TablerMenu is a map of menu sections keyed by identifier
type TablerMenu map[string]*TablerMenuItem
// TableComponent represents a reusable table component with headers and rows.
type TableComponent struct {
ID string
Title string
Headers []TableComponentHeader
Rows []TableComponentRow
EmptyMessage string
PerPageOptions []string
Striped bool
Hover bool
CardClass string
TableClass string
}
// TableComponentHeader defines a single column header.
type TableComponentHeader struct {
Name string
Sort string
Width string
Align string
}
// TableComponentRow represents a single row as a slice of cells.
type TableComponentRow struct {
Cells []TableCell
}
// TableCell represents a single cell in a table row.
// Type controls how the cell is rendered in the template:
// "text" - plain text
// "avatar" - avatar with name/email
// "status" - status dot + text
// "badge" - colored badge
// "tags" - list of tag badges
// "actions" - dropdown action button
// "date" - date display
type TableCell struct {
Type string
Value string
// Used by "avatar" type
AvatarID string
Subtext string
// Used by "status" type
StatusColor string
// Used by "badge" type
BadgeColor string
// Used by "tags" type
Tags []string
}
// FormtablerTextInput renders a basic text/static/password/textarea input.
type FormtablerTextInput struct {
Label string
Placeholder string
Value string
Type string // "text", "static", "password", "textarea"
Name string
}
// FormtablerIconInput renders an input with an icon or loader.
type FormtablerIconInput struct {
Label string
Placeholder string
Icon string // icon name, empty = search icon
Prepend bool
Loader bool
}
// FormtablerIconSeparated renders a search input with a separate button.
type FormtablerIconSeparated struct {
Label string
Placeholder string
ButtonIcon string
}
// FormtablerInputSizing renders three inputs of different sizes.
type FormtablerInputSizing struct{}
// FormtablerFileInput renders a file input.
type FormtablerFileInput struct {
Label string
}
// FormtablerColorInput renders a color swatch picker (radio or checkbox).
type FormtablerColorInput struct {
Label string
Name string
Type string // "radio" or "checkbox"
Colors []FormtablerSwatch
HideBW bool
Rounded bool
}
// FormtablerSwatch is a single color swatch in a color input.
type FormtablerSwatch struct {
Color string
Checked bool
}
// FormtablerColorPicker renders a native HTML5 color picker.
type FormtablerColorPicker struct {
Label string
Color string
}
// FormtablerRangeInput renders range sliders.
type FormtablerRangeInput struct {
Label string
}
// FormtablerDatalist renders an input with a datalist.
type FormtablerDatalist struct {
Label string
Placeholder string
Options []string
}
// FormtablerImageCheck renders image checkboxes.
type FormtablerImageCheck struct {
Label string
Images []FormtablerImageItem
}
// FormtablerImageItem is a single image in an image check group.
type FormtablerImageItem struct {
Src string
Alt string
Checked bool
}
// FormtablerImageRadio renders image radio buttons.
type FormtablerImageRadio struct {
Label string
Images []FormtablerImageItem
}
// FormtablerImagePerson renders person avatar checkboxes.
type FormtablerImagePerson struct {
Label string
People []FormtablerPersonItem
AvatarSize string
}
// FormtablerPersonItem is a single person in a person check group.
type FormtablerPersonItem struct {
Name string
Src string
Checked bool
}
// FormtablerCheckboxes renders a group of checkboxes.
type FormtablerCheckboxes struct {
Label string
Checkboxes []FormtablerCheckItem
}
// FormtablerCheckItem is a single checkbox/radio/switch item.
type FormtablerCheckItem struct {
Title string
Checked bool
Disabled bool
}
// FormtablerCheckboxesInline renders inline checkboxes.
type FormtablerCheckboxesInline struct {
Label string
Checkboxes []FormtablerCheckItem
}
// FormtablerRadios renders a group of radio buttons.
type FormtablerRadios struct {
Label string
Name string
Radios []FormtablerCheckItem
}
// FormtablerRadiosInline renders inline radio buttons.
type FormtablerRadiosInline struct {
Label string
Name string
Radios []FormtablerCheckItem
}
// FormtablerToggle renders toggle switch checkboxes.
type FormtablerToggle struct {
Label string
Toggles []FormtablerCheckItem
}
// FormtablerToggleSingle renders a single toggle switch.
type FormtablerToggleSingle struct {
Label string
Title string
}
// FormtablerSelect renders a select dropdown.
type FormtablerSelect struct {
Label string
Options []string
Multiple bool
}
// FormtablerSelectgroup renders a selectgroup (pill-style toggle buttons).
type FormtablerSelectgroup struct {
Label string
Groups []FormtablerSelectGroup
Pills bool
}
// FormtablerSelectGroup is a single selectgroup set.
type FormtablerSelectGroup struct {
Title string
Values []FormtablerSelectGroupValue
Type string // "radio" or "checkbox"
Name string
Pills bool
WithText bool
}
// FormtablerSelectGroupValue is a single option in a selectgroup.
type FormtablerSelectGroupValue struct {
Label string
Value string
Icon string // icon name like "home", "user"
Checked bool
WithText bool
}
// FormtablerSelectgroupPayments renders payment method selectgroups.
type FormtablerSelectgroupPayments struct {
Label string
Items []FormtablerPaymentItem
}
// FormtablerPaymentItem is a single payment option.
type FormtablerPaymentItem struct {
Provider string // "visa", "mastercard", "paypal"
Ending string // last 4 digits (optional)
Checked bool
}
// FormtablerSelectgroupProjectManager renders a project manager selectgroup.
type FormtablerSelectgroupProjectManager struct {
Label string
Managers []FormtablerPersonItemWithJob
}
// FormtablerPersonItemWithJob extends FormtablerPersonItem with a job title.
type FormtablerPersonItemWithJob struct {
Name string
Src string
JobTitle string
Checked bool
}
// FormtablerFieldset renders a fieldset with inputs.
type FormtablerFieldset struct {
Label string
Inputs []FormtablerFieldsetInput
}
// FormtablerFieldsetInput is a single input inside a fieldset.
type FormtablerFieldsetInput struct {
Label string
Type string // "text", "email", "tel"
Required bool
Placeholder string
}
// FormtablerCheckboxesList renders a list of toggle switches with labels.
type FormtablerCheckboxesList struct {
Label string
Items []FormtablerCheckListItem
}
// FormtablerCheckListItem is a single item in a checkboxes list.
type FormtablerCheckListItem struct {
Title string
Checked bool
}
// FormtablerValidationStates renders validation state inputs.
type FormtablerValidationStates struct {
Label string
Lite bool
}
// FormtablerCardStatus represents a status bar on the card.
type FormtablerCardStatus struct {
Position string // "top", "bottom", "start"
Color string // "blue", "red", "green", "yellow", etc.
}
// FormtablerCardHeader represents a card header section.
type FormtablerCardHeader struct {
Title string
// Tab-based header
UseTabs bool
Tabs []FormtablerCardTab
// Pill-based header
UsePills bool
Pills []FormtablerCardTab
}
// FormtablerCardTab represents a single tab/pill in a card header.
type FormtablerCardTab struct {
Title string
Active bool
Disabled bool
Link string
}
// FormtablerCardAlert represents an alert inside a card.
type FormtablerCardAlert struct {
Text string
Type string // "success", "info", "warning", "danger"
}
// FormtablerCardImage represents an image at top or bottom of a card.
type FormtablerCardImage struct {
Position string // "top", "bottom"
Src string
Ratio string // "21x9", "4x3", etc.
}
// FormtablerCardFooter represents a card footer.
type FormtablerCardFooter struct {
Text string // simple footer text
// Single button
Button string
ButtonLink string
// Two buttons (Cancel / Action)
ButtonsCancel string
ButtonsAction string
ButtonsActionLink string
// Elements row (switch, check, avatars, more)
HasSwitch bool
HasCheck bool
HasAvatars bool
HasMore bool
}
// FormtablerCardBody represents the body content of a card.
type FormtablerCardBody struct {
Title string
Subtitle string
Text string
HasButton bool
ButtonText string
ButtonLink string
}
// FormtablerAlert represents a single alert component.
type FormtablerAlert struct {
Type string // "success", "warning", "danger", "info"
Title string
Description string
List []string // if set, renders as <ul class="alert-list">
Important bool
Minor bool
ShowClose bool
Action string // "Action" button text
Link string // "Link" anchor text
Buttons bool // "Okay" / "Cancel" buttons
Avatar bool
Class string
}
// FormtablerBreadcrumbItem represents a single item in the breadcrumb trail.
type FormtablerBreadcrumbItem struct {
Title string
Link string // empty for the last (active) item
HomeIcon bool // render home icon instead of text for the first item
}
// FormtablerBreadcrumb represents a breadcrumb navigation component.
type FormtablerBreadcrumb struct {
Items []FormtablerBreadcrumbItem
Separator string // optional: "dots", "arrows", "bullets"
Class string
}
// FormtablerToast represents a toast notification component.
type FormtablerToast struct {
ID string
Show bool
HideHeader bool
PersonName string
PersonSrc string
Date string
Text string
Cookies bool // renders cookie consent variant
}
// FormtablerCardProgress represents a progress bar in the card.
type FormtablerCardProgress struct {
Percent int
Color string
}
// FormtablerCard represents a single card component.
// All fields are populated by the caller; the template renders based on what it finds.
type FormtablerCard struct {
// Outer attributes
Link string // if set, card is an <a href> instead of <div>
Active bool
Inactive bool
Class string
// Empty state
Empty bool
// Image top/bottom
Image *FormtablerCardImage
// Status bar
Status *FormtablerCardStatus
// Header
Header *FormtablerCardHeader
// Alert
Alert *FormtablerCardAlert
// Body
Body *FormtablerCardBody
// Footer
Footer *FormtablerCardFooter
// Progress
Progress *FormtablerCardProgress
}
// FormtablerFormElementsPage is the page-specific struct for the form elements demo.
// Each field is one of the 25 form element groups.
type FormtablerFormElementsPage struct {
TextInputs []FormtablerTextInput
IconInputs []FormtablerIconInput
IconSeparated FormtablerIconSeparated
InputSizing FormtablerInputSizing
FileInput FormtablerFileInput
ColorInput FormtablerColorInput
ColorPicker FormtablerColorPicker
RangeInput FormtablerRangeInput
Datalist FormtablerDatalist
ImageCheck FormtablerImageCheck
ImageRadio FormtablerImageRadio
ImagePerson FormtablerImagePerson
Checkboxes FormtablerCheckboxes
CheckboxesInline FormtablerCheckboxesInline
Radios FormtablerRadios
RadiosInline FormtablerRadiosInline
Toggles FormtablerToggle
ToggleSingle FormtablerToggleSingle
Select FormtablerSelect
Selectgroups []FormtablerSelectGroup
SelectgroupPayments FormtablerSelectgroupPayments
SelectgroupProjectManager FormtablerSelectgroupProjectManager
Fieldset FormtablerFieldset
CheckboxesList FormtablerCheckboxesList
ValidationStates FormtablerValidationStates
}
// FormtablerComponentsPage is the page-specific struct for the combined demo
// showing alerts, toasts, and breadcrumbs.
type FormtablerComponentsPage struct {
Alerts []FormtablerAlert
Breadcrumbs []FormtablerBreadcrumb
Toasts []FormtablerToast
}
// FormtablerUserSettingsSection represents a section in the settings sidebar.
type FormtablerUserSettingsSection struct {
Title string
SubItems []FormtablerUserSettingsNavItem
}
// FormtablerUserSettingsNavItem represents a single navigation item in the settings sidebar.
type FormtablerUserSettingsNavItem struct {
Title string
Link string
Active bool
}
// FormtablerUserSettingsPage holds the data for the user settings page.
type FormtablerUserSettingsPage struct {
SidebarSections []FormtablerUserSettingsSection
ActiveTab string
}
// AdminUserRow represents a single user in the admin users list.
type AdminUserRow struct {
Name string
Email string
Status string // "Active", "Inactive", "Invited"
Roles string // comma-separated role names
EditLink string
}
// AdminUsersPage holds the data for the admin users page.
type AdminUsersPage struct {
Users []AdminUserRow
AddLink string
}
// AuthLockPageData holds the data for the account lock page.
type AuthLockPageData struct {
PersonName string
}
// TablerPageData holds the common data for all tabler pages.
// It should NOT contain component-specific fields like tables or forms.
// Add those by creating a page-specific struct that embeds TablerPageData
// and defines the component fields, then use hasField in the template.
type TablerPageData struct {
PageTitle string
PageDescription string
BodyClass string
Content interface{}
// Default layout fields
Sidebar bool
ShowTopbar bool
WrapperFull bool
ContainerCentered bool
ContainerClass string
// Page header
PageHeader string
PagePretitle string
// Navbar fields
UserName string
UserRole string
NavbarMenu TablerMenu
CurrentPage string
}