UNPKG

ideaz-element

Version:

<p align="center"> <a href="" target="_blank" rel="noopener noreferrer"> <img src="./docs/public/logo.svg" alt="Ideaz Element" width="180" style="width: 180px;" /> </a> </p>

1 lines 3.5 kB
{"version":3,"file":"index.mjs","sources":["../../../../../packages/element/descriptions/src/index.tsx"],"sourcesContent":["import type { Slot } from 'vue'\nimport { mergeProps } from 'vue'\nimport { reactiveOmit } from '@vueuse/core'\nimport { ElDescriptions, ElDescriptionsItem } from 'element-plus'\nimport { getContentByRenderAndSlot } from '@ideaz/shared'\nimport { get } from 'lodash-unified'\nimport { isArray, isFunction, isString } from '@ideaz/utils'\nimport { descriptionsProps } from './descriptions'\nimport type { DescriptionsColumn } from './descriptions'\n\nexport default defineComponent({\n name: 'ZDescriptions',\n props: descriptionsProps,\n setup(props, { slots }) {\n const size = useFormSize()\n const config = reactiveOmit(\n props,\n 'title',\n 'extra',\n 'columns',\n 'detail',\n 'align',\n 'labelAlign',\n )\n const ns = useNamespace('descriptions')\n\n function createDetail(item: DescriptionsColumn) {\n if (slots[`detail-${item.prop}`]) {\n return (slots[`detail-${item.prop}`] as Slot)({\n size: size.value,\n item: props.detail,\n })\n }\n else if (item.render) {\n return isFunction(item.render)\n ? item.render(props.detail)\n : String(item.render)\n }\n else {\n const val = get(props.detail, item.prop, '')\n return isArray(val) ? val.join(', ') : val\n }\n }\n\n function createDefault() {\n return props.columns?.map(item =>\n h(\n ElDescriptionsItem,\n {\n ...item,\n align: item.align ?? props.align,\n labelAlign: item.labelAlign ?? props.labelAlign,\n },\n {\n default: () => createDetail(item),\n label: () => getContentByRenderAndSlot(item.label, slots, item),\n },\n ),\n )\n }\n\n function createExtra() {\n if (isFunction(props.extra))\n return props.extra()\n if (isString(props.extra))\n return props.extra\n if (isFunction(slots.extra))\n return slots.extra()\n return null\n }\n\n return () =>\n h(ElDescriptions, mergeProps(config, { class: ns.b() }), {\n default: () => [createDefault(), slots.default && slots.default()],\n title: () => getContentByRenderAndSlot(props.title, slots),\n extra: () => createExtra(),\n })\n },\n})\n"],"names":["ZDescription","defineComponent","name","props","slots","size","useFormSize","config","reactiveOmit","ns","useNamespace","item","val","get","isArray","align","labelAlign","default","isFunction","class","extra"],"mappings":";;;;;;;;;;;;;AAUA,MAAAA,IAAA,gBAAAC,EAAA;AAAA,EACEC,MAAAA;AAAAA,EACAC,OAAAA;AAAAA;IACeC,OAAAA;AAAAA,EAAM,GAAA;AACnB,UAAAC,IAAAC,EAAA,GACAC,IAAAC,EAAAL,GAAA,SAAA,SAAA,WAAA,UAAA,SAAA,YAAA,GASAM,IAAAC,EAAA,cAAA;;;;;;QAOI,CAAA;AACF,UAAAC,EAAA;;AAKA;AAEE,cAAAC,IAAAC,EAAAV,EAAA,QAAAQ,EAAA,MAAA,EAAA;AACA,eAAAG,EAAAF,CAAA,IAAAA,EAAA,KAAA,IAAA,IAAAA;AAAA,MACF;AAAA,IACF;;;;QAOQ,GAAAD;AAAA,QACAI,OAAAA,EAAAA,SAAAA,EAAAA;AAAAA,QACAC,YAAAA,EAAAA,cAAAA,EAAAA;AAAAA,MACF,GAAA;AAAA,QAEEC,SAAAA,MAAAA,EAAAA,CAAAA;AAAAA;MAEF,CAAA;AAAA,IAGN;;AAGE,aAAAC,EAAAf,EAAA,KAAA,IAAAA,EAAA,MAAA,2BAIAe,EAAAd,EAAA,KAAA,IAAAA,EAAA,MAAA,IAEA;AAAA,IACF;;MAGyCe,OAAAA,EAAAA,EAAAA;AAAAA,IAAc,CAAA,GAAA;AAAA,MACnDF,SAAAA,MAAAA,CAAAA,EAAAA,GAAAA,EAAAA,WAAAA,EAAAA,QAAAA,CAAAA;AAAAA;MAEAG,OAAAA,MAAAA,EAAAA;AAAAA,IACF,CAAA;AAAA,EACJ;AACF,CAAA;"}