-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat: add month and year pickers to DateRangePicker and RangeCalendar #3302
Changes from all commits
69ef48b
ce7ee58
ca5c72b
9bd1673
b1559fb
67a1829
70a92fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@nextui-org/calendar": patch | ||
"@nextui-org/date-picker": patch | ||
--- | ||
|
||
Add month and year picker to DateRangePicker and RangeCalendar (#3089, #3090) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const App = `import {DateRangePicker} from "@nextui-org/react"; | ||
|
||
export default function App() { | ||
return ( | ||
<div className="w-full max-w-xl flex flex-row gap-4"> | ||
<DateRangePicker | ||
label="Birth Date" | ||
variant="bordered" | ||
showMonthAndYearPickers | ||
/> | ||
</div> | ||
); | ||
}`; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
export default { | ||
...react, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const App = `import {RangeCalendar} from "@nextui-org/react"; | ||
|
||
export default function App() { | ||
return ( | ||
<RangeCalendar | ||
aria-label="Date (Show Month and Year Picker)" | ||
showMonthAndYearPickers | ||
/> | ||
); | ||
}`; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
export default { | ||
...react, | ||
}; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -83,6 +83,8 @@ You can also pass an error message as a function. This allows for dynamic error | |||||
|
||||||
### With Month and Year Pickers | ||||||
|
||||||
You can show month and year pickers in the calendar popover by setting the `showMonthAndYearPickers` property to `true`. However, passing a number greater than 1 to the `visibleMonths` prop will disable this feature. | ||||||
|
||||||
Comment on lines
+86
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve wording for clarity. The sentence can be improved for better clarity. - You can show month and year pickers in the calendar popover by setting the `showMonthAndYearPickers` property to `true`. However, passing a number greater than 1 to the `visibleMonths` prop will disable this feature.
+ To enable month and year pickers in the calendar popover, set the `showMonthAndYearPickers` property to `true`. Note that setting the `visibleMonths` prop to a number greater than 1 will disable this feature. Committable suggestion
Suggested change
|
||||||
<CodeDemo title="With Month and Year Pickers" files={datePickerContent.withMonthAndYearPickers} /> | ||||||
|
||||||
### With Time Fields | ||||||
|
@@ -319,7 +321,7 @@ import {I18nProvider} from "@react-aria/i18n"; | |||||
| color | `default` \| `primary` \| `secondary` \| `success` \| `warning` \| `danger` | The color of the date input. | `default` | | ||||||
| size | `sm` \| `md` \| `lg` | The size of the date input. | `md` | | ||||||
| radius | `none` \| `sm` \| `md` \| `lg` \| `full` | The radius of the date input. | - | | ||||||
| defaultValue | `string` \| undefined | The default value of the date-picker (uncontrolled). | - | | ||||||
| defaultValue | `string` | The default value of the date-picker (uncontrolled). | - | | ||||||
| placeholderValue | `ZonedDateTime` \| `CalendarDate` \| `CalendarDateTime` \| `undefined` \| `null` | The placeholder of the date-picker. | - | | ||||||
| description | `ReactNode` | A description for the date-picker. Provides a hint such as specific requirements for what to choose. | - | | ||||||
| errorMessage | `ReactNode \| (v: ValidationResult) => ReactNode` | An error message for the date input. | - | | ||||||
|
@@ -332,13 +334,12 @@ import {I18nProvider} from "@react-aria/i18n"; | |||||
| isReadOnly | `boolean` | Whether the date-picker can be selected but not changed by the user. | | | ||||||
| isDisabled | `boolean` | Whether the date-picker is disabled. | `false` | | ||||||
| isInvalid | `boolean` | Whether the date-picker is invalid. | `false` | | ||||||
| visibleMonths | `number` \| `undefined` | The number of months to display at once. Up to 3 months are supported. Passing a number greater than 1 will disable the `showMonthAndYearPickers` prop. | `1` | | ||||||
| visibleMonths | `number` | The number of months to display at once. Up to 3 months are supported. Passing a number greater than 1 will disable the `showMonthAndYearPickers` prop. | `1` | | ||||||
| selectorIcon | `ReactNode` | The icon to toggle the date picker popover. Usually a calendar icon. | | | ||||||
| pageBehavior | `PageBehavior` \| `undefined` | Controls the behavior of paging. Pagination either works by advancing the visible page by visibleDuration (default) or one unit of visibleDuration. | `visible` | | ||||||
| visibleMonths | `number` \| `undefined` | The number of months to display at once. Up to 3 months are supported. Passing a number greater than 1 will disable the `showMonthAndYearPickers` prop. | `1` | | ||||||
| pageBehavior | `PageBehavior` | Controls the behavior of paging. Pagination either works by advancing the visible page by visibleDuration (default) or one unit of visibleDuration. | `visible` | | ||||||
| calendarWidth | `number` | The width to be applied to the calendar component. | `256` | | ||||||
| CalendarTopContent | `ReactNode` | Top content to be rendered in the calendar component. | | | ||||||
| isDateUnavailable | `((date: DateValue) => boolean)` \| `undefined` | Callback that is called for each date of the calendar. If it returns true, then the date is unavailable. | | ||||||
| isDateUnavailable | `((date: DateValue) => boolean)` | Callback that is called for each date of the calendar. If it returns true, then the date is unavailable. | | | ||||||
| autoFocus | `boolean` | Whether the element should receive focus on render. | `false` | | ||||||
| hourCycle | `12` \| `24` | Whether to display the time in 12 or 24 hour format. This is determined by the user's locale. | - | | ||||||
| granularity | `day` \| `hour` \| `minute` \| `second` | Determines the smallest unit that is displayed in the date picker. Typically "day" for dates. | - | | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve clarity in documentation.
The sentence can be improved for better clarity.
Committable suggestion