UNPKG

@schema-render/search-table-react

Version:
89 lines (88 loc) 2.48 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { createElement as _createElement } from "react"; import { utils } from "@schema-render/core-react"; import { Rate, Switch, Tag } from "antd"; import ImagesPreview from "../components/ImagesPreview"; import { STYLE_CODE } from "../constants/style"; import { isEmpty } from "../utils/common"; import CommaNumber from "./CommaNumber"; import LongText from "./LongText"; import LongTextModal from "./LongTextModal"; const { isArray } = utils; export const BUILT_IN_VALUE_TYPES = { /** * 代码块 */ code: ({ value, options })=>{ return /*#__PURE__*/ _jsx("pre", { style: { ...STYLE_CODE, ...options.style }, children: /*#__PURE__*/ _jsx("code", { children: value }) }); }, /** * 百分比 */ percent: ({ value })=>isEmpty(value) ? '-' : `${value}%`, /** * 状态开关 */ switch: ({ value, options })=>/*#__PURE__*/ _jsx(Switch, { ...options, checked: !!value }), /** * 标签 */ tags: ({ value, options })=>{ const data = isArray(value) ? value : [ value ]; return data.map((text, i)=>/*#__PURE__*/ _createElement(Tag, { ...options, key: i }, text)); }, /** * 评分 */ rate: ({ value, options })=>/*#__PURE__*/ _jsx(Rate, { style: { width: 134 }, ...options, disabled: true, value: value }), /** * 数字千分位 */ 'comma-number': (props)=>/*#__PURE__*/ _jsx(CommaNumber, { ...props }), /** * 图片显示 */ images: ({ value, options })=>{ // 排除空数据 if (isEmpty(value)) { return '-'; } const imgList = isArray(value) ? value : [ value ]; const { groupProps, ...imgProps } = options; return /*#__PURE__*/ _jsx(ImagesPreview, { imgList: imgList, imgProps: imgProps, groupProps: groupProps }); }, /** * 长文案 Tooltips 方式显示 */ 'long-text': (props)=>/*#__PURE__*/ _jsx(LongText, { ...props }), /** * 长文案点击弹窗方式显示 */ 'long-text-modal': (props)=>/*#__PURE__*/ _jsx(LongTextModal, { ...props }) };