Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

rc-calendar

react-component536.7k9.15.11TypeScript support: included

React Calendar

react, react-calendar, react-component, calendar, ui component, ui, component

readme

rc-calendar


React Calendar

NPM version build status Test coverage gemnasium deps npm download Code Quality: Javascript Total alerts

Screenshots

Feature

  • support ie9,ie9+,chrome,firefox,safari
  • support date, month, year, decade select panel
  • support week number
  • support en_US and zh_CN locale(UI), use moment.utcOffset to set timezone
  • support aria and keyboard accessibility

Keyboard

  • Previous month (PageUp)
  • Next month (PageDown)
  • tab into hour input: Last hour(Up), Next hour(Down)
  • tab into hour input: Last minute(Up), Next minute(Down)
  • tab into hour input: Last second(Up), Next second(Down)
  • Last year (Control + left)
  • Next year (Control + right)

install

rc-calendar

Usage

import Calendar from 'rc-calendar';
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(<Calendar />, container);

Development

npm install
npm start

Example

http://localhost:8002/examples/

online example:

http://react-component.github.io/calendar/examples/index.html

API

rc-calendar props

name type default description
prefixCls String prefixCls of this component
className String additional css class of root dom node
style Object additional style of root dom node
dateRender (current, value) => React.Node date cell
renderSidebar () => React.Node side bar
renderFooter (mode) => React.Node extra footer
value moment current value like input's value
defaultValue moment defaultValue like input's defaultValue
locale Object import from 'rc-calendar/lib/locale/en_US' calendar locale
format String | String[] depends on whether you set timePicker and your locale use to format/parse date(without time) value to/from input. When an array is provided, all values are used for parsing and first value for display.
disabledDate Function(current:moment):Boolean whether to disable select of current date
disabledTime Function(current:moment):Object a function which return a object with member of disabledHours/disabledMinutes/disabledSeconds according to rc-time-picker
showDateInput Boolean true whether to show input on top of calendar panel
showWeekNumber Boolean false whether to show week number of year
showToday Boolean true whether to show today button
showOk Boolean auto whether has ok button in footer
timePicker React Element rc-timer-picker/lib/module/panel element
onSelect Function(date: moment) called when a date is selected from calendar
onClear Function() called when a date is cleared from calendar
onChange Function(date: moment) called when a date is changed inside calendar (next year/next month/keyboard)
onOk Function(date: moment) called when ok button is pressed, only if it's visible
dateInputPlaceholder String date input's placeholder
mode enum('time', 'date', 'month', 'year', 'decade') 'date' control which kind of panel should be shown
onPanelChange Function(date: moment, mode) called when panel changed
clearIcon ReactNode specific the clear icon.
inputMode string text Change the keyboard in mobile device

rc-calendar/lib/RangeCalendar props

name type default description
prefixCls String prefixCls of this component
className String additional css class of root dom node
style Object additional style of root dom node
renderSidebar () => React.Node side bar
renderFooter () => React.Node extra footer
selectedValue moment[] current selected value range. with two elements.
defaultSelectedValue moment[] default selected value range
locale Object import from 'rc-calendar/lib/locale/en_US' calendar locale
format String depends on whether you set timePicker and your locale use to format/parse date(without time) value to/from input
disabledDate Function(current:moment):Boolean whether to disable select of current date
showWeekNumber Boolean false whether to show week number of year
showToday Boolean true whether to show today button
showOk Boolean auto whether has ok button in footer
showClear Boolean false whether has clear button in header
timePicker React Element rc-timer-picker/lib/module/panel element
onSelect Function(date: moment[]) called when a date range is selected from calendar
onInputSelect Function(date: moment[]) called when a valid date entered in input
onClear Function() called when a date range is cleared from calendar
onChange Function(date: moment[]) called when a date range is changed inside calendar (next year/next month/keyboard)
onOk Function(date: moment) called when ok button is pressed, only if it's visible
dateInputPlaceholder String[] range date input's placeholders
disabledTime Function(current: moment[], type:'start'|'end'):Object a function which return a object with member of disabledHours/disabledMinutes/disabledSeconds according to rc-time-picker
showDateInput Boolean true whether to show date inputs on top of calendar panels
type enum('both','start', 'end') both whether fix start or end selected value. check start-end-range example
mode enum('date', 'month', 'year', 'decade')[] ['date', 'date'] control which kind of panels should be shown
onPanelChange Function(date: moment[], mode) called when panels changed
hoverValue moment[] control hover value
onHoverChange Function(hoverValue: moment[]) called when hover value change
clearIcon ReactNode specific the clear icon.

