import PropTypes, { withUndefined } from '../../_util/vue-types';
import ExpandIcon from './ExpandIcon';
import BaseMixin from '../../_util/BaseMixin';
import { connect } from '../../_util/store';
import { getSlot } from '../../_util/props-util';
const ExpandableRow = {
mixins: [BaseMixin],
name: 'ExpandableRow',
inheritAttrs: false,
props: {
prefixCls: PropTypes.string.isRequired,
rowKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
fixed: withUndefined(PropTypes.oneOfType([PropTypes.string, PropTypes.looseBool])),
record: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,
indentSize: PropTypes.number,
needIndentSpaced: PropTypes.looseBool.isRequired,
expandRowByClick: PropTypes.looseBool,
expanded: PropTypes.looseBool.isRequired,
expandIconAsCell: PropTypes.looseBool,
expandIconColumnIndex: PropTypes.number,
childrenColumnName: PropTypes.string,
expandedRowRender: PropTypes.func,
expandIcon: PropTypes.func,
// onExpandedChange: PropTypes.func.isRequired,
// onRowClick: PropTypes.func,
// children: PropTypes.func.isRequired,
},
beforeUnmount() {
this.handleDestroy();
},
methods: {
hasExpandIcon(columnIndex) {
const { expandRowByClick, expandIcon } = this.$props;
if (this.tempExpandIconAsCell || columnIndex !== this.tempExpandIconColumnIndex) {
return false;
}
return !!expandIcon || !expandRowByClick;
},
handleExpandChange(record, event) {
const { expanded, rowKey } = this;
this.__emit('expandedChange', !expanded, record, event, rowKey);
},
handleDestroy() {
const { rowKey, record } = this;
this.__emit('expandedChange', false, record, null, rowKey, true);
},
handleRowClick(record, index, event) {
const { expandRowByClick } = this;
if (expandRowByClick) {
this.handleExpandChange(record, event);
}
this.__emit('rowClick', record, index, event);
},
renderExpandIcon() {
const { prefixCls, expanded, record, needIndentSpaced, expandIcon } = this;
if (expandIcon) {
return expandIcon({
prefixCls,
expanded,
record,
needIndentSpaced,
expandable: this.expandable,
onExpand: this.handleExpandChange,
});
}
return (