UNPKG

mobile-more

Version:

基于 antd-mobile v5 扩展移动端 UI 组件

44 lines 1.86 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _excluded = ["placeholder", "separator", "options", "value", "fieldNames", "renderCurrentValue"]; import { TextArea } from 'antd-mobile'; import React from 'react'; import BizCheckListPopup from "../../BizCheckListPopup"; var SuperCheckList = function SuperCheckList(_ref) { var placeholder = _ref.placeholder, _ref$separator = _ref.separator, separator = _ref$separator === void 0 ? ', ' : _ref$separator, _ref$options = _ref.options, options = _ref$options === void 0 ? [] : _ref$options, value = _ref.value, fieldNames = _ref.fieldNames, renderCurrentValue = _ref.renderCurrentValue, restProps = _objectWithoutProperties(_ref, _excluded); var _label$value$fieldNam = _objectSpread({ label: 'label', value: 'value' }, fieldNames), labelKey = _label$value$fieldNam.label, valueKey = _label$value$fieldNam.value; var items = options.filter(function (item) { return value === null || value === void 0 ? void 0 : value.includes(item[valueKey]); }); var valueStr = typeof renderCurrentValue === 'function' ? renderCurrentValue(value, items) : items.filter(function (item) { return !!item; }).map(function (item) { return item[labelKey]; }).join(separator); return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextArea, { readOnly: true, value: valueStr, placeholder: placeholder, rows: 1, autoSize: true }), /*#__PURE__*/React.createElement(BizCheckListPopup, _extends({ value: value, options: options, fieldNames: fieldNames }, restProps))); }; export default SuperCheckList;