Skip to content

refactor: move input to app#18819

Merged
adamhaeger merged 26 commits into
mainfrom
refactor/move-Input-to-app
May 20, 2026
Merged

refactor: move input to app#18819
adamhaeger merged 26 commits into
mainfrom
refactor/move-Input-to-app

Conversation

@adamhaeger
Copy link
Copy Markdown
Contributor

@adamhaeger adamhaeger commented May 18, 2026

Issue: #18817

Description

Moves the Input app-component (Input, FormattedInput, NumericInput, constants, styles) from src/App/frontend/src/app-components/Input into the @app/form-component library.

Frontend consumers import from @app/form-component.

Added unit tests and a Storybook story.

Verification

  • Related issues are connected (if applicable)
  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

  • New Features

    • Formatted and numeric input variants; character-limit counter, read-only and text-only modes, and prefix/suffix support.
  • Refactor

    • Inputs consolidated into a shared form-component package; input API simplified (string labels/placeholders, direct characterLimit prop).
    • Language handling switched to language-aware strings for labels/placeholders.
  • Documentation

    • Storybook added showcasing input variants.
  • Tests

    • Extended tests covering input behaviours and formatting.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@adamhaeger has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 30 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a6c69d98-5a03-47b3-a395-abbd494b006b

📥 Commits

Reviewing files that changed from the base of the PR and between 2bc469d and 2232c5e.

📒 Files selected for processing (9)
  • libs/form-component/src/app-components/Input/FormattedInput.test.tsx
  • libs/form-component/src/app-components/Input/Input.test.tsx
  • libs/form-component/src/app-components/Input/Input.tsx
  • libs/form-component/src/app-components/Input/NumericInput.test.tsx
  • libs/form-component/src/app-components/index.ts
  • src/App/frontend/monorepo-changed-paths.txt
  • src/App/frontend/src/layout/Input/InputComponent.tsx
  • src/App/frontend/src/layout/OrganisationLookup/OrganisationLookupComponent.tsx
  • src/App/frontend/src/layout/PersonLookup/PersonLookupComponent.tsx
📝 Walkthrough

Walkthrough

Consolidates Input into libs/form-component: refactors Input props to use plain strings and a caller-provided characterLimit, adds FormattedInput and NumericInput wrappers, exposes an Input barrel, adds stories and tests, and migrates frontend consumers to import from @app/form-component and use langAsString for labels/placeholders.

Changes

Input Component Library Refactoring

Layer / File(s) Summary
Input component core refactoring
libs/form-component/src/app-components/Input/Input.tsx
Removed internal useCharacterLimit and translation-key handling. InputProps now accepts prefix, suffix, placeholder as string, replaces maxLength with characterLimit?: FieldCounterProps, and uses TextfieldProps['type']. Render logic forwards strings directly to Textfield.
FormattedInput and NumericInput wrappers
libs/form-component/src/app-components/Input/FormattedInput.tsx, libs/form-component/src/app-components/Input/NumericInput.tsx
Added FormattedInput (wraps PatternFormat) and NumericInput (wraps NumericFormat) that force customInput to the local Input and omit customInput/size from the public props.
Barrels and Button import
libs/form-component/src/app-components/Input/index.ts, libs/form-component/src/app-components/index.ts, libs/form-component/src/app-components/Button/Button.tsx
Added Input barrel re-exporting Input, InputProps, FormattedInput, and NumericInput. Added export * from './Input' to the top-level app-components barrel. Added default React import to Button.
Input Storybook stories and tests
libs/form-component/src/app-components/Input/Input.stories.tsx, libs/form-component/src/app-components/Input/Input.test.tsx
Added Storybook stories covering placeholder, prefix/suffix, search, error, read-only, text-only, and character-limit cases. Added tests for accessibility, onChange forwarding, read-only/invalid states, prefix/suffix/placeholder rendering, character counter behaviour, textonly rendering, and formatting behaviour for FormattedInput and NumericInput.

Frontend Input Integration and Consumer Migration

