-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Table): improve
expanded
row (#2485)
- Loading branch information
Showing
7 changed files
with
301 additions
and
25 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
docs/components/content/examples/TableExampleDisabledExpandable.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<script setup> | ||
const people = [{ | ||
id: 1, | ||
name: 'Lindsay Walton', | ||
title: 'Front-end Developer', | ||
email: '[email protected]', | ||
role: 'Member' | ||
}, { | ||
id: 2, | ||
name: 'Courtney Henry', | ||
title: 'Designer', | ||
email: '[email protected]', | ||
role: 'Admin', | ||
disabledExpand: true | ||
}, { | ||
id: 3, | ||
name: 'Tom Cook', | ||
title: 'Director of Product', | ||
email: '[email protected]', | ||
role: 'Member' | ||
}, { | ||
id: 4, | ||
name: 'Whitney Francis', | ||
title: 'Copywriter', | ||
email: '[email protected]', | ||
role: 'Admin', | ||
disabledExpand: true | ||
}, { | ||
id: 5, | ||
name: 'Leonard Krasner', | ||
title: 'Senior Designer', | ||
email: '[email protected]', | ||
role: 'Owner' | ||
}, { | ||
id: 6, | ||
name: 'Floyd Miles', | ||
title: 'Principal Designer', | ||
email: '[email protected]', | ||
role: 'Member', | ||
disabledExpand: true | ||
}] | ||
const columns = [ | ||
{ | ||
label: 'Name', | ||
key: 'name' | ||
}, | ||
{ | ||
label: 'title', | ||
key: 'title' | ||
}, | ||
{ | ||
label: 'Email', | ||
key: 'email' | ||
}, | ||
{ | ||
label: 'role', | ||
key: 'role' | ||
} | ||
] | ||
const expand = ref({ | ||
openedRows: [], | ||
row: null | ||
}) | ||
</script> | ||
|
||
<template> | ||
<UTable v-model:expand="expand" :rows="people" :columns="columns"> | ||
<template #expand="{ row }"> | ||
<div class="p-4"> | ||
<pre>{{ row }}</pre> | ||
</div> | ||
</template> | ||
</UTable> | ||
</template> |
65 changes: 65 additions & 0 deletions
65
docs/components/content/examples/TableExampleExpandActionSlot.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<script setup lang='ts'> | ||
const people = [{ | ||
id: 1, | ||
name: 'Lindsay Walton', | ||
title: 'Front-end Developer', | ||
email: '[email protected]', | ||
role: 'Member', | ||
hasExpand: false | ||
}, { | ||
id: 2, | ||
name: 'Courtney Henry', | ||
title: 'Designer', | ||
email: '[email protected]', | ||
role: 'Admin', | ||
hasExpand: true | ||
}, { | ||
id: 3, | ||
name: 'Tom Cook', | ||
title: 'Director of Product', | ||
email: '[email protected]', | ||
role: 'Member', | ||
hasExpand: false | ||
}, { | ||
id: 4, | ||
name: 'Whitney Francis', | ||
title: 'Copywriter', | ||
email: '[email protected]', | ||
role: 'Admin', | ||
hasExpand: true | ||
}, { | ||
id: 5, | ||
name: 'Leonard Krasner', | ||
title: 'Senior Designer', | ||
email: '[email protected]', | ||
role: 'Owner', | ||
hasExpand: false | ||
}, { | ||
id: 6, | ||
name: 'Floyd Miles', | ||
title: 'Principal Designer', | ||
email: '[email protected]', | ||
role: 'Member', | ||
hasExpand: true | ||
}] | ||
const expand = ref({ | ||
openedRows: [people.find(v => v.hasExpand)], | ||
row: {} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<UTable v-model:expand="expand" :rows="people"> | ||
<template #expand="{ row }"> | ||
<div class="p-4"> | ||
<pre>{{ row }}</pre> | ||
</div> | ||
</template> | ||
<template #expand-action="{ row, isExpanded, toggle }"> | ||
<UButton v-if="row.hasExpand" @click="toggle"> | ||
{{ isExpanded ? 'collapse' : 'expand' }} | ||
</UButton> | ||
</template> | ||
</UTable> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<script setup> | ||
<script setup lang='ts'> | ||
const people = [{ | ||
id: 1, | ||
name: 'Lindsay Walton', | ||
|
@@ -36,10 +36,15 @@ const people = [{ | |
email: '[email protected]', | ||
role: 'Member' | ||
}] | ||
const expand = ref({ | ||
openedRows: [people[0]], | ||
row: {} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<UTable :rows="people"> | ||
<UTable v-model:expand="expand" :rows="people"> | ||
<template #expand="{ row }"> | ||
<div class="p-4"> | ||
<pre>{{ row }}</pre> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.