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,46 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var Classable = require('./mixins/classable');
|
3
|
+
var EnhancedButton = require('./enhanced-button');
|
4
|
+
|
5
|
+
var FlatButton = React.createClass({
|
6
|
+
|
7
|
+
mixins: [Classable],
|
8
|
+
|
9
|
+
propTypes: {
|
10
|
+
className: React.PropTypes.string,
|
11
|
+
label: function(props, propName, componentName){
|
12
|
+
if (!props.children && !props.label) {
|
13
|
+
return new Error('Warning: Required prop `label` or `children` was not specified in `'+ componentName + '`.')
|
14
|
+
}
|
15
|
+
},
|
16
|
+
primary: React.PropTypes.bool,
|
17
|
+
secondary: React.PropTypes.bool
|
18
|
+
},
|
19
|
+
|
20
|
+
render: function() {
|
21
|
+
var {
|
22
|
+
label,
|
23
|
+
primary,
|
24
|
+
secondary,
|
25
|
+
...other
|
26
|
+
} = this.props;
|
27
|
+
var classes = this.getClasses('mui-flat-button', {
|
28
|
+
'mui-is-primary': !this.props.disabled && primary,
|
29
|
+
'mui-is-secondary': !this.props.disabled && !primary && secondary
|
30
|
+
});
|
31
|
+
var children;
|
32
|
+
|
33
|
+
if (label) children = <span className="mui-flat-button-label">{label}</span>;
|
34
|
+
else children = this.props.children;
|
35
|
+
|
36
|
+
return (
|
37
|
+
<EnhancedButton {...other}
|
38
|
+
className={classes}>
|
39
|
+
{children}
|
40
|
+
</EnhancedButton>
|
41
|
+
);
|
42
|
+
}
|
43
|
+
|
44
|
+
});
|
45
|
+
|
46
|
+
module.exports = FlatButton;
|
@@ -0,0 +1,123 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var Classable = require('./mixins/classable');
|
3
|
+
var EnhancedButton = require('./enhanced-button');
|
4
|
+
var FontIcon = require('./font-icon');
|
5
|
+
var Paper = require('./paper');
|
6
|
+
|
7
|
+
var getZDepth = function(disabled) {
|
8
|
+
var zDepth = disabled ? 0 : 2;
|
9
|
+
return {
|
10
|
+
zDepth: zDepth,
|
11
|
+
initialZDepth: zDepth
|
12
|
+
};
|
13
|
+
};
|
14
|
+
|
15
|
+
|
16
|
+
var RaisedButton = React.createClass({
|
17
|
+
|
18
|
+
mixins: [Classable],
|
19
|
+
|
20
|
+
propTypes: {
|
21
|
+
className: React.PropTypes.string,
|
22
|
+
iconClassName: React.PropTypes.string,
|
23
|
+
mini: React.PropTypes.bool,
|
24
|
+
onMouseDown: React.PropTypes.func,
|
25
|
+
onMouseUp: React.PropTypes.func,
|
26
|
+
onMouseOut: React.PropTypes.func,
|
27
|
+
onTouchEnd: React.PropTypes.func,
|
28
|
+
onTouchStart: React.PropTypes.func,
|
29
|
+
secondary: React.PropTypes.bool
|
30
|
+
},
|
31
|
+
|
32
|
+
componentWillMount: function() {
|
33
|
+
this.setState(getZDepth(this.props.disabled));
|
34
|
+
},
|
35
|
+
|
36
|
+
componentWillReceiveProps: function(newProps) {
|
37
|
+
if(newProps.disabled !== this.props.disabled){
|
38
|
+
this.setState(getZDepth(newProps.disabled));
|
39
|
+
}
|
40
|
+
},
|
41
|
+
|
42
|
+
componentDidMount: function() {
|
43
|
+
if (process.NODE_ENV !== 'production') {
|
44
|
+
if (this.props.iconClassName && this.props.children) {
|
45
|
+
var warning = 'You have set both an iconClassName and a child icon. ' +
|
46
|
+
'It is recommended you use only one method when adding ' +
|
47
|
+
'icons to FloatingActionButtons.';
|
48
|
+
console.warn(warning);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
},
|
52
|
+
|
53
|
+
|
54
|
+
render: function() {
|
55
|
+
var {
|
56
|
+
icon,
|
57
|
+
mini,
|
58
|
+
secondary,
|
59
|
+
...other } = this.props;
|
60
|
+
var classes = this.getClasses('mui-floating-action-button', {
|
61
|
+
'mui-is-mini': mini,
|
62
|
+
'mui-is-secondary': !this.props.disabled && secondary
|
63
|
+
});
|
64
|
+
|
65
|
+
var icon;
|
66
|
+
if (this.props.iconClassName) icon = <FontIcon className={"mui-floating-action-button-icon " + this.props.iconClassName} />
|
67
|
+
|
68
|
+
|
69
|
+
return (
|
70
|
+
<Paper
|
71
|
+
className={classes}
|
72
|
+
innerClassName="mui-floating-action-button-inner"
|
73
|
+
zDepth={this.state.zDepth}
|
74
|
+
circle={true}>
|
75
|
+
|
76
|
+
<EnhancedButton {...other}
|
77
|
+
className="mui-floating-action-button-container"
|
78
|
+
onMouseDown={this._handleMouseDown}
|
79
|
+
onMouseUp={this._handleMouseUp}
|
80
|
+
onMouseOut={this._handleMouseOut}
|
81
|
+
onTouchStart={this._handleTouchStart}
|
82
|
+
onTouchEnd={this._handleTouchEnd}>
|
83
|
+
|
84
|
+
{icon}
|
85
|
+
{this.props.children}
|
86
|
+
|
87
|
+
</EnhancedButton>
|
88
|
+
|
89
|
+
</Paper>
|
90
|
+
);
|
91
|
+
},
|
92
|
+
|
93
|
+
_handleMouseDown: function(e) {
|
94
|
+
//only listen to left clicks
|
95
|
+
if (e.button === 0) {
|
96
|
+
this.setState({ zDepth: this.state.initialZDepth + 1 });
|
97
|
+
}
|
98
|
+
if (this.props.onMouseDown) this.props.onMouseDown(e);
|
99
|
+
},
|
100
|
+
|
101
|
+
_handleMouseUp: function(e) {
|
102
|
+
this.setState({ zDepth: this.state.initialZDepth });
|
103
|
+
if (this.props.onMouseUp) this.props.onMouseUp(e);
|
104
|
+
},
|
105
|
+
|
106
|
+
_handleMouseOut: function(e) {
|
107
|
+
this.setState({ zDepth: this.state.initialZDepth });
|
108
|
+
if (this.props.onMouseOut) this.props.onMouseOut(e);
|
109
|
+
},
|
110
|
+
|
111
|
+
_handleTouchStart: function(e) {
|
112
|
+
this.setState({ zDepth: this.state.initialZDepth + 1 });
|
113
|
+
if (this.props.onTouchStart) this.props.onTouchStart(e);
|
114
|
+
},
|
115
|
+
|
116
|
+
_handleTouchEnd: function(e) {
|
117
|
+
this.setState({ zDepth: this.state.initialZDepth });
|
118
|
+
if (this.props.onTouchEnd) this.props.onTouchEnd(e);
|
119
|
+
}
|
120
|
+
|
121
|
+
});
|
122
|
+
|
123
|
+
module.exports = RaisedButton;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var Classable = require('./mixins/classable');
|
3
|
+
|
4
|
+
var FontIcon = React.createClass({
|
5
|
+
|
6
|
+
mixins: [Classable],
|
7
|
+
|
8
|
+
render: function() {
|
9
|
+
|
10
|
+
var {
|
11
|
+
className,
|
12
|
+
...other
|
13
|
+
} = this.props;
|
14
|
+
var classes = this.getClasses('mui-font-icon');
|
15
|
+
|
16
|
+
return (
|
17
|
+
<span {...other} className={classes} />
|
18
|
+
);
|
19
|
+
}
|
20
|
+
|
21
|
+
});
|
22
|
+
|
23
|
+
module.exports = FontIcon;
|
@@ -0,0 +1,123 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var Classable = require('./mixins/classable');
|
3
|
+
var EnhancedButton = require('./enhanced-button');
|
4
|
+
var FontIcon = require('./font-icon');
|
5
|
+
var Tooltip = require('./tooltip');
|
6
|
+
|
7
|
+
var IconButton = React.createClass({
|
8
|
+
|
9
|
+
mixins: [Classable],
|
10
|
+
|
11
|
+
propTypes: {
|
12
|
+
className: React.PropTypes.string,
|
13
|
+
disabled: React.PropTypes.bool,
|
14
|
+
iconClassName: React.PropTypes.string,
|
15
|
+
onBlur: React.PropTypes.func,
|
16
|
+
onFocus: React.PropTypes.func,
|
17
|
+
tooltip: React.PropTypes.string,
|
18
|
+
touch: React.PropTypes.bool
|
19
|
+
},
|
20
|
+
|
21
|
+
getInitialState: function() {
|
22
|
+
return {
|
23
|
+
tooltipShown: false
|
24
|
+
};
|
25
|
+
},
|
26
|
+
|
27
|
+
componentDidMount: function() {
|
28
|
+
if (this.props.tooltip) {
|
29
|
+
this._positionTooltip();
|
30
|
+
}
|
31
|
+
if (process.NODE_ENV !== 'production') {
|
32
|
+
if (this.props.iconClassName && this.props.children) {
|
33
|
+
var warning = 'You have set both an iconClassName and a child icon. ' +
|
34
|
+
'It is recommended you use only one method when adding ' +
|
35
|
+
'icons to IconButtons.';
|
36
|
+
console.warn(warning);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
},
|
40
|
+
|
41
|
+
render: function() {
|
42
|
+
var {
|
43
|
+
tooltip,
|
44
|
+
touch,
|
45
|
+
...other } = this.props;
|
46
|
+
var classes = this.getClasses('mui-icon-button');
|
47
|
+
var tooltip;
|
48
|
+
var fonticon;
|
49
|
+
|
50
|
+
if (this.props.tooltip) {
|
51
|
+
tooltip = (
|
52
|
+
<Tooltip
|
53
|
+
ref="tooltip"
|
54
|
+
className="mui-icon-button-tooltip"
|
55
|
+
label={tooltip}
|
56
|
+
show={this.state.tooltipShown}
|
57
|
+
touch={touch} />
|
58
|
+
);
|
59
|
+
}
|
60
|
+
|
61
|
+
if (this.props.iconClassName) {
|
62
|
+
fonticon = (
|
63
|
+
<FontIcon className={this.props.iconClassName}/>
|
64
|
+
);
|
65
|
+
}
|
66
|
+
|
67
|
+
return (
|
68
|
+
<EnhancedButton {...other}
|
69
|
+
ref="button"
|
70
|
+
centerRipple={true}
|
71
|
+
className={classes}
|
72
|
+
onBlur={this._handleBlur}
|
73
|
+
onFocus={this._handleFocus}
|
74
|
+
onMouseOut={this._handleMouseOut}
|
75
|
+
onMouseOver={this._handleMouseOver}>
|
76
|
+
|
77
|
+
{tooltip}
|
78
|
+
{fonticon}
|
79
|
+
{this.props.children}
|
80
|
+
|
81
|
+
</EnhancedButton>
|
82
|
+
);
|
83
|
+
},
|
84
|
+
|
85
|
+
_positionTooltip: function() {
|
86
|
+
var tooltip = this.refs.tooltip.getDOMNode();
|
87
|
+
var tooltipWidth = tooltip.offsetWidth;
|
88
|
+
var buttonWidth = 48;
|
89
|
+
|
90
|
+
tooltip.style.left = (tooltipWidth - buttonWidth) / 2 * -1 + 'px';
|
91
|
+
},
|
92
|
+
|
93
|
+
_showTooltip: function() {
|
94
|
+
if (!this.props.disabled) this.setState({ tooltipShown: true });
|
95
|
+
},
|
96
|
+
|
97
|
+
_hideTooltip: function() {
|
98
|
+
this.setState({ tooltipShown: false });
|
99
|
+
},
|
100
|
+
|
101
|
+
_handleBlur: function(e) {
|
102
|
+
this._hideTooltip();
|
103
|
+
if (this.props.onBlur) this.props.onBlur(e);
|
104
|
+
},
|
105
|
+
|
106
|
+
_handleFocus: function(e) {
|
107
|
+
this._showTooltip();
|
108
|
+
if (this.props.onFocus) this.props.onFocus(e);
|
109
|
+
},
|
110
|
+
|
111
|
+
_handleMouseOut: function(e) {
|
112
|
+
if (!this.refs.button.isKeyboardFocused()) this._hideTooltip();
|
113
|
+
if (this.props.onMouseOut) this.props.onMouseOut(e);
|
114
|
+
},
|
115
|
+
|
116
|
+
_handleMouseOver: function(e) {
|
117
|
+
this._showTooltip();
|
118
|
+
if (this.props.onMouseOver) this.props.onMouseOver(e);
|
119
|
+
}
|
120
|
+
|
121
|
+
});
|
122
|
+
|
123
|
+
module.exports = IconButton;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
|
3
|
+
var InkBar = React.createClass({
|
4
|
+
|
5
|
+
propTypes: {
|
6
|
+
position: React.PropTypes.string
|
7
|
+
},
|
8
|
+
|
9
|
+
render: function() {
|
10
|
+
|
11
|
+
var styles = {
|
12
|
+
left: this.props.left,
|
13
|
+
width: this.props.width
|
14
|
+
}
|
15
|
+
|
16
|
+
return (
|
17
|
+
<div className='mui-ink-bar' style={styles}>
|
18
|
+
|
19
|
+
</div>
|
20
|
+
);
|
21
|
+
}
|
22
|
+
|
23
|
+
});
|
24
|
+
|
25
|
+
module.exports = InkBar;
|
@@ -0,0 +1,143 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var Classable = require('./mixins/classable');
|
3
|
+
var ClassNames = require('classnames');
|
4
|
+
|
5
|
+
var Input = React.createClass({
|
6
|
+
|
7
|
+
propTypes: {
|
8
|
+
multiline: React.PropTypes.bool,
|
9
|
+
inlinePlaceholder: React.PropTypes.bool,
|
10
|
+
rows: React.PropTypes.number,
|
11
|
+
inputStyle: React.PropTypes.string,
|
12
|
+
error: React.PropTypes.string,
|
13
|
+
description: React.PropTypes.string,
|
14
|
+
placeholder: React.PropTypes.string,
|
15
|
+
type: React.PropTypes.string,
|
16
|
+
onChange: React.PropTypes.func
|
17
|
+
},
|
18
|
+
|
19
|
+
mixins: [Classable],
|
20
|
+
|
21
|
+
getInitialState: function() {
|
22
|
+
return {
|
23
|
+
value: this.props.defaultValue,
|
24
|
+
rows: this.props.rows
|
25
|
+
};
|
26
|
+
},
|
27
|
+
|
28
|
+
getDefaultProps: function() {
|
29
|
+
return {
|
30
|
+
multiline: false,
|
31
|
+
type: "text"
|
32
|
+
};
|
33
|
+
},
|
34
|
+
|
35
|
+
componentDidMount: function() {
|
36
|
+
if (process.NODE_ENV !== 'production') {
|
37
|
+
console.warn('Input has been deprecated. Please use TextField instead. See http://material-ui.com/#/components/text-fields');
|
38
|
+
}
|
39
|
+
},
|
40
|
+
|
41
|
+
render: function() {
|
42
|
+
var classes = this.getClasses('mui-input', {
|
43
|
+
'mui-floating': this.props.inputStyle === 'floating',
|
44
|
+
'mui-text': this.props.type === 'text',
|
45
|
+
'mui-error': this.props.error || false,
|
46
|
+
'mui-disabled': !!this.props.disabled,
|
47
|
+
});
|
48
|
+
var placeholder = this.props.inlinePlaceholder ? this.props.placeholder : "";
|
49
|
+
var inputIsNotEmpty = !!this.state.value;
|
50
|
+
var inputClassName = ClassNames({
|
51
|
+
'mui-is-not-empty': inputIsNotEmpty
|
52
|
+
});
|
53
|
+
var textareaClassName = ClassNames({
|
54
|
+
'mui-input-textarea': true,
|
55
|
+
'mui-is-not-empty': inputIsNotEmpty
|
56
|
+
});
|
57
|
+
var inputElement = this.props.multiline ?
|
58
|
+
this.props.valueLink ?
|
59
|
+
<textarea {...this.props} ref="input"
|
60
|
+
className={textareaClassName}
|
61
|
+
placeholder={placeholder}
|
62
|
+
rows={this.state.rows} /> :
|
63
|
+
<textarea {...this.props} ref="input"
|
64
|
+
value={this.state.value}
|
65
|
+
className={textareaClassName}
|
66
|
+
placeholder={placeholder}
|
67
|
+
rows={this.state.rows}
|
68
|
+
onChange={this._onTextAreaChange} /> :
|
69
|
+
this.props.valueLink ?
|
70
|
+
<input {...this.props} ref="input"
|
71
|
+
className={inputClassName}
|
72
|
+
placeholder={placeholder} /> :
|
73
|
+
<input {...this.props} ref="input"
|
74
|
+
className={inputClassName}
|
75
|
+
value={this.state.value}
|
76
|
+
placeholder={placeholder}
|
77
|
+
onChange={this._onInputChange} />;
|
78
|
+
var placeholderSpan = this.props.inlinePlaceholder ? null :
|
79
|
+
<span className="mui-input-placeholder" onClick={this._onPlaceholderClick}>
|
80
|
+
{this.props.placeholder}
|
81
|
+
</span>;
|
82
|
+
|
83
|
+
return (
|
84
|
+
<div ref={this.props.ref} className={classes}>
|
85
|
+
{inputElement}
|
86
|
+
{placeholderSpan}
|
87
|
+
<span className="mui-input-highlight"></span>
|
88
|
+
<span className="mui-input-bar"></span>
|
89
|
+
<span className="mui-input-description">{this.props.description}</span>
|
90
|
+
<span className="mui-input-error">{this.props.error}</span>
|
91
|
+
</div>
|
92
|
+
);
|
93
|
+
},
|
94
|
+
|
95
|
+
getValue: function() {
|
96
|
+
return this.state.value;
|
97
|
+
},
|
98
|
+
|
99
|
+
setValue: function(txt) {
|
100
|
+
this.setState({value: txt});
|
101
|
+
},
|
102
|
+
|
103
|
+
clearValue: function() {
|
104
|
+
this.setValue('');
|
105
|
+
},
|
106
|
+
|
107
|
+
blur: function() {
|
108
|
+
if(this.isMounted()) this.refs.input.getDOMNode().blur();
|
109
|
+
},
|
110
|
+
|
111
|
+
focus: function() {
|
112
|
+
if (this.isMounted()) this.refs.input.getDOMNode().focus();
|
113
|
+
},
|
114
|
+
|
115
|
+
_onInputChange: function(e) {
|
116
|
+
var value = e.target.value;
|
117
|
+
this.setState({value: value});
|
118
|
+
if (this.props.onChange) this.props.onChange(e, value);
|
119
|
+
},
|
120
|
+
|
121
|
+
_onPlaceholderClick: function(e) {
|
122
|
+
this.focus();
|
123
|
+
},
|
124
|
+
|
125
|
+
_onTextAreaChange: function(e) {
|
126
|
+
this._onInputChange(e);
|
127
|
+
this._onLineBreak(e);
|
128
|
+
},
|
129
|
+
|
130
|
+
_onLineBreak: function(e) {
|
131
|
+
var value = e.target.value;
|
132
|
+
var lines = value.split('\n').length;
|
133
|
+
|
134
|
+
if (lines > this.state.rows) {
|
135
|
+
if (this.state.rows !== 20) {
|
136
|
+
this.setState({ rows: ((this.state.rows) + 1)});
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
});
|
142
|
+
|
143
|
+
module.exports = Input;
|