abradley2 / form-elements / FormElements.DatePicker

A "Date Picker" control for selecting dates from a calendar-like interface.

Definitions

view : Model -> Props -> Html Msg

The view for displaying the element.

init : Date -> ( Model, Platform.Cmd.Cmd Msg )

Creates the initial model for the element, using an "index date" to determine what starting date the calendar opens up to. This does not have to be Date.today

update : Msg -> Model -> Props -> DatePickerResult

The main function for updating the element in response to Msg

defaultProps : String -> Props

Convenience function for getting a default Props record. Requires that the element's id be passed in.


type Msg
    = NoOp
    | ToggleShowDatePicker Basics.Bool
    | GetToday Date
    | OnDateSelected Date
    | NextMonth Date
    | PreviousMonth Date

Messages return from the view


type alias Model =
{ showDatePicker : Basics.Bool
, today : Date
, monthMap : MonthMap
, outroMonthMap : Maybe MonthMap 
}

The model the element uses to render itself.


type alias Props =
{ id : String
, label : String
, selectedDateDisplay : Date -> String
, selectedDate : Maybe Date
, weekdayDisplay : Time.Weekday -> String
, monthDisplay : Time.Month -> String
, dateIsHighlighted : Date -> Basics.Bool
, canSelectDate : Date -> Basics.Bool
, canSelectMonth : ( Time.Month
, Basics.Int ) -> Basics.Bool 
}

Configurable properties for rendering the view


type alias DatePickerResult =
ComponentResult Model Msg ExternalMsg Basics.Never

Alias for the element's Component Result type type.


type ExternalMsg
    = DateSelected Date

The external message type for the Component Result type