Skip to main content

teksilo_core/styles/
date_edit_style.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! Tier-3 style protocol for the date-edit family (`DateEdit`,
5//! `TimeEdit`, `DateRangeEdit`, `DateTimeEdit`). See
6//! `docs/styling-system.md`.
7//!
8//! All four widgets compose a themed `TextInput` with an optional
9//! trailing trigger button (calendar or clock popover). The TextInput
10//! itself owns the bordered surface + validation strip chrome via
11//! `TextInputStyle`; the trigger is themed via `IconButtonStyle`. The
12//! remaining family-specific chrome is just the *arrangement* — and in
13//! IntUI today the trigger sits inside `TextInput`'s trailing slot,
14//! so the default recipe is a passthrough.
15//!
16//! The thin `make_body(cfg)` surface still earns its keep as a hook
17//! for apps that want to *wrap* the field (e.g. add a clear button
18//! sibling, attach a help icon, swap the trigger placement). The
19//! recipe also owns the family's dimensions — calendar trigger icon
20//! size, calendar button width, segment gap — as `pub const`s on
21//! `teksilo_widgets::styles::recipe_date_edit_style`.
22
23use std::rc::Rc;
24
25use crate::build_context::BuildContext;
26use crate::widget_id::WidgetId;
27
28pub struct DateEditStyleConfig {
29    /// Pre-assembled body (themed `TextInput` with the optional
30    /// trigger already parked in its trailing slot). The recipe may
31    /// return this id directly or wrap it.
32    pub body: WidgetId,
33}
34
35pub trait DateEditStyle: 'static {
36    fn make_body(&self, cfg: &DateEditStyleConfig, ctx: &mut BuildContext) -> WidgetId;
37}
38
39pub type SharedDateEditStyle = Rc<dyn DateEditStyle>;