🌐 AI搜索 & 代理 主页
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 36 additions & 23 deletions src/components/table/helpers/mixin-tbody-row.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import get from '../../../utils/get'
import toString from '../../../utils/to-string'
import { isFunction, isString, isUndefinedOrNull } from '../../../utils/inspect'
import { BVCollapse } from '../../../utils/bv-collapse'
import { BTr } from '../tr'
import { BTd } from '../td'
import { BTh } from '../th'
Expand All @@ -16,6 +17,10 @@ export default {
detailsTdClass: {
type: [String, Array, Object],
default: null
},
detailsCollapse: {
type: Boolean,
default: false
}
},
methods: {
Expand Down Expand Up @@ -179,6 +184,7 @@ export default {
const tableStriped = this.striped
const hasDetailsSlot = this.hasNormalizedSlot(detailsSlotName)
const rowShowDetails = Boolean(item._showDetails && hasDetailsSlot)
const detailsCollapse = this.detailsCollapse
const hasRowClickHandler = this.$listeners['row-clicked'] || this.hasSelectableRowClick

// We can return more than one TR if rowDetails enabled
Expand Down Expand Up @@ -249,6 +255,8 @@ export default {
)
)

const detailsKey = hasDetailsSlot ? `__b-table-details__${rowKey}` : null

// Row Details slot
if (rowShowDetails) {
const detailsScope = {
Expand All @@ -265,11 +273,6 @@ export default {
detailsScope.unselectRow = () => this.unselectRow(rowIndex)
}

// Render the details slot in a TD
const $details = h(BTd, { props: { colspan: fields.length }, class: this.detailsTdClass }, [
this.normalizeSlot(detailsSlotName, detailsScope)
])

// Add a hidden row to keep table row striping consistent when details showing
// Only added if the table is striped
if (tableStriped) {
Expand All @@ -283,31 +286,41 @@ export default {
)
}

// Render the details slot in a TD
let $details = h(BTd, { props: { colspan: fields.length }, class: this.detailsTdClass }, [
this.normalizeSlot(detailsSlotName, detailsScope)
])
// Add the actual details row
$rows.push(
h(
BTr,
{
key: `__b-table-details__${rowKey}`,
staticClass: 'b-table-details',
class: [
isFunction(this.tbodyTrClass)
? this.tbodyTrClass(item, detailsSlotName)
: this.tbodyTrClass
],
props: { variant: item._rowVariant || null },
attrs: { id: detailsId, tabindex: '-1' }
},
[$details]
)
$details = h(
BTr,
{
key: detailsKey,
staticClass: 'b-table-details',
class: [
isFunction(this.tbodyTrClass)
? this.tbodyTrClass(item, detailsSlotName)
: this.tbodyTrClass
],
props: { variant: item._rowVariant || null },
attrs: { id: detailsId, tabindex: '-1' }
},
[$details]
)
// Wrap in transition if collapsing requested
$details = detailsCollapse
? h(BVCollapse, { key: detailsKey, props: { appear: true } }, [$details])
: $details
$rows.push($details)
} else if (hasDetailsSlot) {
// Only add the placeholder if a the table has a row-details slot defined (but not shown)
$rows.push(h())
if (tableStriped) {
// Add extra placeholder if table is striped
$rows.push(h())
}
// Only add the placeholder if a the table has a row-details slot defined (but not shown)
$rows.push(detailsCollapse
? h(BVCollapse, { key: detailsKey, props: { appear: true } }, [h()])
: h()
)
}

// Return the row(s)
Expand Down