Skip to main content

Module date_edit

Module date_edit 

Source
Expand description

DateEdit — text input + calendar popover, bound to Signal<Option<Date>>.

A single-line editable date field. The underlying surface is a TextInputField displaying the formatted date; commit on Enter or blur parses the input against the active pattern, clamps to [min_date, max_date], and writes the result back. A trailing calendar-icon button opens a Calendar popover anchored below the field for graphical date selection.

§Behaviour

  • Value binding: Signal<Option<Date>> is the source of truth. External writes re-format the text. None shows the placeholder.
  • Pattern: locale-derived strftime-subset (%Y-%m-%d, %m/%d/%Y, …); override via format_pattern.
  • Step keys (preview-pass on the field):
    • Arrow Up / Down → ±1 day; Shift+ → ±7 days.
    • Page Up / Page Down → ±1 month; Shift+ → ±1 year.
    • Alt+ArrowDown (or click the calendar icon) → opens calendar popover.
  • Calendar popover: dismisses on click-outside or Escape, commits on cell click, animates with motion.duration_fast fade.
  • Min / Max: clamps on commit and on step. Out-of-range values in the popover cell are disabled.

§Accessibility

  • Container — Role::DateInput, set_value to ISO selection, set_label from .label() builder, set_placeholder when value is None.
  • Calendar trigger button — Role::Button with set_has_popup(HasPopup::Grid) and set_expanded(open).
  • Internally the editing surface remains a Role::TextInput for AT discoverability (so screen readers know it accepts text); the wrapper carries the DateInput role on the outer node.

§Example

use teksilo::widgets::{DateEdit, common::datetime::Date};

let date = ctx.signal(Some(Date::constant(2026, 5, 2)));
ctx.add(
    DateEdit::new(date.clone())
        .min_date(Date::constant(2020, 1, 1))
        .max_date(Date::constant(2030, 12, 31))
        .label("Birth date"),
);

Structs§

DateEdit
Single-line date input with optional calendar popover. See the module docs for the full feature list.

Enums§

ValidationBehavior
How the date editor reacts to out-of-range or partially invalid input.
WidthPolicy
How a datetime widget claims horizontal space.