element-plus
Version:
A Component Library for Vue 3
78 lines (76 loc) • 2.25 kB
JavaScript
const require_runtime = require('../../../../_virtual/_rolldown/runtime.js');
const require_utils = require('../utils.js');
const require_row = require('../components/row.js');
let vue = require("vue");
//#region ../../packages/components/table-v2/src/renderers/row.tsx
function _isSlot(s) {
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
}
const RowRenderer = (props, { slots }) => {
const { columns, columnsStyles, depthMap, expandColumnKey, expandedRowKeys, estimatedRowHeight, hasFixedColumns, rowData, rowIndex, style, isScrolling, rowProps, rowClass, rowKey, rowEventHandlers, ns, onRowHovered, onRowExpanded } = props;
const rowKls = require_utils.tryCall(rowClass, {
columns,
rowData,
rowIndex
}, "");
const additionalProps = require_utils.tryCall(rowProps, {
columns,
rowData,
rowIndex
});
const _rowKey = rowData[rowKey];
const depth = depthMap[_rowKey] || 0;
const canExpand = Boolean(expandColumnKey);
const isFixedRow = rowIndex < 0;
const kls = [
ns.e("row"),
rowKls,
ns.is("expanded", canExpand && expandedRowKeys.includes(_rowKey)),
ns.is("fixed", !depth && isFixedRow),
ns.is("customized", Boolean(slots.row)),
{ [ns.e(`row-depth-${depth}`)]: canExpand && rowIndex >= 0 }
];
const onRowHover = hasFixedColumns ? onRowHovered : void 0;
const _rowProps = {
...additionalProps,
columns,
columnsStyles,
class: kls,
depth,
expandColumnKey,
estimatedRowHeight: isFixedRow ? void 0 : estimatedRowHeight,
isScrolling,
rowIndex,
rowData,
rowKey: _rowKey,
rowEventHandlers,
style
};
const handlerMouseEnter = (e) => {
onRowHover?.({
hovered: true,
rowKey: _rowKey,
event: e,
rowData,
rowIndex
});
};
const handlerMouseLeave = (e) => {
onRowHover?.({
hovered: false,
rowKey: _rowKey,
event: e,
rowData,
rowIndex
});
};
return (0, vue.createVNode)(require_row.default, (0, vue.mergeProps)(_rowProps, {
"onRowExpand": onRowExpanded,
"onMouseenter": handlerMouseEnter,
"onMouseleave": handlerMouseLeave,
"rowkey": _rowKey
}), _isSlot(slots) ? slots : { default: () => [slots] });
};
//#endregion
exports.default = RowRenderer;
//# sourceMappingURL=row.js.map