{"version":3,"file":"cell.mjs","names":["renderSlot","createVNode","_createVNode","mergeProps","_mergeProps","get","isFunction","isObject","ExpandIcon","TableCell","Alignment","placeholderSign","componentToSlot","enforceUnit","tryCall","combineStyles","CellRenderer","columns","column","columnIndex","depth","expandIconProps","isScrolling","rowData","rowIndex","style","expandedRowKeys","ns","t","cellProps","_cellProps","cellStyle","_cellStyle","expandColumnKey","indentSize","iconSize","rowKey","slots","cellRenderer","dataKey","dataGetter","cellData","em","extraCellProps","class","e","columnCellRenderer","Cell","kls","align","CENTER","is","RIGHT","expandable","key","expanded","includes","IconOrPlaceholder","iconStyle","join","inheritAttrs"],"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'\nimport { combineStyles } from './style-helper'\n\nimport type { FunctionalComponent, UnwrapNestedRefs, VNode } from 'vue'\nimport type { TableV2RowCellRenderParam } from '../components'\nimport type { Translator, 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' | 'cellStyle' | 'expandColumnKey' | 'indentSize' | 'iconSize' | 'rowKey'\n  > &\n  UnwrapNestedRefs<Pick<UseTableReturn, 'expandedRowKeys'>> & {\n    ns: UseNamespaceReturn\n    t: Translator\n  }\n\nconst CellRenderer: FunctionalComponent<CellRendererProps> = (\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    t,\n    // derived props\n    cellProps: _cellProps,\n    cellStyle: _cellStyle,\n    expandColumnKey,\n    indentSize,\n    iconSize,\n    rowKey,\n  },\n  { slots }\n) => {\n  const { cellRenderer, dataKey, dataGetter } = column\n  const cellData = isFunction(dataGetter)\n    ? dataGetter({ columns, column, columnIndex, rowData, rowIndex })\n    : get(rowData, dataKey ?? '')\n  const cellStyle = combineStyles(enforceUnit(style), _cellStyle, {\n    cellData,\n    columns,\n    column,\n    columnIndex,\n    rowIndex,\n    rowData,\n  })\n\n  if (column.placeholderSign === placeholderSign) {\n    return <div class={ns.em('row-cell', 'placeholder')} style={cellStyle} />\n  }\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<typeof cellProps>(cellRenderer)\n  const Cell = columnCellRenderer\n    ? columnCellRenderer(cellProps)\n    : renderSlot(slots, 'default', cellProps, () => [\n        <TableCell {...cellProps}></TableCell>,\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        <ExpandIcon\n          {...expandIconProps}\n          class={[ns.e('expand-icon'), ns.is('expanded', expanded)]}\n          size={iconSize}\n          expanded={expanded}\n          ariaLabel={t(\n            expanded ? 'el.table.collapseRowLabel' : 'el.table.expandRowLabel'\n          )}\n          style={iconStyle}\n          expandable\n        />\n      )\n    } else {\n      IconOrPlaceholder = (\n        <div\n          style={[\n            iconStyle,\n            `width: ${iconSize}px; height: ${iconSize}px;`,\n          ].join(' ')}\n        />\n      )\n    }\n  }\n\n  return (\n    <div class={kls} style={cellStyle} {...extraCellProps} role=\"cell\">\n      {IconOrPlaceholder}\n      {Cell}\n    </div>\n  )\n}\n\nCellRenderer.inheritAttrs = false\n\nexport default CellRenderer\n"],"mappings":";;;;;;;;;;AAyBA,MAAMgB,gBACJ,EAEEC,SACAC,QACAC,aACAC,OACAC,iBACAC,aACAC,SACAC,UAEAC,OACAC,iBACAC,IACAC,GAEAC,WAAWC,YACXC,WAAWC,YACXC,iBACAC,YACAC,UACAC,UAEF,EAAEC,YACC;CACH,MAAM,EAAEC,cAAcC,SAASC,eAAetB;CAC9C,MAAMuB,WAAWnC,WAAWkC,UAAU,IAClCA,WAAW;EAAEvB;EAASC;EAAQC;EAAaI;EAASC;CAAS,CAAC,IAC9DnB,IAAIkB,SAASgB,WAAW,EAAE;CAC9B,MAAMR,YAAYhB,cAAcF,YAAYY,KAAK,GAAGO,YAAY;EAC9DS;EACAxB;EACAC;EACAC;EACAK;EACAD;CACF,CAAC;CAED,IAAIL,OAAOP,oBAAoBA,iBAC7B,OAAAT,YAAA,OAAA;EAAA,SAAmByB,GAAGe,GAAG,YAAY,aAAa;EAAC,SAASX;CAAS,GAAA,IAAA;CAGvE,MAAMY,iBAAiB7B,QAAQgB,YAAY;EACzCW;EACAxB;EACAC;EACAC;EACAK;EACAD;CACF,CAAC;CAED,MAAMM,YAAY;EAChBe,OAAOjB,GAAGkB,EAAE,WAAW;EACvB5B;EACAC;EACAC;EACAsB;EACAnB;EACAC;EACAC;CACF;CACA,MAAMsB,qBAAqBlC,gBAAkC0B,YAAY;CACzE,MAAMS,OAAOD,qBACTA,mBAAmBjB,SAAS,IAC5B7B,WAAWqC,OAAO,WAAWR,iBAAiB,CAAA3B,YAAAO,aAC7BoB,WAAS,IAAA,CAAA,CACzB;CAEL,MAAMmB,MAAM;EACVrB,GAAGkB,EAAE,UAAU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