Skip to content

Render DateTimeField from Form with variant: 'datetime' - #125

Merged
joshunrau merged 3 commits into
DouglasNeuroInformatics:mainfrom
david-roper:datetime-scalar
Oct 7, 2026
Merged

joshunrau merged 3 commits into
DouglasNeuroInformatics:mainfrom
david-roper:datetime-scalar

Conversation

@david-roper

@david-roper david-roper commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Render DateTimeField from Form with variant: 'datetime'

The DateTimeField component already exists, but Form had no way to render it. This PR lets a date field opt into date + time input by setting variant: 'datetime'. Either way, the form stores a single Date.

const content = {
  appointment: {
    kind: 'date',
    label: 'Appointment',
    variant: 'datetime'
  }
};

Changes

  • Dependency: upgrades @douglasneuroinformatics/libui-form-types from ^1.4.0 to ^1.5.0. That version adds the optional variant?: 'date' | 'datetime' to date fields, defaulting to 'date'.
  • ScalarField: for kind: 'date', renders DateTimeField when variant === 'datetime' and DateField otherwise, so existing date fields are unaffected.
  • DateTimeField: props now come from DateFormField (minus kind and variant) instead of BaseFormField, so they match the form field type.
  • Stories: the Form story gains a dateTime field ("Date and Time"), and WithInitialValues sets it.
  • Tests: Form.test.tsx gains two tests:
    • variant: 'datetime' renders the date button and time input, not the date-only input.
    • With no variant, only the date-only input renders.

Notes for reviewers

  • timeFormat="24h" (the segmented 24-hour time input) isn't in the form field type, so fields rendered through Form always use the native time input, which follows the browser locale. Supporting 24h there would need a matching option in libui-form-types.

Testing

  • tsc passes
  • vitest run: 217/217 tests pass

🤖 Generated with Claude Code

Closes issue #122

@david-roper
david-roper requested a review from joshunrau as a code owner October 7, 2026 14:46
@joshunrau
joshunrau merged commit d706d9b into DouglasNeuroInformatics:main Oct 7, 2026
1 check passed
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 6.18.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants