Skip to content

Commit 0484e2b

Browse files
committed
Pass function to close calendar to renderInput prop
Referencing arqex#477.
1 parent 16215b4 commit 0484e2b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

DateTime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ var Datetime = createClass({
428428
value: this.state.inputValue,
429429
}, this.props.inputProps);
430430
if ( this.props.renderInput ) {
431-
children = [ React.createElement('div', { key: 'i' }, this.props.renderInput( finalInputProps, this.openCalendar )) ];
431+
children = [ React.createElement('div', { key: 'i' }, this.props.renderInput( finalInputProps, this.openCalendar, this.closeCalendar )) ];
432432
} else {
433433
children = [ React.createElement('input', assign({ key: 'i' }, finalInputProps ))];
434434
}

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ render: function() {
5757
| **className** | `string` or `string array` | `''` | Extra class name for the outermost markup element. |
5858
| **inputProps** | `object` | `undefined` | Defines additional attributes for the input element of the component. For example: `onClick`, `placeholder`, `disabled`, `required`, `name` and `className` (`className` *sets* the class attribute for the input element). See [Customize the Input Appearance](#customize-the-input-appearance). |
5959
| **isValidDate** | `function` | `() => true` | Define the dates that can be selected. The function receives `(currentDate, selectedDate)` and shall return a `true` or `false` whether the `currentDate` is valid or not. See [selectable dates](#selectable-dates).|
60-
| **renderInput** | `function` | `undefined` | Replace the rendering of the input element. The accepted function has `openCalendar` (a function which opens the calendar) and the default calculated `props` for the input. Must return a React component or `null`. See [Customize the Input Appearance](#customize-the-input-appearance). |
60+
| **renderInput** | `function` | `undefined` | Replace the rendering of the input element. The function has the following arguments: the default calculated `props` for the input, `openCalendar` (a function which opens the calendar) and `closeCalendar` (a function which closes the calendar). Must return a React component or `null`. See [Customize the Input Appearance](#customize-the-input-appearance). |
6161
| **renderDay** | `function` | `DOM.td(day)` | Customize the way that the days are shown in the daypicker. The accepted function has the `selectedDate`, the current date and the default calculated `props` for the cell, and must return a React component. See [Customize the Datepicker Appearance](#customize-the-datepicker-appearance). |
6262
| **renderMonth** | `function` | `DOM.td(month)` | Customize the way that the months are shown in the monthpicker. The accepted function has the `selectedDate`, the current date and the default calculated `props` for the cell, the `month` and the `year` to be shown, and must return a React component. See [Customize the Datepicker Appearance](#customize-the-datepicker-appearance). |
6363
| **renderYear** | `function` | `DOM.td(year)` | Customize the way that the years are shown in the year picker. The accepted function has the `selectedDate`, the current date and the default calculated `props` for the cell, the `year` to be shown, and must return a React component. See [Customize the Datepicker Appearance](#customize-the-datepicker-appearance). |
@@ -97,14 +97,15 @@ var MyDTPicker = React.createClass({
9797
render: function(){
9898
return <Datetime renderInput={ this.renderInput } />;
9999
},
100-
renderInput: function( props, openCalendar ){
100+
renderInput: function( props, openCalendar, closeCalendar ){
101101
function clear(){
102102
props.onChange({target: {value: ''}});
103103
}
104104
return (
105105
<div>
106106
<input {...props} />
107107
<button onClick={openCalendar}>open calendar</button>
108+
<button onClick={closeCalendar}>close calendar</button>
108109
<button onClick={clear}>clear</button>
109110
</div>
110111
);
@@ -144,7 +145,7 @@ var MyDTPicker = React.createClass({
144145

145146
## Specify Available Units
146147
You can filter out what you want the user to be able to pick by using `dateFormat` and `timeFormat`, e.g. to create a timepicker, yearpicker etc.
147-
148+
148149
In this example the component is being used as a *timepicker* and can *only be used for selecting a time*.
149150
```js
150151
<Datetime dateFormat={false} />

0 commit comments

Comments
 (0)