choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
78 lines (70 loc) • 2.6 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _createSuper from "@babel/runtime/helpers/createSuper";
import { __decorate } from "tslib";
import React, { Component } from 'react';
import { observer } from 'mobx-react';
import ObserverTextField from '../text-field/TextField';
import TextArea from '../text-area/TextArea';
import { IntlType } from './enum';
import Form from '../form/Form';
import localeContext from '../locale-context';
var IntlList = /*#__PURE__*/function (_Component) {
_inherits(IntlList, _Component);
var _super = _createSuper(IntlList);
function IntlList() {
_classCallCheck(this, IntlList);
return _super.apply(this, arguments);
}
_createClass(IntlList, [{
key: "renderOptions",
value: function renderOptions() {
var _this$props = this.props,
name = _this$props.name,
lang = _this$props.lang,
maxLengths = _this$props.maxLengths,
type = _this$props.type,
rows = _this$props.rows,
cols = _this$props.cols,
resize = _this$props.resize,
getConfig = _this$props.getConfig;
var supports = localeContext.supports;
var tlsKey = getConfig('tlsKey');
var FieldTag = type === IntlType.multipleLine ? TextArea : ObserverTextField;
var otherProps = type === IntlType.multipleLine ? {
rows: rows,
cols: cols,
resize: resize
} : {};
return Object.keys(supports).map(function (key) {
var maxLengthProps = maxLengths && maxLengths[key] ? {
maxLength: maxLengths[key]
} : {};
return /*#__PURE__*/React.createElement(FieldTag, _extends({}, maxLengthProps, {
name: name ? "".concat(tlsKey, ".").concat(name, ".").concat(key) : key,
autoFocus: key === lang,
key: key
}, otherProps));
});
}
}, {
key: "render",
value: function render() {
var _this$props2 = this.props,
record = _this$props2.record,
disabled = _this$props2.disabled,
readOnly = _this$props2.readOnly;
return /*#__PURE__*/React.createElement(Form, {
disabled: disabled,
readOnly: readOnly,
record: record
}, this.renderOptions());
}
}]);
return IntlList;
}(Component);
IntlList = __decorate([observer], IntlList);
export default IntlList;
//# sourceMappingURL=IntlList.js.map