datepicker

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package datepicker provides date pickers loosely based on Material 3.

Docked is a text field that opens a calendar. Modal opens that calendar in a dialog. ModalDateInput opens a dialog for typing a date and can switch to the same calendar. All three read and write a Date.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date struct {
	Year  int
	Month time.Month
	Day   int
}

Date is a calendar day without a time of day or location. The zero value is an unset date.

func DateFromTime

func DateFromTime(t time.Time) Date

DateFromTime returns the year, month, and day of t in t's location.

func Today

func Today() Date

Today returns the current local date.

func (Date) Compare

func (d Date) Compare(o Date) int

Compare returns -1 if d is before o, 0 if they are equal, and +1 if d is after o.

func (Date) Equal

func (d Date) Equal(o Date) bool

Equal reports whether d and o are the same day.

func (Date) IsZero

func (d Date) IsZero() bool

IsZero reports whether d is the unset date.

func (Date) String

func (d Date) String() string

String returns d in ISO-8601 form (2006-01-02). The zero date is "".

func (Date) Time

func (d Date) Time() time.Time

Time returns local midnight on d.

func (Date) Valid

func (d Date) Valid() bool

Valid reports whether d is a real calendar day (for example, 2026-02-30 is not).

type Docked

type Docked struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

Docked is a text field that opens a calendar dropdown, matching the Material 3 docked date picker: month and year menus, previous/next month, weekday headings, a six-week day grid, and Cancel/OK.

func (*Docked) Build

func (d *Docked) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Docked) HandleButtonInput

func (d *Docked) HandleButtonInput(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult

func (*Docked) Layout

func (d *Docked) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Docked) Measure

func (d *Docked) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Docked) OnValueChanged

func (d *Docked) OnValueChanged(f func(context *guigui.Context, date Date))

OnValueChanged sets the handler invoked when the user confirms a date.

func (*Docked) SetFirstWeekday

func (d *Docked) SetFirstWeekday(day time.Weekday)

SetFirstWeekday sets the first column of the calendar. The default is Sunday.

func (*Docked) SetMaxDate

func (d *Docked) SetMaxDate(date Date)

SetMaxDate sets the latest selectable date. The zero value leaves it unbounded.

func (*Docked) SetMinDate

func (d *Docked) SetMinDate(date Date)

SetMinDate sets the earliest selectable date. The zero value leaves it unbounded.

func (*Docked) SetPlaceholder

func (d *Docked) SetPlaceholder(placeholder string)

SetPlaceholder sets the placeholder shown while no date is selected.

func (*Docked) SetValue

func (d *Docked) SetValue(date Date)

SetValue sets the committed date. The zero value clears the selection.

func (*Docked) Tick

func (d *Docked) Tick(context *guigui.Context, widgetBounds *guigui.WidgetBounds) error

func (*Docked) Value

func (d *Docked) Value() Date

Value returns the committed date. The zero value means no date is selected.

type Modal struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

Modal is a button that opens a modal calendar dialog. The calendar matches the Material 3 docked date picker (month/year menus, day grid, OK/Cancel) and adds a headline plus a toggle into text-input mode.

func (*Modal) Build

func (m *Modal) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Modal) HandleButtonInput

func (m *Modal) HandleButtonInput(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult

func (*Modal) IsOpen

func (m *Modal) IsOpen() bool

func (*Modal) Layout

func (m *Modal) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Modal) Measure

func (m *Modal) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*Modal) OnValueChanged

func (m *Modal) OnValueChanged(f func(context *guigui.Context, date Date))

func (*Modal) SetButtonText

func (m *Modal) SetButtonText(text string)

func (*Modal) SetFirstWeekday

func (m *Modal) SetFirstWeekday(day time.Weekday)

func (*Modal) SetMaxDate

func (m *Modal) SetMaxDate(date Date)

func (*Modal) SetMinDate

func (m *Modal) SetMinDate(date Date)

func (*Modal) SetOpen

func (m *Modal) SetOpen(open bool)

func (*Modal) SetTitle

func (m *Modal) SetTitle(title string)

func (*Modal) SetValue

func (m *Modal) SetValue(date Date)

func (*Modal) Value

func (m *Modal) Value() Date

type ModalDateInput

type ModalDateInput struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

ModalDateInput is a button that opens a modal dialog for typing a date, with a toggle into the same calendar as Modal.

func (*ModalDateInput) Build

func (m *ModalDateInput) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*ModalDateInput) HandleButtonInput

func (m *ModalDateInput) HandleButtonInput(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult

func (*ModalDateInput) IsOpen

func (m *ModalDateInput) IsOpen() bool

func (*ModalDateInput) Layout

func (m *ModalDateInput) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*ModalDateInput) Measure

func (m *ModalDateInput) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*ModalDateInput) OnValueChanged

func (m *ModalDateInput) OnValueChanged(f func(context *guigui.Context, date Date))

func (*ModalDateInput) SetButtonText

func (m *ModalDateInput) SetButtonText(text string)

func (*ModalDateInput) SetFirstWeekday

func (m *ModalDateInput) SetFirstWeekday(day time.Weekday)

func (*ModalDateInput) SetMaxDate

func (m *ModalDateInput) SetMaxDate(date Date)

func (*ModalDateInput) SetMinDate

func (m *ModalDateInput) SetMinDate(date Date)

func (*ModalDateInput) SetOpen

func (m *ModalDateInput) SetOpen(open bool)

func (*ModalDateInput) SetTitle

func (m *ModalDateInput) SetTitle(title string)

func (*ModalDateInput) SetValue

func (m *ModalDateInput) SetValue(date Date)

func (*ModalDateInput) Value

func (m *ModalDateInput) Value() Date

Jump to

Keyboard shortcuts

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