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
26 KiB

1 month ago
  1. {"ast":null,"code":"import { inject, computed, h } from 'vue';\nimport { merge } from 'lodash-unified';\nimport { getRowIdentity } from '../util.mjs';\nimport { TABLE_INJECTION_KEY } from '../tokens.mjs';\nimport useEvents from './events-helper.mjs';\nimport useStyles from './styles-helper.mjs';\nimport TdWrapper from './td-wrapper.mjs';\nimport { useNamespace } from '../../../../hooks/use-namespace/index.mjs';\nimport { isBoolean, isPropAbsent } from '../../../../utils/types.mjs';\nfunction useRender(props) {\n const parent = inject(TABLE_INJECTION_KEY);\n const ns = useNamespace(\"table\");\n const {\n handleDoubleClick,\n handleClick,\n handleContextMenu,\n handleMouseEnter,\n handleMouseLeave,\n handleCellMouseEnter,\n handleCellMouseLeave,\n tooltipContent,\n tooltipTrigger\n } = useEvents(props);\n const {\n getRowStyle,\n getRowClass,\n getCellStyle,\n getCellClass,\n getSpan,\n getColspanRealWidth\n } = useStyles(props);\n const firstDefaultColumnIndex = computed(() => {\n return props.store.states.columns.value.findIndex(({\n type\n }) => type === \"default\");\n });\n const getKeyOfRow = (row, index) => {\n const rowKey = parent.props.rowKey;\n if (rowKey) {\n return getRowIdentity(row, rowKey);\n }\n return index;\n };\n const rowRender = (row, $index, treeRowData, expanded = false) => {\n const {\n tooltipEffect,\n tooltipOptions,\n store\n } = props;\n const {\n indent,\n columns\n } = store.states;\n const rowClasses = getRowClass(row, $index);\n let display = true;\n if (treeRowData) {\n rowClasses.push(ns.em(\"row\", `level-${treeRowData.level}`));\n display = treeRowData.display;\n }\n const displayStyle = display ? null : {\n display: \"none\"\n };\n return h(\"tr\", {\n style: [displayStyle, getRowStyle(row, $index)],\n class: rowClasses,\n key: getKeyOfRow(row, $index),\n onDblclick: $event => handleDoubleClick($event, row),\n onClick: $event => handleClick($event, row),\n onContextmenu: $event => handleContextMenu($event, row),\n onMouseenter: () => handleMouseEnter($index),\n onMouseleave: handleMouseLeave\n }, columns.value.map((column, cellIndex) => {\n const {\n rowspan,\n colspan\n } = getSpan(row, column, $index, cellIndex);\n if (!rowspan || !colspan) {\n return null;\n }\n const columnData = Object.assign({}, column);\n columnData.realWidth = getColspanRealWidth(columns.value, colspan, cellIndex);\n const data = {\n store: props.store,\n _self: props.context || parent,\n column: columnData,\n row,\n $index,\n cellIndex,\n expanded\n };\n if (cellIndex === firstDefaultColumnIndex.value && treeRowData) {\n data.treeNode = {\n indent: treeRowData.level * indent.value,\n level: treeRowData.level\n };\n if (isBoolean(treeRowData.expanded)) {\n data.treeNode.expanded = treeRowData.expanded;\n if (\"loading\" in treeRowData) {\n data.treeNode.loading = treeRowData.loading;\n }\n if (\"noLazyChildren\" in treeRowData) {\n data.treeNode.noLazyChildren = treeRowData.noLazyChildren;\n }\n }\n }\n const baseKey = `${getKeyOfRow(row, $index)},${cellIndex}`;\n const patchKey = columnData.columnKey || columnData.rawColumnKey || \"\";\n const mergedTooltipOptions = column.showOverflowTooltip && merge({\n effect: tooltipEffect\n }, tooltipOptions, column.showOverflowTooltip);\n return h(TdWrapper, {\n style: getCellStyle($index, cellIndex, row, column),\n class: getCellClass($index, cellIndex, row, column, colspan - 1),\n key: `${patchKey}${baseKey}`,\n rowspan,\n colspan,\n onMouseenter: $event => handleCellMouseEnter($event, row, mergedTooltipOptions),\n onMouseleave: handleCellMouseLeave\n }, {\n