Skip to content

Commit ae0b711

Browse files
committed
the great purge
1 parent 0e539cb commit ae0b711

35 files changed

Lines changed: 619 additions & 701 deletions

_test-bootstrap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
/* global it, expect */
33
'use strict';
44
var React = require('react');
5-
var _ = require('./src/util/_')
5+
var widgetHelpers = require('./src/util/widgetHelpers')
66

77
//disable this particular optimization
8-
sinon.stub(_, 'isFirstFocusedRender', ()=> true)
8+
sinon.stub(widgetHelpers, 'isFirstFocusedRender', ()=> true)
99

1010
var testsContext = require.context("./test", true, /\.browser\.(js$|jsx$)/);
1111

src/Calendar.jsx

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import SlideTransition from './SlideTransition';
1414
import dates from './util/dates';
1515
import constants from './util/constants';
1616
import _ from './util/_'; //values, omit
17-
import ifNotDisabled from './util/ifNotDisabled';
17+
import { instanceId, notify } from './util/widgetHelpers';
18+
import { widgetEditable, widgetEnabled } from './util/interaction';
1819

1920
let dir = constants.directions
2021
, values = obj => Object.keys(obj).map( k => obj[k] )
@@ -56,6 +57,9 @@ let format = (props, f) => props[f + 'Format'] || localizers.date.formats[f]
5657

5758
let propTypes = {
5859

60+
disabled: CustomPropTypes.disabled,
61+
readOnly: CustomPropTypes.readOnly,
62+
5963
onChange: React.PropTypes.func,
6064
value: React.PropTypes.instanceOf(Date),
6165

@@ -73,16 +77,6 @@ let propTypes = {
7377
prop. This creates a range that cannot be rendered.`.replace(/\n\t/g, ''))
7478
},
7579

76-
disabled: React.PropTypes.oneOfType([
77-
React.PropTypes.bool,
78-
React.PropTypes.oneOf(['disabled'])
79-
]),
80-
81-
readOnly: React.PropTypes.oneOfType([
82-
React.PropTypes.bool,
83-
React.PropTypes.oneOf(['readOnly'])
84-
]),
85-
8680
culture: React.PropTypes.string,
8781

8882
footer: React.PropTypes.bool,
@@ -109,7 +103,6 @@ var Calendar = React.createClass({
109103
displayName: 'Calendar',
110104

111105
mixins: [
112-
require('./mixins/WidgetMixin'),
113106
require('./mixins/TimeoutMixin'),
114107
require('./mixins/PureRenderMixin'),
115108
require('./mixins/RtlParentContextMixin'),
@@ -181,8 +174,8 @@ var Calendar = React.createClass({
181174

182175
unit = unit === 'day' ? 'date' : unit
183176

184-
let viewID = this._id('_calendar')
185-
, labelID = this._id('_calendar_label')
177+
let viewID = instanceId(this, '_calendar')
178+
, labelID = instanceId(this, '_calendar_label')
186179
, key = view + '_' + dates[view](currentDate);
187180

188181
let elementProps = _.omit(this.props, Object.keys(propTypes))
@@ -250,7 +243,7 @@ var Calendar = React.createClass({
250243
)
251244
},
252245

253-
@ifNotDisabled
246+
@widgetEditable
254247
navigate(direction, date){
255248
var view = this.state.view
256249
, slideDir = (direction === dir.LEFT || direction === dir.UP)
@@ -269,7 +262,7 @@ var Calendar = React.createClass({
269262
view = NEXT_VIEW[view] || view
270263

271264
if ( this.isValidView(view) && dates.inRange(date, this.props.min, this.props.max, view)) {
272-
this.notify('onNavigate', [date, slideDir, view])
265+
notify(this.props.onNavigate, [date, slideDir, view])
273266
this.focus(true);
274267

275268
this.setState({
@@ -287,38 +280,38 @@ var Calendar = React.createClass({
287280
//console.log(document.activeElement)
288281
},
289282

290-
@ifNotDisabled(true)
283+
@widgetEnabled
291284
_focus(focused, e){
292285
if ( +this.props.tabIndex === -1)
293286
return
294287

295288
this.setTimeout('focus', () => {
296289
if( focused !== this.state.focused){
297-
this.notify(focused ? 'onFocus' : 'onBlur', e)
290+
notify(this.props[focused ? 'onFocus' : 'onBlur'], e)
298291
this.setState({ focused })
299292
}
300293
})
301294
},
302295

303-
@ifNotDisabled
296+
@widgetEditable
304297
change(date){
305298
if (this.state.view === this.props.initialView){
306-
this.notify('onChange', date)
299+
notify(this.props.onChange, date)
307300
this.focus();
308301
return;
309302
}
310303

311304
this.navigate(dir.DOWN, date)
312305
},
313306

314-
@ifNotDisabled
307+
@widgetEditable
315308
select(date){
316309
var view = this.props.initialView
317310
, slideDir = view !== this.state.view || dates.gt(date, this.state.currentDate)
318311
? 'left' // move down to a the view
319312
: 'right';
320313

321-
this.notify('onChange', date)
314+
notify(this.props.onChange, date)
322315

323316
if ( this.isValidView(view) && dates.inRange(date, this.props.min, this.props.max, view)) {
324317
this.focus();
@@ -329,7 +322,6 @@ var Calendar = React.createClass({
329322
view: view
330323
})
331324
}
332-
333325
},
334326

335327
nextDate(direction){
@@ -341,7 +333,7 @@ var Calendar = React.createClass({
341333
return dates[method](this.state.currentDate, 1 * multi, unit)
342334
},
343335

344-
@ifNotDisabled
336+
@widgetEditable
345337
_keyDown(e){
346338
var ctrl = e.ctrlKey
347339
, key = e.key
@@ -382,7 +374,7 @@ var Calendar = React.createClass({
382374
}
383375
}
384376

385-
this.notify('onKeyDown', [e])
377+
notify(this.props.onKeyDown, [e])
386378
},
387379

388380
_label() {

src/Century.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import cn from 'classnames';
33
import dates from './util/dates';
44
import config from './util/configuration';import _ from './util/_';
55
import CustomPropTypes from './util/propTypes';
6+
import { instanceId } from './util/widgetHelpers';
67

78
let localizers = config.locale;
89
let format = props => props.decadeFormat || localizers.date.formats.decade
@@ -26,7 +27,6 @@ export default React.createClass({
2627
displayName: 'CenturyView',
2728

2829
mixins: [
29-
require('./mixins/WidgetMixin'),
3030
require('./mixins/PureRenderMixin'),
3131
require('./mixins/RtlChildContextMixin'),
3232
require('./mixins/AriaDescendantMixin')()
@@ -35,7 +35,7 @@ export default React.createClass({
3535
propTypes,
3636

3737
componentDidUpdate() {
38-
let activeId = optionId(this._id(), this.props.focused);
38+
let activeId = optionId(instanceId(this), this.props.focused);
3939
this.ariaActiveDescendant(activeId)
4040
},
4141

@@ -60,9 +60,9 @@ export default React.createClass({
6060

6161
_row(row, rowIdx) {
6262
let {
63-
focused, selected, disabled, onChange
63+
focused, disabled, onChange
6464
, value, today, culture, min, max } = this.props
65-
, id = this._id('_century');
65+
, id = instanceId(this, '_century');
6666

6767
return (
6868
<tr key={'row_' + rowIdx} role='row'>

0 commit comments

Comments
 (0)