-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
138 lines (115 loc) · 3.59 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import React, {Component} from 'react'
import {
DateRangePicker,
} from 'react-dates'
import {
START_DATE,
END_DATE,
HORIZONTAL_ORIENTATION,
VERTICAL_ORIENTATION,
VERTICAL_SCROLLABLE,
ICON_BEFORE_POSITION,
ICON_AFTER_POSITION,
INFO_POSITION_TOP,
INFO_POSITION_BOTTOM,
INFO_POSITION_BEFORE,
INFO_POSITION_AFTER,
ANCHOR_LEFT,
ANCHOR_RIGHT,
OPEN_DOWN,
OPEN_UP,
WEEKDAYS,
} from 'react-dates/lib/constants'
import 'react-dates/initialize'
import 'react-dates/lib/css/_datepicker.css'
const Enum = (options) => ({__ty: 'Enum', options})
const FocusedInputShape = Enum([START_DATE, END_DATE])
const IconPositionShape = Enum([ICON_AFTER_POSITION, ICON_BEFORE_POSITION])
class DateRangeWrapper extends Component {
render() {
return React.createElement(DateRangePicker, Object.assign({}, this.props, {
firstDayOfWeek: Number(this.props.firstDayOfWeek),
focusedInput: this.props.isOpen ? this.props.focusedInput : undefined,
block: true,
}))
}
}
DateRangeWrapper.pdPropControls = {
// required props for a functional interactive DateRangePicker
startDate: 'Number',
endDate: 'Number',
onDatesChange: 'Function',
isOpen: 'Boolean',
focusedInput: FocusedInputShape,
onFocusChange: 'Function',
onClose: 'Function',
// input related props
startDateId: 'Text',
startDatePlaceholderText: 'Text',
endDateId: 'Text',
endDatePlaceholderText: 'Text',
disabled: 'Boolean',
required: 'Boolean',
readOnly: 'Boolean',
screenReaderInputMessage: 'Text',
showClearDates: 'Boolean',
showDefaultInputIcon: 'Boolean',
inputIconPosition: IconPositionShape,
customInputIcon: 'Function',
customArrowIcon: 'Function',
customCloseIcon: 'Function',
noBorder: 'Boolean',
small: 'Boolean',
regular: 'Boolean',
keepFocusOnInput: 'Boolean',
// calendar presentation and interaction related props
// renderMonthText: mutuallyExclusiveProps('Function', 'renderMonthText', 'renderMonthElement'),
// renderMonthElement: mutuallyExclusiveProps('Function', 'renderMonthText', 'renderMonthElement'),
orientation: Enum([HORIZONTAL_ORIENTATION, VERTICAL_ORIENTATION, VERTICAL_SCROLLABLE]),
anchorDirection: Enum([ANCHOR_LEFT, ANCHOR_RIGHT]),
openDirection: Enum([OPEN_UP, OPEN_DOWN]),
horizontalMargin: 'Number',
withPortal: 'Boolean',
withFullScreenPortal: 'Boolean',
appendToBody: 'Boolean',
disableScroll: 'Boolean',
daySize: 'Number',
isRTL: 'Boolean',
firstDayOfWeek: Enum(WEEKDAYS.map(String)),
initialVisibleMonth: 'Function',
numberOfMonths: 'Number',
keepOpenOnDateSelect: 'Boolean',
reopenPickerOnClearDates: 'Boolean',
renderCalendarInfo: 'Function',
calendarInfoPosition: Enum([
INFO_POSITION_TOP,
INFO_POSITION_BOTTOM,
INFO_POSITION_BEFORE,
INFO_POSITION_AFTER,
]),
hideKeyboardShortcutsPanel: 'Boolean',
verticalHeight: 'Number',
transitionDuration: 'Number',
verticalSpacing: 'Number',
// navigation related props
navPrev: 'Function',
navNext: 'Function',
onPrevMonthClick: 'Function',
onNextMonthClick: 'Function',
// day presentation and interaction related props
renderCalendarDay: 'Function',
renderDayContents: 'Function',
minimumNights: 'Number',
enableOutsideDays: 'Boolean',
isDayBlocked: 'Function',
isOutsideRange: 'Function',
isDayHighlighted: 'Function',
// internationalization props
displayFormat: 'Text',
monthFormat: 'Text',
weekDayFormat: 'Text',
// phrases: PropTypes.shape(getPhrasePropTypes(DateRangePickerPhrases)),
dayAriaLabelFormat: 'Text',
}
DateRangeWrapper.pdResizable = ['width']
export default { DateRangePicker: DateRangeWrapper }