|
| 1 | +use crate::components::calendar::component::*; |
| 2 | +use dioxus::prelude::*; |
| 3 | +use dioxus_primitives::calendar::CalendarProps; |
| 4 | +use dioxus_primitives::date_picker::{ |
| 5 | + self, DatePickerInputProps, DatePickerProps, DatePickerTriggerProps, |
| 6 | +}; |
| 7 | + |
| 8 | +use time::UtcDateTime; |
| 9 | + |
| 10 | +#[component] |
| 11 | +pub fn DatePicker(props: DatePickerProps) -> Element { |
| 12 | + rsx! { |
| 13 | + document::Link { |
| 14 | + rel: "stylesheet", |
| 15 | + href: asset!("/src/components/date_picker/style.css"), |
| 16 | + } |
| 17 | + div { |
| 18 | + date_picker::DatePicker { |
| 19 | + class: "date-picker", |
| 20 | + value: props.value, |
| 21 | + on_value_change: props.on_value_change, |
| 22 | + selected_date: props.selected_date, |
| 23 | + disabled: props.disabled, |
| 24 | + read_only: props.read_only, |
| 25 | + separator: props.separator, |
| 26 | + on_format_placeholder: props.on_format_placeholder, |
| 27 | + attributes: props.attributes, |
| 28 | + {props.children} |
| 29 | + } |
| 30 | + } |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +#[component] |
| 35 | +pub fn DatePickerInput(props: DatePickerInputProps) -> Element { |
| 36 | + rsx! { |
| 37 | + date_picker::DatePickerInput { |
| 38 | + class: "date-picker-input", |
| 39 | + attributes: props.attributes, |
| 40 | + {props.children} |
| 41 | + } |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +#[component] |
| 46 | +pub fn DatePickerTrigger(props: DatePickerTriggerProps) -> Element { |
| 47 | + rsx! { |
| 48 | + date_picker::DatePickerTrigger { |
| 49 | + class: "date-picker-trigger", |
| 50 | + attributes: props.attributes, |
| 51 | + {props.children} |
| 52 | + } |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +#[component] |
| 57 | +pub fn DatePickerCalendar(props: CalendarProps) -> Element { |
| 58 | + let mut view_date = use_signal(|| UtcDateTime::now().date()); |
| 59 | + |
| 60 | + rsx! { |
| 61 | + Calendar { |
| 62 | + selected_date: props.selected_date, |
| 63 | + on_date_change: props.on_date_change, |
| 64 | + on_format_weekday: props.on_format_weekday, |
| 65 | + on_format_month: props.on_format_month, |
| 66 | + view_date: view_date(), |
| 67 | + today: props.today, |
| 68 | + on_view_change: move |date| view_date.set(date), |
| 69 | + disabled: props.disabled, |
| 70 | + first_day_of_week: props.first_day_of_week, |
| 71 | + min_date: props.min_date, |
| 72 | + max_date: props.max_date, |
| 73 | + attributes: props.attributes, |
| 74 | + CalendarHeader { |
| 75 | + CalendarNavigation { |
| 76 | + CalendarPreviousMonthButton {} |
| 77 | + CalendarSelectMonth {} |
| 78 | + CalendarSelectYear {} |
| 79 | + CalendarNextMonthButton {} |
| 80 | + } |
| 81 | + } |
| 82 | + CalendarGrid {} |
| 83 | + } |
| 84 | + } |
| 85 | +} |
0 commit comments