feat(field): add LumexField component for consistent field layout#271
feat(field): add LumexField component for consistent field layout#271ogix wants to merge 12 commits intoLumexUI:mainfrom
Conversation
Design document for a reusable field layout component that will provide consistent label, description, and error message rendering across all input components. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add the LumexField component that provides a consistent field layout with label, content, description, and error message support. The component supports both vertical and horizontal orientations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add Label, Description, and ErrorMessage parameters to LumexInputBase so that all input components have these properties available. This is part of the LumexField design to ensure consistency across all inputs. Note: This change introduces CS0108 warnings about hiding inherited members in LumexInputFieldBase, which will be addressed in a follow-up change. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ssage Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…in RadioGroup and Select Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use LumexComponent wrapper to support the As parameter for rendering as any HTML element, and properly pass through Class, Style, and AdditionalAttributes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Refactor LumexRadioGroup to use LumexField internally, which: - Adds ErrorMessage support (previously missing) - Provides consistent label/description rendering - Reduces code duplication Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add ErrorMessage, Invalid, and Required parameters to LumexCheckboxGroup and refactor to use LumexField internally for consistent rendering. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis pull request introduces a new LumexField component and supporting infrastructure to standardize label, description, and error message rendering across input components. It refactors the component hierarchy by moving Label, Description, and ErrorMessage properties from LumexInputFieldBase to LumexInputBase, adds a new Orientation enum and FieldSlots class, and updates multiple components (Checkbox, Radio, Select, Datebox) to use LumexField internally. Comprehensive tests and styling logic are included. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Consumer
participant LF as LumexField
participant Render as Render Methods
participant Helper as Helper Logic
App->>LF: Pass Label, Description, Orientation
LF->>LF: Determine layout (Vertical/Horizontal)
alt Vertical Orientation
LF->>Render: RenderVerticalLayout()
Render->>Render: Render Label slot
Render->>Render: Render Content slot
Render->>Helper: RenderHelper()
else Horizontal Orientation
LF->>Render: RenderHorizontalLayout()
Render->>Render: Render Content slot
Render->>Render: Render LabelWrapper with Label
Render->>Helper: RenderHelper()
end
Helper->>Helper: Check Invalid state
alt Invalid && ErrorMessage
Helper->>Render: Render ErrorMessage slot
else Description exists
Helper->>Render: Render Description slot
end
Render-->>LF: Composed HTML
LF-->>App: Rendered field with labels/errors
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist. 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 |
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/LumexUI/Components/Field/LumexField.razor.cs`:
- Around line 74-80: HasHelper currently returns true if ErrorMessage is
non-empty even when Invalid is false, causing RenderHelper to emit an empty
wrapper; update the logic so error text is only considered when the field is
invalid — e.g., change HasHelper to check !string.IsNullOrEmpty(Description) ||
(!string.IsNullOrEmpty(ErrorMessage) && Invalid) (or alternatively gate the
error rendering inside RenderHelper by only rendering ErrorMessage when Invalid
is true), referencing the HasHelper, ErrorMessage, Invalid, Description and
RenderHelper members.
| private bool HasHelper => | ||
| !string.IsNullOrEmpty( Description ) || | ||
| !string.IsNullOrEmpty( ErrorMessage ); | ||
|
|
||
| private bool HasLabelOrHelper => | ||
| !string.IsNullOrEmpty( Label ) || | ||
| HasHelper; |
There was a problem hiding this comment.
Avoid rendering an empty helper container when error text is inactive.
If ErrorMessage is set but Invalid is false and Description is empty, HasHelper becomes true and RenderHelper produces an empty wrapper (extra spacing). Consider gating error text on Invalid.
🔧 Suggested adjustment
- private bool HasHelper =>
- !string.IsNullOrEmpty( Description ) ||
- !string.IsNullOrEmpty( ErrorMessage );
+ private bool HasHelper =>
+ !string.IsNullOrEmpty( Description ) ||
+ ( Invalid && !string.IsNullOrEmpty( ErrorMessage ) );📝 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.
| private bool HasHelper => | |
| !string.IsNullOrEmpty( Description ) || | |
| !string.IsNullOrEmpty( ErrorMessage ); | |
| private bool HasLabelOrHelper => | |
| !string.IsNullOrEmpty( Label ) || | |
| HasHelper; | |
| private bool HasHelper => | |
| !string.IsNullOrEmpty( Description ) || | |
| ( Invalid && !string.IsNullOrEmpty( ErrorMessage ) ); | |
| private bool HasLabelOrHelper => | |
| !string.IsNullOrEmpty( Label ) || | |
| HasHelper; |
🤖 Prompt for AI Agents
In `@src/LumexUI/Components/Field/LumexField.razor.cs` around lines 74 - 80,
HasHelper currently returns true if ErrorMessage is non-empty even when Invalid
is false, causing RenderHelper to emit an empty wrapper; update the logic so
error text is only considered when the field is invalid — e.g., change HasHelper
to check !string.IsNullOrEmpty(Description) ||
(!string.IsNullOrEmpty(ErrorMessage) && Invalid) (or alternatively gate the
error rendering inside RenderHelper by only rendering ErrorMessage when Invalid
is true), referencing the HasHelper, ErrorMessage, Invalid, Description and
RenderHelper members.
Summary
This PR introduces the
LumexFieldcomponent, which provides a consistent field layout with label, content, description, and error message slots. It also refactors existing components to use this new component for consistency.Changes
LumexFieldcomponent with vertical and horizontal orientationsFieldSlotsclass for customizable slot stylingLabel,Description,ErrorMessageproperties to base classLumexInputFieldBaseto use inherited propertiesRadioGroupandSelectto use inherited propertiesRadioGroupandCheckboxGroupto useLumexFieldfor layoutLumexComponentfor polymorphic renderingNew Component Usage
Test plan
LumexFieldcomponentFindAllBySlottest extension method🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Tests