import {designComponent, getComponentCls, PropType, useClasses} from "@peryl/react-compose"; import './paragraph.scss'; import {ParagraphItem} from "../ParagraphItem"; import {i18n} from "../i18n"; export const Paragraph = designComponent({ name: 'paragraph', props: { order: { type: Boolean }, list: { type: [String, Array] as PropType }, }, slots: ['default'], setup({ props, slots }) { const classes = useClasses(() => [ getComponentCls('paragraph') ]); return () => { const Type = props.order ? 'ol' : 'ul'; return ( {slots.default()} {!!props.list?.length && (() => { let arr: string[] = []; if (typeof props.list === "string") { const i18nResult = i18n.$intl(props.list).d(props.list); if (Array.isArray(i18nResult)) { arr.push(...i18nResult); } else { arr.push(i18nResult); } } else { arr.push(...props.list); } return arr.map((item, index) => ( {item} )); })()} ); }; }, }); export default Paragraph;