{"version":3,"file":"index.mjs","sources":["../../../../../../../packages/components/table/src/table-footer/index.ts"],"sourcesContent":["// @ts-nocheck\nimport { defineComponent, h } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport useStyle from './style-helper'\nimport type { Store } from '../store'\n\nimport type { PropType } from 'vue'\nimport type { DefaultRow, Sort, SummaryMethod } from '../table/defaults'\nexport interface TableFooter {\n fixed: string\n store: Store\n summaryMethod: SummaryMethod\n sumText: string\n border: boolean\n defaultSort: Sort\n}\n\nexport default defineComponent({\n name: 'ElTableFooter',\n\n props: {\n fixed: {\n type: String,\n default: '',\n },\n store: {\n required: true,\n type: Object as PropType['store']>,\n },\n summaryMethod: Function as PropType<\n TableFooter['summaryMethod']\n >,\n sumText: String,\n border: Boolean,\n defaultSort: {\n type: Object as PropType['defaultSort']>,\n default: () => {\n return {\n prop: '',\n order: '',\n }\n },\n },\n },\n setup(props) {\n const { getCellClasses, getCellStyles, columns } = useStyle(\n props as TableFooter\n )\n const ns = useNamespace('table')\n return {\n ns,\n getCellClasses,\n getCellStyles,\n columns,\n }\n },\n render() {\n const { columns, getCellStyles, getCellClasses, summaryMethod, sumText } =\n this\n const data = this.store.states.data.value\n let sums = []\n if (summaryMethod) {\n sums = summaryMethod({\n columns,\n data,\n })\n } else {\n columns.forEach((column, index) => {\n if (index === 0) {\n sums[index] = sumText\n return\n }\n const values = data.map((item) => Number(item[column.property]))\n const precisions = []\n let notNumber = true\n values.forEach((value) => {\n if (!Number.isNaN(+value)) {\n notNumber = false\n const decimal = `${value}`.split('.')[1]\n precisions.push(decimal ? decimal.length : 0)\n }\n })\n const precision = Math.max.apply(null, precisions)\n if (!notNumber) {\n sums[index] = values.reduce((prev, curr) => {\n const value = Number(curr)\n if (!Number.isNaN(+value)) {\n return Number.parseFloat(\n (prev + curr).toFixed(Math.min(precision, 20))\n )\n } else {\n return prev\n }\n }, 0)\n } else {\n sums[index] = ''\n }\n })\n }\n return h(\n h('tfoot', [\n h('tr', {}, [\n ...columns.map((column, cellIndex) =>\n h(\n 'td',\n {\n key: cellIndex,\n colspan: column.colSpan,\n rowspan: column.rowSpan,\n class: getCellClasses(columns, cellIndex),\n style: getCellStyles(column, cellIndex),\n },\n [\n h(\n 'div',\n {\n class: ['cell', column.labelClassName],\n },\n [sums[cellIndex]]\n ),\n ]\n )\n ),\n ]),\n ])\n )\n },\n})\n"],"names":[],"mappings":";;;;;AAGA,kBAAe,eAAe,CAAC;AAC/B,EAAE,IAAI,EAAE,eAAe;AACvB,EAAE,KAAK,EAAE;AACT,IAAI,KAAK,EAAE;AACX,MAAM,IAAI,EAAE,MAAM;AAClB,MAAM,OAAO,EAAE,EAAE;AACjB,KAAK;AACL,IAAI,KAAK,EAAE;AACX,MAAM,QAAQ,EAAE,IAAI;AACpB,MAAM,IAAI,EAAE,MAAM;AAClB,KAAK;AACL,IAAI,aAAa,EAAE,QAAQ;AAC3B,IAAI,OAAO,EAAE,MAAM;AACnB,IAAI,MAAM,EAAE,OAAO;AACnB,IAAI,WAAW,EAAE;AACjB,MAAM,IAAI,EAAE,MAAM;AAClB,MAAM,OAAO,EAAE,MAAM;AACrB,QAAQ,OAAO;AACf,UAAU,IAAI,EAAE,EAAE;AAClB,UAAU,KAAK,EAAE,EAAE;AACnB,SAAS,CAAC;AACV,OAAO;AACP,KAAK;AACL,GAAG;AACH,EAAE,KAAK,CAAC,KAAK,EAAE;AACf,IAAI,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvE,IAAI,MAAM,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;AACrC,IAAI,OAAO;AACX,MAAM,EAAE;AACR,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,OAAO;AACb,KAAK,CAAC;AACN,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,OAAO,E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