1 | 'use strict';
|
2 |
|
3 | exports.__esModule = true;
|
4 |
|
5 | var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
6 |
|
7 | var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
8 |
|
9 | var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
10 |
|
11 | var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
12 |
|
13 | var _inherits2 = require('babel-runtime/helpers/inherits');
|
14 |
|
15 | var _inherits3 = _interopRequireDefault(_inherits2);
|
16 |
|
17 | var _react = require('react');
|
18 |
|
19 | var _react2 = _interopRequireDefault(_react);
|
20 |
|
21 | var _classnames = require('classnames');
|
22 |
|
23 | var _classnames2 = _interopRequireDefault(_classnames);
|
24 |
|
25 | var _util = require('../util');
|
26 |
|
27 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
28 |
|
29 | var makeChain = _util.func.makeChain;
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | var UIState = function (_Component) {
|
37 | (0, _inherits3.default)(UIState, _Component);
|
38 |
|
39 | function UIState(props) {
|
40 | (0, _classCallCheck3.default)(this, UIState);
|
41 |
|
42 | var _this = (0, _possibleConstructorReturn3.default)(this, _Component.call(this, props));
|
43 |
|
44 | _this.state = {};
|
45 | ['_onUIFocus', '_onUIBlur'].forEach(function (item) {
|
46 | _this[item] = _this[item].bind(_this);
|
47 | });
|
48 | return _this;
|
49 | }
|
50 |
|
51 |
|
52 |
|
53 | UIState.prototype.getStateElement = function getStateElement(base) {
|
54 | var _props = this.props,
|
55 | onFocus = _props.onFocus,
|
56 | onBlur = _props.onBlur;
|
57 |
|
58 | return _react2.default.cloneElement(base, {
|
59 | onFocus: makeChain(this._onUIFocus, onFocus),
|
60 | onBlur: makeChain(this._onUIBlur, onBlur)
|
61 | });
|
62 | };
|
63 |
|
64 |
|
65 |
|
66 | UIState.prototype.getStateClassName = function getStateClassName() {
|
67 | var focused = this.state.focused;
|
68 |
|
69 | return (0, _classnames2.default)({
|
70 | focused: focused
|
71 | });
|
72 | };
|
73 |
|
74 |
|
75 |
|
76 | UIState.prototype.resetUIState = function resetUIState() {
|
77 | this.setState({
|
78 | focused: false
|
79 | });
|
80 | };
|
81 |
|
82 | UIState.prototype._onUIFocus = function _onUIFocus() {
|
83 | this.setState({
|
84 | focused: true
|
85 | });
|
86 | };
|
87 |
|
88 | UIState.prototype._onUIBlur = function _onUIBlur() {
|
89 | this.setState({
|
90 | focused: false
|
91 | });
|
92 | };
|
93 |
|
94 | return UIState;
|
95 | }(_react.Component);
|
96 |
|
97 | UIState.displayName = 'UIState';
|
98 | exports.default = UIState;
|
99 | module.exports = exports['default']; |
\ | No newline at end of file |