{"version":3,"file":"index.js","sources":["../../../../../../../packages/components/table/src/table-body/index.ts"],"sourcesContent":["// @ts-nocheck\nimport {\n defineComponent,\n getCurrentInstance,\n h,\n inject,\n onUnmounted,\n watch,\n} from 'vue'\nimport { addClass, isClient, rAF, removeClass } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport useLayoutObserver from '../layout-observer'\nimport { removePopper } from '../util'\nimport { TABLE_INJECTION_KEY } from '../tokens'\nimport useRender from './render-helper'\nimport defaultProps from './defaults'\n\nimport type { VNode } from 'vue'\n\nexport default defineComponent({\n name: 'ElTableBody',\n props: defaultProps,\n setup(props) {\n const instance = getCurrentInstance()\n const parent = inject(TABLE_INJECTION_KEY)\n const ns = useNamespace('table')\n const { wrappedRowRender, tooltipContent, tooltipTrigger } =\n useRender(props)\n const { onColumnsChange, onScrollableChange } = useLayoutObserver(parent!)\n\n const hoveredCellList = []\n watch(props.store.states.hoverRow, (newVal: any, oldVal: any) => {\n const el = instance?.vnode.el as HTMLElement\n const rows = Array.from(el?.children || []).filter((e) =>\n e?.classList.contains(`${ns.e('row')}`)\n )\n\n // hover rowSpan > 1 choose the whole row\n let rowNum = newVal\n const childNodes = rows[rowNum]?.childNodes\n if (childNodes?.length) {\n let control = 0\n const indexes = Array.from(childNodes).reduce((acc, item, index) => {\n // drop colsSpan\n if (childNodes[index]?.colSpan > 1) {\n control = childNodes[index]?.colSpan\n }\n if (item.nodeName !== 'TD' && control === 0) {\n acc.push(index)\n }\n control > 0 && control--\n return acc\n }, [])\n\n indexes.forEach((rowIndex) => {\n rowNum = newVal\n while (rowNum > 0) {\n // find from previous\n const preChildNodes = rows[rowNum - 1]?.childNodes\n if (\n preChildNodes[rowIndex] &&\n preChildNodes[rowIndex].nodeName === 'TD' &&\n preChildNodes[rowIndex].rowSpan > 1\n ) {\n addClass(preChildNodes[rowIndex], 'hover-cell')\n hoveredCellList.push(preChildNodes[rowIndex])\n break\n }\n rowNum--\n }\n })\n } else {\n hoveredCellList.forEach((item) => removeClass(item, 'hover-cell'))\n hoveredCellList.length = 0\n }\n if (!props.store.states.isComplex.value || !isClient) return\n\n rAF(() => {\n // just get first level children; fix #9723\n const oldRow = rows[oldVal]\n const newRow = rows[newVal]\n // when there is fixed row, hover on rowSpan > 1 should not clear the class\n if (oldRow && !oldRow.classList.contains('hover-fixed-row')) {\n removeClass(oldRow, 'hover-row')\n }\n if (newRow) {\n addClass(newRow, 'hover-row')\n }\n })\n })\n\n onUnmounted(() => {\n removePopper?.()\n })\n\n return {\n ns,\n onColumnsChange,\n onScrollableChange,\n wrappedRowRender,\n tooltipContent,\n tooltipTrigger,\n }\n },\n render() {\n const { wrappedRowRender, store } = this\n const data = store.states.data.value || []\n // Why do we need tabIndex: -1 ?\n // If you set the tabindex attribute on an element ,\n // then its child content cannot be scrolled with the arrow keys,\n // unless you set tabindex on the content too\n // See https://github.com/facebook/react/issues/25462#issuecomment-1274775248 or https://developer.mozilla.org/zh-CN/docs/Web/HTML/Global_attributes/tabindex\n return h('tbody', { tabIndex: -1 }, [\n data.reduce((acc: VNode[], row) => {\n return acc.concat(wrappedRowRender(row, acc.length))\n }, []),\n ])\n },\n})\n"],"names":["defineComponent","defaultProps","getCurrentInstance","inject","TABLE_INJECTION_KEY","useNamespace","useRender","useLayoutObserver","watch","addClass","removeClass","isClient","rAF","onUnmounted","removePopper","h"],"mappings":";;;;;;;;;;;;;;;;;AAeA,gBAAeA,mBAAe,CAAC;AAC/B,EAAE,IAAI,EAAE,aAAa;AACrB,EAAE,KAAK,EAAEC,mBAAY;AACrB,EAAE,KAAK,CAAC,KAAK,EAAE;AACf,IAAI,MAAM,QAAQ,GAAGC,sBAAkB,EAAE,CAAC;AAC1C,IAAI,MAAM,MAAM,GAAGC,UAAM,CAACC,0BAAmB,CAAC,CAAC;AAC/C,IAAI,MAAM,EAAE,GAAGC,kBAAY,CAAC,OAAO,CAAC,CAAC;AACrC,IAAI,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAA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