Extract visibility and validation helpers in elements index

This commit is contained in:
2026-04-07 15:44:02 +01:00
parent eccb87e4a1
commit 30bd8c49da
2 changed files with 126 additions and 73 deletions
+30
View File
@@ -3555,3 +3555,33 @@ Validation:
Follow-ups:
- Continue Phase 2 with bounded renderer/module extractions from `components/elements/index.js` (one cohesive bundle per commit).
---
### CL-100: 22500 `components/elements/index.js` helper normalization (validation messages + visibility checks)
date: 2026-04-07
author: Cline
scope: `components/elements/index.js`
type: change
rationale: Apply the requested next bounded refactor slice by consolidating repeated validation message setup and parent-field visibility logic into shared local helpers.
impact: No intended behavior change; EN/CY and accessibility behavior preserved while reducing repeated logic and future drift risk.
status: completed
Summary:
- Added `getValidationMessages(t)` helper for repeated `required/emoji/postcode` message retrieval.
- Added visibility helpers:
- `hasParentFieldValue(...)`
- `isVisibleByEquality(...)`
- `isVisibleByInclusion(...)`
- Replaced repeated inline visibility and validation-message setup across field wrappers with helper usage (Textfield, MultiLinefield, RichMultiLinefield, DateFieldPicker, YesNofield, Radiofield, NumericField, DecimalField).
- Kept existing field render paths, conditions, and validation calls intact.
Validation:
- `npx eslint components/elements/index.js` -> pass
Follow-ups:
- Continue bounded no-behavior-change slices by removing dead locals/comments and extracting one additional low-risk field wrapper at a time.