ming-demo3
Version:
mdf metaui web
92 lines (72 loc) • 2.72 kB
JavaScript
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = _interopRequireWildcard(require("react"));
var _baseui = require("@mdf/baseui");
var _richtext = _interopRequireDefault(require("../basic/richtext"));
var BasicComponents = {
RichText: _richtext["default"]
};
var BasicTest = function (_Component) {
(0, _inherits2["default"])(BasicTest, _Component);
function BasicTest(props) {
var _this;
(0, _classCallCheck2["default"])(this, BasicTest);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(BasicTest).call(this, props));
_this.state = {
checked: true
};
return _this;
}
(0, _createClass2["default"])(BasicTest, [{
key: "componentDidMount",
value: function componentDidMount() {
this.setState({
viewModel: cb.loader.initMetaCommonViewModel('TestViewModel', 'testViewModel')
});
}
}, {
key: "onChange",
value: function onChange(checked) {
this.setState({
checked: checked
});
this.state.viewModel.setReadOnly(!checked);
}
}, {
key: "render",
value: function render() {
var _this2 = this;
if (!this.state.viewModel) return null;
var children = [],
BasicComponent,
model;
children.push(_react["default"].createElement(_baseui.Switch, {
defaultChecked: this.state.checked,
onChange: function onChange(checked) {
return _this2.onChange(checked);
}
}));
for (var attr in BasicComponents) {
BasicComponent = BasicComponents[attr];
model = this.state.viewModel.get(attr.trim().toLocaleLowerCase());
children.push(_react["default"].createElement(BasicComponent, {
model: model
}));
}
return _react["default"].createElement("div", null, children);
}
}]);
return BasicTest;
}(_react.Component);
exports["default"] = BasicTest;
//# sourceMappingURL=index.js.map
;