ID:WORK-110Status:readyPriority:highComplexity:simpleMilestone:v1.0.0
Add value mapping to modifier config
Extend ModifierConfig with valueMap and mapTarget fields so that modifier values can be declaratively mapped to different data attribute values. This is the smallest SPEC-033 feature and eliminates 2 existing postTransform uses.
Acceptance Criteria
ModifierConfiginpackages/transform/src/types.tshasvalueMap?: Record<string, string>andmapTarget?: stringfields- The engine's modifier resolution in
packages/transform/src/engine.tsappliesvalueMapbefore emitting data attributes — mapped values go tomapTarget(or the same attribute ifmapTargetis not set) - Unmapped values pass through unchanged
mergeThemeConfigcorrectly mergesvalueMapoverrides (theme replaces base valueMap per modifier)- Unit tests cover: basic mapping, unmapped passthrough, mapTarget redirection, merge behavior
- TypeScript compiles cleanly across all packages
- All existing tests pass
Approach
- Add
valueMapandmapTargettoModifierConfiginpackages/transform/src/types.ts - In the engine's modifier application logic, after resolving the raw value from meta tags, check for
valueMap— if present, look up the value and replace it (or pass through if not found) - If
mapTargetis set, emit the mapped value as a separate data attribute (e.g.,data-checked) in addition to or instead of the original modifier attribute - Update
mergeThemeConfiginpackages/transform/src/merge.tsto handlevalueMap(theme valueMap replaces base, not deep-merged) - Write tests validating the mapping behavior
References
- SPEC-033 (Feature 2 — Value Mapping)