element-plus
Version:
A Component Library for Vue 3
1 lines • 5.05 kB
Source Map (JSON)
{"version":3,"file":"row.mjs","sources":["../../../../../../../packages/components/table-v2/src/renderers/row.tsx"],"sourcesContent":["import { Row } from '../components'\nimport { tryCall } from '../utils'\n\nimport type { FunctionalComponent, UnwrapNestedRefs } from 'vue'\nimport type { UseNamespaceReturn } from '@element-plus/hooks'\nimport type { UseTableReturn } from '../use-table'\nimport type { TableV2Props } from '../table'\nimport type { TableGridRowSlotParams } from '../table-grid'\n\ntype RowRendererProps = TableGridRowSlotParams &\n Pick<\n TableV2Props,\n | 'expandColumnKey'\n | 'estimatedRowHeight'\n | 'rowProps'\n | 'rowClass'\n | 'rowKey'\n | 'rowEventHandlers'\n > &\n UnwrapNestedRefs<\n Pick<\n UseTableReturn,\n | 'depthMap'\n | 'expandedRowKeys'\n | 'hasFixedColumns'\n | 'hoveringRowKey'\n | 'onRowHovered'\n | 'onRowExpanded'\n >\n > & {\n ns: UseNamespaceReturn\n }\n\nconst RowRenderer: FunctionalComponent<RowRendererProps> = (\n props,\n { slots }\n) => {\n const {\n columns,\n depthMap,\n expandColumnKey,\n expandedRowKeys,\n estimatedRowHeight,\n hasFixedColumns,\n hoveringRowKey,\n rowData,\n rowIndex,\n style,\n isScrolling,\n rowProps,\n rowClass,\n rowKey,\n rowEventHandlers,\n ns,\n onRowHovered,\n onRowExpanded,\n } = props\n\n const rowKls = tryCall(rowClass, { columns, rowData, rowIndex }, '')\n const additionalProps = tryCall(rowProps, {\n columns,\n rowData,\n rowIndex,\n })\n const _rowKey = rowData[rowKey]\n const depth = depthMap[_rowKey] || 0\n const canExpand = Boolean(expandColumnKey)\n const isFixedRow = rowIndex < 0\n const kls = [\n ns.e('row'),\n rowKls,\n {\n [ns.e(`row-depth-${depth}`)]: canExpand && rowIndex >= 0,\n [ns.is('expanded')]: canExpand && expandedRowKeys.includes(_rowKey),\n [ns.is('hovered')]: !isScrolling && _rowKey === hoveringRowKey,\n [ns.is('fixed')]: !depth && isFixedRow,\n [ns.is('customized')]: Boolean(slots.row),\n },\n ]\n\n const onRowHover = hasFixedColumns ? onRowHovered : undefined\n\n const _rowProps = {\n ...additionalProps,\n columns,\n class: kls,\n depth,\n expandColumnKey,\n estimatedRowHeight: isFixedRow ? undefined : estimatedRowHeight,\n isScrolling,\n rowIndex,\n rowData,\n rowKey: _rowKey,\n rowEventHandlers,\n style,\n }\n\n return (\n <Row {..._rowProps} onRowHover={onRowHover} onRowExpand={onRowExpanded}>\n {slots}\n </Row>\n )\n}\n\nexport default RowRenderer\n"],"names":["RowRenderer","slots","columns","depthMap","expandColumnKey","expandedRowKeys","estimatedRowHeight","hasFixedColumns","hoveringRowKey","rowData","rowIndex","style","isScrolling","rowProps","rowClass","rowKey","rowEventHandlers","ns","onRowHovered","onRowExpanded","_rowKey","depth","canExpand","Boolean","isFixedRow","kls","e","is","class","_createVNode","Row","_mergeProps"],"mappings":";;;;;;;;;;AAiCA,CAAA,KAAMA;AAEFC,EAAAA,MAAAA;AAAF,IACG,OAAA;AACH,IAAM,QAAA;AACJC,IAAAA,eADI;AAEJC,IAAAA,eAFI;AAGJC,IAAAA,kBAHI;AAIJC,IAAAA,eAJI;AAKJC,IAAAA,cALI;AAMJC,IAAAA,OANI;AAOJC,IAAAA,QAPI;AAQJC,IAAAA,KARI;AASJC,IAAAA,WATI;AAUJC,IAAAA,QAVI;AAWJC,IAAAA,QAXI;AAYJC,IAAAA,MAZI;AAaJC,IAAAA,gBAbI;AAcJC,IAAAA,EAdI;AAeJC,IAAAA,YAfI;AAgBJC,IAAAA,aAhBI;AAiBJC,GAAAA,GAjBI,KAAA,CAAA;AAkBJC,EAAAA,MAAAA,MAAAA,GAAAA,OAAAA,CAAAA,QAAAA,EAAAA;AAlBI,IAAA,OAAN;AAqBA,IAAA,OAAY;AAAuBjB,IAAAA,QAAF;AAAWO,GAAAA,EAAX,EAAA,CAAA,CAAA;AAAoBC,EAAAA,MAAAA,eAAAA,GAAAA,OAAAA,CAAAA,QA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