{"version":3,"file":"header-cell.mjs","sources":["../../../../../../../packages/components/table-v2/src/renderers/header-cell.tsx"],"sourcesContent":["import { renderSlot } from 'vue'\nimport { HeaderCell, SortIcon } from '../components'\n// import ColumnResizer from '../table-column-resizer'\nimport { Alignment, SortOrder, oppositeOrderMap } from '../constants'\nimport { placeholderSign } from '../private'\nimport { componentToSlot, enforceUnit, tryCall } from '../utils'\n\nimport type { FunctionalComponent, UnwrapNestedRefs } from 'vue'\nimport type { UseNamespaceReturn } from '@element-plus/hooks'\nimport type { TableV2HeaderRowCellRendererParams } from '../components'\nimport type { UseTableReturn } from '../use-table'\nimport type { TableV2Props } from '../table'\n\nexport type HeaderCellRendererProps = TableV2HeaderRowCellRendererParams &\n UnwrapNestedRefs> &\n Pick & {\n ns: UseNamespaceReturn\n }\n\nconst HeaderCellRenderer: FunctionalComponent = (\n props,\n { slots }\n) => {\n const { column, ns, style, onColumnSorted } = props\n\n const cellStyle = enforceUnit(style)\n\n if (column.placeholderSign === placeholderSign) {\n return (\n
\n )\n }\n\n const { headerCellRenderer, headerClass, sortable } = column\n\n /**\n * render Cell children\n */\n\n const cellProps = {\n ...props,\n class: ns.e('header-cell-text'),\n }\n\n const columnCellRenderer =\n componentToSlot(headerCellRenderer)\n\n const Cell = columnCellRenderer\n ? columnCellRenderer(cellProps)\n : renderSlot(slots, 'default', cellProps, () => [\n ,\n ])\n\n /**\n * Render cell container and sort indicator\n */\n const { sortBy, sortState, headerCellProps } = props\n\n let sorting: boolean, sortOrder: SortOrder\n if (sortState) {\n const order = sortState[column.key!]\n sorting = Boolean(oppositeOrderMap[order])\n sortOrder = sorting ? order : SortOrder.ASC\n } else {\n sorting = column.key === sortBy.key\n sortOrder = sorting ? sortBy.order : SortOrder.ASC\n }\n\n const cellKls = [\n ns.e('header-cell'),\n tryCall(headerClass, props, ''),\n column.align === Alignment.CENTER && ns.is('align-center'),\n column.align === Alignment.RIGHT && ns.is('align-right'),\n sortable && ns.is('sortable'),\n ]\n\n const cellWrapperProps = {\n ...tryCall(headerCellProps, props),\n onClick: column.sortable ? onColumnSorted : undefined,\n class: cellKls,\n style: cellStyle,\n ['data-key']: column.key,\n }\n\n // For now we don't deliver resizable column feature since it has some UX issue.\n return (\n
\n {Cell}\n\n {sortable && (\n \n )}\n
\n )\n}\n\nexport default HeaderCellRenderer\nexport type HeaderCellSlotProps = HeaderCellRendererProps & { class: string }\n"],"names":["enforceUnit","HeaderCellRenderer","slots","column","ns","onColumnSorted","props","_createVNode","placeholderSign","cellStyle","headerClass","sortable","class","Cell","columnCellRenderer","sortBy","headerCellProps","sorting","sortOrder","sortState","_mergeProps","cellKls"],"mappings":";;;;;;;;AAKA,MAAA,kBAAA,GAA0BA,CAAAA,KAAAA,EAAAA;;AAc1B,CAAA,KAAMC;AAEFC,EAAAA,MAAAA;AAAF,IACG,MAAA;IACG,EAAA;IAAEC,KAAF;IAAUC,cAAV;MAAA,KAAA,CAAA;AAAqBC,EAAAA,MAAAA,SAAAA,GAAAA,WAAAA,CAAAA,KAAAA,CAAAA,CAAAA;AAArB,EAAA,IAAwCC,MAA9C,CAAA,eAAA,KAAA,eAAA,EAAA;AAEA,IAAA,OAAeC,WAAc,CAAA,KAAA,EAAA;;AAE7B,MAAIJ,OAAOK,EAAP,SAAA;AACF,KAAA,EAAA,IAAA,CAAA,CAAA;AAAA,GAAA;QAC8DC;AAD9D,IAAA,kBAAA;AAGD,IAAA,WAAA;;GAEK,GAAA,MAAA,CAAA;QAAA,SAAA,GAAA;IAAsBC,GAAtB,KAAA;AAAmCC,IAAAA,KAAAA,EAAAA,EAAAA,CAAAA,CAAAA,CAAAA,kBAAAA,CAAAA;AAAnC,GAAA,CAAA;AAEN,EAAA,MAAA,kBAAA,GAAA,eAAA,CAAA,kBAAA,CAAA,CAAA;AACF,EAAA,MAAA,IAAA,GAAA,kBAAA,GAAA,kBAAA,CAAA,SAAA,CAAA,GAAA,UAAA,CAAA,KAAA,EAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CA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