Skip to content

refactor(form-numeric-input): unify help/error text into StatusText and update story - #257

Merged
BleedingDev merged 3 commits into
masterfrom
refactor/form-numeric-input-status-text
Dec 30, 2025
Merged

BleedingDev merged 3 commits into
masterfrom
refactor/form-numeric-input-status-text

Conversation

@KaiUweCZE

@KaiUweCZE KaiUweCZE commented Dec 28, 2025 •

Copy link
Copy Markdown
Collaborator

Replace separate ErrorText/ExtraText usage with a single StatusText in
FormNumericInput to centralize status-driven messaging and icon logic.
Add showHelpTextIcon prop (defaults to true when status is not "default")
and remove extraText prop and related IDs. Simplify container spacing
class to use gap-form-field-gap and keep label/numeric input markup.

Update storybook: add argTypes for validateStatus, helpText,
showHelpTextIcon and size; replace WithExtraText story with a
ValidationStates story that demonstrates default, error, success and
warning examples using multiple FormNumericInput instances.

These changes reduce duplicated components, simplify props/IDs, and make
status rendering consistent across validation states.

Summary by CodeRabbit

  • New Features

    • Added showHelpTextIcon property to control whether help text displays an icon.
  • Improvements

    • Consolidated help text into a single StatusText for consistent validation feedback.
    • Unified form field spacing for more consistent layout.
    • Enhanced validation visuals for default, error, success and warning states.
  • Breaking Changes

    • Removed extraText prop from the FormNumericInput public API.
  • Documentation

    • Updated stories to showcase validation states and expose new controls.

✏️ Tip: You can customize this high-level summary in your review settings.

…nd update story

Replace separate ErrorText/ExtraText usage with a single StatusText in
FormNumericInput to centralize status-driven messaging and icon logic.
Add showHelpTextIcon prop (defaults to true when status is not "default")
and remove extraText prop and related IDs. Simplify container spacing
class to use gap-form-field-gap and keep label/numeric input markup.

Update storybook: add argTypes for validateStatus, helpText,
showHelpTextIcon and size; replace WithExtraText story with a
ValidationStates story that demonstrates default, error, success and
warning examples using multiple FormNumericInput instances.

These changes reduce duplicated components, simplify props/IDs, and make
status rendering consistent across validation states.
@semanticdiff-com

semanticdiff-com Bot commented Dec 28, 2025 •

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  libs/ui/stories/molecules/form-numeric-input.stories.tsx  29% smaller
  libs/ui/src/molecules/form-numeric-input.tsx  26% smaller

@mesa-dot-dev

mesa-dot-dev Bot commented Dec 28, 2025

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@vercel

vercel Bot commented Dec 28, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
new-engine-ui-storybook Ready Ready Preview, Comment Dec 30, 2025 9:47pm

@coderabbitai

coderabbitai Bot commented Dec 28, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

FormNumericInput now consolidates help-text rendering into a single StatusText driven by validateStatus; extraText removed and showHelpTextIcon?: boolean added. Storybook updated to expose controls and a ValidationStates story demonstrating multiple validation states.

Changes

Cohort / File(s) Summary
Form component
libs/ui/src/molecules/form-numeric-input.tsx
Replace ErrorText/ExtraText conditional rendering with StatusText. Add showHelpTextIcon?: boolean prop (default tied to validateStatus); remove extraText prop and related IDs. Replace per-size data attributes and fixed gap classes with gap-form-field-gap.
Storybook stories
libs/ui/stories/molecules/form-numeric-input.stories.tsx
Add argTypes for validateStatus, helpText, showHelpTextIcon, size. Replace WithExtraText story with ValidationStates showing four independent examples (default, error, success, warning); remove extraText usage.

Sequence Diagram(s)

(Section omitted — changes are component-level rendering and Storybook updates; no multi-component sequential flow requiring a diagram.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

✨ One StatusText to tidy the line,
ExtraText retired, the props now align.
showHelpTextIcon winks on demand,
Stories refreshed for a clearer stand. 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarises the main refactoring work: consolidating ErrorText/ExtraText into StatusText and updating corresponding Storybook stories to demonstrate validation states.
✨ 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 refactor/form-numeric-input-status-text

📜 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 5c5423d and bdaee08.

📒 Files selected for processing (1)
  • libs/ui/src/molecules/form-numeric-input.tsx
🧰 Additional context used
📓 Path-based instructions (4)
libs/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Implement UI library components using Zag.js for React and Tailwind CSS for styling

Files:

  • libs/ui/src/molecules/form-numeric-input.tsx
libs/ui/src/{atoms,molecules}/**/*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

libs/ui/src/{atoms,molecules}/**/*.tsx: React 19 components must not use forwardRef; pass ref as a prop instead
Do not use useCallback in components
Component implementations should use tv() with token-based classes (no raw Tailwind arbitrary values)
Use data attributes for state-based styling (e.g., data-[state=open], data-[disabled])
Do not use arbitrary Tailwind values in class names (e.g., bg-[#ff0000], bg-[var(--...)]); use token classes instead
Do not use direct semantic tokens like bg-primary; use component-specific token classes (e.g., bg-button-bg-primary)
Exported React components should be PascalCase (e.g., ComponentName)
Do not use abbreviations in component names (e.g., btn, pc)
When using Zag.js, derive styles from data attributes (e.g., data-state) rather than imperative styling

Files:

  • libs/ui/src/molecules/form-numeric-input.tsx
libs/ui/src/molecules/**/*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

Interactive components must use Zag.js patterns (machine, useMachine, normalizeProps, connect)

Files:

  • libs/ui/src/molecules/form-numeric-input.tsx
libs/ui/src/{atoms,molecules}/[a-z0-9-]*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

Component files must be placed under src/atoms or src/molecules and named in kebab-case (component-name.tsx)

Files:

  • libs/ui/src/molecules/form-numeric-input.tsx
🧠 Learnings (16)
📓 Common learnings
Learnt from: KaiUweCZE
Repo: NMIT-WR/new-engine PR: 0
File: :0-0
Timestamp: 2025-12-29T13:43:28.258Z
Learning: In the NMIT-WR/new-engine repository, the comprehensive form refactoring (PRs #249-258) migrates all form components to a unified validation API. Components now use `validateStatus` ("default" | "error" | "success" | "warning") and `helpText` props instead of separate `helperText`/`errorText` props, with validation messages rendered via the StatusText component.
Learnt from: KaiUweCZE
Repo: NMIT-WR/new-engine PR: 250
File: libs/ui/src/molecules/slider.tsx:277-285
Timestamp: 2025-12-29T13:25:52.634Z
Learning: In libs/ui components, avoid duplicating default values across component boundaries. If a child component has a default parameter (e.g., StatusText with status = "default"), do not explicitly pass that default from parent components using fallback operators like ?? "default". This maintains a single source of truth for default values.
📚 Learning: 2025-12-29T13:43:28.258Z
Learnt from: KaiUweCZE
Repo: NMIT-WR/new-engine PR: 0
File: :0-0
Timestamp: 2025-12-29T13:43:28.258Z
Learning: In the NMIT-WR/new-engine repository, the comprehensive form refactoring (PRs #249-258) migrates all form components to a unified validation API. Components now use `validateStatus` ("default" | "error" | "success" | "warning") and `helpText` props instead of separate `helperText`/`errorText` props, with validation messages rendered via the StatusText component.

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/{atoms,molecules}/**/*.tsx : Component implementations should use tv() with token-based classes (no raw Tailwind arbitrary values)

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/molecules/**/*.tsx : Interactive components must use Zag.js patterns (machine, useMachine, normalizeProps, connect)

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/{atoms,molecules}/**/*.tsx : Do not use direct semantic tokens like bg-primary; use component-specific token classes (e.g., bg-button-bg-primary)

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/{atoms,molecules}/**/*.tsx : Use data attributes for state-based styling (e.g., data-[state=open], data-[disabled])

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/{atoms,molecules}/**/*.tsx : Do not use abbreviations in component names (e.g., btn, pc)

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/{atoms,molecules}/**/*.tsx : React 19 components must not use forwardRef; pass ref as a prop instead

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:29:55.558Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: apps/frontend-demo/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:29:55.558Z
Learning: Applies to apps/frontend-demo/src/components/@(atoms|molecules|organisms)/*.tsx : In each component TSX file, import its token CSS (e.g., import './_component-name.css')

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/{atoms,molecules}/**/*.tsx : Exported React components should be PascalCase (e.g., ComponentName)

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/{atoms,molecules}/[a-z0-9-]*.tsx : Component files must be placed under src/atoms or src/molecules and named in kebab-case (component-name.tsx)

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:29:55.558Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: apps/frontend-demo/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:29:55.558Z
Learning: Applies to apps/frontend-demo/src/components/@(atoms|molecules|organisms)/*.tsx : Do not hardcode colors or spacing in JSX/TSX; use design tokens and/or tv()

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-12-29T13:25:52.634Z
Learnt from: KaiUweCZE
Repo: NMIT-WR/new-engine PR: 250
File: libs/ui/src/molecules/slider.tsx:277-285
Timestamp: 2025-12-29T13:25:52.634Z
Learning: In the libs/ui project, when a child component defines a default value for a prop (for example StatusText has status = 'default'), do not override this value from the parent with a nullish coalescing operator (??) or other fallbacks. Centralize defaults in the child component (via default parameter or defaultProps) to ensure a single source of truth. Apply this pattern to TSX components under libs/ui (e.g., any files in libs/ui/src/**/*.tsx).

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-10-03T08:38:48.431Z
Learnt from: KaiUweCZE
Repo: NMIT-WR/new-engine PR: 151
File: libs/ui/stories/molecules/product-card.stories.tsx:214-227
Timestamp: 2025-10-03T08:38:48.431Z
Learning: Story files in libs/ui/stories/**/*.tsx can use semantic tokens (e.g., bg-accent, text-accent-fg, hover:bg-accent-hover) for demonstration purposes, unlike component implementation files which should use component-specific token classes.

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:29:55.558Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: apps/frontend-demo/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:29:55.558Z
Learning: Applies to apps/frontend-demo/src/components/@(atoms|molecules|organisms)/*.tsx : Define component props with TypeScript interfaces

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-12-16T19:45:17.746Z
Learnt from: BleedingDev
Repo: NMIT-WR/new-engine PR: 207
File: libs/ui/src/molecules/select.tsx:50-50
Timestamp: 2025-12-16T19:45:17.746Z
Learning: When reviewing Tailwind classes in TSX/TS files, prefer using square brackets for arbitrary CSS values and complex expressions. Specifically: - Do not use the parentheses syntax (z-(--z-index)) for anything beyond simple CSS variable references; this syntax auto-wraps in var() and cannot handle calc or complex functions. - Use the square brackets syntax (e.g., h-[calc(var(--available-height)-var(--spacing-content))]) for calc expressions, var with calc, and any complex CSS expressions. This rule applies broadly to Tailwind v4 usage in TSX code across the project.

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
🧬 Code graph analysis (1)
libs/ui/src/molecules/form-numeric-input.tsx (1)
libs/ui/src/atoms/numeric-input.tsx (1)
  • NumericInputProps (95-109)
🪛 GitHub Actions: CI
libs/ui/src/molecules/form-numeric-input.tsx

[error] 4-4: Cannot find module '../atoms/status-text' or its corresponding type declarations. This caused failure during declaration file generation for the UI library.


[error] pnpm build && pnpm build:storybook failed due to TS error in form-numeric-input.tsx. Declaration file generation and overall build aborted.

🔇 Additional comments (1)
libs/ui/src/molecules/form-numeric-input.tsx (1)

8-56: Excellent refactor to unified StatusText component.

The refactor successfully consolidates help text rendering into StatusText whilst maintaining clean prop handling:

  • The showHelpTextIcon default derives sensibly from validateStatus (line 22)
  • Layout simplification to gap-form-field-gap removes size-specific complexity (line 31)
  • StatusText integration (lines 48-56) passes props cleanly without duplicating defaults
  • Follows the unified validation API pattern from the comprehensive form refactoring

The implementation adheres to all coding guidelines: token-based classes, no arbitrary Tailwind values, and no inappropriate default overrides.

Based on learnings: This refactor aligns with the comprehensive form refactoring (PRs #249-258) that migrates all form components to the unified validation API using validateStatus and helpText props with the StatusText component.


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.

@mesa-dot-dev

mesa-dot-dev Bot commented Dec 28, 2025 •

Copy link
Copy Markdown

Mesa Description

TL;DR

Refactored FormNumericInput to unify help and error messages into a single StatusText component, improving consistency and simplifying prop management, and updated Storybook to reflect these changes with new validation state examples.

What changed?

  • libs/ui/src/molecules/form-numeric-input.tsx:
    • Refactored to use the new StatusText component, replacing ErrorText and ExtraText.
    • Removed the extraText prop and related IDs.
    • Added a showHelpTextIcon prop (defaults to true when status is not "default").
    • Simplified the root div's spacing class to gap-form-field-gap.
  • libs/ui/stories/molecules/form-numeric-input.stories.tsx:
    • Added argTypes for validateStatus, helpText, showHelpTextIcon, and size for improved Storybook controls.
    • Replaced the WithExtraText story with a new ValidationStates story demonstrating default, error, success, and warning examples.
    • Removed the extraText prop from the ComplexDemo story.

Description generated by Mesa. Update settings

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9dbf1d3 and 5c5423d.

📒 Files selected for processing (2)
  • libs/ui/src/molecules/form-numeric-input.tsx
  • libs/ui/stories/molecules/form-numeric-input.stories.tsx
🧰 Additional context used
📓 Path-based instructions (5)
libs/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Implement UI library components using Zag.js for React and Tailwind CSS for styling

Files:

  • libs/ui/stories/molecules/form-numeric-input.stories.tsx
  • libs/ui/src/molecules/form-numeric-input.tsx
libs/ui/stories/**/*.stories.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

libs/ui/stories/**/*.stories.tsx: Storybook stories must exist for components and cover all variants and states
Use Storybook title hierarchy matching the layer (e.g., Atoms/ComponentName)

Files:

  • libs/ui/stories/molecules/form-numeric-input.stories.tsx
libs/ui/src/{atoms,molecules}/**/*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

libs/ui/src/{atoms,molecules}/**/*.tsx: React 19 components must not use forwardRef; pass ref as a prop instead
Do not use useCallback in components
Component implementations should use tv() with token-based classes (no raw Tailwind arbitrary values)
Use data attributes for state-based styling (e.g., data-[state=open], data-[disabled])
Do not use arbitrary Tailwind values in class names (e.g., bg-[#ff0000], bg-[var(--...)]); use token classes instead
Do not use direct semantic tokens like bg-primary; use component-specific token classes (e.g., bg-button-bg-primary)
Exported React components should be PascalCase (e.g., ComponentName)
Do not use abbreviations in component names (e.g., btn, pc)
When using Zag.js, derive styles from data attributes (e.g., data-state) rather than imperative styling

Files:

  • libs/ui/src/molecules/form-numeric-input.tsx
libs/ui/src/molecules/**/*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

Interactive components must use Zag.js patterns (machine, useMachine, normalizeProps, connect)

Files:

  • libs/ui/src/molecules/form-numeric-input.tsx
libs/ui/src/{atoms,molecules}/[a-z0-9-]*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

Component files must be placed under src/atoms or src/molecules and named in kebab-case (component-name.tsx)

Files:

  • libs/ui/src/molecules/form-numeric-input.tsx
🧠 Learnings (11)
📓 Common learnings
Learnt from: KaiUweCZE
Repo: NMIT-WR/new-engine PR: 151
File: libs/ui/stories/molecules/product-card.stories.tsx:214-227
Timestamp: 2025-10-03T08:38:48.431Z
Learning: Story files in libs/ui/stories/**/*.tsx can use semantic tokens (e.g., bg-accent, text-accent-fg, hover:bg-accent-hover) for demonstration purposes, unlike component implementation files which should use component-specific token classes.
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/stories/**/*.stories.tsx : Storybook stories must exist for components and cover all variants and states
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/stories/**/*.stories.tsx : Storybook stories must exist for components and cover all variants and states

Applied to files:

  • libs/ui/stories/molecules/form-numeric-input.stories.tsx
📚 Learning: 2025-10-03T08:38:48.431Z
Learnt from: KaiUweCZE
Repo: NMIT-WR/new-engine PR: 151
File: libs/ui/stories/molecules/product-card.stories.tsx:214-227
Timestamp: 2025-10-03T08:38:48.431Z
Learning: Story files in libs/ui/stories/**/*.tsx can use semantic tokens (e.g., bg-accent, text-accent-fg, hover:bg-accent-hover) for demonstration purposes, unlike component implementation files which should use component-specific token classes.

Applied to files:

  • libs/ui/stories/molecules/form-numeric-input.stories.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/stories/**/*.stories.tsx : Use Storybook title hierarchy matching the layer (e.g., Atoms/ComponentName)

Applied to files:

  • libs/ui/stories/molecules/form-numeric-input.stories.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/{atoms,molecules}/**/*.tsx : Use data attributes for state-based styling (e.g., data-[state=open], data-[disabled])

Applied to files:

  • libs/ui/stories/molecules/form-numeric-input.stories.tsx
  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-12-16T19:45:17.746Z
Learnt from: BleedingDev
Repo: NMIT-WR/new-engine PR: 207
File: libs/ui/src/molecules/select.tsx:50-50
Timestamp: 2025-12-16T19:45:17.746Z
Learning: When reviewing Tailwind classes in TSX/TS files, prefer using square brackets for arbitrary CSS values and complex expressions. Specifically: - Do not use the parentheses syntax (z-(--z-index)) for anything beyond simple CSS variable references; this syntax auto-wraps in var() and cannot handle calc or complex functions. - Use the square brackets syntax (e.g., h-[calc(var(--available-height)-var(--spacing-content))]) for calc expressions, var with calc, and any complex CSS expressions. This rule applies broadly to Tailwind v4 usage in TSX code across the project.

Applied to files:

  • libs/ui/stories/molecules/form-numeric-input.stories.tsx
  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/{atoms,molecules}/**/*.tsx : Component implementations should use tv() with token-based classes (no raw Tailwind arbitrary values)

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/molecules/**/*.tsx : Interactive components must use Zag.js patterns (machine, useMachine, normalizeProps, connect)

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/{atoms,molecules}/**/*.tsx : Do not use direct semantic tokens like bg-primary; use component-specific token classes (e.g., bg-button-bg-primary)

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:29:55.558Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: apps/frontend-demo/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:29:55.558Z
Learning: Applies to apps/frontend-demo/src/components/@(atoms|molecules|organisms)/*.tsx : Define component props with TypeScript interfaces

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
Repo: NMIT-WR/new-engine PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/src/{atoms,molecules}/**/*.tsx : React 19 components must not use forwardRef; pass ref as a prop instead

Applied to files:

  • libs/ui/src/molecules/form-numeric-input.tsx
🧬 Code graph analysis (2)
libs/ui/stories/molecules/form-numeric-input.stories.tsx (2)
libs/ui/src/molecules/form-numeric-input.tsx (1)
  • FormNumericInput (17-59)
libs/ui/src/atoms/numeric-input.tsx (1)
  • NumericInput (111-192)
libs/ui/src/molecules/form-numeric-input.tsx (1)
libs/ui/src/atoms/numeric-input.tsx (1)
  • NumericInputProps (95-109)
🪛 GitHub Actions: CI
libs/ui/src/molecules/form-numeric-input.tsx

[error] 4-4: Cannot find module '../atoms/status-text' or its corresponding type declarations.

🔇 Additional comments (2)
libs/ui/stories/molecules/form-numeric-input.stories.tsx (2)

19-38: Excellent addition of Storybook controls.

The argTypes configuration properly exposes the new props (validateStatus, helpText, showHelpTextIcon, size) for interactive demonstration in Storybook. This follows best practices for component documentation.

Based on coding guidelines, Storybook stories must exist for components and cover all variants and states.


133-228: Well-structured ValidationStates story demonstrating all states.

The replacement of WithExtraText with ValidationStates effectively showcases all four validation states (default, error, success, warning) using independent state management for each example. This provides clear, isolated demonstrations of the StatusText integration across different validation scenarios.

Based on coding guidelines, stories must cover all variants and states, which this implementation satisfies.

@KaiUweCZE

Copy link
Copy Markdown
Collaborator Author

@coderabbitai This PR depends on #249 which introduces the StatusText component. Review assuming #249 is merged first.

@coderabbitai

coderabbitai Bot commented Dec 29, 2025

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch the PR diff and changed files
gh pr view 257 --repo NMIT-WR/new-engine --json files --jq '.files[] | "\(.path)"'

Length of output: 101


🏁 Script executed:

#!/bin/bash
# Get the full content of the FormNumericInput component
cat libs/ui/src/molecules/form-numeric-input.tsx

Length of output: 1394


🏁 Script executed:

#!/bin/bash
# Get the full content of the Storybook story
cat libs/ui/stories/molecules/form-numeric-input.stories.tsx

Length of output: 16143


🏁 Script executed:

#!/bin/bash
# Check if StatusText component exists in the codebase (to understand the dependency)
fd -t f "status-text.tsx" libs/ui/src/

Length of output: 0


@KaiUweCZE, thank you for the heads-up about the dependency on PR #249! I've reviewed this PR assuming StatusText is available, and the refactoring looks excellent. Here are my observations:

✅ Positive Aspects

Clean Refactoring

  • The consolidation of ErrorText/ExtraText into a single StatusText component significantly simplifies the help text rendering logic
  • The new showHelpTextIcon prop with its conditional default (validateStatus === "default" ? false : true) provides sensible behavior out of the box
  • Removing extraText in favor of helpText makes the prop naming more consistent with the validation-driven approach

Default Value Handling
The code correctly follows the established pattern from the retrieved learning: validateStatus is simply passed through to StatusText without duplicating defaults using fallback operators. The showHelpTextIcon conditional is business logic, not default duplication, so this is appropriate.

Comprehensive Storybook Coverage
The new ValidationStates story is much more valuable than the previous WithExtraText story:

  • Demonstrates all four validation states side-by-side (default, error, success, warning)
  • Each instance has independent state management
  • The argTypes additions make the component controls more discoverable

Simplified Layout
Using gap-form-field-gap for consistent spacing is cleaner than size-specific data attributes.

🔍 Code Quality

The implementation is straightforward and maintainable:

{helpText && (
  <StatusText
    status={validateStatus}
    showIcon={showHelpTextIcon}
    size={size}
  >
    {helpText}
  </StatusText>
)}

This conditional rendering pattern is clear and follows React best practices.

📝 Conventional Commits

The PR title follows conventional commit guidelines correctly: refactor(form-numeric-input): ...

The refactoring achieves its stated goals of reducing duplication, simplifying props, and making status rendering consistent. Once PR #249 is merged, this is ready to go! 🚀


🐰✨
Ears perked up with interest, noting the well-structured dependency chain!


🧠 Learnings used
Learnt from: KaiUweCZE
Repo: NMIT-WR/new-engine PR: 172
File: libs/ui/src/templates/product-card.tsx:77-172
Timestamp: 2025-10-24T06:44:22.155Z
Learning: When reviewing PRs in the NMIT-WR/new-engine repository, check for dependencies on other open PRs before flagging missing types or components as errors. The CI may report errors when a PR depends on changes in another unmerged PR.

Learnt from: KaiUweCZE
Repo: NMIT-WR/new-engine PR: 250
File: libs/ui/src/molecules/slider.tsx:277-285
Timestamp: 2025-12-29T13:25:52.634Z
Learning: In libs/ui components, avoid duplicating default values across component boundaries. If a child component has a default parameter (e.g., StatusText with status = "default"), do not explicitly pass that default from parent components using fallback operators like ?? "default". This maintains a single source of truth for default values.

@BleedingDev
BleedingDev merged commit 34b30ff into master Dec 30, 2025
5 of 6 checks passed

This branch was successfully deployed

1 active deployment
Preview — 0962e5b9 Deployed Dec 30, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants