nsn-comp
Version:
NSN核心组件
55 lines (49 loc) • 2.1 kB
JavaScript
import "antd/es/select/style";
import _Select from "antd/es/select";
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { NIcon, NLocale, NStr } from 'nsn-util';
import React from 'react';
var FormItemIconSelect = function FormItemIconSelect(props) {
var config = props.config,
dataIndex = props.item.dataIndex,
form = props.form,
defaultValue = props.defaultValue,
_props$showSearch = props.showSearch,
showSearch = _props$showSearch === void 0 ? true : _props$showSearch,
_props$allowClear = props.allowClear,
allowClear = _props$allowClear === void 0 ? true : _props$allowClear,
_props$style = props.style,
style = _props$style === void 0 ? {
width: '100%'
} : _props$style,
mode = props.mode,
_props$placeholder = props.placeholder,
placeholder = _props$placeholder === void 0 ? NLocale.getText('common.placeholder.select') : _props$placeholder;
return React.createElement(_Select, Object.assign({}, {
showSearch: showSearch,
allowClear: allowClear,
style: style,
mode: mode,
placeholder: placeholder
}, {
defaultValue: NStr.isTrimEmpty("".concat(defaultValue)) ? undefined : defaultValue,
optionFilterProp: "label",
optionLabelProp: "label",
onChange: function onChange(value) {
var _config$onChange;
if (dataIndex) {
form.setFieldsValue(_defineProperty({}, "".concat(dataIndex), value));
}
(_config$onChange = config.onChange) === null || _config$onChange === void 0 ? void 0 : _config$onChange.call(config, value);
},
value: NStr.isTrimEmpty(config.value) ? undefined : config.value
}), Object.keys(NIcon.ALL).map(function (key) {
var Icon = NIcon.ALL[key];
return React.createElement(_Select.Option, {
key: key,
value: key,
label: key
}, React.createElement(Icon, null), " ", key);
}));
};
export default FormItemIconSelect;