MCPcopy Create free account
hub / github.com/DioxusLabs/dioxus-components / DatePickerMonthSegment

Function DatePickerMonthSegment

primitives/src/date_picker.rs:894–925  ·  view source on GitHub ↗
(props: DatePickerMonthSegmentProps)

Source from the content-addressed store, hash-verified

892/// A month segment in a date input.
893#[component]
894pub fn DatePickerMonthSegment(props: DatePickerMonthSegmentProps) -> Element {
895 let mut ctx = use_context::<DateElementContext>();
896 let base_ctx = use_context::<BaseDatePickerContext>();
897 let today = OffsetDateTime::now_local_date();
898 let min_date = base_ctx.enabled_date_range.start();
899 let max_date = base_ctx.enabled_date_range.end();
900 let min_year = min_date.year();
901 let max_year = max_date.year();
902 let min_month = match (ctx.year_value)() {
903 Some(year) if year == min_year => min_date.month(),
904 _ => Month::January,
905 };
906 let max_month = match (ctx.year_value)() {
907 Some(year) if year == max_year => max_date.month(),
908 _ => Month::December,
909 };
910
911 rsx! {
912 DateSegment {
913 aria_label: "month",
914 index: ctx.start_index + 1usize,
915 value: ctx.month_value,
916 default: today.month() as u8,
917 on_value_change: move |value: Option<u8>| ctx.month_value.set(value),
918 min: min_month as u8,
919 max: max_month as u8,
920 max_length: 2,
921 on_format_placeholder: ctx.on_format_month_placeholder,
922 attributes: props.attributes,
923 }
924 }
925}
926
927/// A day segment in a date input.
928#[component]

Callers

nothing calls this directly

Calls 2

startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected