react-form-fy
Version:
140 lines (113 loc) • 9.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require("react");
var _react2 = _interopRequireDefault(_react);
var _reactUiSvg = require("react-ui-svg");
var svg = _interopRequireWildcard(_reactUiSvg);
var _utilsFy = require("utils-fy");
var _publicStyle = require("./publicStyle");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* gufuyan
* @content 小icon组件
* @date 2017-04-30 1.0版本
* 2017-10-23 修改版 主题
* @param props
* @constructor
*/
var svgSize = 20;
var propTypes = {
svgType: _react.PropTypes.string.isRequired,
width: _react.PropTypes.number,
height: _react.PropTypes.number,
fill: _react.PropTypes.string,
//handleChange: PropTypes.func,
showBackAmi: _react.PropTypes.string
};
var IconBtn = function (_Component) {
_inherits(IconBtn, _Component);
function IconBtn(props) {
_classCallCheck(this, IconBtn);
var _this2 = _possibleConstructorReturn(this, (IconBtn.__proto__ || Object.getPrototypeOf(IconBtn)).call(this, props));
_this2.handleChange = function (value) {
var _this = _this2;
_this.setState({
amiback: _utilsFy.Obj.merge(_this.state.iconBtnSty.amibackMove, _this.props.width ? _this.state.amiboxzdy : _this.state.amiboxdef)
});
setTimeout(function () {
_this.setState({
amiback: _utilsFy.Obj.merge(_this.state.iconBtnSty.amibackDefault, _this.props.width ? _this.state.amiboxzdy : _this.state.amiboxdef)
});
}, 400);
//this.props.handleChange && this.props.handleChange(value);
};
_this2.state = {
iconBtnSty: eval("(" + JSON.stringify((0, _publicStyle.iconBtnStyles)(svgSize)) + ")"),
amiboxdef: {
width: svgSize / 2 / 16 + "rem", height: svgSize / 2 / 16 + "rem"
},
iconBoxdef: {
height: svgSize / 16 + "rem", width: svgSize / 16 + "rem"
},
amiboxzdy: {
width: svgSize / 2 / 16 + "rem", height: svgSize / 2 / 16 + "rem"
},
iconBoxzdy: {
height: svgSize / 16 + "rem", width: svgSize / 16 + "rem"
}
};
return _this2;
}
_createClass(IconBtn, [{
key: "componentWillMount",
value: function componentWillMount() {
this.setState({
amiback: _utilsFy.Obj.merge(this.state.iconBtnSty.amibackDefault, this.props.width ? this.state.amiboxzdy : this.state.amiboxdef)
});
if (this.props.width) {
this.setState({
iconBoxzdy: {
width: this.props.width / 16 + "rem",
height: this.props.width / 16 + "rem"
},
amiboxzdy: {
width: this.props.width / 2 / 16 + "rem",
height: this.props.width / 2 / 16 + "rem"
}
});
}
}
}, {
key: "render",
value: function render() {
var props = _objectWithoutProperties(this.props, []);
var SvgType = svg[props.svgType];
var widHig = this.props.width ? this.state.iconBoxzdy : this.state.iconBoxdef;
var a = _utilsFy.Obj.merge(this.state.iconBtnSty.iconBox, widHig);
var b = _utilsFy.Obj.merge(this.state.iconBtnSty.svgBox, widHig);
return _react2.default.createElement(
"div",
{ style: a, onClick: this.handleChange.bind(this, props.value || null) },
props.showBackAmi == 'no' ? null : _react2.default.createElement("div", { style: this.state.amiback }),
_react2.default.createElement(
"span",
{ style: b },
_react2.default.createElement(SvgType, { width: props.width ? props.width / 16 + 'rem' : svgSize / 16 + 'rem',
height: props.height ? props.height / 16 + 'rem' : svgSize / 16 + 'rem',
fill: props.fill || (props.themeObj ? props.themeObj.default : "rgb(0, 188, 212)") })
)
);
}
}]);
return IconBtn;
}(_react.Component);
IconBtn.propTypes = propTypes;
exports.default = IconBtn;
//# sourceMappingURL=iconBtn.js.map