calendar

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

templ: version: v0.3.977

Index

Constants

View Source
const NavigatePath = "/api/calendar/navigate"

NavigatePath is the standard handler path for calendar navigation. Mount it under your app's base path: basePath + NavigatePath.

Variables

This section is empty.

Functions

func Calendar

func Calendar(props Props) templ.Component

Calendar renders a month grid with selectable days controlled by Datastar signals. Week starts on Monday.

func NavigateHandler(calendarID string, mode Mode) http.HandlerFunc

NavigateHandler returns an http.HandlerFunc that handles SSE-based month navigation for a calendar component. The calendarID must match the ID used when rendering the Calendar component so that PatchElementTempl can morph the correct DOM node.

func NavigateHandlerFromQuery() http.HandlerFunc

NavigateHandlerFromQuery returns an http.HandlerFunc that reads the calendar ID and mode from query parameters "id" and "mode". This is useful when a single endpoint serves multiple calendar instances.

Types

type CalendarSignals

type CalendarSignals struct {
	Selected string `json:"selected"`
}

CalendarSignals holds the reactive state for a single-select calendar.

type Mode

type Mode int

Mode controls the selection behavior of a calendar.

const (
	ModeSingle Mode = iota
	ModeRange
)
type NavigableSignals struct {
	Selected string `json:"selected"`
	Year     int    `json:"year"`
	Month    int    `json:"month"`
}

NavigableSignals holds the reactive state for a navigable calendar. The SSE handler reads/writes these to navigate between months.

type Props

type Props struct {
	ID         string
	Class      string
	Year       int
	Month      time.Month
	Selected   string // initial selection in "2006-01-02" format
	Mode       Mode
	RangeStart string // initial range start in "2006-01-02" format
	RangeEnd   string // initial range end in "2006-01-02" format
}

Props configures a calendar. Year and Month default to the current month when left at zero.

type RangeCalendarSignals

type RangeCalendarSignals struct {
	RangeStart string `json:"rangeStart"`
	RangeEnd   string `json:"rangeEnd"`
}

RangeCalendarSignals holds the reactive state for a range-select calendar.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL