-
Notifications
You must be signed in to change notification settings - Fork 94
refactor: move datepicker to lib #18800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0666d9a
moved Datepicker to lib
adamhaeger a09dac2
merge
adamhaeger 6aa43c2
fix
adamhaeger ba1ac3c
changed paths update
adamhaeger 4cdd85b
extracted mocks to __mocks__
adamhaeger 0a0d7b6
Merge branch 'main' into refactor/move-Datepicker-to-app
adamhaeger 731f2a2
importing from @app
adamhaeger 3124efd
cleanup after code review
adamhaeger cca3019
Merge branch 'main' into refactor/move-Datepicker-to-app
adamhaeger d4e361d
fixed broken imports
adamhaeger da05e62
merge
adamhaeger 81ee904
Merge branch 'main' into refactor/move-Datepicker-to-app
adamhaeger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
5 changes: 2 additions & 3 deletions
5
...ponents/Datepicker/DatePickerCalendar.tsx → ...ponents/Datepicker/DatePickerCalendar.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { useState } from 'react'; | ||
| import type { MonthCaptionProps } from 'react-day-picker'; | ||
|
|
||
| import type { Meta, StoryObj } from '@storybook/react-vite'; | ||
|
|
||
| import 'react-day-picker/style.css'; | ||
|
|
||
| import { DatePickerControl } from './Datepicker'; | ||
|
|
||
| const NoopDropdownCaption = ({ calendarMonth }: MonthCaptionProps) => ( | ||
| <div style={{ padding: 8, fontWeight: 600 }}> | ||
| {calendarMonth.date.toLocaleString('en', { month: 'long', year: 'numeric' })} | ||
| </div> | ||
| ); | ||
|
|
||
| const meta = { | ||
| title: 'AppComponents/DatePickerControl', | ||
| component: DatePickerControl, | ||
| } satisfies Meta<typeof DatePickerControl>; | ||
|
adamhaeger marked this conversation as resolved.
|
||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| const Wrapper = (args: React.ComponentProps<typeof DatePickerControl>) => { | ||
| const [value, setValue] = useState(args.value); | ||
| return <DatePickerControl {...args} value={value} onValueChange={setValue} />; | ||
| }; | ||
|
|
||
| export const Preview: Story = { | ||
| args: { | ||
| id: 'datepicker-preview', | ||
| value: '2025-03-15', | ||
| dateFormat: 'dd.MM.yyyy', | ||
| locale: 'nb', | ||
| buttonAriaLabel: 'Open date picker', | ||
| calendarIconTitle: 'Calendar', | ||
| DropdownCaption: NoopDropdownCaption, | ||
| }, | ||
| render: (args) => <Wrapper {...args} />, | ||
| }; | ||
|
|
||
| export const ReadOnly: Story = { | ||
| args: { | ||
| ...Preview.args, | ||
| readOnly: true, | ||
| }, | ||
| render: (args) => <Wrapper {...args} />, | ||
| }; | ||
|
|
||
| export const WithMinMax: Story = { | ||
| args: { | ||
| ...Preview.args, | ||
| minDate: new Date('2025-01-01'), | ||
| maxDate: new Date('2025-12-31'), | ||
| }, | ||
| render: (args) => <Wrapper {...args} />, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...omponents/Datepicker/DatepickerDialog.tsx → ...omponents/Datepicker/DatepickerDialog.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
libs/form-component/src/app-components/Datepicker/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| export { DatePickerControl } from './Datepicker'; | ||
| export type { DatePickerControlProps } from './Datepicker'; | ||
| export { DatePickerCalendar } from './DatePickerCalendar'; | ||
| export type { CalendarDialogProps } from './DatePickerCalendar'; | ||
| export { DatePickerInput } from './DatePickerInput'; | ||
| export type { DatePickerInputProps } from './DatePickerInput'; | ||
| export { DatePickerDialog, useDatePickerClose } from './DatepickerDialog'; | ||
| export { | ||
| DateFlags, | ||
| DatepickerMinDateDefault, | ||
| DatepickerMaxDateDefault, | ||
| DatepickerFormatDefault, | ||
| PrettyDateAndTime, | ||
| getDateFormat, | ||
| getSaveFormattedDateString, | ||
| getDateConstraint, | ||
| formatISOString, | ||
| isDate, | ||
| getLocale, | ||
| getDateLib, | ||
| strictParseISO, | ||
| strictParseFormat, | ||
| dateFormatCanBeNumericInReactPatternFormat, | ||
| getFormatAsPatternFormat, | ||
| getMonths, | ||
| getYears, | ||
| } from './utils/dateHelpers'; | ||
| export type { Token } from './utils/dateHelpers'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { Flex } from './Flex'; | ||
| export type { IGridStyling } from './Flex'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export { | ||
| useIsMini, | ||
| useIsMobile, | ||
| useIsTablet, | ||
| useBrowserWidth, | ||
| breakpoints, | ||
| } from './useDeviceWidths'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| export * from './AccordionItem'; | ||
| export * from './Button'; | ||
| export * from './Card'; | ||
| export * from './Datepicker'; | ||
| export * from './Flex'; | ||
| export * from './hooks'; | ||
| export * from './DisplayDate'; | ||
| export * from './Spinner'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.