material-ui 0.7.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +31 -0
  6. data/Rakefile +20 -0
  7. data/lib/material-ui.rb +4 -0
  8. data/material-ui-gem.gemspec +33 -0
  9. data/vendor/assets/javascripts/material-ui.js +1 -0
  10. data/vendor/assets/javascripts/material-ui/components/app-bar.jsx +93 -0
  11. data/vendor/assets/javascripts/material-ui/components/app-canvas.jsx +27 -0
  12. data/vendor/assets/javascripts/material-ui/components/checkbox.jsx +60 -0
  13. data/vendor/assets/javascripts/material-ui/components/date-picker/calendar-month.jsx +59 -0
  14. data/vendor/assets/javascripts/material-ui/components/date-picker/calendar-toolbar.jsx +64 -0
  15. data/vendor/assets/javascripts/material-ui/components/date-picker/calendar.jsx +194 -0
  16. data/vendor/assets/javascripts/material-ui/components/date-picker/date-display.jsx +79 -0
  17. data/vendor/assets/javascripts/material-ui/components/date-picker/date-picker-dialog.jsx +118 -0
  18. data/vendor/assets/javascripts/material-ui/components/date-picker/date-picker.jsx +116 -0
  19. data/vendor/assets/javascripts/material-ui/components/date-picker/day-button.jsx +49 -0
  20. data/vendor/assets/javascripts/material-ui/components/dialog-window.jsx +183 -0
  21. data/vendor/assets/javascripts/material-ui/components/dialog.jsx +54 -0
  22. data/vendor/assets/javascripts/material-ui/components/drop-down-icon.jsx +68 -0
  23. data/vendor/assets/javascripts/material-ui/components/drop-down-menu.jsx +94 -0
  24. data/vendor/assets/javascripts/material-ui/components/enhanced-button.jsx +147 -0
  25. data/vendor/assets/javascripts/material-ui/components/enhanced-switch.jsx +296 -0
  26. data/vendor/assets/javascripts/material-ui/components/enhanced-textarea.jsx +113 -0
  27. data/vendor/assets/javascripts/material-ui/components/flat-button.jsx +46 -0
  28. data/vendor/assets/javascripts/material-ui/components/floating-action-button.jsx +123 -0
  29. data/vendor/assets/javascripts/material-ui/components/font-icon.jsx +23 -0
  30. data/vendor/assets/javascripts/material-ui/components/icon-button.jsx +123 -0
  31. data/vendor/assets/javascripts/material-ui/components/ink-bar.jsx +25 -0
  32. data/vendor/assets/javascripts/material-ui/components/input.jsx +143 -0
  33. data/vendor/assets/javascripts/material-ui/components/left-nav.jsx +105 -0
  34. data/vendor/assets/javascripts/material-ui/components/menu/link-menu-item.jsx +42 -0
  35. data/vendor/assets/javascripts/material-ui/components/menu/menu-item.jsx +105 -0
  36. data/vendor/assets/javascripts/material-ui/components/menu/menu.jsx +325 -0
  37. data/vendor/assets/javascripts/material-ui/components/menu/subheader-menu-item.jsx +18 -0
  38. data/vendor/assets/javascripts/material-ui/components/mixins/classable.js +42 -0
  39. data/vendor/assets/javascripts/material-ui/components/mixins/click-awayable.js +35 -0
  40. data/vendor/assets/javascripts/material-ui/components/mixins/window-listenable.js +23 -0
  41. data/vendor/assets/javascripts/material-ui/components/overlay.jsx +58 -0
  42. data/vendor/assets/javascripts/material-ui/components/paper.jsx +58 -0
  43. data/vendor/assets/javascripts/material-ui/components/radio-button-group.jsx +112 -0
  44. data/vendor/assets/javascripts/material-ui/components/radio-button.jsx +65 -0
  45. data/vendor/assets/javascripts/material-ui/components/raised-button.jsx +102 -0
  46. data/vendor/assets/javascripts/material-ui/components/ripples/circle.jsx +35 -0
  47. data/vendor/assets/javascripts/material-ui/components/ripples/focus-ripple.jsx +40 -0
  48. data/vendor/assets/javascripts/material-ui/components/ripples/touch-ripple.jsx +174 -0
  49. data/vendor/assets/javascripts/material-ui/components/slider.jsx +178 -0
  50. data/vendor/assets/javascripts/material-ui/components/snackbar.jsx +76 -0
  51. data/vendor/assets/javascripts/material-ui/components/svg-icons/drop-down-arrow.jsx +16 -0
  52. data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-chevron-left.jsx +16 -0
  53. data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-chevron-right.jsx +17 -0
  54. data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-menu.jsx +16 -0
  55. data/vendor/assets/javascripts/material-ui/components/svg-icons/svg-icon.jsx +23 -0
  56. data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-check-box-checked.jsx +16 -0
  57. data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-check-box-outline-blank.jsx +16 -0
  58. data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-radio-button-off.jsx +16 -0
  59. data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-radio-button-on.jsx +16 -0
  60. data/vendor/assets/javascripts/material-ui/components/table-header.jsx +50 -0
  61. data/vendor/assets/javascripts/material-ui/components/table-rows-item.jsx +31 -0
  62. data/vendor/assets/javascripts/material-ui/components/table-rows.jsx +57 -0
  63. data/vendor/assets/javascripts/material-ui/components/tabs/tab.jsx +38 -0
  64. data/vendor/assets/javascripts/material-ui/components/tabs/tabTemplate.jsx +15 -0
  65. data/vendor/assets/javascripts/material-ui/components/tabs/tabs.jsx +96 -0
  66. data/vendor/assets/javascripts/material-ui/components/text-field.jsx +215 -0
  67. data/vendor/assets/javascripts/material-ui/components/toggle.jsx +62 -0
  68. data/vendor/assets/javascripts/material-ui/components/toolbar-group.jsx +28 -0
  69. data/vendor/assets/javascripts/material-ui/components/toolbar.jsx +21 -0
  70. data/vendor/assets/javascripts/material-ui/components/tooltip.jsx +58 -0
  71. data/vendor/assets/javascripts/material-ui/components/transition-groups/slide-in.jsx +48 -0
  72. data/vendor/assets/javascripts/material-ui/components/utils/css-event.js +52 -0
  73. data/vendor/assets/javascripts/material-ui/components/utils/date-time.js +132 -0
  74. data/vendor/assets/javascripts/material-ui/components/utils/dom.js +71 -0
  75. data/vendor/assets/javascripts/material-ui/components/utils/events.js +34 -0
  76. data/vendor/assets/javascripts/material-ui/components/utils/key-code.js +10 -0
  77. data/vendor/assets/javascripts/material-ui/components/utils/key-line.js +13 -0
  78. data/vendor/assets/javascripts/material-ui/components/utils/unique-id.js +7 -0
  79. data/vendor/assets/stylesheets/material-ui.less +2 -0
  80. data/vendor/assets/stylesheets/material-ui/components.less +5 -0
  81. data/vendor/assets/stylesheets/material-ui/components/app-bar.less +37 -0
  82. data/vendor/assets/stylesheets/material-ui/components/card.less +20 -0
  83. data/vendor/assets/stylesheets/material-ui/components/checkbox.less +66 -0
  84. data/vendor/assets/stylesheets/material-ui/components/components.less +37 -0
  85. data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar-month.less +11 -0
  86. data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar-toolbar.less +23 -0
  87. data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar.less +59 -0
  88. data/vendor/assets/stylesheets/material-ui/components/date-picker/date-display.less +84 -0
  89. data/vendor/assets/stylesheets/material-ui/components/date-picker/date-picker-dialog.less +18 -0
  90. data/vendor/assets/stylesheets/material-ui/components/date-picker/date-picker.less +9 -0
  91. data/vendor/assets/stylesheets/material-ui/components/date-picker/day-button.less +35 -0
  92. data/vendor/assets/stylesheets/material-ui/components/dialog-window.less +42 -0
  93. data/vendor/assets/stylesheets/material-ui/components/dialog.less +10 -0
  94. data/vendor/assets/stylesheets/material-ui/components/drop-down-icon.less +43 -0
  95. data/vendor/assets/stylesheets/material-ui/components/drop-down-menu.less +77 -0
  96. data/vendor/assets/stylesheets/material-ui/components/enhanced-button.less +24 -0
  97. data/vendor/assets/stylesheets/material-ui/components/enhanced-switch.less +52 -0
  98. data/vendor/assets/stylesheets/material-ui/components/enhanced-textarea.less +16 -0
  99. data/vendor/assets/stylesheets/material-ui/components/flat-button.less +93 -0
  100. data/vendor/assets/stylesheets/material-ui/components/floating-action-button.less +95 -0
  101. data/vendor/assets/stylesheets/material-ui/components/font-icon.less +6 -0
  102. data/vendor/assets/stylesheets/material-ui/components/icon-button.less +46 -0
  103. data/vendor/assets/stylesheets/material-ui/components/ink-bar.less +9 -0
  104. data/vendor/assets/stylesheets/material-ui/components/input.less +186 -0
  105. data/vendor/assets/stylesheets/material-ui/components/left-nav.less +31 -0
  106. data/vendor/assets/stylesheets/material-ui/components/menu-item.less +69 -0
  107. data/vendor/assets/stylesheets/material-ui/components/menu.less +50 -0
  108. data/vendor/assets/stylesheets/material-ui/components/overlay.less +21 -0
  109. data/vendor/assets/stylesheets/material-ui/components/paper.less +59 -0
  110. data/vendor/assets/stylesheets/material-ui/components/radio-button.less +67 -0
  111. data/vendor/assets/stylesheets/material-ui/components/raised-button.less +132 -0
  112. data/vendor/assets/stylesheets/material-ui/components/ripples/circle.less +31 -0
  113. data/vendor/assets/stylesheets/material-ui/components/ripples/focus-ripple.less +30 -0
  114. data/vendor/assets/stylesheets/material-ui/components/ripples/touch-ripple.less +9 -0
  115. data/vendor/assets/stylesheets/material-ui/components/slider.less +163 -0
  116. data/vendor/assets/stylesheets/material-ui/components/snackbar.less +44 -0
  117. data/vendor/assets/stylesheets/material-ui/components/subheader.less +17 -0
  118. data/vendor/assets/stylesheets/material-ui/components/svg-icon.less +11 -0
  119. data/vendor/assets/stylesheets/material-ui/components/table.less +46 -0
  120. data/vendor/assets/stylesheets/material-ui/components/tabs.less +41 -0
  121. data/vendor/assets/stylesheets/material-ui/components/text-field.less +168 -0
  122. data/vendor/assets/stylesheets/material-ui/components/toggle.less +83 -0
  123. data/vendor/assets/stylesheets/material-ui/components/toolbar.less +95 -0
  124. data/vendor/assets/stylesheets/material-ui/components/tooltip.less +73 -0
  125. data/vendor/assets/stylesheets/material-ui/components/transition-groups/slide-in.less +92 -0
  126. data/vendor/assets/stylesheets/material-ui/core/base.less +31 -0
  127. data/vendor/assets/stylesheets/material-ui/core/core.less +4 -0
  128. data/vendor/assets/stylesheets/material-ui/core/keylines.less +29 -0
  129. data/vendor/assets/stylesheets/material-ui/core/layouts.less +12 -0
  130. data/vendor/assets/stylesheets/material-ui/core/typography.less +158 -0
  131. data/vendor/assets/stylesheets/material-ui/mixins/clearfix.less +22 -0
  132. data/vendor/assets/stylesheets/material-ui/mixins/mixins.less +3 -0
  133. data/vendor/assets/stylesheets/material-ui/mixins/no-wrap.less +3 -0
  134. data/vendor/assets/stylesheets/material-ui/mixins/transitions.less +17 -0
  135. data/vendor/assets/stylesheets/material-ui/resets/normalize.css +430 -0
  136. data/vendor/assets/stylesheets/material-ui/resets/typography-resets.less +34 -0
  137. data/vendor/assets/stylesheets/material-ui/scaffolding.less +10 -0
  138. data/vendor/assets/stylesheets/material-ui/variables/colors.less +285 -0
  139. data/vendor/assets/stylesheets/material-ui/variables/custom-variables.less +163 -0
  140. data/vendor/assets/stylesheets/material-ui/variables/media-queries.less +4 -0
  141. data/vendor/assets/stylesheets/material-ui/variables/spacing.less +16 -0
  142. 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
+ &nbsp;
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;