material-ui 0.7.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +31 -0
- data/Rakefile +20 -0
- data/lib/material-ui.rb +4 -0
- data/material-ui-gem.gemspec +33 -0
- data/vendor/assets/javascripts/material-ui.js +1 -0
- data/vendor/assets/javascripts/material-ui/components/app-bar.jsx +93 -0
- data/vendor/assets/javascripts/material-ui/components/app-canvas.jsx +27 -0
- data/vendor/assets/javascripts/material-ui/components/checkbox.jsx +60 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/calendar-month.jsx +59 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/calendar-toolbar.jsx +64 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/calendar.jsx +194 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/date-display.jsx +79 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/date-picker-dialog.jsx +118 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/date-picker.jsx +116 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/day-button.jsx +49 -0
- data/vendor/assets/javascripts/material-ui/components/dialog-window.jsx +183 -0
- data/vendor/assets/javascripts/material-ui/components/dialog.jsx +54 -0
- data/vendor/assets/javascripts/material-ui/components/drop-down-icon.jsx +68 -0
- data/vendor/assets/javascripts/material-ui/components/drop-down-menu.jsx +94 -0
- data/vendor/assets/javascripts/material-ui/components/enhanced-button.jsx +147 -0
- data/vendor/assets/javascripts/material-ui/components/enhanced-switch.jsx +296 -0
- data/vendor/assets/javascripts/material-ui/components/enhanced-textarea.jsx +113 -0
- data/vendor/assets/javascripts/material-ui/components/flat-button.jsx +46 -0
- data/vendor/assets/javascripts/material-ui/components/floating-action-button.jsx +123 -0
- data/vendor/assets/javascripts/material-ui/components/font-icon.jsx +23 -0
- data/vendor/assets/javascripts/material-ui/components/icon-button.jsx +123 -0
- data/vendor/assets/javascripts/material-ui/components/ink-bar.jsx +25 -0
- data/vendor/assets/javascripts/material-ui/components/input.jsx +143 -0
- data/vendor/assets/javascripts/material-ui/components/left-nav.jsx +105 -0
- data/vendor/assets/javascripts/material-ui/components/menu/link-menu-item.jsx +42 -0
- data/vendor/assets/javascripts/material-ui/components/menu/menu-item.jsx +105 -0
- data/vendor/assets/javascripts/material-ui/components/menu/menu.jsx +325 -0
- data/vendor/assets/javascripts/material-ui/components/menu/subheader-menu-item.jsx +18 -0
- data/vendor/assets/javascripts/material-ui/components/mixins/classable.js +42 -0
- data/vendor/assets/javascripts/material-ui/components/mixins/click-awayable.js +35 -0
- data/vendor/assets/javascripts/material-ui/components/mixins/window-listenable.js +23 -0
- data/vendor/assets/javascripts/material-ui/components/overlay.jsx +58 -0
- data/vendor/assets/javascripts/material-ui/components/paper.jsx +58 -0
- data/vendor/assets/javascripts/material-ui/components/radio-button-group.jsx +112 -0
- data/vendor/assets/javascripts/material-ui/components/radio-button.jsx +65 -0
- data/vendor/assets/javascripts/material-ui/components/raised-button.jsx +102 -0
- data/vendor/assets/javascripts/material-ui/components/ripples/circle.jsx +35 -0
- data/vendor/assets/javascripts/material-ui/components/ripples/focus-ripple.jsx +40 -0
- data/vendor/assets/javascripts/material-ui/components/ripples/touch-ripple.jsx +174 -0
- data/vendor/assets/javascripts/material-ui/components/slider.jsx +178 -0
- data/vendor/assets/javascripts/material-ui/components/snackbar.jsx +76 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/drop-down-arrow.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-chevron-left.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-chevron-right.jsx +17 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-menu.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/svg-icon.jsx +23 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-check-box-checked.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-check-box-outline-blank.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-radio-button-off.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-radio-button-on.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/table-header.jsx +50 -0
- data/vendor/assets/javascripts/material-ui/components/table-rows-item.jsx +31 -0
- data/vendor/assets/javascripts/material-ui/components/table-rows.jsx +57 -0
- data/vendor/assets/javascripts/material-ui/components/tabs/tab.jsx +38 -0
- data/vendor/assets/javascripts/material-ui/components/tabs/tabTemplate.jsx +15 -0
- data/vendor/assets/javascripts/material-ui/components/tabs/tabs.jsx +96 -0
- data/vendor/assets/javascripts/material-ui/components/text-field.jsx +215 -0
- data/vendor/assets/javascripts/material-ui/components/toggle.jsx +62 -0
- data/vendor/assets/javascripts/material-ui/components/toolbar-group.jsx +28 -0
- data/vendor/assets/javascripts/material-ui/components/toolbar.jsx +21 -0
- data/vendor/assets/javascripts/material-ui/components/tooltip.jsx +58 -0
- data/vendor/assets/javascripts/material-ui/components/transition-groups/slide-in.jsx +48 -0
- data/vendor/assets/javascripts/material-ui/components/utils/css-event.js +52 -0
- data/vendor/assets/javascripts/material-ui/components/utils/date-time.js +132 -0
- data/vendor/assets/javascripts/material-ui/components/utils/dom.js +71 -0
- data/vendor/assets/javascripts/material-ui/components/utils/events.js +34 -0
- data/vendor/assets/javascripts/material-ui/components/utils/key-code.js +10 -0
- data/vendor/assets/javascripts/material-ui/components/utils/key-line.js +13 -0
- data/vendor/assets/javascripts/material-ui/components/utils/unique-id.js +7 -0
- data/vendor/assets/stylesheets/material-ui.less +2 -0
- data/vendor/assets/stylesheets/material-ui/components.less +5 -0
- data/vendor/assets/stylesheets/material-ui/components/app-bar.less +37 -0
- data/vendor/assets/stylesheets/material-ui/components/card.less +20 -0
- data/vendor/assets/stylesheets/material-ui/components/checkbox.less +66 -0
- data/vendor/assets/stylesheets/material-ui/components/components.less +37 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar-month.less +11 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar-toolbar.less +23 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar.less +59 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/date-display.less +84 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/date-picker-dialog.less +18 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/date-picker.less +9 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/day-button.less +35 -0
- data/vendor/assets/stylesheets/material-ui/components/dialog-window.less +42 -0
- data/vendor/assets/stylesheets/material-ui/components/dialog.less +10 -0
- data/vendor/assets/stylesheets/material-ui/components/drop-down-icon.less +43 -0
- data/vendor/assets/stylesheets/material-ui/components/drop-down-menu.less +77 -0
- data/vendor/assets/stylesheets/material-ui/components/enhanced-button.less +24 -0
- data/vendor/assets/stylesheets/material-ui/components/enhanced-switch.less +52 -0
- data/vendor/assets/stylesheets/material-ui/components/enhanced-textarea.less +16 -0
- data/vendor/assets/stylesheets/material-ui/components/flat-button.less +93 -0
- data/vendor/assets/stylesheets/material-ui/components/floating-action-button.less +95 -0
- data/vendor/assets/stylesheets/material-ui/components/font-icon.less +6 -0
- data/vendor/assets/stylesheets/material-ui/components/icon-button.less +46 -0
- data/vendor/assets/stylesheets/material-ui/components/ink-bar.less +9 -0
- data/vendor/assets/stylesheets/material-ui/components/input.less +186 -0
- data/vendor/assets/stylesheets/material-ui/components/left-nav.less +31 -0
- data/vendor/assets/stylesheets/material-ui/components/menu-item.less +69 -0
- data/vendor/assets/stylesheets/material-ui/components/menu.less +50 -0
- data/vendor/assets/stylesheets/material-ui/components/overlay.less +21 -0
- data/vendor/assets/stylesheets/material-ui/components/paper.less +59 -0
- data/vendor/assets/stylesheets/material-ui/components/radio-button.less +67 -0
- data/vendor/assets/stylesheets/material-ui/components/raised-button.less +132 -0
- data/vendor/assets/stylesheets/material-ui/components/ripples/circle.less +31 -0
- data/vendor/assets/stylesheets/material-ui/components/ripples/focus-ripple.less +30 -0
- data/vendor/assets/stylesheets/material-ui/components/ripples/touch-ripple.less +9 -0
- data/vendor/assets/stylesheets/material-ui/components/slider.less +163 -0
- data/vendor/assets/stylesheets/material-ui/components/snackbar.less +44 -0
- data/vendor/assets/stylesheets/material-ui/components/subheader.less +17 -0
- data/vendor/assets/stylesheets/material-ui/components/svg-icon.less +11 -0
- data/vendor/assets/stylesheets/material-ui/components/table.less +46 -0
- data/vendor/assets/stylesheets/material-ui/components/tabs.less +41 -0
- data/vendor/assets/stylesheets/material-ui/components/text-field.less +168 -0
- data/vendor/assets/stylesheets/material-ui/components/toggle.less +83 -0
- data/vendor/assets/stylesheets/material-ui/components/toolbar.less +95 -0
- data/vendor/assets/stylesheets/material-ui/components/tooltip.less +73 -0
- data/vendor/assets/stylesheets/material-ui/components/transition-groups/slide-in.less +92 -0
- data/vendor/assets/stylesheets/material-ui/core/base.less +31 -0
- data/vendor/assets/stylesheets/material-ui/core/core.less +4 -0
- data/vendor/assets/stylesheets/material-ui/core/keylines.less +29 -0
- data/vendor/assets/stylesheets/material-ui/core/layouts.less +12 -0
- data/vendor/assets/stylesheets/material-ui/core/typography.less +158 -0
- data/vendor/assets/stylesheets/material-ui/mixins/clearfix.less +22 -0
- data/vendor/assets/stylesheets/material-ui/mixins/mixins.less +3 -0
- data/vendor/assets/stylesheets/material-ui/mixins/no-wrap.less +3 -0
- data/vendor/assets/stylesheets/material-ui/mixins/transitions.less +17 -0
- data/vendor/assets/stylesheets/material-ui/resets/normalize.css +430 -0
- data/vendor/assets/stylesheets/material-ui/resets/typography-resets.less +34 -0
- data/vendor/assets/stylesheets/material-ui/scaffolding.less +10 -0
- data/vendor/assets/stylesheets/material-ui/variables/colors.less +285 -0
- data/vendor/assets/stylesheets/material-ui/variables/custom-variables.less +163 -0
- data/vendor/assets/stylesheets/material-ui/variables/media-queries.less +4 -0
- data/vendor/assets/stylesheets/material-ui/variables/spacing.less +16 -0
- metadata +268 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
|
3
|
+
var SubheaderMenuItem = React.createClass({
|
4
|
+
|
5
|
+
propTypes: {
|
6
|
+
index: React.PropTypes.number.isRequired,
|
7
|
+
text: React.PropTypes.string.isRequired
|
8
|
+
},
|
9
|
+
|
10
|
+
render: function() {
|
11
|
+
return (
|
12
|
+
<div key={this.props.index} className="mui-subheader">{this.props.text}</div>
|
13
|
+
);
|
14
|
+
}
|
15
|
+
|
16
|
+
});
|
17
|
+
|
18
|
+
module.exports = SubheaderMenuItem;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var classNames = require('classnames');
|
3
|
+
|
4
|
+
module.exports = {
|
5
|
+
|
6
|
+
propTypes: {
|
7
|
+
className: React.PropTypes.string
|
8
|
+
},
|
9
|
+
|
10
|
+
getClasses: function(initialClasses, additionalClassObj) {
|
11
|
+
var classString = '';
|
12
|
+
|
13
|
+
//Initialize the classString with the classNames that were passed in
|
14
|
+
if (this.props.className) classString += ' ' + this.props.className;
|
15
|
+
|
16
|
+
//Add in initial classes
|
17
|
+
if (typeof initialClasses === 'object') {
|
18
|
+
classString += ' ' + classNames(initialClasses);
|
19
|
+
} else {
|
20
|
+
classString += ' ' + initialClasses;
|
21
|
+
}
|
22
|
+
|
23
|
+
//Add in additional classes
|
24
|
+
if (additionalClassObj) classString += ' ' + classNames(additionalClassObj);
|
25
|
+
|
26
|
+
//Convert the class string into an object and run it through the class set
|
27
|
+
return classNames(this.getClassSet(classString));
|
28
|
+
},
|
29
|
+
|
30
|
+
getClassSet: function(classString) {
|
31
|
+
var classObj = {};
|
32
|
+
|
33
|
+
if (classString) {
|
34
|
+
classString.split(' ').forEach(function(className) {
|
35
|
+
if (className) classObj[className] = true;
|
36
|
+
});
|
37
|
+
}
|
38
|
+
|
39
|
+
return classObj;
|
40
|
+
}
|
41
|
+
|
42
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
var Events = require('../utils/events');
|
2
|
+
var Dom = require('../utils/dom');
|
3
|
+
|
4
|
+
module.exports = {
|
5
|
+
|
6
|
+
//When the component mounts, listen to click events and check if we need to
|
7
|
+
//Call the componentClickAway function.
|
8
|
+
componentDidMount: function() {
|
9
|
+
if (!this.manuallyBindClickAway) this._bindClickAway();
|
10
|
+
},
|
11
|
+
|
12
|
+
componentWillUnmount: function() {
|
13
|
+
this._unbindClickAway();
|
14
|
+
},
|
15
|
+
|
16
|
+
_checkClickAway: function(e) {
|
17
|
+
var el = this.getDOMNode();
|
18
|
+
|
19
|
+
// Check if the target is inside the current component
|
20
|
+
if (this.isMounted() &&
|
21
|
+
e.target != el &&
|
22
|
+
!Dom.isDescendant(el, e.target)) {
|
23
|
+
if (this.componentClickAway) this.componentClickAway();
|
24
|
+
}
|
25
|
+
},
|
26
|
+
|
27
|
+
_bindClickAway: function() {
|
28
|
+
Events.on(document, 'click', this._checkClickAway);
|
29
|
+
},
|
30
|
+
|
31
|
+
_unbindClickAway: function() {
|
32
|
+
Events.off(document, 'click', this._checkClickAway);
|
33
|
+
}
|
34
|
+
|
35
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
var Events = require('../utils/events');
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
|
5
|
+
componentDidMount: function() {
|
6
|
+
var listeners = this.windowListeners;
|
7
|
+
|
8
|
+
for (var eventName in listeners) {
|
9
|
+
var callbackName = listeners[eventName];
|
10
|
+
Events.on(window, eventName, this[callbackName]);
|
11
|
+
}
|
12
|
+
},
|
13
|
+
|
14
|
+
componentWillUnmount: function() {
|
15
|
+
var listeners = this.windowListeners;
|
16
|
+
|
17
|
+
for (var eventName in listeners) {
|
18
|
+
var callbackName = listeners[eventName];
|
19
|
+
Events.off(window, eventName, this[callbackName]);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
var React = require('react'),
|
2
|
+
Classable = require('./mixins/classable');
|
3
|
+
|
4
|
+
var Overlay = React.createClass({
|
5
|
+
|
6
|
+
mixins: [Classable],
|
7
|
+
|
8
|
+
propTypes: {
|
9
|
+
show: React.PropTypes.bool,
|
10
|
+
autoLockScrolling: React.PropTypes.bool
|
11
|
+
},
|
12
|
+
|
13
|
+
getDefaultProps: function() {
|
14
|
+
return {
|
15
|
+
autoLockScrolling: true
|
16
|
+
};
|
17
|
+
},
|
18
|
+
|
19
|
+
componentDidUpdate: function(prevProps, prevState) {
|
20
|
+
if (this.props.autoLockScrolling) (this.props.show) ? this._preventScrolling() : this._allowScrolling();
|
21
|
+
},
|
22
|
+
|
23
|
+
render: function() {
|
24
|
+
var
|
25
|
+
{
|
26
|
+
className,
|
27
|
+
...other
|
28
|
+
} = this.props,
|
29
|
+
classes = this.getClasses('mui-overlay', {
|
30
|
+
'mui-is-shown': this.props.show
|
31
|
+
});
|
32
|
+
|
33
|
+
return (
|
34
|
+
<div {...other} className={classes} />
|
35
|
+
);
|
36
|
+
},
|
37
|
+
|
38
|
+
preventScrolling: function() {
|
39
|
+
if (!this.props.autoLockScrolling) this._preventScrolling();
|
40
|
+
},
|
41
|
+
|
42
|
+
allowScrolling: function() {
|
43
|
+
if (!this.props.autoLockScrolling) this._allowScrolling();
|
44
|
+
},
|
45
|
+
|
46
|
+
_preventScrolling: function() {
|
47
|
+
var body = document.getElementsByTagName('body')[0];
|
48
|
+
body.style.overflow = 'hidden';
|
49
|
+
},
|
50
|
+
|
51
|
+
_allowScrolling: function() {
|
52
|
+
var body = document.getElementsByTagName('body')[0];
|
53
|
+
body.style.overflow = '';
|
54
|
+
}
|
55
|
+
|
56
|
+
});
|
57
|
+
|
58
|
+
module.exports = Overlay;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
var React = require('react'),
|
2
|
+
Classable = require('./mixins/classable');
|
3
|
+
|
4
|
+
var Paper = React.createClass({
|
5
|
+
|
6
|
+
mixins: [Classable],
|
7
|
+
|
8
|
+
propTypes: {
|
9
|
+
circle: React.PropTypes.bool,
|
10
|
+
innerClassName: React.PropTypes.string,
|
11
|
+
innerStyle: React.PropTypes.object,
|
12
|
+
rounded: React.PropTypes.bool,
|
13
|
+
zDepth: React.PropTypes.oneOf([0,1,2,3,4,5])
|
14
|
+
},
|
15
|
+
|
16
|
+
getDefaultProps: function() {
|
17
|
+
return {
|
18
|
+
innerClassName: '',
|
19
|
+
rounded: true,
|
20
|
+
zDepth: 1
|
21
|
+
};
|
22
|
+
},
|
23
|
+
|
24
|
+
render: function() {
|
25
|
+
var {
|
26
|
+
className,
|
27
|
+
circle,
|
28
|
+
innerClassName,
|
29
|
+
rounded,
|
30
|
+
zDepth,
|
31
|
+
...other } = this.props,
|
32
|
+
classes = this.getClasses(
|
33
|
+
'mui-paper ' +
|
34
|
+
'mui-z-depth-' + this.props.zDepth, {
|
35
|
+
'mui-rounded': this.props.rounded,
|
36
|
+
'mui-circle': this.props.circle
|
37
|
+
}),
|
38
|
+
insideClasses =
|
39
|
+
this.props.innerClassName + ' ' +
|
40
|
+
'mui-paper-container ' +
|
41
|
+
'mui-z-depth-bottom';
|
42
|
+
|
43
|
+
return (
|
44
|
+
<div {...other} className={classes}>
|
45
|
+
<div ref="innerContainer" className={insideClasses} style={this.props.innerStyle || {}}>
|
46
|
+
{this.props.children}
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
);
|
50
|
+
},
|
51
|
+
|
52
|
+
getInnerContainer: function() {
|
53
|
+
return this.refs.innerContainer;
|
54
|
+
}
|
55
|
+
|
56
|
+
});
|
57
|
+
|
58
|
+
module.exports = Paper;
|
@@ -0,0 +1,112 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var Paper = require('./paper');
|
3
|
+
var Classable = require('./mixins/classable');
|
4
|
+
var EnhancedSwitch = require('./enhanced-switch');
|
5
|
+
var RadioButton = require('./radio-button');
|
6
|
+
|
7
|
+
var RadioButtonGroup = React.createClass({
|
8
|
+
|
9
|
+
mixins: [Classable],
|
10
|
+
|
11
|
+
propTypes: {
|
12
|
+
name: React.PropTypes.string.isRequired,
|
13
|
+
valueSelected: React.PropTypes.string,
|
14
|
+
defaultSelected: React.PropTypes.string,
|
15
|
+
labelPosition: React.PropTypes.oneOf(['left', 'right']),
|
16
|
+
onChange: React.PropTypes.func
|
17
|
+
},
|
18
|
+
|
19
|
+
_hasCheckAttribute: function(radioButton) {
|
20
|
+
return radioButton.props.hasOwnProperty('checked') &&
|
21
|
+
radioButton.props.checked;
|
22
|
+
},
|
23
|
+
|
24
|
+
getInitialState: function() {
|
25
|
+
return {
|
26
|
+
numberCheckedRadioButtons: 0,
|
27
|
+
selected: this.props.valueSelected || this.props.defaultSelected || ''
|
28
|
+
};
|
29
|
+
},
|
30
|
+
|
31
|
+
componentWillMount: function() {
|
32
|
+
var cnt = 0;
|
33
|
+
|
34
|
+
this.props.children.forEach(function(option) {
|
35
|
+
if (this._hasCheckAttribute(option)) cnt++;
|
36
|
+
}, this);
|
37
|
+
|
38
|
+
this.setState({numberCheckedRadioButtons: cnt});
|
39
|
+
},
|
40
|
+
|
41
|
+
componentWillReceiveProps: function(nextProps) {
|
42
|
+
if (nextProps.hasOwnProperty('valueSelected')) {
|
43
|
+
this.setState({selected: nextProps.valueSelected});
|
44
|
+
}
|
45
|
+
},
|
46
|
+
|
47
|
+
render: function() {
|
48
|
+
|
49
|
+
var options = this.props.children.map(function(option) {
|
50
|
+
|
51
|
+
var {
|
52
|
+
name,
|
53
|
+
value,
|
54
|
+
label,
|
55
|
+
onCheck,
|
56
|
+
...other
|
57
|
+
} = option.props;
|
58
|
+
|
59
|
+
return <RadioButton
|
60
|
+
{...other}
|
61
|
+
ref={option.props.value}
|
62
|
+
name={this.props.name}
|
63
|
+
key={option.props.value}
|
64
|
+
value={option.props.value}
|
65
|
+
label={option.props.label}
|
66
|
+
labelPosition={this.props.labelPosition}
|
67
|
+
onCheck={this._onChange}
|
68
|
+
checked={option.props.value == this.state.selected}/>
|
69
|
+
|
70
|
+
}, this);
|
71
|
+
|
72
|
+
return (
|
73
|
+
<div>
|
74
|
+
{options}
|
75
|
+
</div>
|
76
|
+
);
|
77
|
+
},
|
78
|
+
|
79
|
+
_updateRadioButtons: function(newSelection) {
|
80
|
+
if (this.state.numberCheckedRadioButtons == 0) {
|
81
|
+
this.setState({selected: newSelection});
|
82
|
+
} else if (process.NODE_ENV !== 'production') {
|
83
|
+
var message = "Cannot select a different radio button while another radio button " +
|
84
|
+
"has the 'checked' property set to true.";
|
85
|
+
console.error(message);
|
86
|
+
}
|
87
|
+
},
|
88
|
+
|
89
|
+
_onChange: function(e, newSelection) {
|
90
|
+
this._updateRadioButtons(newSelection);
|
91
|
+
|
92
|
+
// Successful update
|
93
|
+
if (this.state.numberCheckedRadioButtons == 0) {
|
94
|
+
if (this.props.onChange) this.props.onChange(e, newSelection);
|
95
|
+
}
|
96
|
+
},
|
97
|
+
|
98
|
+
getSelectedValue: function() {
|
99
|
+
return this.state.selected;
|
100
|
+
},
|
101
|
+
|
102
|
+
setSelectedValue: function(newSelection) {
|
103
|
+
this._updateRadioButtons(newSelection);
|
104
|
+
},
|
105
|
+
|
106
|
+
clearValue: function() {
|
107
|
+
this.setSelectedValue('');
|
108
|
+
}
|
109
|
+
|
110
|
+
});
|
111
|
+
|
112
|
+
module.exports = RadioButtonGroup;
|
@@ -0,0 +1,65 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var Classable = require('./mixins/classable');
|
3
|
+
var EnhancedSwitch = require('./enhanced-switch');
|
4
|
+
var RadioButtonOff = require('./svg-icons/toggle-radio-button-off');
|
5
|
+
var RadioButtonOn = require('./svg-icons/toggle-radio-button-on');
|
6
|
+
|
7
|
+
var RadioButton = React.createClass({
|
8
|
+
|
9
|
+
mixins: [Classable],
|
10
|
+
|
11
|
+
propTypes: {
|
12
|
+
onCheck: React.PropTypes.func
|
13
|
+
},
|
14
|
+
|
15
|
+
render: function() {
|
16
|
+
|
17
|
+
var {
|
18
|
+
onCheck,
|
19
|
+
...other
|
20
|
+
} = this.props;
|
21
|
+
|
22
|
+
var radioButtonElement = (
|
23
|
+
<div>
|
24
|
+
<RadioButtonOff className="mui-radio-button-target" />
|
25
|
+
<RadioButtonOn className="mui-radio-button-fill" />
|
26
|
+
</div>
|
27
|
+
);
|
28
|
+
|
29
|
+
var enhancedSwitchProps = {
|
30
|
+
ref: "enhancedSwitch",
|
31
|
+
inputType: "radio",
|
32
|
+
switchElement: radioButtonElement,
|
33
|
+
className: "mui-radio-button",
|
34
|
+
iconClassName: "mui-radio-button-icon",
|
35
|
+
onSwitch: this._handleCheck,
|
36
|
+
labelPosition: (this.props.labelPosition) ? this.props.labelPosition : "right"
|
37
|
+
};
|
38
|
+
|
39
|
+
return (
|
40
|
+
<EnhancedSwitch
|
41
|
+
{...other}
|
42
|
+
{...enhancedSwitchProps}/>
|
43
|
+
);
|
44
|
+
},
|
45
|
+
|
46
|
+
// Only called when selected, not when unselected.
|
47
|
+
_handleCheck: function(e) {
|
48
|
+
if (this.props.onCheck) this.props.onCheck(e, this.props.value);
|
49
|
+
},
|
50
|
+
|
51
|
+
isChecked: function() {
|
52
|
+
return this.refs.enhancedSwitch.isSwitched();
|
53
|
+
},
|
54
|
+
|
55
|
+
setChecked: function(newCheckedValue) {
|
56
|
+
this.refs.enhancedSwitch.setSwitched(newCheckedValue);
|
57
|
+
this.setState({switched: newCheckedValue});
|
58
|
+
},
|
59
|
+
|
60
|
+
getValue: function() {
|
61
|
+
return this.refs.enhancedSwitch.getValue();
|
62
|
+
}
|
63
|
+
});
|
64
|
+
|
65
|
+
module.exports = RadioButton;
|
@@ -0,0 +1,102 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var Classable = require('./mixins/classable');
|
3
|
+
var EnhancedButton = require('./enhanced-button');
|
4
|
+
var Paper = require('./paper');
|
5
|
+
|
6
|
+
var RaisedButton = React.createClass({
|
7
|
+
|
8
|
+
mixins: [Classable],
|
9
|
+
|
10
|
+
propTypes: {
|
11
|
+
className: React.PropTypes.string,
|
12
|
+
label: function(props, propName, componentName){
|
13
|
+
if (!props.children && !props.label) {
|
14
|
+
return new Error('Warning: Required prop `label` or `children` was not specified in `'+ componentName + '`.')
|
15
|
+
}
|
16
|
+
},
|
17
|
+
onMouseDown: React.PropTypes.func,
|
18
|
+
onMouseUp: React.PropTypes.func,
|
19
|
+
onMouseOut: React.PropTypes.func,
|
20
|
+
onTouchEnd: React.PropTypes.func,
|
21
|
+
onTouchStart: React.PropTypes.func,
|
22
|
+
primary: React.PropTypes.bool,
|
23
|
+
secondary: React.PropTypes.bool
|
24
|
+
},
|
25
|
+
|
26
|
+
getInitialState: function() {
|
27
|
+
var zDepth = this.props.disabled ? 0 : 1;
|
28
|
+
return {
|
29
|
+
zDepth: zDepth,
|
30
|
+
initialZDepth: zDepth
|
31
|
+
};
|
32
|
+
},
|
33
|
+
|
34
|
+
componentWillReceiveProps: function(nextProps) {
|
35
|
+
var zDepth = nextProps.disabled ? 0 : 1;
|
36
|
+
this.setState({
|
37
|
+
zDepth: zDepth,
|
38
|
+
initialZDepth: zDepth
|
39
|
+
});
|
40
|
+
},
|
41
|
+
|
42
|
+
render: function() {
|
43
|
+
var {
|
44
|
+
label,
|
45
|
+
primary,
|
46
|
+
secondary,
|
47
|
+
...other } = this.props;
|
48
|
+
var classes = this.getClasses('mui-raised-button', {
|
49
|
+
'mui-is-primary': !this.props.disabled && primary,
|
50
|
+
'mui-is-secondary': !this.props.disabled && !primary && secondary
|
51
|
+
});
|
52
|
+
var children;
|
53
|
+
|
54
|
+
if (label) children = <span className="mui-raised-button-label">{label}</span>;
|
55
|
+
else children = this.props.children;
|
56
|
+
|
57
|
+
return (
|
58
|
+
<Paper className={classes} zDepth={this.state.zDepth}>
|
59
|
+
<EnhancedButton {...other}
|
60
|
+
className="mui-raised-button-container"
|
61
|
+
onMouseUp={this._handleMouseUp}
|
62
|
+
onMouseDown={this._handleMouseDown}
|
63
|
+
onMouseOut={this._handleMouseOut}
|
64
|
+
onTouchStart={this._handleTouchStart}
|
65
|
+
onTouchEnd={this._handleTouchEnd}>
|
66
|
+
{children}
|
67
|
+
</EnhancedButton>
|
68
|
+
</Paper>
|
69
|
+
);
|
70
|
+
},
|
71
|
+
|
72
|
+
_handleMouseDown: function(e) {
|
73
|
+
//only listen to left clicks
|
74
|
+
if (e.button === 0) {
|
75
|
+
this.setState({ zDepth: this.state.initialZDepth + 1 });
|
76
|
+
}
|
77
|
+
if (this.props.onMouseDown) this.props.onMouseDown(e);
|
78
|
+
},
|
79
|
+
|
80
|
+
_handleMouseUp: function(e) {
|
81
|
+
this.setState({ zDepth: this.state.initialZDepth });
|
82
|
+
if (this.props.onMouseUp) this.props.onMouseUp(e);
|
83
|
+
},
|
84
|
+
|
85
|
+
_handleMouseOut: function(e) {
|
86
|
+
this.setState({ zDepth: this.state.initialZDepth });
|
87
|
+
if (this.props.onMouseOut) this.props.onMouseOut(e);
|
88
|
+
},
|
89
|
+
|
90
|
+
_handleTouchStart: function(e) {
|
91
|
+
this.setState({ zDepth: this.state.initialZDepth + 1 });
|
92
|
+
if (this.props.onTouchStart) this.props.onTouchStart(e);
|
93
|
+
},
|
94
|
+
|
95
|
+
_handleTouchEnd: function(e) {
|
96
|
+
this.setState({ zDepth: this.state.initialZDepth });
|
97
|
+
if (this.props.onTouchEnd) this.props.onTouchEnd(e);
|
98
|
+
}
|
99
|
+
|
100
|
+
});
|
101
|
+
|
102
|
+
module.exports = RaisedButton;
|