Skip to content

feat(form): Add InputDate class for HTML <input type="date"> element with attributes and rendering capabilities.#52

Merged
terabytesoftw merged 1 commit intomainfrom
feature_22
Feb 21, 2026
Merged

feat(form): Add InputDate class for HTML <input type="date"> element with attributes and rendering capabilities.#52
terabytesoftw merged 1 commit intomainfrom
feature_22

Conversation

@terabytesoftw
Copy link
Contributor

Pull Request

Q A
Is bugfix?
New feature? ✔️
Breaks BC?

…ent with attributes and rendering capabilities.
@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a new date input form component with support for HTML attributes including autofocus, readonly, required, autocomplete, form, list, min, max, step, and tabindex.
  • Tests

    • Added comprehensive test coverage for the date input component.

Walkthrough

Introduces a new InputDate form component class that extends BaseInput to render HTML <input type="date"> elements with comprehensive attribute support, accompanied by a changelog entry and extensive unit test coverage.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added changelog entry documenting the introduction of the InputDate class and its HTML date input rendering capabilities.
Input Component Implementation
src/Form/InputDate.php
New InputDate class extending BaseInput that composes traits for HTML date attributes (autofocus, readonly, required, autocomplete, form, list, max, min, step, tabindex, value) and implements getTag, loadDefault, and run methods for rendering.
Unit Tests
tests/Form/InputDateTest.php
Comprehensive test suite with 60+ test methods covering attribute handling, rendering with various combinations (ARIA attributes, data attributes, boolean attributes, enum-backed values), prefix/suffix wrapping, template rendering, theme/default providers, and fluent API behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 A date picker blooms, so clean and bright,
With min and max to set things right,
Autofocus traits dance in the light,
HTML's calendar, finally in sight!
📅✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: introducing the InputDate class for HTML element with full attribute and rendering support.
Description check ✅ Passed The description is directly related to the changeset, clearly stating this is a new feature introducing the InputDate class for HTML element.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature_22

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.

@codecov
Copy link

codecov bot commented Feb 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e8e313d) to head (6859013).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##                main       #52   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       155       158    +3     
===========================================
  Files             80        81    +1     
  Lines            370       376    +6     
===========================================
+ Hits             370       376    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coderabbitai coderabbitai bot added the enhancement New feature or request label Feb 21, 2026
Copy link

@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

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8e313d and 6859013.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/Form/InputDate.php
  • tests/Form/InputDateTest.php
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-02-06T21:37:44.509Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 24
File: tests/Form/InputTextTest.php:33-620
Timestamp: 2026-02-06T21:37:44.509Z
Learning: In the ui-awesome/html repository, prefer individual test methods over PHPUnit data providers in test classes. This helps maintainers see exactly how each test behaves without cross-referencing data providers. Apply to all PHP test files under tests. Use separate, descriptively named test methods to cover different inputs/edge cases; retain data providers only if they clearly improve readability or reduce duplication.

Applied to files:

  • tests/Form/InputDateTest.php
📚 Learning: 2026-02-11T14:56:18.277Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 37
File: tests/Form/InputTextTest.php:448-457
Timestamp: 2026-02-11T14:56:18.277Z
Learning: In PHP test files under the repository ui-awesome/html (e.g., tests/Form/InputTextTest.php), it is acceptable to use short variable names (e.g., 2-character names like $id). PHPMD's short-variable rule does not need to be strictly followed in test code. During reviews, allow short names in test files and note that this relaxed style applies to tests, while production code should adhere to the standard variable naming conventions.

Applied to files:

  • tests/Form/InputDateTest.php
📚 Learning: 2026-02-21T01:17:40.877Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 51
File: tests/List/UlTest.php:282-283
Timestamp: 2026-02-21T01:17:40.877Z
Learning: In the ui-awesome/html repository, for PHP tests, ensure that assertion messages in tests/List/UlTest.php for methods named testRenderWith*UsingEnum remain identical to the corresponding non-enum tests (i.e., do not append 'using enum' to the failure message). The reason: the underlying render method treats enum and string inputs the same, so failure output should be uniform. Apply this pattern to all similar test cases under tests/ to maintain consistent failure messages across enum vs non-enum variants.

Applied to files:

  • tests/Form/InputDateTest.php
🧬 Code graph analysis (2)
src/Form/InputDate.php (1)
src/Root/Html.php (1)
  • Html (27-40)
tests/Form/InputDateTest.php (4)
src/Root/Html.php (1)
  • Html (27-40)
src/Form/InputDate.php (1)
  • InputDate (51-96)
tests/Support/Stub/DefaultProvider.php (1)
  • DefaultProvider (17-34)
tests/Support/Stub/DefaultThemeProvider.php (1)
  • DefaultThemeProvider (17-39)
🪛 PHPMD (2.15.0)
tests/Form/InputDateTest.php

[warning] 42-1022: The class InputDateTest has 67 public methods and attributes. Consider reducing the number of public items to less than 45. (undefined)

(ExcessivePublicCount)


[warning] 42-1022: The class InputDateTest has 67 non-getter- and setter-methods. Consider refactoring InputDateTest to keep number of methods under 25. (undefined)

(TooManyMethods)


[warning] 42-1022: The class InputDateTest has 67 public methods. Consider refactoring InputDateTest to keep number of public methods under 10. (undefined)

(TooManyPublicMethods)


[warning] 42-1022: The class InputDateTest has an overall complexity of 67 which is very high. The configured complexity threshold is 50. (undefined)

(ExcessiveClassComplexity)


[error] 42-1022: The class InputDateTest has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13. (undefined)

(CouplingBetweenObjects)


[warning] 544-544: Avoid variables with short names like $id. Configured minimum length is 3. (undefined)

(ShortVariable)


[error] 555-558: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 570-573: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 987-993: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)


[error] 1003-1006: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: composer-require-checker / PHP 8.5-ubuntu-latest
  • GitHub Check: easy-coding-standard / PHP 8.5-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: mutation / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-windows-2022
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.2-windows-2022
  • GitHub Check: phpunit / PHP 8.1-windows-2022
  • GitHub Check: phpunit / PHP 8.3-windows-2022
🔇 Additional comments (3)
src/Form/InputDate.php (1)

51-95: LGTM — well-structured and consistent with sibling input classes.

The MDN @link at line 46 using /Reference/Elements/ (instead of the older /Element/) resolves correctly; MDN restructured their HTML reference paths and both URLs are live.

Trait selection matches every spec-valid attribute for <input type="date"> (autocomplete, autofocus, form, list, max, min, readonly, required, step, tabindex, value). The + union operator in loadDefault() is correct here — as long as BaseInput::loadDefault() does not already set a type key (confirmed by test output), the child's Type::DATE is applied via the right-hand side.

tests/Form/InputDateTest.php (1)

41-1022: Comprehensive test suite — well-aligned with project conventions.

  • All 67 tests are individual methods with no data providers — compliant with the project preference.
  • Every enum/non-enum pair (testRenderWith* vs testRenderWith*UsingEnum) carries identical assertion messages — compliant with the cross-repo learning.
  • The short $id at line 544 is acceptable per the project's relaxed short-variable rule for test code.
  • PHPMD warnings (TooManyMethods, ExcessivePublicCount, CouplingBetweenObjects) are expected consequences of the deliberately granular individual-method style; they are not actionable here.

Based on learnings from PRs #24, #37, and #51 in this repository: individual test methods are preferred over data providers, short variable names are acceptable in test code, and assertion messages in enum vs non-enum variant tests must be identical.

CHANGELOG.md (1)

39-39: LGTM — changelog entry is correctly formatted and placed.

Enh #51`` correctly references the issue number (PR is #52), the description matches the PR objective, and the entry is in the right `0.4.0 Under development` section following the established format.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/Form/InputDateTest.php`:
- Around line 553-574: The test methods testRenderWithGlobalDefaultsAreApplied
and testRenderWithUserOverridesGlobalDefaults set global defaults via
SimpleFactory::setDefaults but reset them only after assertions, so failures can
leak state; wrap the arrangement and assertion in a try/finally in each test:
call SimpleFactory::setDefaults(InputDate::class, ['class'=>'default-class'])
(or the user-overrides setup) before the try, perform the assertion inside the
try block, and always call SimpleFactory::setDefaults(InputDate::class, [])
inside the finally to ensure cleanup regardless of test outcome.

@terabytesoftw terabytesoftw merged commit 313c7a2 into main Feb 21, 2026
49 checks passed
@terabytesoftw terabytesoftw deleted the feature_22 branch February 21, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant