Skip to content

feat: add a2ui DateTimeInput catalog component#2718

Merged
MoonfaceX merged 2 commits into
lynx-family:mainfrom
MoonfaceX:codex/add-a2ui-datetimeinput
May 27, 2026
Merged

feat: add a2ui DateTimeInput catalog component#2718
MoonfaceX merged 2 commits into
lynx-family:mainfrom
MoonfaceX:codex/add-a2ui-datetimeinput

Conversation

@MoonfaceX
Copy link
Copy Markdown
Collaborator

@MoonfaceX MoonfaceX commented May 26, 2026

Summary

  • add the built-in A2UI DateTimeInput catalog component for ReactLynx
  • implement internal calendar/date-time helpers and themed Lynx UI styles
  • register the component in package exports, playground examples, server agent catalog, and catalog docs
  • add an empty changeset for the private GenUI package change

Validation

  • pnpm turbo build --filter @lynx-js/a2ui-reactlynx
  • pnpm -F @lynx-js/a2ui-reactlynx test -- --runInBand
  • pnpm dev in packages/genui/a2ui-playground, verified /, /render, and /__rspeedy_url on port 3001

Summary by CodeRabbit

  • New Features

    • Added DateTimeInput: dialog-based date/time selector with calendar navigation, day selection, and hour/minute picker; works in date-only, time-only, or combined modes
    • Supports min/max validation and flexible output formatting (default date output: YYYY-MM-DD)
  • Styles

    • New stylesheet for DateTimeInput dialog, calendar, time picker, and error/invalid states
  • Documentation

    • Catalog docs updated to include DateTimeInput and usage example
  • Tests

    • Unit tests added for DateTimeInput utilities and formatting behaviors

Review Change Stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 26, 2026

🦋 Changeset detected

Latest commit: 66d5681

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

Walkthrough

Adds a new DateTimeInput catalog component: utilities for parsing/formatting and calendar grid building, a React dialog-based date/time picker component, stylesheet, tests, package/catalog exports, playground registration, server manifest, README updates, instructions, and a changeset.

Changes

DateTimeInput Catalog Component

Layer / File(s) Summary
Date/time utilities and types
packages/genui/a2ui/src/catalog/DateTimeInput/utils.ts
Exports types and utilities for normalizing/parsing values, converting parts↔Date, formatting, weekday labels, comparisons, min/max checks, and building 42-day month pages.
DateTimeInput component with dialog picker
packages/genui/a2ui/src/catalog/DateTimeInput/index.tsx
React component and DateTimeInputProps managing normalized committed value, dialog draft state, calendar month navigation, time steppers, declarative checks, in-dialog validation, and committing formatted output via setValue.
DateTimeInput stylesheet
packages/genui/a2ui/styles/catalog/DateTimeInput.css
Styles for the input field, dialog/backdrop/animations, calendar grid/day states, time picker layout/steppers, and dialog action button variants.
Unit tests for utilities
packages/genui/a2ui/test/dateTimeInput.test.ts
Tests for parsing/normalization, mode fallback, output formatting, month page completeness/selection, min/max disabling, comparison ordering, increment wraparound, and label/placeholder normalization.
Package exports and catalog registration
packages/genui/a2ui/package.json, packages/genui/a2ui/src/catalog/index.ts, packages/genui/a2ui/src/index.ts
Adds ./catalog/DateTimeInput exports and re-exports DateTimeInput through catalog and package entrypoints.
Playground component registration
packages/genui/a2ui-playground/lynx-src/a2ui/App.tsx, packages/genui/a2ui-playground/src/catalog/a2ui.ts
Imports DateTimeInput and its catalog.json, registers it in ALL_BUILTINS and COMPONENT_CATALOG with generated props and example usage entries.
Server-side agent catalog schema and registration
packages/genui/server/agent/a2ui-catalog.ts, packages/genui/server/agent/catalog/DateTimeInput/catalog.json
Adds manifest JSON schema for DateTimeInput (fields: value, label, enableDate, enableTime, outputFormat, min, max, checks) and registers it in server catalog manifests and summaries.
Documentation, instructions, and changeset
.github/a2ui-catalog.instructions.md, packages/genui/a2ui/src/catalog/README.md, .changeset/flat-moons-kneel.md
Adds instruction that date-enabled default output is YYYY-MM-DD unless outputFormat provided, updates README example to include DateTimeInput, and records a changeset entry.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes


Suggested reviewers

  • PupilTong
  • HuJean
  • Sherry-hue
  • gaoachao

🐰
In moonlit code I hop and chart,
Dates and minutes play their part.
A dialog opens, numbers climb,
I stitch the hours, I stitch the time.
Hooray — a neat small picker art!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add a2ui DateTimeInput catalog component' clearly and concisely summarizes the main change: implementing a new DateTimeInput component for the A2UI catalog.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MoonfaceX MoonfaceX marked this pull request as ready for review May 26, 2026 14:47
@MoonfaceX MoonfaceX changed the title [codex] add a2ui DateTimeInput catalog component feat: add a2ui DateTimeInput catalog component May 26, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/genui/a2ui/test/dateTimeInput.test.ts (1)

