Skip to content

[Feature]: DateField improvements #2376

@nuno-am

Description

@nuno-am

Describe the feature

ℹ️ I've recently started looking into the DateField component, but from my brief investigation, I couldn't find answers for what I'll consider now as feature requests for it.

  • Format filled segments with leading zeros

    • Whether via a new prop or a formatting function, I'd like to have a possibility of displaying a leading 0 for date segments, namely for day and month;
    • I see now that this automatically happens depending on the current locale...
  • Possibility to tell if a segment has a value or not

    • I believe this is possible right now, by checking if the value for a given segment is actually a number, but a built-in mechanism would be preferable
    • This is useful to style the segment accordingly. For example:
      • No value: color it like a placeholder (like a shade of gray)
      • Has value: color it like a regular input value (like black)
    • I was able to customize it via data-[placeholder] class
  • Possibility of having a property (data-attribute, for example) on the Root component, that informs if one of the segments currently has a focus.

    • This is useful to display an outline on the root input, similar to what a regular text input would have, if it was focused.
    • I managed to solve it by placing @focus/@blur events on the DateFieldInput components that update a ref. Then I used a data-focused attribute on the DateFieldRoot based on that ref value. Not sure if that's the right approach, though...

Apologies if any of these features already exist. I simply wasn't able to figure them out.

Additional information

  • I intend to submit a PR for this feature.
  • I have already implemented and/or tested this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions