Repository navigation
feat(input-otp): add input-otp - #49
Conversation
|
Warning Review limit reached
Next review available in: 38 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughAdds a new Angular OTP input primitive with ControlValueAccessor support, public package exports, theme styles and caret animation, dynamic documentation examples, and a dedicated documentation page. ChangesInput OTP primitive
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant NgpInputOtpState
participant MgnpInputOtp
participant AngularForm
User->>NgpInputOtpState: Enter OTP characters
NgpInputOtpState-->>MgnpInputOtp: Emit valueChange
MgnpInputOtp->>AngularForm: Call onChange
NgpInputOtpState-->>MgnpInputOtp: Emit complete
MgnpInputOtp->>AngularForm: Call onTouched
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/ng-primitives/_theme/components/input-otp.css`:
- Around line 21-29: Remove the fixed horizontal padding utility from the OTP
slot base styles while preserving the vertical padding, border, rounding, and
size-specific utilities in the input OTP slot styling. Ensure fixed-size slots
retain usable content width under border-box sizing.
In `@packages/ng-primitives/input-otp/src/lib/mgnp-input-otp/mgnp-input-otp.ts`:
- Line 47: Update MgnpInputOtp.writeValue to assign the incoming form-control
value through the host directive’s mgnpInputOtpValue state rather than only
updating the local value accessor. Normalize null and undefined to an empty
string, preserving the primitive’s expected value representation so
initialization, setValue, and reset update the slots and hidden input.
- Around line 60-64: Remove the onTouched subscription from the state().complete
stream and register it on the hidden input’s blur or focusout event instead.
Update the relevant input event wiring in the mgnp-input-otp component so
onTouched is invoked when focus leaves, regardless of OTP completion state.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 13cf480d-7463-475f-9e4b-312f6e89d0bd
📒 Files selected for processing (16)
apps/documentation/src/content/documentation/ng-primitives/input-otp.mdapps/documentation/src/examples/button/size.tsapps/documentation/src/examples/input-otp/size.tsapps/documentation/src/previews/input-otp.tspackages/ng-primitives/_theme/_animation.csspackages/ng-primitives/_theme/components/input-otp.csspackages/ng-primitives/_theme/components/input-otp/color.csspackages/ng-primitives/_theme/components/input-otp/size.csspackages/ng-primitives/_theme/mgnp.csspackages/ng-primitives/input-otp/README.mdpackages/ng-primitives/input-otp/ng-package.jsonpackages/ng-primitives/input-otp/src/index.tspackages/ng-primitives/input-otp/src/lib/mgnp-input-otp-input/mgnp-input-otp-input.tspackages/ng-primitives/input-otp/src/lib/mgnp-input-otp-slot/mgnp-input-otp-slot.tspackages/ng-primitives/input-otp/src/lib/mgnp-input-otp/mgnp-input-otp.tstsconfig.base.json
| @apply py-2 px-4; | ||
| @apply border rounded-lg; | ||
|
|
||
| /* Sizes */ | ||
| @apply data-[mgnp-input-otp-slot-size=xs]:mgnp-input-otp-slot-size-xs; | ||
| @apply data-[mgnp-input-otp-slot-size=sm]:mgnp-input-otp-slot-size-sm; | ||
| @apply data-[mgnp-input-otp-slot-size=md]:mgnp-input-otp-slot-size-md; | ||
| @apply data-[mgnp-input-otp-slot-size=lg]:mgnp-input-otp-slot-size-lg; | ||
| @apply data-[mgnp-input-otp-slot-size=xl]:mgnp-input-otp-slot-size-xl; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Remove fixed horizontal padding from fixed-size slots.
Line [21] applies px-4 to every slot while Lines [25-29] apply fixed size-* utilities. With Tailwind’s default border-box sizing, size-8 is 2rem wide but px-4 already consumes 2rem horizontally, leaving no usable content width for the OTP character; larger sizes are also unnecessarily constrained. (tailwindcss.com)
Proposed fix
- `@apply` py-2 px-4;
+ `@apply` p-0;Based on the supplied Tailwind v4 theme and fixed slot-size contract.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @apply py-2 px-4; | |
| @apply border rounded-lg; | |
| /* Sizes */ | |
| @apply data-[mgnp-input-otp-slot-size=xs]:mgnp-input-otp-slot-size-xs; | |
| @apply data-[mgnp-input-otp-slot-size=sm]:mgnp-input-otp-slot-size-sm; | |
| @apply data-[mgnp-input-otp-slot-size=md]:mgnp-input-otp-slot-size-md; | |
| @apply data-[mgnp-input-otp-slot-size=lg]:mgnp-input-otp-slot-size-lg; | |
| @apply data-[mgnp-input-otp-slot-size=xl]:mgnp-input-otp-slot-size-xl; | |
| `@apply` p-0; | |
| `@apply` border rounded-lg; | |
| /* Sizes */ | |
| `@apply` data-[mgnp-input-otp-slot-size=xs]:mgnp-input-otp-slot-size-xs; | |
| `@apply` data-[mgnp-input-otp-slot-size=sm]:mgnp-input-otp-slot-size-sm; | |
| `@apply` data-[mgnp-input-otp-slot-size=md]:mgnp-input-otp-slot-size-md; | |
| `@apply` data-[mgnp-input-otp-slot-size=lg]:mgnp-input-otp-slot-size-lg; | |
| `@apply` data-[mgnp-input-otp-slot-size=xl]:mgnp-input-otp-slot-size-xl; |
🤖 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/ng-primitives/_theme/components/input-otp.css` around lines 21 - 29,
Remove the fixed horizontal padding utility from the OTP slot base styles while
preserving the vertical padding, border, rounding, and size-specific utilities
in the input OTP slot styling. Ensure fixed-size slots retain usable content
width under border-box sizing.
Summary by CodeRabbit
New Features
Documentation