Documentation ¶
Overview ¶
Package datepicker provides a bubble tea component for viewing and selecting a date from a monthly view.
Index ¶
- type Focus
- type KeyMap
- type Model
- func (m *Model) Blur()
- func (m Model) Init() tea.Cmd
- func (m *Model) LastMonth()
- func (m *Model) LastWeek()
- func (m *Model) LastYear()
- func (m *Model) NextMonth()
- func (m *Model) NextWeek()
- func (m *Model) NextYear()
- func (m *Model) SelectDate()
- func (m *Model) SetFocus(f Focus)
- func (m *Model) SetTime(t time.Time)
- func (m *Model) Tomorrow()
- func (m *Model) UnselectDate()
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- func (m *Model) Yesterday()
- type Styles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Focus ¶
type Focus int
Focus is a value passed to `model.SetFocus` to indicate what component controls should be available.
const ( // FocusNone is a value passed to `model.SetFocus` to ignore all date altering key msgs FocusNone Focus = iota // FocusHeaderMonth is a value passed to `model.SetFocus` to accept key msgs that change the month FocusHeaderMonth // FocusHeaderYear is a value passed to `model.SetFocus` to accept key msgs that change the year FocusHeaderYear // FocusCalendar is a value passed to `model.SetFocus` to accept key msgs that change the week or date FocusCalendar )
type KeyMap ¶
type KeyMap struct { Up key.Binding Right key.Binding Down key.Binding Left key.Binding FocusPrev key.Binding FocusNext key.Binding Quit key.Binding }
KeyMap is the key bindings for different actions within the datepicker.
func DefaultKeyMap ¶
func DefaultKeyMap() KeyMap
DefaultKeyMap returns a KeyMap struct with default values
type Model ¶
type Model struct { // Time is the `time.Time` struct that represents the selected date month and year Time time.Time // KeyMap encodes the keybindings recognized by the model KeyMap KeyMap // Styles represent the Styles struct used to render the datepicker Styles Styles // Focused indicates the component which the end user is focused on Focused Focus // Selected indicates whether a date is Selected in the datepicker Selected bool }
Model is a struct that contains the state of the datepicker component and satisfies the `tea.Model` interface
func (*Model) LastMonth ¶
func (m *Model) LastMonth()
LastMonth sets the model's `Time` struct back 1 month
func (*Model) LastWeek ¶
func (m *Model) LastWeek()
LastWeek sets the model's `Time` struct back 7 days
func (*Model) LastYear ¶
func (m *Model) LastYear()
LastYear sets the model's `Time` struct back 1 year
func (*Model) NextMonth ¶
func (m *Model) NextMonth()
NextMonth sets the model's `Time` struct forward 1 month
func (*Model) NextWeek ¶
func (m *Model) NextWeek()
NextWeek sets the model's `Time` struct forward 7 days
func (*Model) NextYear ¶
func (m *Model) NextYear()
NextYear sets the model's `Time` struct forward 1 year
func (*Model) SelectDate ¶
func (m *Model) SelectDate()
SelectDate changes the model's Selected to true
func (*Model) SetFocus ¶
SetsFocus focuses one of the datepicker components. This can also be used to blur the datepicker by passing the Focus `FocusNone`.
func (*Model) SetTime ¶
SetTime sets the model's `Time` struct and is used as reference to the selected date
func (*Model) Tomorrow ¶
func (m *Model) Tomorrow()
Tomorrow sets the model's `Time` struct forward 1 day
func (*Model) UnselectDate ¶
func (m *Model) UnselectDate()
UnselectDate changes the model's Selected to false
func (Model) Update ¶
Update changes the state of the datepicker. Update satisfies the `tea.Model` interface