choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
119 lines (104 loc) • 3.62 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 _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
function _createSuper(Derived) {
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
return function () {
var Super = _getPrototypeOf(Derived),
result;
if (isNativeReflectConstruct()) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
import { __decorate } from "tslib";
import React, { Component } from 'react';
import { observer } from 'mobx-react';
import PropTypes from 'prop-types';
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 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 React.createElement(Form, {
disabled: disabled,
readOnly: readOnly,
record: record
}, this.renderOptions());
}
}]);
return IntlList;
}(Component);
IntlList.propTypes = {
record: PropTypes.object,
name: PropTypes.string,
lang: PropTypes.string,
maxLengths: PropTypes.object
};
IntlList = __decorate([observer], IntlList);
export default IntlList;
//# sourceMappingURL=IntlList.js.map