46-50: ⚡ Quick win

Add regression tests for invalid rollover inputs and large negative deltas.

These cases would lock in expected behavior for the parsing and stepping edge cases.

Suggested test additions
   test('ignores unsupported values', () => {
     expect(normalizeDateTimeInputValue(undefined)).toBeNull();
     expect(normalizeDateTimeInputValue('bad')).toBeNull();
     expect(normalizeDateTimeInputValue({ path: '/date' })).toBeNull();
+    expect(normalizeDateTimeInputValue('2026-02-31')).toBeNull();
+    expect(normalizeDateTimeInputValue('24:99')).toBeNull();
   });
@@
   test('compares date-time parts and wraps time stepping', () => {
@@
     expect(
       incrementDateTimePart(
         { year: 2026, month: 5, day: 26, hour: 23, minute: 59 },
         'minute',
         1,
       ).minute,
     ).toBe(0);
+    expect(
+      incrementDateTimePart(
+        { year: 2026, month: 5, day: 26, hour: 23, minute: 59 },
+        'minute',
+        -121,
+      ).minute,
+    ).toBe(58);
   });

Also applies to: 131-152

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/genui/a2ui/test/dateTimeInput.test.ts` around lines 46 - 50, Add
regression tests to dateTimeInput.test.ts covering invalid rollover inputs and
very large negative deltas to lock in parsing/stepping behavior: extend the
existing test block that calls normalizeDateTimeInputValue (and the related
step/rollover helpers used in the later tests around lines 131-152) with cases
that pass invalid rollover strings (e.g., malformed unit/format) and extremely
negative numeric deltas to assert they return null or the expected clamped
value; reference normalizeDateTimeInputValue and the step/rollover functions
used in those later tests so the new assertions mirror the existing expectations
for unsupported values and edge-case deltas.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/genui/a2ui/src/catalog/DateTimeInput/utils.ts`:
- Around line 86-97: The input parsing currently allows impossible calendar/time
parts because createLocalDate is allowed to auto-normalize invalid values;
before constructing the Date in the dateTimeMatch handling (and the similar
block at 100-111), validate the numeric components themselves: ensure month ∈
[1,12], day ∈ [1, daysInMonth(year, month)], hour ∈ [0,23], minute ∈ [0,59]; if
any component is out of range return null immediately instead of calling
createLocalDate/isValidDate/partsFromDate. Use the same validation logic for the
other similar parsing branch to reject impossible inputs before Date
normalization.
- Around line 362-365: The wrap-around calculation for next using (current +
delta + limit) % limit can still yield negative values for large negative delta;
update the computation in utils.ts (where limit, current, next, parts, part,
delta are used) to normalize with a double-mod pattern so next is always in [0,
limit): replace the existing modulus expression with a robust form that first
applies modulus then adds limit and mods again (i.e., ((current + delta) % limit
+ limit) % limit) to ensure correct wrapping for any delta magnitude.

---

Nitpick comments:
In `@packages/genui/a2ui/test/dateTimeInput.test.ts`:
- Around line 46-50: Add regression tests to dateTimeInput.test.ts covering
invalid rollover inputs and very large negative deltas to lock in
parsing/stepping behavior: extend the existing test block that calls
normalizeDateTimeInputValue (and the related step/rollover helpers used in the
later tests around lines 131-152) with cases that pass invalid rollover strings
(e.g., malformed unit/format) and extremely negative numeric deltas to assert
they return null or the expected clamped value; reference
normalizeDateTimeInputValue and the step/rollover functions used in those later
tests so the new assertions mirror the existing expectations for unsupported
values and edge-case deltas.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1909ae89-8a5e-4df6-af1d-82cfc4997876

📥 Commits

Reviewing files that changed from the base of the PR and between 735f695 and e36fdb2.

📒 Files selected for processing (14)
  • .changeset/flat-moons-kneel.md
  • .github/a2ui-catalog.instructions.md
  • packages/genui/a2ui-playground/lynx-src/a2ui/App.tsx
  • packages/genui/a2ui-playground/src/catalog/a2ui.ts
  • packages/genui/a2ui/package.json
  • packages/genui/a2ui/src/catalog/DateTimeInput/index.tsx
  • packages/genui/a2ui/src/catalog/DateTimeInput/utils.ts
  • packages/genui/a2ui/src/catalog/README.md
  • packages/genui/a2ui/src/catalog/index.ts
  • packages/genui/a2ui/src/index.ts
  • packages/genui/a2ui/styles/catalog/DateTimeInput.css
  • packages/genui/a2ui/test/dateTimeInput.test.ts
  • packages/genui/server/agent/a2ui-catalog.ts
  • packages/genui/server/agent/catalog/DateTimeInput/catalog.json