rc-calendar/lib/MonthCalendar props

name type default description
prefixCls String prefixCls of this component
className String additional css class of root dom node
style Object additional style of root dom node
value moment current value like input's value
defaultValue moment defaultValue like input's defaultValue
locale Object import from 'rc-calendar/lib/locale/en_US' calendar locale
disabledDate Function(current:moment):Boolean whether to disable select of current month
onSelect Function(date: moment) called when a date is selected from calendar
monthCellRender function Custom month cell render method
monthCellContentRender function Custom month cell content render method,the content will be appended to the cell.
onChange Function(date: moment) called when a date is changed inside calendar (next year/next month/keyboard)
renderFooter () => React.Node extra footer

rc-calendar/lib/Picker props

name type default description
prefixCls String prefixCls of this component
calendar Calendar React Element
disabled Boolean whether picker is disabled
placement String|Object one of ['left','right','top','bottom', 'topLeft', 'topRight', 'bottomLeft', 'bottomRight']
align Object: alignConfig of [dom-align](https://github.com/yiminghe/dom-align) value will be merged into placement's align config.
animation String index.css support 'slide-up'
transitionName String css class for animation
value moment|moment[] current value like input's value
defaultValue moment|moment[] defaultValue like input's defaultValue
onChange Function called when select a different value
onOpenChange (open:boolean) => void called when open/close picker
open Boolean current open state of picker. controlled prop
getCalendarContainer () => HTMLElement () => {return document.body;} dom node where calendar to be rendered into
dropdownClassName string additional className applied to dropdown

rc-calendar/lib/FullCalendar props

name type default description
prefixCls String prefixCls of this component
Select React Component Class rc-select Component Class
value moment current value like input's value
defaultValue moment defaultValue like input's defaultValue
defaultType string date default panel type: date/month
type string panel type: date/month
onTypeChange function(type) called when panel type change
fullscreen bool false
monthCellRender function Custom month cell render method
dateCellRender function Custom date cell render method
monthCellContentRender function Custom month cell content render method,the content will be appended to the cell.
dateCellContentRender function Custom date cell content render method,the content will be appended to the cell.
onSelect Function(date: moment) called when a date is selected from calendar

Test Case

npm test

Coverage

npm run coverage

open coverage/ dir

License

rc-calendar is released under the MIT license.

changelog

History


9.15.0 / 2019-05-26

  • Support Malay locales

9.15.0 / 2019-06-06

  • Add numeric keyboard support

9.14.0 / 2019-05-24

  • Support Latvian locales

9.13.0 / 2019-04-02

  • Support close onBlur

9.12.0 / 2019-03-16

  • RangerPicker support null as start or end

9.11.0 / 2019-03-14

  • RangerPicker can select same month

9.10.0 / 2019-01-02

  • add focusablePanel prop.

9.9.0 / 2018-12-23

  • renderFooter(mode) support all modes.

9.8.0 / 2018-11-30

  • DateInput support multiple date format

9.7.0 / 2018-08-07

  • Add clearIcon.

9.6.0 / 2018-02-08

  • Add Picker[dropdownClassName]

9.5.0 / 2017-12-26

  • Add Kurdish

9.4.0 / 2017-12-26

  • Add Uyghur

9.2.0 / 2017-11-06

  • React 16 support

9.1.0 / 2017-07-27

  • Support control panel #284

9.0.0 / 2017-07-27

  • Replace react string refs with function way #282

8.4.0 / 2017-05-31

  • Supporting Bulgarian.
  • UX: can select end date first, and then start date.

8.3.0 / 2017-05-18

  • expose hoverValue as controlled property and onHoverChange

8.2.0 / 2017-05-16

  • Time of Calendar[timePicker] & RangeCalendar[timePicker] could be set now
  • Fix that two panels of RangeCalendar should not be the same month

8.1.0 / 2017-04-10

  • Add locale fi_FI

8.0.0 / 2017-04-07

  • Improve UX of RangeCalendar
  • A breaking change for hidden API

7.8.0 / 2017-04-01

  • zh-TW locale
  • tr-TR locale

7.6.0 / 2017-01-11

  • remove arrow inside year and century panel

7.5.0 / 2016-11-16

  • add showToday for RangeCalendar

7.4.0 / 2016-11-01

  • add monthCellContentRender/cellContentRender for MonthCalendar

7.3.0 / 2016-10-18

  • disabledTime support type param for range-calendar

7.2.0 / 2016-09-23

  • add week calendar example
  • support renderSidebar, renderFooter prop
  • add type prop to support start-end-range example
  • picker remove onClose, change onOpen to onOpenChange

7.1.0 / 2016-09-10

7.0.0 / 2016-08-06

  • goodbye gregorian-calendar, hello moment

6.0.0 / 2016-07-13

  • use rc-time-picker/lib/module/panel as timepicker element
  • merge date input and time input. formatter can control time part.

5.6.0 / 2016-06-20

  • optimize keyboard, add onKeyDown for Picker children

5.5.0 / 2016-03-22

  • support monthCellContentRender/dateCellContentRender

5.3.0 / 2016-01-18

  • support clear for RangeCalendar

5.1.0 / 2015-12-25

  • support dateInputPlaceholder for RangeCalendar

5.0.0 / 2015-12-21

  • use rc-time-picker, add timePicker, disabledTime props
  • remove showTime props
  • remove bootstrap style

4.0.0 / 2015-11-18

  • refactor!
  • support input inside rc-calendar
  • change MonthCalendar to require('rc-calendar/lib/MonthCalendar')
  • change Picker to require('rc-calendar/lib/Picker')
  • change Picker's orient to placement and align as rc-trigger
  • add RangeCalendar: require('rc-calendar/lib/RangeCalendar')
  • add FullCalendar: require('rc-calendar/lib/FullCalendar')

3.16.0 / 2015-08-25

-- add Calendar.MonthCalendar component

3.15.0 / 2015-08-24

-- add onChange prop

3.14.0 / 2015-08-21

-- remove renderCalendarToBody. defaults to true

3.13.0 / 2015-08-15

  • support controlled open prop for Picker
  • add onOpen/onClose callback for Picker

3.12.0 / 2015-07-30

use rc-animate & rc-align (css change)

3.11.0 / 2015-07-20

support disabled prop for picker

3.10.1 / 2015-07-02

add adjustOrientOnCalendarOverflow prop for picker

3.10.0 / 2015-07-01

new support picker animation #39

3.9.0 / 2015-06-11

improved fix by #33 #34 #35

3.8.0 / 2015-06-03

improved refactor by split components

3.7.0 / 2015-06-01

improved move nextDecade and prevDecade button to YearPanel body, optimize disable style for ant-design

3.5.0 / 2015-05-26

new publish transformed es5 code to npm

3.4.0 / 2015-05-19

new #21 add trigger prop for DatePicker

3.3.0 / 2015-05-13

use jsx as extension name

3.2.0 / 2015-05-11

add ant-design theme(index.css).

3.1.1 / 2015-04-21

fix ie broken focus

3.1.0 / 2015-03-23

improved #17 support today button to select

3.0.0 / 2015-03-13

upgrade to react 0.13 and es6

2.1.0 / 2015-03-10

new #16 support clear button

2.0.0 / 2015-03-04

new #15 support defaultValue improved upgrade gregorian-calendar and gregorian-calendar-format to 3.x

1.5.0 / 2015-01-22

new #13 support DatePicker

1.4.0 / 2015-01-05

new #12 support time select (@yiminghe)

new #11 support prefixCls (@yiminghe)

new #10 support nextMonth previousMonth in calendar panel (@yiminghe)

1.3.0 / 2014-12-30

new #9 support className prop (@yiminghe)

new #8 support orient prop (@yiminghe)

1.2.4 / 2014-12-26

new #7 release 1.2.4 (@yiminghe)