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.

0 lines
9.2 KiB

1 month ago
  1. {"ast":null,"code":"import { inject } from 'vue';\nimport { getFixedColumnOffset, ensurePosition, getFixedColumnsClass } from '../util.mjs';\nimport { TABLE_INJECTION_KEY } from '../tokens.mjs';\nimport { useNamespace } from '../../../../hooks/use-namespace/index.mjs';\nimport { isFunction, isString } from '@vue/shared';\nfunction useStyle(props) {\n const parent = inject(TABLE_INJECTION_KEY);\n const ns = useNamespace(\"table\");\n const getHeaderRowStyle = rowIndex => {\n const headerRowStyle = parent == null ? void 0 : parent.props.headerRowStyle;\n if (isFunction(headerRowStyle)) {\n return headerRowStyle.call(null, {\n rowIndex\n });\n }\n return headerRowStyle;\n };\n const getHeaderRowClass = rowIndex => {\n const classes = [];\n const headerRowClassName = parent == null ? void 0 : parent.props.headerRowClassName;\n if (isString(headerRowClassName)) {\n classes.push(headerRowClassName);\n } else if (isFunction(headerRowClassName)) {\n classes.push(headerRowClassName.call(null, {\n rowIndex\n }));\n }\n return classes.join(\" \");\n };\n const getHeaderCellStyle = (rowIndex, columnIndex, row, column) => {\n var _a;\n let headerCellStyles = (_a = parent == null ? void 0 : parent.props.headerCellStyle) != null ? _a : {};\n if (isFunction(headerCellStyles)) {\n headerCellStyles = headerCellStyles.call(null, {\n rowIndex,\n columnIndex,\n row,\n column\n });\n }\n const fixedStyle = getFixedColumnOffset(columnIndex, column.fixed, props.store, row);\n ensurePosition(fixedStyle, \"left\");\n ensurePosition(fixedStyle, \"right\");\n return Object.assign({}, headerCellStyles, fixedStyle);\n };\n const getHeaderCellClass = (rowIndex, columnIndex, row, column) => {\n const fixedClasses = getFixedColumnsClass(ns.b(), columnIndex, column.fixed, props.store, row);\n const classes = [column.id, column.order, column.headerAlign, column.className, column.labelClassName, ...fixedClasses];\n if (!column.children) {\n classes.push(\"is-leaf\");\n }\n if (column.sortable) {\n classes.push(\"is-sortable\");\n }\n const headerCellClassName = parent == null ? void 0 : parent.props.headerCellClassName;\n if (isString(headerCellClassName)) {\n classes.push(headerCellClassName);\n } else if (isFunction(headerCellClassName)) {\n classes.push(headerCellClassName.call(null, {\n rowIndex,\n columnIndex,\n row,\n column\n }));\n }\n classes.push(ns.e(\"cell\"));\n return classes.filter(className => Boolean(className)).join(\" \");\n };\n return {\n getHeaderRowStyle,\n getHeaderRowClass,\n getHeaderCellStyle,\n getHeaderCellClass\n };\n}\nexport { useStyle as default };","map":{"version":3,"names":["useStyle","props","parent","inject","TABLE_INJECTION_KEY","ns","useNamespace","getHeaderRowStyle","rowIndex","headerRowStyle","isFunction","call","getHeaderRowClass","classes","headerRowClassName","isString","push","join","getHeaderCellStyle","columnIndex","row","column","_a","headerCellStyles","headerCellStyle","fixedStyle","getFixedColumnOffset","fixed","store","ensurePosition","Object","assign","getHeaderCellClass","fixedClasses","getFixedColumnsClass","b","id","order","headerAlign","className","labelClassName","children","sortable","headerCellClassName","e","filter","Boolean"],"sources":["../../../../../../../packages/components/table/src/table-header/style.helper.ts"],"sourcesContent":["import { inject } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { isFunction, isString } from '@element-plus/utils'\n\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<T>(props: TableHeaderProps<T>) {\n const parent = inject(TABLE_INJECTION_KEY)\n const ns = useNamespace('tabl