{"version":3,"file":"style.helper.js","sources":["../../../../../../../packages/components/table/src/table-header/style.helper.ts"],"sourcesContent":["import { inject } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport {\n ensurePosition,\n getFixedColumnOffset,\n getFixedColumnsClass,\n} from '../util'\nimport { TABLE_INJECTION_KEY } from '../tokens'\nimport type { TableColumnCtx } from '../table-column/defaults'\nimport type { TableHeaderProps } from '.'\n\nfunction useStyle(props: TableHeaderProps) {\n const parent = inject(TABLE_INJECTION_KEY)\n const ns = useNamespace('table')\n\n const getHeaderRowStyle = (rowIndex: number) => {\n const headerRowStyle = parent?.props.headerRowStyle\n if (typeof headerRowStyle === 'function') {\n return headerRowStyle.call(null, { rowIndex })\n }\n return headerRowStyle\n }\n\n const getHeaderRowClass = (rowIndex: number): string => {\n const classes: string[] = []\n const headerRowClassName = parent?.props.headerRowClassName\n if (typeof headerRowClassName === 'string') {\n classes.push(headerRowClassName)\n } else if (typeof headerRowClassName === 'function') {\n classes.push(headerRowClassName.call(null, { rowIndex }))\n }\n\n return classes.join(' ')\n }\n\n const getHeaderCellStyle = (\n rowIndex: number,\n columnIndex: number,\n row: T,\n column: TableColumnCtx\n ) => {\n let headerCellStyles = parent?.props.headerCellStyle ?? {}\n if (typeof headerCellStyles === 'function') {\n headerCellStyles = headerCellStyles.call(null, {\n rowIndex,\n columnIndex,\n row,\n column,\n })\n }\n const fixedStyle = getFixedColumnOffset(\n columnIndex,\n column.fixed,\n props.store,\n row as unknown as TableColumnCtx[]\n )\n ensurePosition(fixedStyle, 'left')\n ensurePosition(fixedStyle, 'right')\n return Object.assign({}, headerCellStyles, fixedStyle)\n }\n\n const getHeaderCellClass = (\n rowIndex: number,\n columnIndex: number,\n row: T,\n column: TableColumnCtx\n ) => {\n const fixedClasses = getFixedColumnsClass(\n ns.b(),\n columnIndex,\n column.fixed,\n props.store,\n row as unknown as TableColumnCtx[]\n )\n const classes = [\n column.id,\n column.order,\n column.headerAlign,\n column.className,\n column.labelClassName,\n ...fixedClasses,\n ]\n\n if (!column.children) {\n classes.push('is-leaf')\n }\n\n if (column.sortable) {\n classes.push('is-sortable')\n }\n\n const headerCellClassName = parent?.props.headerCellClassName\n if (typeof headerCellClassName === 'string') {\n classes.push(headerCellClassName)\n } else if (typeof headerCellClassName === 'function') {\n classes.push(\n headerCellClassName.call(null, {\n rowIndex,\n columnIndex,\n row,\n column,\n })\n )\n }\n\n classes.push(ns.e('cell'))\n\n return classes.filter((className) => Boolean(className)).join(' ')\n }\n\n return {\n getHeaderRowStyle,\n getHeaderRowClass,\n getHeaderCellStyle,\n getHeaderCellClass,\n }\n}\n\nexport default useStyle\n"],"names":["inject","TABLE_INJECTION_KEY","useNamespace","getFixedColumnOffset","ensurePosition","getFixedColumnsClass"],"mappings":";;;;;;;;;;AAQA,SAAS,QAAQ,CAAC,KAAK,EAAE;AACzB,EAAE,MAAM,MAAM,GAAGA,UAAM,CAACC,0BAAmB,CAAC,CAAC;AAC7C,EAAE,MAAM,EAAE,GAAGC,kBAAY,CAAC,OAAO,CAAC,CAAC;AACnC,EAAE,MAAM,iBAAiB,GAAG,CAAC,QAAQ,KAAK;AAC1C,IAAI,MAAM,cAAc,GAAG,MAAM,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC;AACjF,IAAI,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE;AAC9C,MAAM,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;AACrD,KAAK;AACL,IAAI,OAAO,cAAc,CAAC;AAC1B,GAAG,CAAC;AACJ,EAAE,MAAM,iBAAiB,GAAG,CAAC,QAAQ,KAAK;AAC1C,IAAI,MAAM,OAAO,GAAG,EAAE,CAAC;AACvB,IAAI,MAAM,kBAAkB,GAAG,MAAM,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC;AACzF,IAAI,IA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