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
9.0 KiB
1 lines
9.0 KiB
{"ast":null,"code":"import { createVNode, renderSlot, mergeProps } from 'vue';\nimport { get } from 'lodash-unified';\nimport { Alignment } from '../constants.mjs';\nimport { placeholderSign } from '../private.mjs';\nimport { enforceUnit, tryCall, componentToSlot } from '../utils.mjs';\nimport TableCell from '../components/cell.mjs';\nimport ExpandIcon from '../components/expand-icon.mjs';\nimport { isFunction, isObject } from '@vue/shared';\nconst CellRenderer = ({\n columns,\n column,\n columnIndex,\n depth,\n expandIconProps,\n isScrolling,\n rowData,\n rowIndex,\n style,\n expandedRowKeys,\n ns,\n cellProps: _cellProps,\n expandColumnKey,\n indentSize,\n iconSize,\n rowKey\n}, {\n slots\n}) => {\n const cellStyle = enforceUnit(style);\n if (column.placeholderSign === placeholderSign) {\n return createVNode(\"div\", {\n \"class\": ns.em(\"row-cell\", \"placeholder\"),\n \"style\": cellStyle\n }, null);\n }\n const {\n cellRenderer,\n dataKey,\n dataGetter\n } = column;\n const cellData = isFunction(dataGetter) ? dataGetter({\n columns,\n column,\n columnIndex,\n rowData,\n rowIndex\n }) : get(rowData, dataKey != null ? dataKey : \"\");\n const extraCellProps = tryCall(_cellProps, {\n cellData,\n columns,\n column,\n columnIndex,\n rowIndex,\n rowData\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 ? columnCellRenderer(cellProps) : renderSlot(slots, \"default\", cellProps, () => [createVNode(TableCell, cellProps, null)]);\n const kls = [ns.e(\"row-cell\"), column.class, column.align === Alignment.CENTER && ns.is(\"align-center\"), column.align === Alignment.RIGHT && ns.is(\"align-right\")];\n const expandable = rowIndex >= 0 && expandColumnKey && column.key === expandColumnKey;\n const expanded = rowIndex >= 0 && expandedRowKeys.includes(rowData[rowKey]);\n let IconOrPlaceholder;\n const iconStyle = `margin-inline-start: ${depth * indentSize}px;`;\n if (expandable) {\n if (isObject(expandIconProps)) {\n IconOrPlaceholder = createVNode(ExpandIcon, mergeProps(expandIconProps, {\n \"class\": [ns.e(\"expand-icon\"), ns.is(\"expanded\", expanded)],\n \"size\": iconSize,\n \"expanded\": expanded,\n \"style\": iconStyle,\n \"expandable\": true\n }), null);\n } else {\n IconOrPlaceholder = createVNode(\"div\", {\n \"style\": [iconStyle, `width: ${iconSize}px; height: ${iconSize}px;`].join(\" \")\n }, null);\n }\n }\n return createVNode(\"div\", mergeProps({\n \"class\": kls,\n \"style\": cellStyle\n }, extraCellProps, {\n \"role\": \"cell\"\n }), [IconOrPlaceholder, Cell]);\n};\nCellRenderer.inheritAttrs = false;\nvar Cell = CellRenderer;\nexport { Cell as default };","map":{"version":3,"names":["columns","column","columnIndex","depth","expandIconProps","isScrolling","rowData","rowIndex","style","expandedRowKeys","ns","cellProps","_cellProps","expandColumnKey","indentSize","iconSize","rowKey","slots","cellStyle","enforceUnit","placeholderSign","createVNode","em","cellRenderer","dataGetter","get","dataKey","extraCellProps","tryCall","cellData","class","e","columnCellRenderer","componentToSlot","Cell","renderSlot","TableCell","kls","align","Alignment","CENTER","is","RIGHT","expandable","key","expanded","includes","IconOrPlaceholder","iconStyle","isObject","ExpandIcon","mergeProps","join","CellRenderer"],"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<Pick<UseTableReturn, 'expandedRowKeys'>> & {\n ns: UseNamespaceReturn\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 // 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 <div class={ns.em('row-cell', 'placeholder')} style={cellStyle} />\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<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 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":";;;;;;;;;EAuBMA,OAAA;EAEFC,MAAA;EACAC,WAFF;EAGEC,KAHF;EAIEC,eAJF;EAKEC,WALF;EAMEC,OANF;EAOEC,QAPF;EAQEC,KARF;EASEC,eATF;EAUEC,EAAA;EACAC,SAXF,EAAAC,UAAA;EAYEC,eAZF;EAaEC,UAbF;EAcEC,QAAA;EACAC;GAfF;EAiBEC;MAjBF;EAmBE,MAAAC,SAAA,GAAAC,WAAA,CAAAX,KAAA;EAEF,IAAAP,MAAA,CAAAmB,eAAA,KAAAA,eAAA;IAAE,OAAAC,WAAA;MACC,SAAAX,EAAA,CAAAY,EAAA;MACH,OAAe,EAAAJ;;EAEf;EACE;IAAAK,YAAA;WAA4D;IAA5DC;EACD,IAAAvB,MAAA;;IACKD,OAAA;IAAEC,MAAF;IAAgBC,WAAhB;IAAyBI,OAAA;IAAzBC;GAEA,IAAAkB,GAAA,CAAAnB,OAAA,EAAqBoB,OAAA,WAAAA,OAAA;QACZC,cAAA,GAAAC,OAAA,CAAAhB,UAAA;IAAWiB,QAAX;IAAmB7B,OAAnB;IAAgCC,MAAhC;IAAyCC,WAAA;IADvCK,QAAA;IAIjBD;IACE;QADyCK,SAAA;IAGzCmB,KAHyC,EAAApB,EAAA,CAAAqB,CAAA;IAIzC/B,OAJyC;IAKzCC,MALyC;IAMzCC,WAAA;IANF2B,QAAA;IASAxB,WAAA;IACEC,OAAO;IACPC;;QAFgByB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