alexbruf/elm-cally/1.0.0

NOTE: the latest version is 1.1.0

Cally.Context

The record a picker builds and hands to each of its children.

Cally passes this down with an atomico context provider and slots the children into the light DOM. elm-cally has no shadow DOM, so a child is a function of Context: Cally.Date.view applies it to every child you give it, which means children can sit in any order and anywhere in the tree, including inside the heading slot.

type alias Context msg =
{ id : String
, selection : Selection
, today : Date
, locale : Locale
, min : Maybe Date
, max : Maybe Date
, firstDayOfWeek : Weekday
, isDateDisallowed : Date -> Bool
, getDayParts : Date -> List String
, page : Page
, focusedDate : Date
, showOutsideDays : Bool
, showWeekNumbers : Bool
, formatWeekday : WeekdayFormat
, onSelectDay : Date -> msg
, onFocusDay : Date -> msg
, onHoverDay : Date -> msg
}

Everything a child needs to render, and the three messages it can send back.

id is Config.id, the prefix of every DOM id the picker generates.

The three callbacks are the picker's own internal messages, already wrapped with Config.toMsg:

  • onSelectDay is a click on a day that is not disallowed. The picker both selects and focuses that day, because a DOM event can only produce one Elm message.
  • onFocusDay is a click on a disallowed day, a keyboard move, or a <select> change. The date is already clamped to min/max.
  • onHoverDay is mouseover on a day that is neither disallowed nor disabled. Only Cally.Range does anything with it.
= SelectedDate (Maybe Date)
| SelectedRange (Maybe ( Date, Date ))
| SelectedMulti (List Date)

What the picker has selected. Each picker produces its own variant, so a child such as Cally.Month.view can render all three.

type alias Page =
{ start : YearMonth
, end : YearMonth
}

The months currently on screen. end is start plus months - 1.