UNPKG

ming-demo3

Version:
998 lines (907 loc) 36.7 kB
"use strict"; 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 _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); 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 _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _react = _interopRequireWildcard(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _antd = require("antd"); var _FormInputControl = _interopRequireDefault(require("./FormInputControl.js")); var _modal = _interopRequireDefault(require("./modal.js")); var _SvgIcon = _interopRequireDefault(require("@mdf/metaui-web/lib/components/common/SvgIcon")); function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } process.env.__CLIENT__ && require("./index.css"); var FormItem = _antd.Form.Item; var propTypes = { className: _propTypes["default"].string, status: _propTypes["default"].string, onOk: _propTypes["default"].func, onCancel: _propTypes["default"].func, locale: _propTypes["default"].string.isRequired, localeList: _propTypes["default"].object.isRequired, onChange: _propTypes["default"].func, isTextarea: _propTypes["default"].bool, modalLocale: _propTypes["default"].object, backdrop: _propTypes["default"].bool, required: _propTypes["default"].bool, isPopConfirm: _propTypes["default"].bool, showIcon: _propTypes["default"].bool }; var defaultProps = { classnames: '', status: 'preview', isTextarea: false, backdrop: true, required: false, isPopConfirm: false, showIcon: true }; var AC_DEFAULT_SYSLOCALE = 'zh_CN'; var AC_DEFAULT_LOCALE = 'zh_CN'; var AC_DEFAULT_LOCALELIST = { "zh_CN": "", "en_US": "", "zh_TW": "", "fr_FR": "" }; var getContent = function getContent(localeList, modalLocale, locale) { return Object.keys(localeList).map(function (localeKey) { return _react["default"].createElement(_antd.Row, { key: 'preview' + localeKey, className: "input-locale-text" }, _react["default"].createElement("div", { className: "input-locale-text-r" }, modalLocale['label'][localeKey], ":"), _react["default"].createElement("div", { className: "input-locale-text-l" }, localeList[localeKey])); }); }; var AcInputLocale = function (_Component) { (0, _inherits2["default"])(AcInputLocale, _Component); function AcInputLocale(props) { var _this; (0, _classCallCheck2["default"])(this, AcInputLocale); _this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(AcInputLocale).call(this, props)); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMouseEnterIcon", function () { _this.isMouseEnterIcon = true; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMouseLeaveIcon", function () { _this.isMouseEnterIcon = false; }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onClose", function () { var isPopConfirm = _this.state.isPopConfirm; _this.isMouseEnterIcon = false; _this.state.isPopConfirm ? _this.setState({ showPop: false, focused: true }) : _this.setState({ showModal: false, focused: true }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "open", function (event) { event.stopPropagation(); var _this$props = _this.props, status = _this$props.status, localeList = _this$props.localeList; if (status === 'preview') { return; } _this.isMouseEnterIcon = true; _this.state.isPopConfirm ? _this.setState({ showPop: true, focused: false }) : _this.setState({ showModal: true, focused: false }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onOk", function () { var _this$state = _this.state, localeList = _this$state.localeList, _localeList = _this$state._localeList, locale = _this$state.locale, required = _this$state.required; var inputId = _this.props.inputId; var validatedArray = []; var fireChange = false; Object.keys(_localeList).forEach(function (localeKey) { validatedArray.push(inputId + "_" + localeKey); if (localeList[localeKey] != _localeList[localeKey]) { localeList[localeKey] = _localeList[localeKey]; fireChange = true; } }); fireChange && _this.onChange(_localeList[locale], _localeList); if (required) { var obj = {}; obj[_this.props.inputId] = _localeList[locale]; _this.props.form.validateFields(validatedArray, function (err, values) { if (err) { console.log('validate failed', values); return; } else { _this.props.form.setFieldsValue(obj); _this.props.onOk && _this.props.onOk(_localeList); _this.onClose(); } }); } else { _this.props.onOk && _this.props.onOk(_localeList); _this.onClose(); } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCancel", function () { var _localeList = JSON.parse(JSON.stringify(_this.state.localeList)); _this.setState({ _localeList: _localeList }); _this.onClose(); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "stringTrim", function (str) { return str.replace(/^\s+|\s+$/gm, ''); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "checkValidValue", function (rule, value, callback) { var self = (0, _assertThisInitialized2["default"])(_this); var _self$state = self.state, required = _self$state.required, localeList = _self$state.localeList, locale = _self$state.locale, sysLocale = _self$state.sysLocale; var currentLanguage = self.state.modalLocale ? self.state.modalLocale.currentLang : "当前语种"; var defaultLanguage = self.state.modalLocale ? self.state.modalLocale.defaultLang : "默认语种"; var errMessage = self.state.modalLocale ? self.state.modalLocale.errorMsg : "不能为空"; if (required) { if (!self.stringTrim(localeList[locale])) { callback(currentLanguage + " " + errMessage); } if (!self.stringTrim(localeList[sysLocale])) { callback(defaultLanguage + " " + errMessage); } } callback(); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "renderLabelLeft", function (localeKey) { var _this$state2 = _this.state, localeValue = _this$state2.localeValue, locale = _this$state2.locale, localeList = _this$state2.localeList, status = _this$state2.status, modalLocale = _this$state2.modalLocale, sysLocale = _this$state2.sysLocale; if (locale === sysLocale) { if (localeKey === locale) { return _react["default"].createElement("span", { className: "label-default" }, "(", modalLocale.localeFlag + "/" + modalLocale.defaultFlag, ")"); } } else { if (localeKey === locale) { return _react["default"].createElement("span", { className: "label-default" }, "(", modalLocale.localeFlag, ")"); } if (localeKey === sysLocale) { return _react["default"].createElement("span", { className: "label-default" }, "(", modalLocale.defaultFlag, ")"); } } }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "renderLabelright", function (localeKey) { var _this$state3 = _this.state, localeValue = _this$state3.localeValue, locale = _this$state3.locale, localeList = _this$state3.localeList, status = _this$state3.status, modalLocale = _this$state3.modalLocale, sysLocale = _this$state3.sysLocale, required = _this$state3.required; if (required) { if (locale == sysLocale) { if (localeKey == locale) { return _react["default"].createElement("span", { className: "require-star uf uf-mi" }, " *"); } } else { if (localeKey == locale || localeKey == sysLocale) { return _react["default"].createElement("span", { className: "require-star uf uf-mi" }, " *"); } } } return _react["default"].createElement("span", { className: "require-star" }); }); (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "forceSyncChange", function (localeList, value) { var _this$props2 = _this.props, inputId = _this$props2.inputId, form = _this$props2.form; Object.keys(localeList).forEach(function (item) { localeList[item] = value; if (form) { var setFieldsValue = form.setFieldsValue; var key = "".concat(inputId, "_").concat(item); var obj = {}; obj[key] = value; setFieldsValue(obj); } }); return localeList; }); var _locale = props.locale, _localeList2 = props.localeList, _status = props.status, _modalLocale = props.modalLocale, _sysLocale = props.sysLocale, _required = props.required, isPopConfirm = props.isPopConfirm, focus = props.focus; _sysLocale = _sysLocale || AC_DEFAULT_SYSLOCALE; _locale = _locale || _sysLocale; if (_localeList2) { _localeList2 = _objectSpread({}, _this.getDefaultLocalList(), {}, _localeList2); } else { _localeList2 = _objectSpread({}, _this.getDefaultLocalList()); } var localeValue = _localeList2[_locale]; var modalLocaleTmp = Object.assign({}, { 'title': '多语言设置', 'okName': '保存', 'cancelName': '取消', 'localeFlag': '当前', 'defaultFlag': '默认', 'placeholder': '请输入...', 'errorMsg': '不能为空', 'currentLang': '当前语种', 'defaultLang': '默认语种', 'label': { "zh_CN": "简体中文", "en_US": "英文", "zh_TW": "繁体中文", "fr_FR": "法语", "de_DE": "德语", "ja_JP": "日语", "ko_KR": "韩语", "ru_RU": "俄语", "it_IT": "意大利语", "pt_PT": "葡萄牙语" } }, _modalLocale); _this.state = { localeList: JSON.parse(JSON.stringify(_localeList2)), _localeList: JSON.parse(JSON.stringify(_localeList2)), localeValue: localeValue, sysLocale: _sysLocale, locale: _locale, status: _status, required: _required, showModal: false, showPop: false, isPopConfirm: isPopConfirm, modalLocale: modalLocaleTmp, focused: _this.props.focus ? true : false, gct: { a: 1, b: 'test' } }; _this.isMouseEnterIcon = false; _this.onClose = _this.onClose.bind((0, _assertThisInitialized2["default"])(_this)); _this.open = _this.open.bind((0, _assertThisInitialized2["default"])(_this)); _this.onOk = _this.onOk.bind((0, _assertThisInitialized2["default"])(_this)); _this.onCancel = _this.onCancel.bind((0, _assertThisInitialized2["default"])(_this)); _this.onBlur = _this.onBlur.bind((0, _assertThisInitialized2["default"])(_this)); _this.onFocus = _this.onFocus.bind((0, _assertThisInitialized2["default"])(_this)); _this.onMouseEnterIcon = _this.onMouseEnterIcon.bind((0, _assertThisInitialized2["default"])(_this)); _this.onMouseLeaveIcon = _this.onMouseLeaveIcon.bind((0, _assertThisInitialized2["default"])(_this)); return _this; } (0, _createClass2["default"])(AcInputLocale, [{ key: "componentDidMount", value: function componentDidMount() {} }, { key: "componentWillReceiveProps", value: function componentWillReceiveProps(nextProps) { if (this.props.localeList !== nextProps.localeList) { var locale = nextProps.locale, localeList = nextProps.localeList; locale = locale || this.state.sysLocale; if (localeList) { localeList = _objectSpread({}, this.getDefaultLocalList(), {}, localeList); } else { localeList = _objectSpread({}, this.getDefaultLocalList()); } var localeValue = localeList[locale]; this.setState({ localeList: localeList, _localeList: JSON.parse(JSON.stringify(localeList)), localeValue: localeValue, locale: locale }); } if (nextProps.locale !== this.props.locale && nextProps.localeList === this.props.localeList) { var _locale2 = nextProps.locale, sysLocale = nextProps.sysLocale; if (!_locale2) { _locale2 = sysLocale || 'zh_CN'; } var _localeValue = ''; Object.keys(nextProps.localeList).forEach(function (localeKey) { if (localeKey === _locale2) { _localeValue = nextProps.localeList[localeKey]; } }); this.setState({ locale: _locale2, localeValue: _localeValue }); } if (nextProps.status !== this.props.status) { this.setState({ status: nextProps.status }); } } }, { key: "getDefaultLocalList", value: function getDefaultLocalList() { return AC_DEFAULT_LOCALELIST; } }, { key: "getPreviewElement", value: function getPreviewElement(localeValue, defaultValue, localeList, modalLocale, locale) { return _react["default"].createElement("div", null, _react["default"].createElement(_FormInputControl["default"], { readOnly: true, value: localeValue || defaultValue }), this.props.showIcon ? _react["default"].createElement(_antd.Popover, { placement: "right", content: getContent(localeList, modalLocale, locale), trigger: "hover", id: "right" }, _react["default"].createElement("i", { className: "uf uf-globe input-icon" })) : ''); } }, { key: "getLocaleNoFormElement", value: function getLocaleNoFormElement(localeList, modalLocale, locale) { var _this2 = this; return Object.keys(localeList).map(function (localeKey) { return _react["default"].createElement("div", { className: "edit-panel edit-panel-all", key: localeKey }, _react["default"].createElement(FormItem, null, _react["default"].createElement("div", { className: "u-form-item-label" }, _react["default"].createElement("label", { className: "u-label", title: modalLocale['label'][localeKey] }, _this2.isShowNoneLeftLable ? _this2.renderLabelLeft(localeKey) : null, modalLocale['label'][localeKey], _this2.renderLabelright(localeKey))), _react["default"].createElement("div", { style: { 'display': 'inline-block', 'width': 'calc(100% - 150px)' } }, _react["default"].createElement(_FormInputControl["default"], { value: localeList[localeKey], placeholder: modalLocale.placeholder, onChange: function onChange(v) { var _localeList = _this2.state._localeList; _localeList[localeKey] = v; _this2.setState({ _localeList: _localeList }); } })))); }); } }, { key: "getLocaleFormElement", value: function getLocaleFormElement(localeList, modalLocale, locale, sysLocale, getFieldProps, getFieldError) { var _this3 = this; return Object.keys(localeList).map(function (localeKey) { return _react["default"].createElement("div", { className: "edit-panel edit-panel-all", key: localeKey }, _react["default"].createElement(FormItem, null, _react["default"].createElement("div", { className: "u-form-item-label" }, _react["default"].createElement("label", { className: "u-label", title: modalLocale['label'][localeKey] }, _this3.isShowNoneLeftLable ? _this3.renderLabelLeft(localeKey) : null, modalLocale['label'][localeKey], _this3.renderLabelright(localeKey))), _react["default"].createElement("div", { style: { 'display': 'inline-block', 'width': 'calc(100% - 150px)' } }, _react["default"].createElement("div", null, _react["default"].createElement(_FormInputControl["default"], (0, _extends2["default"])({ placeholder: modalLocale.placeholder }, getFieldProps(_this3.props.inputId + "_" + localeKey, { validateTrigger: 'onBlur', initialValue: localeList[localeKey], getValueProps: function getValueProps(value) { return { value: localeList[localeKey] }; }, rules: [{ required: localeKey == locale || localeKey == sysLocale ? true : false, message: modalLocale["errorMsg"] }], onChange: function onChange(v) { var _localeList = _this3.state._localeList; _localeList[localeKey] = v; _this3.setState({ _localeList: _localeList }); } }), { onClick: function onClick(e) { e.stopPropagation(); } })), _this3.props.showIcon ? _react["default"].createElement("div", { className: "input-icon", onClick: _this3.open }) : '')))); }); } }, { key: "equalLang", value: function equalLang(obj1, obj2) { var _equal = function _equal(obj1, obj2) { try { for (var key in obj1) { if (obj1[key] != obj2[key]) { return false; } } } catch (e) { return false; } return true; }; return _equal(obj1, obj2) && _equal(obj2, obj1); } }, { key: "onChange", value: function onChange(localeValue, localeList) { localeList[this.state.locale] = localeValue; if (this.props.forceSync) localeList = this.forceSyncChange(localeList, localeValue); this.props.onChange && this.props.onChange(localeValue, localeList); this.setState({ localeValue: localeValue, localeList: localeList }); } }, { key: "onBlur", value: function onBlur(localeValue, localeList) { localeList[this.state.locale] = localeValue; if (!this.isMouseEnterIcon) { this.props.onBlur && this.props.onBlur(localeValue, localeList); this.setState({ focused: false }); } } }, { key: "onFocus", value: function onFocus(e) { var target = e.target; this.props.onFocus && this.props.onFocus(); this.setState({ focused: true }); } }, { key: "_renderModalInputLocal", value: function _renderModalInputLocal() { var _this4 = this; var self = this; var _this$props3 = this.props, className = _this$props3.className, isTextarea = _this$props3.isTextarea, backdrop = _this$props3.backdrop, disabled = _this$props3.disabled, forceSync = _this$props3.forceSync, onChange = _this$props3.onChange, onBlur = _this$props3.onBlur; var _this$state4 = this.state, localeValue = _this$state4.localeValue, locale = _this$state4.locale, localeList = _this$state4.localeList, _localeList = _this$state4._localeList, status = _this$state4.status, modalLocale = _this$state4.modalLocale, sysLocale = _this$state4.sysLocale, required = _this$state4.required, isPopConfirm = _this$state4.isPopConfirm; var defaultValue; if (localeList && localeList[sysLocale]) { defaultValue = localeList[sysLocale]; } var formControlTypeOption = {}; isTextarea ? formControlTypeOption = { componentClass: 'textarea' } : null; var selfProps = {}; if (this.state.focused) { selfProps['focus'] = true; } var getFieldProps, getFieldError; return _react["default"].createElement("div", { className: "ac-input-locale ".concat(className ? className : null) }, status === 'preview' ? this.getPreviewElement(localeValue, defaultValue, localeList, modalLocale, locale) : _react["default"].createElement("div", null, _react["default"].createElement(_FormInputControl["default"], (0, _extends2["default"])({}, selfProps, { className: "input-text", value: localeValue }, formControlTypeOption, { onChange: function onChange(value) { localeList[locale] = value; if (forceSync) localeList = self.forceSyncChange(localeList, value); self.onChange && self.onChange(value, localeList); if (!_this4.equalLang(localeList, _this4.state.localeList)) { _this4.setState({ localeValue: value, localeList: localeList }); } }, onBlur: function onBlur(value) { if (_this4.isMouseEnterIcon) return; localeList[locale] = value; if (forceSync) { localeList = self.forceSyncChange(localeList, value); } self.onBlur && self.onBlur(value, localeList); if (!_this4.equalLang(localeList, _this4.state.localeList)) { _this4.setState({ localeValue: value, localeList: localeList }); } }, onFocus: function onFocus(e) { return self.onFocus(e); }, onClick: function onClick(e) { e.stopPropagation(); }, ref: function ref(input) { _this4.textInput = input; } })), this.props.showIcon ? _react["default"].createElement("div", { className: "input-icon", onClick: disabled ? function () {} : this.open, onMouseEnter: this.onMouseEnterIcon, onMouseLeave: this.onMouseLeaveIcon }, _react["default"].createElement(_SvgIcon["default"], { type: "yingwen" })) : ''), _react["default"].createElement(_modal["default"], { title: modalLocale.title, showModal: this.state.showModal, backdrop: backdrop, cancelName: modalLocale.cancelName, onOk: this.onOk, onCancel: this.onCancel, okName: modalLocale.okName, close: this.onClose }, this.getLocaleNoFormElement(_localeList, modalLocale, locale))); } }, { key: "_renderModalRequireInputLocal", value: function _renderModalRequireInputLocal() { var _this5 = this; var self = this; var _this$props4 = this.props, className = _this$props4.className, isTextarea = _this$props4.isTextarea, backdrop = _this$props4.backdrop, disabled = _this$props4.disabled, forceSync = _this$props4.forceSync, onChange = _this$props4.onChange, onBlur = _this$props4.onBlur; var _this$state5 = this.state, localeValue = _this$state5.localeValue, locale = _this$state5.locale, localeList = _this$state5.localeList, _localeList = _this$state5._localeList, status = _this$state5.status, modalLocale = _this$state5.modalLocale, sysLocale = _this$state5.sysLocale, required = _this$state5.required, isPopConfirm = _this$state5.isPopConfirm; var defaultValue; if (localeList && localeList[sysLocale]) { defaultValue = localeList[sysLocale]; } var formControlTypeOption = {}; isTextarea ? formControlTypeOption = { componentClass: 'textarea' } : null; var selfProps = {}; if (this.state.focused) { selfProps['focus'] = true; } var getFieldProps = this.props.form.getFieldProps; var getFieldError = this.props.form.getFieldError; return _react["default"].createElement("div", { className: "ac-input-locale ".concat(className ? className : null) }, status === 'preview' ? this.getPreviewElement(localeValue, defaultValue, localeList, modalLocale, locale) : _react["default"].createElement("div", null, _react["default"].createElement(_FormInputControl["default"], (0, _extends2["default"])({}, selfProps, { className: "input-text", disabled: disabled }, formControlTypeOption, getFieldProps(this.props.inputId, { getValueProps: function getValueProps(value) { return { value: localeValue }; }, initialValue: localeValue }), { onChange: function onChange(value) { localeList[locale] = value; if (forceSync) localeList = self.forceSyncChange(localeList, value); self.onChange && self.onChange(value, localeList); if (!_this5.equalLang(localeList, _this5.state.localeList)) { _this5.setState({ localeValue: value, localeList: localeList }); } }, onBlur: function onBlur(value) { if (_this5.isMouseEnterIcon) return; localeList[locale] = value; if (forceSync) { localeList = self.forceSyncChange(localeList, value); } self.onBlur && self.onBlur(value, localeList); if (!_this5.equalLang(localeList, _this5.state.localeList)) { _this5.setState({ localeValue: value, localeList: localeList }); } }, onFocus: function onFocus(e) { return self.onFocus(e); }, onClick: function onClick(e) { e.stopPropagation(); }, ref: function ref(input) { _this5.textInput = input; } })), this.props.showIcon ? _react["default"].createElement("div", { className: "input-icon", onClick: disabled ? function () {} : this.open, onMouseEnter: this.onMouseEnterIcon, onMouseLeave: this.onMouseLeaveIcon }, _react["default"].createElement(_SvgIcon["default"], { type: "yingwen" }), " ") : '', getFieldError(this.props.inputId) ? _react["default"].createElement("span", { className: "error uf uf-exc-t" }, getFieldError(this.props.inputId)) : ''), _react["default"].createElement(_modal["default"], { title: modalLocale.title, showModal: this.state.showModal, backdrop: backdrop, cancelName: modalLocale.cancelName, onOk: this.onOk, onCancel: this.onCancel, okName: modalLocale.okName, close: this.onClose }, this.getLocaleFormElement(_localeList, modalLocale, locale, sysLocale, getFieldProps, getFieldError))); } }, { key: "_renderPopconfirmRequireInputLocal", value: function _renderPopconfirmRequireInputLocal() { var _this6 = this; var self = this; var _this$props5 = this.props, className = _this$props5.className, isTextarea = _this$props5.isTextarea, backdrop = _this$props5.backdrop, disabled = _this$props5.disabled, forceSync = _this$props5.forceSync, onChange = _this$props5.onChange, onBlur = _this$props5.onBlur; var _this$state6 = this.state, localeValue = _this$state6.localeValue, locale = _this$state6.locale, localeList = _this$state6.localeList, _localeList = _this$state6._localeList, status = _this$state6.status, modalLocale = _this$state6.modalLocale, sysLocale = _this$state6.sysLocale, required = _this$state6.required, isPopConfirm = _this$state6.isPopConfirm; var defaultValue; if (localeList && localeList[sysLocale]) { defaultValue = localeList[sysLocale]; } var formControlTypeOption = {}; isTextarea ? formControlTypeOption = { componentClass: 'textarea' } : null; var getFieldProps, getFieldError; return _react["default"].createElement("div", { className: "ac-input-locale ".concat(className ? className : null) }, status === 'preview' ? this.getPreviewElement(localeValue, defaultValue, localeList, modalLocale, locale) : _react["default"].createElement("div", null, _react["default"].createElement(_FormInputControl["default"], (0, _extends2["default"])({ className: "input-text", disabled: disabled }, formControlTypeOption, getFieldProps(this.props.inputId, { validateTrigger: 'onBlur', rules: [{ validator: this.checkValidValue }], getValueProps: function getValueProps(value) { return { value: localeValue }; }, initialValue: localeValue, onChange: function onChange(curValue) { _this6.onChange(curValue, localeList); }, onBlur: function onBlur(curValue) { Object.keys(localeList).forEach(function (localeKey) { if (localeKey === locale) { localeList[localeKey] = curValue; } }); if (forceSync) { localeList = self.forceSyncChange(localeList, curValue); } self.onBlur && self.onBlur(localeList, curValue); if (!_this6.equalLang(localeList, _this6.state.localeList)) { _this6.setState({ localeValue: curValue, localeList: localeList }); } } }), { onClick: function onClick(e) { e.stopPropagation(); }, ref: function ref(input) { _this6.textInput = input; } })), _react["default"].createElement(_antd.Popconfirm, { placement: "right", okText: modalLocale.okName, cancelText: modalLocale.cancelName, overlayClassName: "ac-input-locale-popconfirm", onConfirm: this.onOk, onCancel: this.onClose, icon: "", visible: this.state.showPop, onClick: this.open, title: this.getLocaleFormElement(localeList, modalLocale, locale, sysLocale, getFieldProps, getFieldError) }, _react["default"].createElement("div", { className: "input-pop-icon" }, _react["default"].createElement(_SvgIcon["default"], { type: "yingwen" }))))); } }, { key: "_renderPopconfirmInputLocal", value: function _renderPopconfirmInputLocal() { var _this7 = this; var self = this; var _this$props6 = this.props, className = _this$props6.className, isTextarea = _this$props6.isTextarea, backdrop = _this$props6.backdrop, disabled = _this$props6.disabled, forceSync = _this$props6.forceSync, _onChange = _this$props6.onChange, onBlur = _this$props6.onBlur; var _this$state7 = this.state, localeValue = _this$state7.localeValue, locale = _this$state7.locale, localeList = _this$state7.localeList, status = _this$state7.status, modalLocale = _this$state7.modalLocale, sysLocale = _this$state7.sysLocale, required = _this$state7.required, isPopConfirm = _this$state7.isPopConfirm; var defaultValue; if (localeList && localeList[sysLocale]) { defaultValue = localeList[sysLocale]; } var formControlTypeOption = {}; isTextarea ? formControlTypeOption = { componentClass: 'textarea' } : null; var getFieldProps, getFieldError; return _react["default"].createElement("div", { className: "ac-input-locale ".concat(className ? className : null) }, status === 'preview' ? this.getPreviewElement(localeValue, defaultValue, localeList, modalLocale, locale) : _react["default"].createElement("div", null, _react["default"].createElement(_FormInputControl["default"], (0, _extends2["default"])({ className: "input-text", value: localeValue }, formControlTypeOption, { onChange: function onChange(value) { localeList[locale] = value; if (forceSync) localeList = self.forceSyncChange(localeList, value); _onChange && _onChange(value, localeList); _this7.setState({ localeValue: value, localeList: localeList }); }, onBlur: function onBlur(value) { localeList[locale] = value; if (forceSync) { localeList = self.forceSyncChange(localeList, value); } self.onBlur && self.onBlur(value, localeList); if (!_this7.equalLang(localeList, _this7.state.localeList)) { _this7.setState({ localeValue: value, localeList: localeList }); } }, onClick: function onClick(e) { e.stopPropagation(); }, ref: function ref(input) { _this7.textInput = input; } })), _react["default"].createElement(_antd.Popconfirm, { okText: modalLocale.okName, cancelText: modalLocale.cancelName, overlayClassName: "ac-input-locale-popconfirm", onConfirm: this.onOk, onCancel: this.onClose, icon: "", visible: this.state.showPop, onClick: this.open, title: this.getLocaleNoFormElement(localeList, modalLocale, locale) }, _react["default"].createElement("div", { className: "input-pop-icon" }, _react["default"].createElement(_SvgIcon["default"], { type: "yingwen" }))))); } }, { key: "render", value: function render() { var _this$state8 = this.state, required = _this$state8.required, isPopConfirm = _this$state8.isPopConfirm; if (required) { if (isPopConfirm) { return this._renderPopconfirmRequireInputLocal(); } else { return this._renderModalRequireInputLocal(); } } else { if (isPopConfirm) { return this._renderPopconfirmInputLocal(); } else { return this._renderModalInputLocal(); } } } }]); return AcInputLocale; }(_react.Component); AcInputLocale.propTypes = propTypes; AcInputLocale.defaultProps = defaultProps; AcInputLocale = _antd.Form.create({})(AcInputLocale); var _default = AcInputLocale; exports["default"] = _default; //# sourceMappingURL=index.js.map