Skip to content

Commit c117119

Browse files
committed
Rename autoOpen to openOnMount. Keep props sorted alphabetically and update readme. #28
1 parent 2ad8adb commit c117119

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

Diff for: README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@ For detailed documentation, take a look into the [styleguide][]. The source code
3939
|---|---|---|---|
4040
|autoOk|`bool`|`false`|If true, automatically accept and close the picker on set minutes.|
4141
|cancelLabel|`string`|`'Cancel'`|Override the label of the cancel button.|
42-
|defaultValue|`Date`||The default value of the input and picker.|
43-
|initialTime|`Date`||The initial value of the time picker.|
42+
|ClockProps|`object`||Properties to pass down to the Clock component.|
43+
|defaultValue|`Date`||This default value overrides initialTime and placeholder.|
44+
|initialTime|`Date`||The default value for the time picker.|
4445
|inputComponent|`elementType`|`Input`|The component used for the input. Either a string to use a DOM element or a component.|
45-
|placeholder|`string`||The initial value of the actual input before a value is selected.|
46+
|placeholder|`string`||The placeholder value for the time picker before a time has been selected.|
4647
|mode|`enum: '12h' '24h'`|`'12h'`|Sets the clock mode, 12-hour or 24-hour clocks are supported.|
4748
|okLabel|`string`|`'Ok'`|Override the label of the ok button.|
4849
|onChange|`func`||Callback that is called with the new date (as Date instance) when the value is changed.|
50+
|openOnMount|`bool`||If true, automatically opens the dialog when the component is mounted.|
51+
|TimePickerProps|`object`||Properties to pass down to the TimePicker component.|
4952
|value|`Date`||The value of the time picker, for use in controlled mode.|
5053

5154
Note: `TimeInput` behaves like Material-UI's `Input` component and can be used inside `FormControl`s.

Diff for: src/TimeInput.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TimeInput extends React.Component {
2525
defaultValue.setSeconds(0)
2626
defaultValue.setMilliseconds(0)
2727

28-
const open = !!props.autoOpen
28+
const open = !!props.openOnMount
2929
const value = props.value || props.defaultValue || props.initialTime || defaultValue
3030

3131
this.state = {
@@ -84,9 +84,9 @@ class TimeInput extends React.Component {
8484
render () {
8585
const {
8686
autoOk,
87-
autoOpen, // eslint-disable-line
8887
cancelLabel,
8988
classes,
89+
ClockProps,
9090
defaultValue,
9191
disabled: disabledProp,
9292
initialTime,
@@ -95,9 +95,9 @@ class TimeInput extends React.Component {
9595
mode,
9696
okLabel,
9797
onChange,
98-
value: valueProp,
99-
ClockProps,
98+
openOnMount,
10099
TimePickerProps,
100+
value: valueProp,
101101
...other
102102
} = this.props
103103

@@ -142,10 +142,10 @@ class TimeInput extends React.Component {
142142
TimeInput.propTypes = {
143143
/** If true, automatically accept and close the picker on set minutes. */
144144
autoOk: PropTypes.bool,
145-
/** If true, automatically opens the dialog when the component is mounted */
146-
autoOpen: PropTypes.bool,
147145
/** Override the label of the cancel button. */
148146
cancelLabel: PropTypes.string,
147+
/** Properties to pass down to the Clock component. */
148+
ClockProps: PropTypes.object,
149149
/** This default value overrides initialTime and placeholder. */
150150
defaultValue: PropTypes.instanceOf(Date),
151151
/** The default value for the time picker. */
@@ -160,12 +160,12 @@ TimeInput.propTypes = {
160160
okLabel: PropTypes.string,
161161
/** Callback that is called with the new date (as Date instance) when the value is changed. */
162162
onChange: PropTypes.func,
163-
/** The value of the time picker, for use in controlled mode. */
164-
value: PropTypes.instanceOf(Date),
165-
/** Properties to pass down to the TimePicker component */
163+
/** If true, automatically opens the dialog when the component is mounted. */
164+
openOnMount: PropTypes.bool,
165+
/** Properties to pass down to the TimePicker component. */
166166
TimePickerProps: PropTypes.object,
167-
/** Properties to pass down to the Clock component */
168-
ClockProps: PropTypes.object
167+
/** The value of the time picker, for use in controlled mode. */
168+
value: PropTypes.instanceOf(Date)
169169
}
170170

171171
TimeInput.defaultProps = {

Diff for: src/TimeInput.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ describe('<TimeInput />', () => {
194194
expect(tree.find(CustomInput).length).toBe(1)
195195
})
196196

197-
it('automatically opens when the autoOpen prop is true', () => {
197+
it('automatically opens when the openOnMount prop is true', () => {
198198
const tree = mount(<TimeInput />)
199199
expect(tree.find(TimePicker).length).toBe(0)
200200

201-
const tree2 = mount(<TimeInput autoOpen />)
201+
const tree2 = mount(<TimeInput openOnMount />)
202202
expect(tree2.find(TimePicker).length).toBe(1)
203203
})
204204

@@ -207,7 +207,7 @@ describe('<TimeInput />', () => {
207207
some: 'timePickerProp'
208208
}
209209

210-
const tree = mount(<TimeInput TimePickerProps={TimePickerProps} autoOpen />)
210+
const tree = mount(<TimeInput TimePickerProps={TimePickerProps} openOnMount />)
211211
expect(tree.find(TimePicker).prop('some')).toEqual('timePickerProp')
212212
})
213213

@@ -216,7 +216,7 @@ describe('<TimeInput />', () => {
216216
some: 'clockProp'
217217
}
218218

219-
const tree = mount(<TimeInput ClockProps={ClockProps} autoOpen />)
219+
const tree = mount(<TimeInput ClockProps={ClockProps} openOnMount />)
220220
expect(tree.find(Clock).prop('some')).toEqual('clockProp')
221221
})
222222
})

0 commit comments

Comments
 (0)