UNPKG

tav-ui

Version:
1 lines 1.59 kB
{"version":3,"file":"useTableStyle2.mjs","sources":["../../../../../../../../packages/components/table/src/hooks/useTableStyle.ts"],"sourcesContent":["import { unref } from 'vue'\nimport { isFunction } from '@tav-ui/utils/is'\nimport type { ComputedRef } from 'vue'\nimport type { BasicTableProps, TableCustomRecord } from '../types/table'\n\nexport function useTableStyle(propsRef: ComputedRef<BasicTableProps>, prefixCls: string) {\n function getRowClassName(record: TableCustomRecord, index: number) {\n const { striped, rowClassName } = unref(propsRef)\n const classNames: string[] = []\n if (striped) {\n classNames.push((index || 0) % 2 === 1 ? `${prefixCls}-row__striped` : '')\n }\n if (rowClassName && isFunction(rowClassName)) {\n classNames.push(rowClassName(record, index))\n }\n return classNames.filter((cls) => !!cls).join(' ')\n }\n\n return { getRowClassName }\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE;AACnD,EAAE,SAAS,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE;AAC1C,IAAI,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;AACtD,IAAI,MAAM,UAAU,GAAG,EAAE,CAAC;AAC1B,IAAI,IAAI,OAAO,EAAE;AACjB,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC;AACjF,KAAK;AACL,IAAI,IAAI,YAAY,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE;AAClD,MAAM,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AACnD,KAAK;AACL,IAAI,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvD,GAAG;AACH,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;AAC7B;;;;"}