refactor: move datepicker to lib#18800
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (11)
📝 WalkthroughWalkthroughAdds 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 ChangesForm component library API establishment and frontend consolidation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winRemove duplicate dependency declarations.
Lines 20, 21, 22, 23 declare
classnames,date-fns,react-day-picker, andreact-number-formatindependencies, but these same libraries are duplicated indevDependenciesat lines 46, 47, 49, and 50. For a library package, runtime dependencies should only appear independencies. 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
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (69)
libs/form-component/package.jsonlibs/form-component/src/app-components/Datepicker/Calendar.module.csslibs/form-component/src/app-components/Datepicker/DatePickerCalendar.tsxlibs/form-component/src/app-components/Datepicker/DatePickerInput.tsxlibs/form-component/src/app-components/Datepicker/Datepicker.stories.tsxlibs/form-component/src/app-components/Datepicker/Datepicker.tsxlibs/form-component/src/app-components/Datepicker/DatepickerDialog.tsxlibs/form-component/src/app-components/Datepicker/index.tslibs/form-component/src/app-components/Datepicker/utils/dateHelpers.test.tslibs/form-component/src/app-components/Datepicker/utils/dateHelpers.tslibs/form-component/src/app-components/Datepicker/utils/dateLocales.tslibs/form-component/src/app-components/Flex/Flex.module.csslibs/form-component/src/app-components/Flex/Flex.tsxlibs/form-component/src/app-components/Flex/index.tslibs/form-component/src/app-components/hooks/index.tslibs/form-component/src/app-components/hooks/useDeviceWidths.tslibs/form-component/src/app-components/index.tssrc/App/frontend/monorepo-changed-paths.txtsrc/App/frontend/src/app-components/DynamicForm/DynamicForm.tsxsrc/App/frontend/src/app-components/Label/Fieldset.tsxsrc/App/frontend/src/app-components/Label/Label.tsxsrc/App/frontend/src/app-components/Pagination/Pagination.tsxsrc/App/frontend/src/app-components/Panel/Panel.tsxsrc/App/frontend/src/components/AltinnCollapsible.tsxsrc/App/frontend/src/components/altinnParty.tsxsrc/App/frontend/src/components/form/Form.tsxsrc/App/frontend/src/components/label/Label.tsxsrc/App/frontend/src/components/message/ErrorReport.tsxsrc/App/frontend/src/components/molecules/AltinnSubstatus.tsxsrc/App/frontend/src/components/presentation/Header.tsxsrc/App/frontend/src/components/presentation/Presentation.tsxsrc/App/frontend/src/components/wrappers/ProcessWrapper.tsxsrc/App/frontend/src/features/instantiate/containers/InstantiationErrorPage.tsxsrc/App/frontend/src/features/instantiate/containers/PartySelection.tsxsrc/App/frontend/src/features/pdf/PdfFromLayout.tsxsrc/App/frontend/src/features/receipt/ReceiptContainer.tsxsrc/App/frontend/src/layout/Accordion/Accordion.tsxsrc/App/frontend/src/layout/Address/AddressComponent.tsxsrc/App/frontend/src/layout/ButtonGroup/ButtonGroupComponent.tsxsrc/App/frontend/src/layout/Cards/Cards.tsxsrc/App/frontend/src/layout/Checkboxes/MultipleChoiceSummary.tsxsrc/App/frontend/src/layout/ComponentStructureWrapper.tsxsrc/App/frontend/src/layout/Datepicker/DatepickerComponent.test.tsxsrc/App/frontend/src/layout/Datepicker/DatepickerComponent.tsxsrc/App/frontend/src/layout/Datepicker/DropdownCaption.module.csssrc/App/frontend/src/layout/Datepicker/DropdownCaption.tsxsrc/App/frontend/src/layout/Datepicker/index.tsxsrc/App/frontend/src/layout/Datepicker/useDatepickerValidation.tssrc/App/frontend/src/layout/FileUploadWithTag/EditWindowComponent.tsxsrc/App/frontend/src/layout/GenericComponent.tsxsrc/App/frontend/src/layout/Group/GroupSummary.tsxsrc/App/frontend/src/layout/Image/ImageComponent.tsxsrc/App/frontend/src/layout/InstanceInformation/InstanceInformationComponent.tsxsrc/App/frontend/src/layout/NavigationBar/NavigationBarComponent.tsxsrc/App/frontend/src/layout/RepeatingGroup/Container/RepeatingGroupContainer.tsxsrc/App/frontend/src/layout/RepeatingGroup/EditContainer/RepeatingGroupsEditContainer.tsxsrc/App/frontend/src/layout/RepeatingGroup/Summary2/RepeatingGroupSummary.tsxsrc/App/frontend/src/layout/RepeatingGroup/Table/RepeatingGroupTableRow.tsxsrc/App/frontend/src/layout/Subform/SubformComponent.tsxsrc/App/frontend/src/layout/Subform/Summary/SubformSummaryComponent2.tsxsrc/App/frontend/src/layout/Subform/Summary/SubformSummaryTable.tsxsrc/App/frontend/src/layout/Summary/SummaryComponent.tsxsrc/App/frontend/src/layout/Summary2/CommonSummaryComponents/LayoutSetSummaryAccordion.tsxsrc/App/frontend/src/layout/Summary2/SummaryComponent2/ComponentSummary.tsxsrc/App/frontend/src/layout/Summary2/SummaryComponent2/PageSummary.tsxsrc/App/frontend/src/layout/Tabs/Tabs.tsxsrc/App/frontend/src/layout/Tabs/TabsSummary.tsxsrc/App/frontend/src/layout/TimePicker/TimePickerComponent.tsxsrc/App/frontend/src/utils/dateUtils.test.ts
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Description
Moves the
Datepickercomponent (and its helpers) fromsrc/app-components/Datepicker/to the shared@app/form-componentlib.Also moves
FlexanduseDeviceWidthssince they're consumed both byDatepickerand across the rest of the app.Datepicker/,Flex/,hooks/dateHelpers.test.tsported from jest to vitestsrc/layout/Datepicker/DropdownCaption.module.cssto keep the layout-level component decoupled from the lib's CSS modulereact-day-picker,date-fns,react-number-format,@navikt/aksel-icons,classnamestolibs/form-component/package.json(peer + dev)@app/form-componentDatePickerControlVerification
Summary by CodeRabbit
New Features
Style
Chores