Layer / File(s) Summary
InputComponent refactor and integration
src/App/frontend/src/layout/Input/InputComponent.tsx, src/App/frontend/src/layout/Input/config.ts
Updated imports to use components from @app/form-component, added useLanguage() usage, derived characterLimit from maxLength, passed characterLimit into all variants, and switched aria-label/prefix/suffix rendering to langAsString.
Frontend consumers migration
src/App/frontend/src/features/devtools/components/DevToolsLogs/DevToolsLogs.tsx, src/App/frontend/src/features/instantiate/containers/PartySelection.tsx, src/App/frontend/src/layout/Address/AddressComponent.tsx, src/App/frontend/src/layout/OrganisationLookup/OrganisationLookupComponent.tsx, src/App/frontend/src/layout/PersonLookup/PersonLookupComponent.tsx, src/App/frontend/monorepo-changed-paths.txt
Migrated DevToolsLogs, PartySelection, AddressComponent, OrganisationLookup, and PersonLookup to import Input/NumericInput from @app/form-component, replaced translationKey uses with langAsString for accessible labels/placeholders, and added the Input directory to changed-paths tracking.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

kind/chore, frontend

Suggested reviewers

  • phlipsterit
  • framitdavid
  • lassopicasso

"🐰 I hopped through lines and found the keys,
Strings unwrapped, counters set free with ease,
Numbers wrapped neat, inputs tidy and bright,
Lang strings now guiding each aria light,
A little hop — components all feel right."

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor: move input to app' accurately summarizes the main objective—moving the Input component from src/app-components to @app/form-component library.
Description check ✅ Passed The PR description provides a clear summary, references the related issue, describes the changes comprehensively, and includes a completed verification checklist covering all required sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/move-Input-to-app

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.

