Skip to content

feat(attribute): Add HasInputmode trait and inputmode() method to manage inputmode attribute for HTML elements.#79

Merged
terabytesoftw merged 1 commit into
mainfrom
feature_43
Feb 7, 2026
Merged

feat(attribute): Add HasInputmode trait and inputmode() method to manage inputmode attribute for HTML elements.#79
terabytesoftw merged 1 commit into
mainfrom
feature_43

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

Pull Request

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

… manage `inputmode` attribute for HTML elements.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 7, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added inputmode attribute management for HTML elements with support for eight distinct input modes: decimal, email, none, numeric, search, tel, text, and URL. Includes built-in validation and immutable API design for reliable attribute handling.

Walkthrough

This PR adds support for the HTML inputmode attribute through a new HasInputMode trait, an InputMode enum with eight cases (decimal, email, none, numeric, search, tel, text, url), comprehensive unit tests with data providers, and changelog documentation.

Changes

Cohort / File(s) Summary
Inputmode Attribute Implementation
src/Global/HasInputMode.php, src/Values/InputMode.php
Introduces HasInputMode trait with an immutable inputMode() method that validates values against InputMode enum cases; adds InputMode string-backed enum with eight standardized HTML inputmode values.
Test Coverage
tests/Global/HasInputModeTest.php, tests/Provider/Global/InputModeProvider.php
Implements comprehensive unit tests for HasInputMode trait covering immutability, empty attributes, attribute setting/rendering, and validation error handling; adds data provider with dynamic enum-based and static predefined test cases.
Maintenance
CHANGELOG.md, tests/Provider/Global/PopoverProvider.php
Updates changelog for new HasInputMode trait feature; refines PopoverProvider test data by renaming 'string auto' case to 'string' and removing 'string manual' case.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 A new inputmode hops into place,
Eight enum cases embrace the trace,
Validation swift with traits so fine,
Tests ensure each input will shine! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% 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 accurately describes the main change: adding a HasInputmode trait and inputmode() method to manage the inputmode attribute, which aligns with all the file changes in the PR.
Description check ✅ Passed The description is related to the changeset by confirming this is a new feature (not a bugfix) that does not break backward compatibility, which corresponds to the trait and method additions.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature_43

No actionable comments were generated in the recent review. 🎉

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b84a08e and b6e2a64.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • src/Global/HasInputMode.php
  • src/Values/InputMode.php
  • tests/Global/HasInputModeTest.php
  • tests/Provider/Global/InputModeProvider.php
  • tests/Provider/Global/PopoverProvider.php
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-01-09T16:05:15.502Z
Learnt from: terabytesoftw
Repo: ui-awesome/html-attribute PR: 18
File: tests/Support/Provider/Global/ContentEditableProvider.php:32-33
Timestamp: 2026-01-09T16:05:15.502Z
Learning: Preserve the original copyright year in file headers when moving PHP source files between packages within the ui-awesome repositories (e.g., from ui-awesome/html-core to ui-awesome/html-attribute). Do not update the header year to the current year; keep the original creation year as stated in the header. This applies to all PHP files throughout the repo that are moved between packages.

Applied to files:

  • src/Values/InputMode.php
  • tests/Provider/Global/PopoverProvider.php
  • tests/Global/HasInputModeTest.php
  • src/Global/HasInputMode.php
  • tests/Provider/Global/InputModeProvider.php
📚 Learning: 2026-02-07T13:44:00.931Z
Learnt from: terabytesoftw
Repo: ui-awesome/html-attribute PR: 78
File: tests/Global/HasDirTest.php:92-92
Timestamp: 2026-02-07T13:44:00.931Z
Learning: In PHP test methods that start with testThrowInvalidArgumentException, do not append 'Invalid' again in the method name suffix (e.g., prefer testThrowInvalidArgumentExceptionForSettingDirValue over testThrowInvalidArgumentExceptionForSettingInvalidDirValue). The exception type already communicates invalid input, so the repeated word is redundant. Apply this convention to all similar test methods under the tests/ directory.

Applied to files:

  • tests/Provider/Global/PopoverProvider.php
  • tests/Global/HasInputModeTest.php
  • tests/Provider/Global/InputModeProvider.php
🧬 Code graph analysis (2)
tests/Global/HasInputModeTest.php (4)
tests/Provider/Global/InputModeProvider.php (1)
  • InputModeProvider (19-68)
src/Global/HasInputMode.php (1)
  • inputMode (41-46)
src/Global/HasClass.php (1)
  • class (50-61)
src/Exception/Message.php (1)
  • getMessage (53-56)
tests/Provider/Global/InputModeProvider.php (2)
tests/Provider/Global/PopoverProvider.php (1)
  • values (24-67)
src/Global/HasClass.php (1)
  • class (50-61)
🪛 PHPMD (2.15.0)
tests/Global/HasInputModeTest.php

[warning] 70-70: Avoid excessively long variable names like $expectedRenderAttribute. Keep variable name length under 20. (undefined)

(LongVariable)


[error] 87-87: Avoid using static access to class '\UIAwesome\Html\Helper\Attributes' in method 'testSetInputModeAttributeValue'. (undefined)

(StaticAccess)


[error] 104-104: Avoid using static access to class '\UIAwesome\Html\Helper\Enum' in method 'testThrowInvalidArgumentExceptionForSettingInputModeValue'. (undefined)

(StaticAccess)


[error] 104-104: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\InputMode' in method 'testThrowInvalidArgumentExceptionForSettingInputModeValue'. (undefined)

(StaticAccess)

src/Global/HasInputMode.php

[error] 43-43: Avoid using static access to class '\UIAwesome\Html\Helper\Validator' in method 'inputMode'. (undefined)

(StaticAccess)


[error] 43-43: Avoid using static access to class '\UIAwesome\Html\Attribute\Values\InputMode' in method 'inputMode'. (undefined)

(StaticAccess)

tests/Provider/Global/InputModeProvider.php

[error] 26-26: Avoid using static access to class '\PHPForge\Support\EnumDataProvider' in method 'values'. (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). (3)
  • GitHub Check: linter / Super Linter
  • GitHub Check: mutation / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
🔇 Additional comments (6)
CHANGELOG.md (1)

52-52: LGTM!

Changelog entry follows the established format and correctly references the new feature.

tests/Provider/Global/PopoverProvider.php (1)

50-56: LGTM!

Renaming the test case key to 'string' is consistent with the convention used in the new InputModeProvider and other providers.

src/Global/HasInputMode.php (1)

1-47: LGTM!

The trait follows the established pattern of other Has* traits in the codebase. Validation, immutability via addAttribute, and documentation are all consistent.

tests/Provider/Global/InputModeProvider.php (1)

1-68: LGTM!

The data provider mirrors the established PopoverProvider structure and covers the key scenarios: empty string, null, replacement, string value, and unsetting with null.

src/Values/InputMode.php (1)

1-72: LGTM!

The enum correctly covers all eight valid inputmode attribute values per the HTML specification, with accurate MDN documentation links.

tests/Global/HasInputModeTest.php (1)

1-110: LGTM!

Tests are well-structured, covering immutability, empty state, data-driven attribute setting/rendering, and invalid input validation. The test method naming follows the project convention (no redundant "Invalid" suffix). Based on learnings: "In PHP test methods that start with testThrowInvalidArgumentException, do not append 'Invalid' again in the method name suffix."

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

@coderabbitai coderabbitai Bot added the enhancement New feature or request label Feb 7, 2026
@terabytesoftw terabytesoftw merged commit 85858b8 into main Feb 7, 2026
47 checks passed
@terabytesoftw terabytesoftw deleted the feature_43 branch February 7, 2026 14:33
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