acud
Version:
acg react 组件库
55 lines • 2.55 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _extends from "@babel/runtime/helpers/esm/extends";
var __rest = this && this.__rest || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
import * as React from 'react';
import Tag from './';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider';
var TagList = function TagList(_a) {
var customizePrefixCls = _a.prefixCls,
_a$type = _a.type,
type = _a$type === void 0 ? '' : _a$type,
_a$tagDatas = _a.tagDatas,
tagDatas = _a$tagDatas === void 0 ? [] : _a$tagDatas,
className = _a.className,
restProps = __rest(_a, ["prefixCls", "type", "tagDatas", "className"]);
var _React$useContext = React.useContext(ConfigContext),
getPrefixCls = _React$useContext.getPrefixCls;
var prefixCls = getPrefixCls('tag-list', customizePrefixCls);
var showBorder = type === 'outline';
var showEnhance = type === 'enhance';
return /*#__PURE__*/React.createElement(React.Fragment, null, tagDatas.map(function (item, index) {
var color = item.color,
bgColor = item.bgColor,
bColor = item.border,
_item$icon = item.icon,
iconDom = _item$icon === void 0 ? null : _item$icon,
text = item.text;
var tagStyle = _extends(_extends(_extends({}, color ? {
color: color
} : {}), bgColor ? {
backgroundColor: bgColor
} : {}), bColor ? {
border: "1px solid ".concat(bColor)
} : {});
var i = index % 10;
var isBorder = showBorder && !bColor;
return /*#__PURE__*/React.createElement(Tag, _extends({
key: index
}, type ? {
type: type
} : {}, {
style: tagStyle,
className: classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-order-color-").concat(i + 1), !showEnhance && !color), "".concat(prefixCls, "-order-bg-color-").concat(i + 1), !showEnhance && !bgColor), "".concat(prefixCls, "-order-bg-color-").concat(i + 1, "-enhance"), showEnhance && !bgColor), "".concat(prefixCls, "-order-border-color-").concat(i + 1), isBorder), className),
icon: iconDom
}, restProps), text);
}));
};
export default TagList;