Skip to content

Commit 4fc7833

Browse files
committed
feat(data-table): add no-data slot
1 parent 13f786b commit 4fc7833

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

packages/ui/src/components/va-data-table/VaDataTable.stories.ts

+31
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,34 @@ export const ExpandableRow = () => ({
197197
</VaDataTable>
198198
`,
199199
})
200+
201+
export const NoDataText = () => ({
202+
components: { VaDataTable, VaPagination },
203+
data: () => ({ columns, items }),
204+
205+
template: `
206+
<VaDataTable :items="[]" :columns="columns" no-data-html="Test no data" />
207+
`,
208+
})
209+
210+
export const NoDataTextSlot = () => ({
211+
components: { VaDataTable, VaPagination },
212+
data: () => ({ columns, items }),
213+
214+
template: `
215+
<VaDataTable :items="[]" :columns="columns">
216+
<template #no-data>
217+
<div class="text-center">No data Test</div>
218+
</template>
219+
</VaDataTable>
220+
`,
221+
})
222+
223+
export const NoFilteredDataText = () => ({
224+
components: { VaDataTable, VaPagination },
225+
data: () => ({ columns, items }),
226+
227+
template: `
228+
<VaDataTable :items="[]" :columns="columns" filter="Aaa" no-data-filtered-html="Test no filtered data" />
229+
`,
230+
})

packages/ui/src/components/va-data-table/VaDataTable.vue

+12-4
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@
7676
<td
7777
class="va-data-table__table-td no-data"
7878
colspan="99999"
79-
v-html="noDataHtml"
80-
/>
79+
>
80+
<slot name="no-data">
81+
<div v-html="noDataHtml" />
82+
</slot>
83+
</td>
8184
</tr>
8285

8386
<tr
@@ -88,8 +91,13 @@
8891
<td
8992
class="va-data-table__table-td no-data"
9093
colspan="99999"
91-
v-html="noDataFilteredHtml"
92-
/>
94+
>
95+
<slot name="no-filtered-data">
96+
<slot name="no-data">
97+
<div v-html="noDataFilteredHtml" />
98+
</slot>
99+
</slot>
100+
</td>
93101
</tr>
94102

95103
<template

0 commit comments

Comments
 (0)