Default Props Table
Prop | Type | Descriptions |
---|---|---|
position | String | current position of the plugin |
nodes | Object | to determine if there is another plugin around the current plugin |
Calendar | HTML Div Element | |
DatePicker | HTML Div Element | |
calendarProps | Object | |
datePickerProps | Object | |
state | Object | the state of the calendar |
setState | Function | |
registerListener | Function | |
handleChange | Function | if you want to trigger a change event |
handlePropsChange | Function | if you want to trigger a props change event |
handleFocusedDate | Function | if you want to trigger a focus change event |
Calendar & DatePicker
Contain the HTML elements of the calendar and date picker, each of them is stored separately in its own ref.
For example, because the closeCalendar function is in the DatePicker ref. it can be used to closing the calendar from your plugin.
Just note that if the user uses your plugin in the Calendar instead of DatePicker, the DatePicker and datePickerProps will be undefined.
import React from "react";
import DatePicker from "react-multi-date-picker";
function MyPlugin({ DatePicker }) {
return (
<div>
<button
style={{ margin: "5px" }}
disabled={!DatePicker}
onClick={() => DatePicker.closeCalendar()}
>
Close
</button>
</div>
);
}
export default function Example() {
return (
<DatePicker
plugins={[
<MyPlugin position="bottom" />
]}
/>
)
}
calendarProps & datePickerProps
The point about these two properties is that the value of datePickerProps always takes precedence over the value of calendarProps. Because DatePicker changes some props of Calendar.
To determine whether you should use calendarProps or datePickerProps, it is better to follow the example below:
function MyPlugin({ datePickerProps, calendarProps }) {
const props = datePickerProps || calendarProps
...
}
State Prop
An object that contains the data that is required by the calendar.
The properties of this object are written in the table below.
Note that the type of any of these properties should not be changed.
Property | Type | Descriptions |
---|---|---|
date | DateObject | The date displayed by the calendar |
selectedDate | DateObject or DateObject[] | user-selected date(s) |
multiple | Boolean | Specifies whether it is in multiple or range mode. If you want to change the value of any of these properties to true, you must change the value of the selectedDate from DateObject to DateObject[]. |
range | Boolean | |
onlyMonthPicker | Boolean | |
onlyYearPicker | Boolean | |
initialValue | - | |
value | - | |
focused | DateObject or undefined | the date that is focused by the user |
calendar | Object Calendar | |
locale | Object Locale | |
format | String | |
year | Number | |
today | DateObject | changing this value interferes with calendar performance |