Skip to content

refactor: move datepicker to lib#18800

Merged
adamhaeger merged 12 commits into
mainfrom
refactor/move-Datepicker-to-app
May 19, 2026
Merged

refactor: move datepicker to lib#18800
adamhaeger merged 12 commits into
mainfrom
refactor/move-Datepicker-to-app

Conversation

@adamhaeger
Copy link
Copy Markdown
Contributor

@adamhaeger adamhaeger commented May 15, 2026

Description

Moves the Datepicker component (and its helpers) from src/app-components/Datepicker/ to the shared @app/form-component lib.

Also moves Flex and useDeviceWidths since they're consumed both by Datepicker and across the rest of the app.

  • New in lib: Datepicker/, Flex/, hooks/
  • dateHelpers.test.ts ported from jest to vitest
  • DropdownCaption-specific styles extracted to a new local src/layout/Datepicker/DropdownCaption.module.css to keep the layout-level component decoupled from the lib's CSS module
  • Added react-day-picker, date-fns, react-number-format, @navikt/aksel-icons, classnames to libs/form-component/package.json (peer + dev)
  • All ~60 frontend call sites updated to import from @app/form-component
  • Added Storybook stories for DatePickerControl

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

    • Storybook preview for the date picker with Preview, ReadOnly and WithMinMax scenarios.
  • Style

    • Responsive datepicker caption styling for improved mobile/layout behaviour.
  • Chores

    • Consolidated form components and date utilities into a shared package to simplify imports and reuse.
    • Updated package metadata to include date, date‑picker, number‑formatting and icon libraries; test tooling adjusted to Vitest.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 40ad5a01-ec66-4f35-88e4-1b1465ec597f

📥 Commits

Reviewing files that changed from the base of the PR and between a09dac2 and 81ee904.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (11)
  • libs/form-component/package.json
  • 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/DatepickerDialog.tsx
  • libs/form-component/src/app-components/Flex/Flex.tsx
  • src/App/frontend/monorepo-changed-paths.txt
  • src/App/frontend/package.json
  • src/App/frontend/src/app-components/Label/Label.tsx
  • src/App/frontend/src/layout/Datepicker/DatepickerComponent.test.tsx
  • src/App/frontend/src/layout/Datepicker/DropdownCaption.tsx
  • src/App/frontend/src/layout/Summary2/CommonSummaryComponents/LayoutSetSummaryAccordion.tsx

📝 Walkthrough

Walkthrough

Adds a public API for the form-component library (barrel exports for datepicker, Flex and hooks), localises internal imports, adds DatePicker Storybook stories and CSS, updates tests to Vitest timers, modifies package metadata, and migrates many frontend imports to use @app/form-component.

Changes

Form component library API establishment and frontend consolidation

Layer / File(s) Summary
Package metadata and tracked paths
libs/form-component/package.json, src/App/frontend/monorepo-changed-paths.txt
Update scripts and dependencies (add date-fns, react-day-picker, react-number-format, add @navikt/aksel-icons to devDeps), remove lint script, and update monorepo changed-paths to include src/app-components/Datepicker/ and src/app-components/Flex/.
Datepicker barrel, helpers, stories, tests, CSS
libs/form-component/src/app-components/Datepicker/index.ts, libs/form-component/src/app-components/Datepicker/utils/dateHelpers.ts, libs/form-component/src/app-components/Datepicker/utils/dateHelpers.test.ts, libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx, src/App/frontend/src/layout/Datepicker/DropdownCaption.module.css
Add a Datepicker barrel export re-exporting components and date helpers, convert internal locales import to relative path, reformat helper signatures, add Storybook stories (Preview, ReadOnly, WithMinMax) and caption CSS, and update tests to use vi.useFakeTimers.
Flex component and hooks re-exports
libs/form-component/src/app-components/Flex/Flex.tsx, libs/form-component/src/app-components/Flex/index.ts, libs/form-component/src/app-components/hooks/index.ts, libs/form-component/src/app-components/hooks/useDeviceWidths.ts
Localise CSS import in Flex, inline and export IGridStyling from Flex, add Flex index export, and re-export device-width hooks via hooks index; formatting-only changes preserve runtime behaviour.
Internal import localisation within libs
libs/form-component/src/app-components/Datepicker/*, 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/DatepickerDialog.tsx
Change absolute src/... imports to relative local imports across Datepicker components; no changes to runtime logic or component APIs.
Frontend import migration to @app/form-component
Many files under src/App/frontend/src/... (Datepicker usage, Label/Fieldset, Pagination, Panel, many layout and component files listed in the diff)
Consolidate consumer imports to @app/form-component for Datepicker components, date helpers, Flex and hooks across 50+ frontend files; update test mocks accordingly.
Frontend tests and mocks
src/App/frontend/src/layout/Datepicker/DatepickerComponent.test.tsx, src/App/frontend/src/utils/dateUtils.test.ts
Adjust test mocks to reference @app/form-component and preserve mocked getDateFormat via jest.requireActual; update imports for PrettyDateAndTime in tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

frontend

Suggested reviewers

  • phlipsterit
  • lassopicasso

Poem

🐰 I hopped through modules, neat and spry,
Barrelled threads beneath the sky,
Stories, helpers, Flex in line,
Imports tidy — everything fine.
Hooray — a carrot for the build! 🥕

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The PR description covers all required template sections: a detailed description of changes, and a complete verification checklist with all items marked as completed.
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.
Title check ✅ Passed The title 'refactor: move datepicker to lib' clearly and concisely summarizes the main objective of moving the Datepicker component to the shared library, which aligns with the primary changes throughout the changeset.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/move-Datepicker-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 backend kind/dependencies Used for issues or pull requests that are dependency updates solution/studio/designer labels May 15, 2026
Base automatically changed from refactor/move-display-date-to-app to refactor/move-button-to-app-components May 15, 2026 11:13
Base automatically changed from refactor/move-button-to-app-components to main May 15, 2026 11:47
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
libs/form-component/package.json (1)

19-50: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove duplicate dependency declarations.

Lines 20, 21, 22, 23 declare classnames, date-fns, react-day-picker, and react-number-format in dependencies, but these same libraries are duplicated in devDependencies at lines 46, 47, 49, and 50. For a library package, runtime dependencies should only appear in dependencies. The duplication is redundant and can cause version conflicts between consumer and development environments.

📦 Proposed fix to remove duplication
     "@vitejs/plugin-react": "^5.0.0",
-    "classnames": "2.5.1",
-    "date-fns": "4.1.0",
     "jsdom": "^26.1.0",
-    "react-day-picker": "9.14.0",
-    "react-number-format": "5.4.5",
     "storybook": "^10.2.11",
🤖 Prompt for 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.

In `@libs/form-component/package.json` around lines 19 - 50, The package.json
currently lists classnames, date-fns, react-day-picker, and react-number-format
in both "dependencies" and "devDependencies"; remove the duplicate entries from
"devDependencies" so these runtime libraries only appear under "dependencies"
(leave the entries under "dependencies" intact) to avoid version conflicts for
consumers; locate the duplicate names in the devDependencies block and delete
those four lines.
🤖 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 `@src/App/frontend/src/layout/Datepicker/DatepickerComponent.test.tsx`:
- Around line 13-17: Replace the inline module factory mock for
'@app/form-component' in DatepickerComponent.test.tsx with a plain
jest.mock('@app/form-component') and move the mock implementation into a manual
mock file under src/__mocks__ named to match the module; in that mock file
export a mocked getDateFormat (e.g., export const getDateFormat = jest.fn(() =>
'dd.MM.yyyy')) and preserve any other exports you rely on from
'@app/form-component' so tests using getDateFormat, DatepickerComponent, or
other symbols still resolve correctly.

In
`@src/App/frontend/src/layout/Summary2/CommonSummaryComponents/LayoutSetSummaryAccordion.tsx`:
- Around line 3-4: The imports in LayoutSetSummaryAccordion.tsx use internal
paths; update the two imports so they use the package's public barrel export
instead of src paths — replace imports of AccordionItem and Flex that currently
reference '@app/form-component/src/app-components/...' with imports from
'@app/form-component' (keep the same named symbols AccordionItem and Flex) so
the file uses the library's public API surface.

---

Outside diff comments:
In `@libs/form-component/package.json`:
- Around line 19-50: The package.json currently lists classnames, date-fns,
react-day-picker, and react-number-format in both "dependencies" and
"devDependencies"; remove the duplicate entries from "devDependencies" so these
runtime libraries only appear under "dependencies" (leave the entries under
"dependencies" intact) to avoid version conflicts for consumers; locate the
duplicate names in the devDependencies block and delete those four lines.
🪄 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: 3996059e-3ec7-4b9a-a84a-e8145c9c3e7d

📥 Commits

Reviewing files that changed from the base of the PR and between d5d32d4 and a09dac2.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (69)
  • libs/form-component/package.json
  • 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/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/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/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/InstanceInformation/InstanceInformationComponent.tsx
  • src/App/frontend/src/layout/NavigationBar/NavigationBarComponent.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

Comment thread src/App/frontend/src/layout/Datepicker/DatepickerComponent.test.tsx
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.84%. Comparing base (97894a6) to head (da05e62).
⚠️ Report is 74 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18800      +/-   ##
==========================================
+ Coverage   95.71%   95.84%   +0.12%     
==========================================
  Files        2587     3018     +431     
  Lines       33007    39575    +6568     
  Branches     4080     4849     +769     
==========================================
+ Hits        31593    37931    +6338     
- Misses       1069     1230     +161     
- Partials      345      414      +69     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@adamhaeger adamhaeger changed the title Refactor/move datepicker to app refactor: move datepicker to lib May 15, 2026
Comment thread libs/form-component/package.json Outdated
Comment thread src/App/frontend/src/__mocks__/@app/form-component.ts Outdated
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.

Nice work :)

@adamhaeger adamhaeger requested a review from a team as a code owner May 18, 2026 12:36
@adamhaeger adamhaeger enabled auto-merge (squash) May 19, 2026 07:03
@adamhaeger adamhaeger merged commit e428520 into main May 19, 2026
5 of 17 checks passed
@adamhaeger adamhaeger deleted the refactor/move-Datepicker-to-app branch May 19, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/chore 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 solution/studio/designer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants