From e6e50bbd87e5cec2b81d5a2832fefed778396ebc Mon Sep 17 00:00:00 2001 From: Brian Kuzma Date: Wed, 1 Nov 2017 16:47:38 -0400 Subject: [PATCH 1/2] add option to disable calendar popover, add test and update example --- example/app.jsx | 7 +++++++ src/index.jsx | 25 +++++++++++++++---------- test/core.test.jsx | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/example/app.jsx b/example/app.jsx index 4d2836c..d8e3639 100755 --- a/example/app.jsx +++ b/example/app.jsx @@ -129,6 +129,13 @@ const App = createReactClass({ Help + + + Calendar Disabled + + Help + + diff --git a/src/index.jsx b/src/index.jsx index 1ac50bf..db6c4f1 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -267,6 +267,7 @@ export default createReactClass({ onFocus: PropTypes.func, autoFocus: PropTypes.bool, disabled: PropTypes.bool, + calendarDisabled: PropTypes.bool, weekStartsOnMonday: (props, propName, componentName) => { if (props[propName]) { return new Error(`Prop '${propName}' supplied to '${componentName}' is obsolete. Use 'weekStartsOn' instead.`); @@ -328,6 +329,7 @@ export default createReactClass({ showClearButton: true, autoFocus: false, disabled: false, + calendarDisabled: false, showTodayButton: false, todayButtonLabel: 'Today', autoComplete: 'on', @@ -676,13 +678,8 @@ export default createReactClass({ noValidate={this.props.noValidate} />; - return - {control} - + /> - -
+ ; + + return + {control} + {overlay} + {!this.props.calendarDisabled &&
} {this.props.showClearButton && !this.props.customControl && + +
; + } + }); + yield new Promise(function(resolve, reject){ + ReactDOM.render(, container, resolve); + }); + const inputElement = document.querySelector("input.form-control"); + TestUtils.Simulate.focus(inputElement); + const popover = document.querySelector(".date-picker-popover"); + assert.equal(popover, null); + ReactDOM.unmountComponentAtNode(container); + })); it("should display the correct day of the week in the calendar.", co.wrap(function *(){ const id = UUID.v4(); let value = null; From e60b59fbe294bab71ad29c8172578cec67ae800b Mon Sep 17 00:00:00 2001 From: Brian Kuzma Date: Wed, 1 Nov 2017 17:24:26 -0400 Subject: [PATCH 2/2] update README with calendarDisabled prop --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 245643b..b5a122a 100755 --- a/README.md +++ b/README.md @@ -116,6 +116,10 @@ DatePicker component. Renders as a [React-Bootstrap InputGroup](https://react-bo * **Optional** * **Type:** `bool` * **Example:** `false` + * `calendarDisabled` - Whether or not the calendar popover will be disabled. + * **Optional** + * **Type:** `bool` + * **Example:** `false` * `onChange` - Focus callback function. * **Optional** * **Type:** `function`