allo-media/elm-daterange-picker/1.0.0

NOTE: the latest version is 4.0.2

Renamed to n1k0/elm-daterange-picker. It is published under that name, and new versions come out there.

Versions published as allo-media/elm-daterange-picker still install under that name. 8 versions of 8 come from the new location (see their notes).

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/n1k0/elm-daterange-picker.

What we checked: The repo moved to github.com/n1k0/elm-daterange-picker. Rebuilt with git archive from commit 75bb635d73fa of https://github.com/n1k0/elm-daterange-picker (zip prefix allo-media-elm-daterange-picker-75bb635/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 0c4c148b1ef79a256923bd882ef896694891994d.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/allo-media/elm-daterange-picker/zipball/1.0.0/

DateRangePicker

A configurable date range picker widget.

Configuration

type alias Config =
{ allowFuture : Bool
, applyRangeImmediately : Bool
, weekdayFormatter : Weekday -> String
, monthFormatter : Month -> String
, noRangeCaption : String
, weeksStartOn : Weekday
}

DateRangePicker configuration:

  • allowFuture: Allow picking a range in the future
  • applyRangeImmediately: Apply predefined range immediately when clicked
  • weekdayFormatter: How to format a Time.Weekday
  • monthFormatter: How to format a Time.Month
  • noRangeCaption: The String to render when no range is set
  • weeksStartOn: The Time.Weekday weeks start on (eg. Time.Mon or Time.Sun)
configure : (Config -> Config) -> Config

Helper for selectively altering defaultConfig:

configure (\default -> { default | weeksStartOn = Time.Sun })
    |> init Nothing
defaultConfig : Config

A Config featuring the following default values:

{ allowFuture = True
, applyRangeImmediately = True
, weekdayFormatter = Helpers.weekdayToString
, monthFormatter = Helpers.monthToString
, noRangeCaption = "N/A"
, weeksStartOn = Time.Mon
}

State

type State

DateRangePicker state.

Use helpers to set or retrieve values out of it.

init : Config -> Maybe Range -> Posix -> State

Initializes a State with the current day represented as a Posix.

import Time


init defaultConfig Nothing (Time.millisToPosix 0)
initToday : Config -> Maybe Range -> Task Never State

Initializes a State using a Task for fetching today's date.

import Task


type Msg
  = DateRangePickerCreated State


initToday defaultConfig Nothing
  |> Task.perform DateRangePickerCreated
getValue : State -> Maybe Range

Get the current DateRangePicker.Range of the DateRangePicker, if any.

disable : Bool -> State -> State

Disable or enable a DateRangePicker.

isDisabled : State -> Bool

Checks if the DateRangePicker is currently disabled.

open : Bool -> State -> State

Open or close a DateRangePicker.

isOpened : State -> Bool

Checks if the DateRangePicker is currently opened.

setRange : Maybe Range -> State -> State

Assign a DateRangePicker.Range value to the DateRangePicker.

import DateRangePicker.Range exposing (Range)


state |> setRange (Range begin end)

View

view : (State -> msg) -> State -> Html msg

The main DateRangePicker view.

If you only need the panel content, have a look at panel.

panel : (State -> msg) -> State -> Html msg

A DateRangePicker panel view.

The panel is the content of the window containing the ranges and the two calendars. This is useful when you don't need to deal with the clickable date input.

Usage is similar to view.

Subscriptions

subscriptions : (State -> msg) -> State -> Sub msg

DateRangePicker subscriptions. They're useful if you want an opened DateRangePicker panel to be closed when clicking outside of it.