feat(tui-prompts): WIP Add DateTime type#92
Conversation
|
Thanks for sharing this. Date is on the old My instinct is that this is too much surface area for the crate as-is. The datetime part may be better explored as a standalone widget/example first. The current UI also feels a bit literal/heavy to me, so I’d lean simpler there. The larger prompt-state changes are probably worth a separate design discussion. The original I don’t think we should merge the current WIP directly, but I’d be open to a narrower follow-up around either the standalone date/datetime widget idea or a design issue for the prompt API changes. |
This is a work in progress, but I thought this would be a good point to share what I have so far.
The DateTime prompt does most of what I want it to, and the trait changes relating to prompt state should make it easier to add other compound prompts (like a radio button prompt).
That said, working on this demonstrated just how opinionated a prompt that handles date and time has to be.
It may be less of a headache long-term to include the datetime module only in the examples directory, while keeping the code allowing compound state that it's built on.
Please let me know what you think!
What this changes
State traits
Creates a CompoundState, intended as a container to hold the state of multiple child prompts.
Creates a TextualState to hold functionality separate from the container-like CompoundState.
Creates a StateCommon, to hold core functionality shared by all state types.
Validation
is_valid_char)chrono::NaiveDateTime) on marking prompt Status as DonedatetimeModuleDateTimeState, DateTimePrompt, NumericChildState and NumericPrompt
Styling
The datetime prompt has a default display shown when no text is entered.
Example
Adds the
utc_timeexample, which requires thedatetimefeature:The status doesn't do anything.
Remaining issues
I haven't written much documentation or any tests for the new code yet.
Validity
No builtin way of checking semantic validity yet.
This is important where the value of one prompt is related to the value of another, or where there is an external constraint.
Does it need to be builtin? I'm not sure
Status
With validation on submission, there is now the possibility for an "invalid" status. I have made no changes to this, so the Status (or more broadly, how status is considered and handled) needs review.
Adding Style
The
*RenderStyletypes would benefit from more generalisation.Prompt Sizing
I haven't yet done anything to allow for resizing of the DateTimePrompt.