@github-actions github-actions Bot added skip-releasenotes Issues that do not make sense to list in our release notes kind/dependencies Used for issues or pull requests that are dependency updates labels May 18, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@libs/form-component/src/app-components/Flex/Flex.tsx`:
- Around line 10-16: IGridStyling now exposes xl but the Flex component never
maps size.xl into the generated CSS classes, so add handling for size.xl where
classes are composed in Flex.tsx: update the class-generation logic (the
function/block that reads the size prop and creates breakpoint classes) to check
for size.xl and append the corresponding xl class name (consistent with the
existing pattern for xs/sm/md/lg), ensuring the xl value is included when
building the element's className.

In `@src/App/frontend/src/layout/Datepicker/DatepickerComponent.test.tsx`:
- Around line 13-17: Create a manual mock for the external module
'`@app/form-component`' under src/__mocks__/ that exports __esModule: true and a
mocked getDateFormat (jest.fn(() => 'dd.MM.yyyy')) matching the shape used in
DatepickerComponent.test.tsx; then remove the inline jest.mock block from
DatepickerComponent.test.tsx and instead ensure the test calls
jest.mock('`@app/form-component`') (or relies on Jest's automatic manual mock
resolution) so the shared mock in src/__mocks__ is used across the frontend test
suite.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 56edb378-cf38-4f39-a2b5-9b194f8b3953

📥 Commits

Reviewing files that changed from the base of the PR and between 69ad7f0 and ca3d464.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (85)
  • libs/form-component/package.json
  • libs/form-component/src/app-components/Button/Button.tsx
  • libs/form-component/src/app-components/Datepicker/Calendar.module.css
  • libs/form-component/src/app-components/Datepicker/DatePickerCalendar.tsx
  • libs/form-component/src/app-components/Datepicker/DatePickerInput.tsx
  • libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx
  • libs/form-component/src/app-components/Datepicker/Datepicker.tsx
  • libs/form-component/src/app-components/Datepicker/DatepickerDialog.tsx
  • libs/form-component/src/app-components/Datepicker/index.ts
  • libs/form-component/src/app-components/Datepicker/utils/dateHelpers.test.ts
  • libs/form-component/src/app-components/Datepicker/utils/dateHelpers.ts
  • libs/form-component/src/app-components/Datepicker/utils/dateLocales.ts
  • libs/form-component/src/app-components/Flex/Flex.module.css
  • libs/form-component/src/app-components/Flex/Flex.tsx
  • libs/form-component/src/app-components/Flex/index.ts
  • libs/form-component/src/app-components/Input/FormattedInput.tsx
  • libs/form-component/src/app-components/Input/Input.module.css
  • libs/form-component/src/app-components/Input/Input.stories.tsx
  • libs/form-component/src/app-components/Input/Input.test.tsx
  • libs/form-component/src/app-components/Input/Input.tsx
  • libs/form-component/src/app-components/Input/NumericInput.tsx
  • libs/form-component/src/app-components/Input/constants.ts
  • libs/form-component/src/app-components/Input/index.ts
  • libs/form-component/src/app-components/hooks/index.ts
  • libs/form-component/src/app-components/hooks/useDeviceWidths.ts
  • libs/form-component/src/app-components/index.ts
  • src/App/frontend/monorepo-changed-paths.txt
  • src/App/frontend/src/app-components/DynamicForm/DynamicForm.tsx
  • src/App/frontend/src/app-components/Input/FormattedInput.tsx
  • src/App/frontend/src/app-components/Input/NumericInput.tsx
  • src/App/frontend/src/app-components/Label/Fieldset.tsx
  • src/App/frontend/src/app-components/Label/Label.tsx
  • src/App/frontend/src/app-components/Pagination/Pagination.tsx
  • src/App/frontend/src/app-components/Panel/Panel.tsx
  • src/App/frontend/src/components/AltinnCollapsible.tsx
  • src/App/frontend/src/components/altinnParty.tsx
  • src/App/frontend/src/components/form/Form.tsx
  • src/App/frontend/src/components/label/Label.tsx
  • src/App/frontend/src/components/message/ErrorReport.tsx
  • src/App/frontend/src/components/molecules/AltinnSubstatus.tsx
  • src/App/frontend/src/components/presentation/Header.tsx
  • src/App/frontend/src/components/presentation/Presentation.tsx
  • src/App/frontend/src/components/wrappers/ProcessWrapper.tsx
  • src/App/frontend/src/features/devtools/components/DevToolsLogs/DevToolsLogs.tsx
  • src/App/frontend/src/features/instantiate/containers/InstantiationErrorPage.tsx
  • src/App/frontend/src/features/instantiate/containers/PartySelection.tsx
  • src/App/frontend/src/features/pdf/PdfFromLayout.tsx
  • src/App/frontend/src/features/receipt/ReceiptContainer.tsx
  • src/App/frontend/src/layout/Accordion/Accordion.tsx
  • src/App/frontend/src/layout/Address/AddressComponent.tsx
  • src/App/frontend/src/layout/ButtonGroup/ButtonGroupComponent.tsx
  • src/App/frontend/src/layout/Cards/Cards.tsx
  • src/App/frontend/src/layout/Checkboxes/MultipleChoiceSummary.tsx
  • src/App/frontend/src/layout/ComponentStructureWrapper.tsx
  • src/App/frontend/src/layout/Datepicker/DatepickerComponent.test.tsx
  • src/App/frontend/src/layout/Datepicker/DatepickerComponent.tsx
  • src/App/frontend/src/layout/Datepicker/DropdownCaption.module.css
  • src/App/frontend/src/layout/Datepicker/DropdownCaption.tsx
  • src/App/frontend/src/layout/Datepicker/index.tsx
  • src/App/frontend/src/layout/Datepicker/useDatepickerValidation.ts
  • src/App/frontend/src/layout/FileUploadWithTag/EditWindowComponent.tsx
  • src/App/frontend/src/layout/GenericComponent.tsx
  • src/App/frontend/src/layout/Group/GroupSummary.tsx
  • src/App/frontend/src/layout/Image/ImageComponent.tsx
  • src/App/frontend/src/layout/Input/InputComponent.tsx
  • src/App/frontend/src/layout/Input/config.ts
  • src/App/frontend/src/layout/InstanceInformation/InstanceInformationComponent.tsx
  • src/App/frontend/src/layout/NavigationBar/NavigationBarComponent.tsx
  • src/App/frontend/src/layout/OrganisationLookup/OrganisationLookupComponent.tsx
  • src/App/frontend/src/layout/PersonLookup/PersonLookupComponent.tsx
  • src/App/frontend/src/layout/RepeatingGroup/Container/RepeatingGroupContainer.tsx
  • src/App/frontend/src/layout/RepeatingGroup/EditContainer/RepeatingGroupsEditContainer.tsx
  • src/App/frontend/src/layout/RepeatingGroup/Summary2/RepeatingGroupSummary.tsx
  • src/App/frontend/src/layout/RepeatingGroup/Table/RepeatingGroupTableRow.tsx
  • src/App/frontend/src/layout/Subform/SubformComponent.tsx
  • src/App/frontend/src/layout/Subform/Summary/SubformSummaryComponent2.tsx
  • src/App/frontend/src/layout/Subform/Summary/SubformSummaryTable.tsx
  • src/App/frontend/src/layout/Summary/SummaryComponent.tsx
  • src/App/frontend/src/layout/Summary2/CommonSummaryComponents/LayoutSetSummaryAccordion.tsx
  • src/App/frontend/src/layout/Summary2/SummaryComponent2/ComponentSummary.tsx
  • src/App/frontend/src/layout/Summary2/SummaryComponent2/PageSummary.tsx
  • src/App/frontend/src/layout/Tabs/Tabs.tsx
  • src/App/frontend/src/layout/Tabs/TabsSummary.tsx
  • src/App/frontend/src/layout/TimePicker/TimePickerComponent.tsx
  • src/App/frontend/src/utils/dateUtils.test.ts
💤 Files with no reviewable changes (2)
  • src/App/frontend/src/app-components/Input/FormattedInput.tsx
  • src/App/frontend/src/app-components/Input/NumericInput.tsx

Comment thread libs/form-component/src/app-components/Flex/Flex.tsx
Comment thread src/App/frontend/src/layout/Datepicker/DatepickerComponent.test.tsx
@adamhaeger adamhaeger requested a review from a team as a code owner May 18, 2026 13:25
@adamhaeger adamhaeger changed the base branch from main to refactor/move-Datepicker-to-app May 18, 2026 13:53
@adamhaeger adamhaeger changed the title Refactor/move input to app refactor: move input to app May 18, 2026
Comment thread libs/form-component/package.json Outdated
Base automatically changed from refactor/move-Datepicker-to-app to main May 19, 2026 07:03
@adamhaeger adamhaeger enabled auto-merge (squash) May 20, 2026 08:35
@adamhaeger adamhaeger requested a review from phlipsterit May 20, 2026 08:35
@phlipsterit phlipsterit self-assigned this May 20, 2026
Copy link
Copy Markdown
Contributor

@phlipsterit phlipsterit left a comment

Choose a reason for hiding this comment

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

Clean refactor 👏

Comment thread libs/form-component/src/app-components/Input/Input.test.tsx
Comment thread libs/form-component/src/app-components/Input/Input.test.tsx Outdated
Comment thread libs/form-component/src/app-components/Input/Input.test.tsx
Comment thread libs/form-component/src/app-components/Input/Input.tsx Outdated
Comment thread src/App/frontend/src/layout/Input/InputComponent.tsx Outdated
Comment thread libs/form-component/src/app-components/Input/Input.stories.tsx
@adamhaeger adamhaeger merged commit 1c0e5b6 into main May 20, 2026
7 of 13 checks passed
@adamhaeger adamhaeger deleted the refactor/move-Input-to-app branch May 20, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/dependencies Used for issues or pull requests that are dependency updates skip-releasenotes Issues that do not make sense to list in our release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants