goilluminate / elm-fancy-daterangepicker / DateRangePicker

A customizable daterangepicker component.


type Msg

A type representing msgs that are fired from the update function.


type DateRangePicker

The DateRangePicker model.

init : ( DateRangePicker, Platform.Cmd.Cmd Msg )

The default initial state of the DateRangePicker. You must execute the returned command in order to set the current date and for the daterangepicker to behave correctly.

update : Msg -> DateRangePicker -> ( DateRangePicker, Platform.Cmd.Cmd Msg )

The daterangepicker update function.

subscriptions : DateRangePicker -> Platform.Sub.Sub Msg

Subscribes to a mouse click

isOpen : DateRangePicker -> Basics.Bool

Expose if the daterange picker is open

setOpen : Basics.Bool -> DateRangePicker -> DateRangePicker

Sets the the open state of the DateRangePicker

view : DateRangePicker -> Html Msg

The daterange picker view. The date range passed is whatever date range it should treat as selected.

getDateRange : DateRangePicker -> Maybe DateRange

Expose the current selected daterange.

setDateRange : Maybe DateRange -> DateRangePicker -> DateRangePicker

Sets the current daterange for the daterangepicker.

getToday : DateRangePicker -> Date

Expose today's date.


type CalendarDisplay
    = FullCalendar
    | ThreeMonths
    | TwoMonths
    | OneMonth

A type representing how the calendar will be displayed


type alias DateRange =
Types.DateRange

A type representing a date range with a start date and end date.


type RestrictedDateRange
    = Off
    | ToPresent
    | FromPresent
    | Past
    | Future
    | Between Date Date
    | To Date
    | From Date

A type representing a restricted range for the datepicker. All dates not within the restricted date range will be disabled.

daysInRange : DateRange -> Basics.Int

A function that returns the number of days as a whole number in the daterange

inRange : Date -> DateRange -> Basics.Bool

A function to check if a given date is within a given dateRange.

mkDateRange : Date -> Date -> DateRange

A function that creates a DateRange by taking in two dates (start and end). This function assumes that start <= end

mkEnabledDateRangeFromRestrictedDateRange : RestrictedDateRange -> Date -> Maybe Types.EnabledDateRange

An opaque function that makes the EnabledDateRange from settings.

EnabledDateRange is Nothing if RestrictedDateRange is Off

monthAbbr : Time.Month -> String

A function that formats a Month into the abbreviated string.

monthsInRange : DateRange -> Basics.Int

A function that returns the number of months as a whole number in the daterange

setDisableRange : Basics.Bool -> DateRangePicker -> DateRangePicker

Sets whether range selection is disabled for the daterangepicker.

startOfQuarter : Date -> Date

A function that takes a Date and returns the date representing the first date of the quarter that the passed in date belongs to.

weeksInRange : DateRange -> Basics.Int

A function that returns the number of weeks as a whole number in the daterange

yearsInRange : DateRange -> Basics.Int

A function that returns the number of years as a whole number in the daterange

Settings


type alias Settings =
{ placeholder : String
, inputName : Maybe String
, inputId : Maybe String
, inputIcon : Maybe (Html Msg)
, inputAttributes : List (Html.Attribute Msg)
, presetOptions : PresetOptions
, restrictedDateRange : RestrictedDateRange
, formatDateRange : DateRange -> String
, calendarDisplay : CalendarDisplay
, inputView : Maybe (String -> List (Html Msg))
, disableRange : Basics.Bool 
}

The settings that the DateRangePicker uses.

defaultSettings : Settings

A record of default settings for the daterangepicker.

setSettings : Settings -> DateRangePicker -> DateRangePicker

Sets the settings for the daterange picker

setDateRangeFormat : (DateRange -> String) -> DateRangePicker -> DateRangePicker

Sets the date range formatter for the daterangepicker.

setPlaceholder : String -> DateRangePicker -> DateRangePicker

Sets the placeholder for the daterangepicker.

setInputName : String -> DateRangePicker -> DateRangePicker

Sets the name for the daterangepicker.

setInputText : Maybe String -> DateRangePicker -> DateRangePicker

Sets the inputText for the daterangepicker.

setInputId : String -> DateRangePicker -> DateRangePicker

Sets the id for the daterangepicker.

setInputIcon : Html Msg -> DateRangePicker -> DateRangePicker

Sets the input icon for the daterangepicker.

setInputAttributes : List (Html.Attribute Msg) -> DateRangePicker -> DateRangePicker

Sets the input attributes for the daterangepicker.

setPresetOptions : PresetOptions -> DateRangePicker -> DateRangePicker

Sets the preset options for the daterangepicker.

setRestrictedDateRange : RestrictedDateRange -> DateRangePicker -> DateRangePicker

Sets the restricted date range for the daterangepicker.

formatDateRange : DateRange -> String

A function that formats a daterange to a string.

getMinDate : DateRangePicker -> Maybe Date

Expose the min date in the enabled date range.

getMaxDate : DateRangePicker -> Maybe Date

Expose the max date in the enabled date range.

setCalendarDisplay : CalendarDisplay -> DateRangePicker -> DateRangePicker

Sets the CalendarDisplay for the daterangepicker

setInputView : Maybe (String -> List (Html Msg)) -> DateRangePicker -> DateRangePicker

Sets the inputView function for the daterangepicker

Presets


type alias PresetOptions =
{ presetOption : PresetOption
, presetSettings : List PresetSetting
, presets : List Preset 
}

A type representing your preset options for your date range picker.


type PresetOption
    = DefaultPresets
    | CustomPresetsFromSettings
    | CustomPresets
    | CustomOnly
    | AllPresets
    | NoPresets

A type representing which presets to use.


type alias Preset =
{ name : String
, dateRange : DateRange
, presetDateOption : PresetType 
}

A type that represents a preset daterange.


type alias PresetSetting =
{ name : String
, interval : PresetInterval
, presetRelativeToToday : PresetRelativeToToday
, value : Basics.Int 
}

A type used to generate preset dateranges.

Example

{ name = "Past Month"
, interval = Months
, presetRelativeToday = ToToday
, value = 1
}


type PresetInterval
    = Days
    | Months
    | Years

A type representing what the value in PresetSettings is measured in.


type PresetRelativeToToday
    = ToToday
    | FromToday

A type representing how the preset is relative to today.

defaultPresetOptions : PresetOptions

A record of default preset options for the daterangepicker.

defaultPresets : Date -> List Preset

An opaque function used to make the default presets

mkPresetFromDateRange : String -> DateRange -> PresetType -> Preset

A function that creates a Preset from a name and a dateRange

mkPresetFromDates : String -> Date -> Date -> PresetType -> Preset

A function that creates a Preset from a name, startDate, and endDate

getPresets : DateRangePicker -> List Preset

Expose the current presets.


type PresetType
    = Today
    | Yesterday
    | PastWeek
    | PastMonth
    | PastYear
    | WeeksFromToday Basics.Int
    | MonthsFromToday Basics.Int
    | EndOfTime
    | NoneSelected

A type that can be used for calculating relative presets outside of the daterangepicker.

defaultSingleSelectPresets : Date -> List Preset

An opaque function used to make the default presets

getSelectedPreset : DateRangePicker -> PresetType

Expose the currently selected preset.