Comment thread packages/genui/a2ui/src/catalog/DateTimeInput/utils.ts
Comment thread packages/genui/a2ui/src/catalog/DateTimeInput/utils.ts
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 26, 2026

Merging this PR will improve performance by 16.95%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 80 untouched benchmarks
⏩ 26 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
transform 1000 view elements 47.1 ms 40.2 ms +16.95%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing MoonfaceX:codex/add-a2ui-datetimeinput (66d5681) with main (735f695)

Open in CodSpeed

Footnotes

  1. 26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 26, 2026

React External

#1813 Bundle Size — 699.5KiB (0%).

66d5681(current) vs 735f695 main#1803(baseline)

Bundle metrics  no changes
                 Current
#1813
     Baseline
#1803
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 17 17
No change  Duplicate Modules 5 5
No change  Duplicate Code 7.13% 7.13%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#1813
     Baseline
#1803
No change  Other 699.5KiB 699.5KiB

Bundle analysis reportBranch MoonfaceX:codex/add-a2ui-datetim...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 26, 2026

React Example

#8698 Bundle Size — 238KiB (0%).

66d5681(current) vs 735f695 main#8687(baseline)

Bundle metrics  no changes
                 Current
#8698
     Baseline
#8687
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 204 204
No change  Duplicate Modules 81 81
No change  Duplicate Code 44.59% 44.59%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#8698
     Baseline
#8687
No change  IMG 145.76KiB 145.76KiB
No change  Other 92.24KiB 92.24KiB

Bundle analysis reportBranch MoonfaceX:codex/add-a2ui-datetim...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 26, 2026

React MTF Example

#1832 Bundle Size — 208.94KiB (0%).

66d5681(current) vs 735f695 main#1821(baseline)

Bundle metrics  no changes
                 Current
#1832
     Baseline
#1821
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 199 199
No change  Duplicate Modules 78 78
No change  Duplicate Code 44.08% 44.08%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#1832
     Baseline
#1821
No change  IMG 111.23KiB 111.23KiB
No change  Other 97.71KiB 97.71KiB

Bundle analysis reportBranch MoonfaceX:codex/add-a2ui-datetim...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 26, 2026

React Example with Element Template

#966 Bundle Size — 204.36KiB (0%).

66d5681(current) vs 735f695 main#956(baseline)

Bundle metrics  no changes
                 Current
#966
     Baseline
#956
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 124 124
No change  Duplicate Modules 50 50
No change  Duplicate Code 45.19% 45.19%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#966
     Baseline
#956
No change  IMG 145.76KiB 145.76KiB
No change  Other 58.61KiB 58.61KiB

Bundle analysis reportBranch MoonfaceX:codex/add-a2ui-datetim...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 26, 2026

Web Explorer

#10274 Bundle Size — 903.53KiB (0%).

66d5681(current) vs 735f695 main#10264(baseline)

Bundle metrics  Change 1 change
                 Current
#10274
     Baseline
#10264
No change  Initial JS 45.06KiB 45.06KiB
No change  Initial CSS 2.22KiB 2.22KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 9 9
No change  Assets 11 11
Change  Modules 232(+0.43%) 231
No change  Duplicate Modules 11 11
No change  Duplicate Code 27.12% 27.12%
No change  Packages 10 10
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#10274
     Baseline
#10264
No change  JS 499.15KiB 499.15KiB
No change  Other 402.16KiB 402.16KiB
No change  CSS 2.22KiB 2.22KiB

Bundle analysis reportBranch MoonfaceX:codex/add-a2ui-datetim...Project dashboard


Generated by RelativeCIDocumentationReport issue

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/genui/a2ui/src/catalog/DateTimeInput/utils.ts`:
- Around line 72-81: The code incorrectly relies on new Date(year, ...)
semantics where years 0–99 are mapped to 1900–1999; update validation to guard
against years 0..99 before any Date construction: in isValidDatePart (and thus
parseDateTimeString path) add an explicit check that rejects years in the range
0 through 99 (or otherwise handle them by constructing the Date without the
legacy mapping), and ensure daysInMonth either isn’t called with a 0..99 year or
is updated to construct dates using a method that preserves the literal year
(e.g., create the Date then call setFullYear(year) or validate year first).
Target the functions named isValidDatePart and daysInMonth when making this
change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 31cdb3c0-4013-49b6-84cc-285b011a9bee

📥 Commits

Reviewing files that changed from the base of the PR and between e36fdb2 and 66d5681.

📒 Files selected for processing (3)
  • packages/genui/a2ui/src/catalog/DateTimeInput/index.tsx
  • packages/genui/a2ui/src/catalog/DateTimeInput/utils.ts
  • packages/genui/a2ui/test/dateTimeInput.test.ts

Comment thread packages/genui/a2ui/src/catalog/DateTimeInput/utils.ts
Copy link
Copy Markdown
Collaborator

@Huxpro Huxpro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good after fixing the DateTimeInput validation and time-only dialog title edge cases.

@MoonfaceX MoonfaceX enabled auto-merge (squash) May 27, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants