{"version":3,"file":"cell.js","sources":["../../../../../../../packages/components/table-v2/src/renderers/cell.tsx"],"sourcesContent":["import { renderSlot } from 'vue'\nimport { get } from 'lodash-unified'\nimport { isFunction, isObject } from '@element-plus/utils'\nimport { ExpandIcon, TableCell } from '../components'\nimport { Alignment } from '../constants'\nimport { placeholderSign } from '../private'\nimport { componentToSlot, enforceUnit, tryCall } from '../utils'\n\nimport type { FunctionalComponent, UnwrapNestedRefs, VNode } from 'vue'\nimport type { TableV2RowCellRenderParam } from '../components'\nimport type { UseNamespaceReturn } from '@element-plus/hooks'\nimport type { UseTableReturn } from '../use-table'\nimport type { TableV2Props } from '../table'\n\ntype CellRendererProps = TableV2RowCellRenderParam &\n Pick<\n TableV2Props,\n 'cellProps' | 'expandColumnKey' | 'indentSize' | 'iconSize' | 'rowKey'\n > &\n UnwrapNestedRefs> & {\n ns: UseNamespaceReturn\n }\n\nconst CellRenderer: FunctionalComponent = (\n {\n // renderer props\n columns,\n column,\n columnIndex,\n depth,\n expandIconProps,\n isScrolling,\n rowData,\n rowIndex,\n // from use-table\n style,\n expandedRowKeys,\n ns,\n // derived props\n cellProps: _cellProps,\n expandColumnKey,\n indentSize,\n iconSize,\n rowKey,\n },\n { slots }\n) => {\n const cellStyle = enforceUnit(style)\n\n if (column.placeholderSign === placeholderSign) {\n return
\n }\n const { cellRenderer, dataKey, dataGetter } = column\n\n const cellData = isFunction(dataGetter)\n ? dataGetter({ columns, column, columnIndex, rowData, rowIndex })\n : get(rowData, dataKey ?? '')\n\n const extraCellProps = tryCall(_cellProps, {\n cellData,\n columns,\n column,\n columnIndex,\n rowIndex,\n rowData,\n })\n\n const cellProps = {\n class: ns.e('cell-text'),\n columns,\n column,\n columnIndex,\n cellData,\n isScrolling,\n rowData,\n rowIndex,\n }\n const columnCellRenderer = componentToSlot(cellRenderer)\n const Cell = columnCellRenderer\n ? columnCellRenderer(cellProps)\n : renderSlot(slots, 'default', cellProps, () => [\n ,\n ])\n\n const kls = [\n ns.e('row-cell'),\n column.class,\n column.align === Alignment.CENTER && ns.is('align-center'),\n column.align === Alignment.RIGHT && ns.is('align-right'),\n ]\n\n const expandable =\n rowIndex >= 0 && expandColumnKey && column.key === expandColumnKey\n const expanded = rowIndex >= 0 && expandedRowKeys.includes(rowData[rowKey])\n\n let IconOrPlaceholder: VNode | undefined\n const iconStyle = `margin-inline-start: ${depth * indentSize}px;`\n if (expandable) {\n if (isObject(expandIconProps)) {\n IconOrPlaceholder = (\n \n )\n } else {\n IconOrPlaceholder = (\n \n )\n }\n }\n\n return (\n
\n {IconOrPlaceholder}\n {Cell}\n
\n )\n}\n\nCellRenderer.inheritAttrs = false\n\nexport default CellRenderer\n"],"names":["CellRenderer","columns","column","columnIndex","depth","expandIconProps","isScrolling","rowData","rowIndex","style","expandedRowKeys","ns","cellProps","indentSize","rowKey","placeholderSign","slots","cellStyle","cellRenderer","dataKey","dataGetter","cellData","tryCall","class","componentToSlot","renderSlot","_createVNode","TableCell","Alignment","columnCellRenderer","Cell","kls","expandColumnKey","ExpandIcon","_mergeProps","expanded","includes","iconStyle","isObject","IconOrPlaceholder"],"mappings":";;;;;;;;;;;;;;;;AAuBA,EAAMA,OAAAA;AAEF,EAAA,MAAA;EACAC,WAFF;EAGEC,KAHF;EAIEC,eAJF;EAKEC,WALF;EAMEC,OANF;EAOEC,QAPF;EAQEC,KARF;EASEC,eATF;AAUE,EAAA,EAAA;EACAC,SAXF,EAAA,UAAA;EAYEC,eAZF;EAaEC,UAbF;AAcE,EAAA,QAAA;AACAC,EAAAA,MAAAA;GAfF;EAiBEC,KAjBF;MAAA;AAmBEC,EAAAA,MAAAA,SAAAA,GAAAA,iBAAAA,CAAAA,KAAAA,CAAAA,CAAAA;AAnBF,EAqBA,IAAA,MAAA,CAAA,eAAA,KAAAC,wBAAA,EAAA;AAAEC,IAAAA,OAAAA,eAAAA,CAAAA,KAAAA,EAAAA;AAAF,MACG,OAAA,EAAA,EAAA,CAAA,EAAA,CAAA,UAAA,EAAA,aAA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