You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 lines
12 KiB

{"ast":null,"code":"import { defineComponent, inject, withDirectives, h } from 'vue';\nimport { isNil } from 'lodash-unified';\nimport { descriptionsKey } from './token.mjs';\nimport { getNormalizedProps } from '../../../utils/vue/vnode.mjs';\nimport { addUnit } from '../../../utils/dom/style.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nvar ElDescriptionsCell = defineComponent({\n name: \"ElDescriptionsCell\",\n props: {\n cell: {\n type: Object\n },\n tag: {\n type: String,\n default: \"td\"\n },\n type: {\n type: String\n }\n },\n setup() {\n const descriptions = inject(descriptionsKey, {});\n return {\n descriptions\n };\n },\n render() {\n var _a;\n const item = getNormalizedProps(this.cell);\n const directives = (((_a = this.cell) == null ? void 0 : _a.dirs) || []).map(dire => {\n const {\n dir,\n arg,\n modifiers,\n value\n } = dire;\n return [dir, value, arg, modifiers];\n });\n const {\n border,\n direction\n } = this.descriptions;\n const isVertical = direction === \"vertical\";\n const renderLabel = () => {\n var _a2, _b, _c;\n return ((_c = (_b = (_a2 = this.cell) == null ? void 0 : _a2.children) == null ? void 0 : _b.label) == null ? void 0 : _c.call(_b)) || item.label;\n };\n const renderContent = () => {\n var _a2, _b, _c;\n return (_c = (_b = (_a2 = this.cell) == null ? void 0 : _a2.children) == null ? void 0 : _b.default) == null ? void 0 : _c.call(_b);\n };\n const span = item.span;\n const rowspan = item.rowspan;\n const align = item.align ? `is-${item.align}` : \"\";\n const labelAlign = item.labelAlign ? `is-${item.labelAlign}` : align;\n const className = item.className;\n const labelClassName = item.labelClassName;\n const width = this.type === \"label\" ? item.labelWidth || this.descriptions.labelWidth || item.width : item.width;\n const style = {\n width: addUnit(width),\n minWidth: addUnit(item.minWidth)\n };\n const ns = useNamespace(\"descriptions\");\n switch (this.type) {\n case \"label\":\n return withDirectives(h(this.tag, {\n style,\n class: [ns.e(\"cell\"), ns.e(\"label\"), ns.is(\"bordered-label\", border), ns.is(\"vertical-label\", isVertical), labelAlign, labelClassName],\n colSpan: isVertical ? span : 1,\n rowspan: isVertical ? 1 : rowspan\n }, renderLabel()), directives);\n case \"content\":\n return withDirectives(h(this.tag, {\n style,\n class: [ns.e(\"cell\"), ns.e(\"content\"), ns.is(\"bordered-content\", border), ns.is(\"vertical-content\", isVertical), align, className],\n colSpan: isVertical ? span : span * 2 - 1,\n rowspan: isVertical ? rowspan * 2 - 1 : rowspan\n }, renderContent()), directives);\n default:\n {\n const label = renderLabel();\n const labelStyle = {};\n const width2 = addUnit(item.labelWidth || this.descriptions.labelWidth);\n if (width2) {\n labelStyle.width = width2;\n labelStyle.display = \"inline-block\";\n }\n return withDirectives(h(\"td\", {\n style,\n class: [ns.e(\"cell\"), align],\n colSpan: span,\n rowspan\n }, [!isNil(label) ? h(\"span\", {\n style: labelStyle,\n class: [ns.e(\"label\"), labelClassName]\n }, label) : void 0, h(\"span\", {\n class: [ns.e(\"content\"), className]\n }, renderContent())]), directives);\n }\n }\n }\n});\nexport { ElDescriptionsCell as default };","map":{"version":3,"names":["ElDescriptionsCell","defineComponent","name","props","cell","type","Object","tag","String","default","setup","descriptions","inject","descriptionsKey","render","_a","item","getNormalizedProps","directives","dirs","map","dire","dir","arg","modifiers","value","border","direction","isVertical","renderLabel","_a2","_b","_c","children","label","call","renderContent","span","rowspan","align","labelAlign","className","labelClassName","width","labelWidth","style","addUnit","minWidth","ns","useNamespace","withDirectives","h","class","e","is","colSpan","labelStyle","width2","display","isNil"],"sources":["../../../../../../packages/components/descriptions/src/descriptions-cell.ts"],"sourcesContent":["import { defineComponent, h, inject, withDirectives } from 'vue'\nimport { isNil } from 'lodash-unified'\nimport { addUnit, getNormalizedProps } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { descriptionsKey } from './token'\nimport type { DirectiveArguments, PropType, VNode } from 'vue'\n\nimport type {\n IDescriptionsInject,\n IDescriptionsItemInject,\n} from './descriptions.type'\nimport type { DescriptionItemVNode } from './description-item'\n\nexport default defineComponent({\n name: 'ElDescriptionsCell',\n props: {\n cell: {\n type: Object as PropType<DescriptionItemVNode>,\n },\n tag: {\n type: String,\n default: 'td',\n },\n type: {\n type: String,\n },\n },\n setup() {\n const descriptions = inject(descriptionsKey, {} as IDescriptionsInject)\n\n return {\n descriptions,\n }\n },\n render() {\n const item = getNormalizedProps(\n this.cell as VNode\n ) as IDescriptionsItemInject\n\n const directives = (this.cell?.dirs || []).map((dire) => {\n const { dir, arg, modifiers, value } = dire\n return [dir, value, arg, modifiers]\n }) as DirectiveArguments\n\n const { border, direction } = this.descriptions\n const isVertical = direction === 'vertical'\n const renderLabel = () => this.cell?.children?.label?.() || item.label\n const renderContent = () => this.cell?.children?.default?.()\n const span = item.span\n const rowspan = item.rowspan\n const align = item.align ? `is-${item.align}` : ''\n const labelAlign = item.labelAlign ? `is-${item.labelAlign}` : align\n const className = item.className\n const labelClassName = item.labelClassName\n const width =\n this.type === 'label'\n ? item.labelWidth || this.descriptions.labelWidth || item.width\n : item.width\n\n const style = {\n width: addUnit(width),\n minWidth: addUnit(item.minWidth),\n }\n const ns = useNamespace('descriptions')\n\n switch (this.type) {\n case 'label':\n return withDirectives(\n h(\n this.tag,\n {\n style,\n class: [\n ns.e('cell'),\n ns.e('label'),\n ns.is('bordered-label', border),\n ns.is('vertical-label', isVertical),\n labelAlign,\n labelClassName,\n ],\n colSpan: isVertical ? span : 1,\n rowspan: isVertical ? 1 : rowspan,\n },\n renderLabel()\n ),\n directives\n )\n case 'content':\n return withDirectives(\n h(\n this.tag,\n {\n style,\n class: [\n ns.e('cell'),\n ns.e('content'),\n ns.is('bordered-content', border),\n ns.is('vertical-content', isVertical),\n align,\n className,\n ],\n colSpan: isVertical ? span : span * 2 - 1,\n rowspan: isVertical ? rowspan * 2 - 1 : rowspan,\n },\n renderContent()\n ),\n directives\n )\n default: {\n const label = renderLabel()\n const labelStyle: Record<string, any> = {}\n const width = addUnit(item.labelWidth || this.descriptions.labelWidth)\n if (width) {\n labelStyle.width = width\n labelStyle.display = 'inline-block'\n }\n return withDirectives(\n h(\n 'td',\n {\n style,\n class: [ns.e('cell'), align],\n colSpan: span,\n rowspan,\n },\n [\n !isNil(label)\n ? h(\n 'span',\n {\n style: labelStyle,\n class: [ns.e('label'), labelClassName],\n },\n label\n )\n : undefined,\n h(\n 'span',\n {\n class: [ns.e('content'), className],\n },\n renderContent()\n ),\n ]\n ),\n directives\n )\n }\n }\n },\n})\n"],"mappings":";;;;;;AAKA,IAAAA,kBAAA,GAAeC,eAAe,CAAC;EAC7BC,IAAI,EAAE,oBAAoB;EAC1BC,KAAK,EAAE;IACLC,IAAI,EAAE;MACJC,IAAI,EAAEC;IACZ,CAAK;IACDC,GAAG,EAAE;MACHF,IAAI,EAAEG,MAAM;MACZC,OAAO,EAAE;IACf,CAAK;IACDJ,IAAI,EAAE;MACJA,IAAI,EAAEG;IACZ;EACA,CAAG;EACDE,KAAKA,CAAA,EAAG;IACN,MAAMC,YAAY,GAAGC,MAAM,CAACC,eAAe,EAAE,EAAE,CAAC;IAChD,OAAO;MACLF;IACN,CAAK;EACL,CAAG;EACDG,MAAMA,CAAA,EAAG;IACP,IAAIC,EAAE;IACN,MAAMC,IAAI,GAAGC,kBAAkB,CAAC,IAAI,CAACb,IAAI,CAAC;IAC1C,MAAMc,UAAU,GAAG,CAAC,CAAC,CAACH,EAAE,GAAG,IAAI,CAACX,IAAI,KAAK,IAAI,GAAG,KAAK,CAAC,GAAGW,EAAE,CAACI,IAAI,KAAK,EAAE,EAAEC,GAAG,CAAEC,IAAI,IAAK;MACrF,MAAM;QAAEC,GAAG;QAAEC,GAAG;QAAEC,SAAS;QAAEC;MAAK,CAAE,GAAGJ,IAAI;MAC3C,OAAO,CAACC,GAAG,EAAEG,KAAK,EAAEF,GAAG,EAAEC,SAAS,CAAC;IACzC,CAAK,CAAC;IACF,MAAM;MAAEE,MAAM;MAAEC;IAAS,CAAE,GAAG,IAAI,CAAChB,YAAY;IAC/C,MAAMiB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