LedgerUI.Components.TimePicker (LedgerUI v0.2.0)

Copy Markdown View Source

Time picker: an input with a clock icon that opens a scrollable list of times (variant="input"), or a list of fixed slots (variant="list").

<.time_picker field={@form[:opens_at]} placeholder="Choose time..." />
<.time_picker name="alarm" time_24hr min_time="15:00" max_time="22:30" minute_step={15} />
<.time_picker field={@form[:slot]} variant="list" min_time="14:00" max_time="14:45" minute_step={15} />

The form gets "HH:MM" (24-hour) through a hidden input named like the field and every change fires a bubbling input event, so phx-change runs. The behaviour lives in the LedgerUI.TimePicker hook (priv/static/ledger_ui/hooks/time_picker.js).

time_picker_panel/1 renders only the popup surface (lu-pop > lu-times).

Summary

Functions

Renders a time input.

The popup surface: a lu-pop with the list of times.

Functions

time_picker(assigns)

Renders a time input.

Attributes

  • id (:string) - Defaults to nil.
  • name (:string) - Defaults to nil.
  • value (:any)
  • field (Phoenix.HTML.FormField) - Defaults to nil.
  • label (:string) - Defaults to nil.
  • help (:string) - Defaults to nil.
  • errors (:list) - Defaults to [].
  • placeholder (:string) - Defaults to nil.
  • time_24hr (:boolean) - Defaults to false.
  • min_time (:string) - Defaults to nil.
  • max_time (:string) - Defaults to nil.
  • minute_step (:integer) - Defaults to 5.
  • step (:integer) - The same as minute_step; it wins when given. Defaults to nil.
  • hour_step (:integer) - Defaults to 1.
  • default_hour (:integer) - Defaults to 12.
  • display_format (:string) - Defaults to nil.
  • locale (:string) - Defaults to "en". Must be one of "en", or "pt_BR".
  • labels (:map) - Defaults to %{}.
  • variant (:string) - Defaults to "input". Must be one of "input", or "list".
  • show_icon (:boolean) - Defaults to true.
  • disabled (:boolean) - Defaults to false.
  • on_change (:string) - Defaults to nil.
  • target (:any) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • icon - Replaces the clock icon.
  • trailing - Buttons joined to the right of the input.

time_picker_panel(assigns)

The popup surface: a lu-pop with the list of times.

Attributes

  • times (:list) - The "HH:MM" texts of the buttons. Defaults to [].
  • value (:any) - The chosen time ("HH:MM") highlighted. Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.