diff --git a/src/runtime/components/Table.vue b/src/runtime/components/Table.vue index 00c17056..7138f742 100644 --- a/src/runtime/components/Table.vue +++ b/src/runtime/components/Table.vue @@ -161,6 +161,7 @@ type DynamicCellSlots = Record = { expanded: (props: { row: Row }) => any empty: (props?: {}) => any + loading: (props?: {}) => any caption: (props?: {}) => any } & DynamicHeaderSlots & DynamicCellSlots @@ -175,7 +176,7 @@ import { reactiveOmit } from '@vueuse/core' import { useLocale } from '../composables/useLocale' const props = defineProps>() -defineSlots>() +const slots = defineSlots>() const { t } = useLocale() @@ -359,7 +360,13 @@ defineExpose({ - + + + + + + + {{ t('table.noData') }} diff --git a/src/theme/table.ts b/src/theme/table.ts index 6f7bb757..75943e59 100644 --- a/src/theme/table.ts +++ b/src/theme/table.ts @@ -10,7 +10,8 @@ export default (options: Required) => ({ tr: 'data-[selected=true]:bg-(--ui-bg-elevated)/50', th: 'px-4 py-3.5 text-sm text-(--ui-text-highlighted) text-left rtl:text-right font-semibold [&:has([role=checkbox])]:pe-0', td: 'p-4 text-sm text-(--ui-text-muted) whitespace-nowrap [&:has([role=checkbox])]:pe-0', - empty: 'py-6 text-center text-sm text-(--ui-text-muted)' + empty: 'py-6 text-center text-sm text-(--ui-text-muted)', + loading: 'py-6 text-center' }, variants: { pinned: { diff --git a/test/components/Table.spec.ts b/test/components/Table.spec.ts index b834f5d8..053d67c1 100644 --- a/test/components/Table.spec.ts +++ b/test/components/Table.spec.ts @@ -158,7 +158,8 @@ describe('Table', () => { ['with header slot', { props, slots: { 'id-header': () => 'ID Header slot' } }], ['with cell slot', { props, slots: { 'id-cell': () => 'ID Cell slot' } }], ['with expanded slot', { props, slots: { expanded: () => 'Expanded slot' } }], - ['with empty slot', { props, slots: { empty: () => 'Empty slot' } }], + ['with empty slot', { props: { ...props, data: [], columns }, slots: { empty: () => 'Empty slot' } }], + ['with loading slot', { props: { ...props, data: [], columns, loading: true }, slots: { loading: () => 'Loading slot' } }], ['with caption slot', { props, slots: { caption: () => 'Caption slot' } }] ])('renders %s correctly', async (nameOrHtml: string, options: { props?: TableProps, slots?: Partial> }) => { const html = await ComponentRender(nameOrHtml, options, Table) diff --git a/test/components/__snapshots__/Table-vue.spec.ts.snap b/test/components/__snapshots__/Table-vue.spec.ts.snap index 64d4d83b..bf848e8a 100644 --- a/test/components/__snapshots__/Table-vue.spec.ts.snap +++ b/test/components/__snapshots__/Table-vue.spec.ts.snap @@ -514,48 +514,33 @@ exports[`Table > renders with empty slot correctly 1`] = ` - Id - Amount + +
+
+ +
+ + # + Date Status - Email + + +
Amount
+ + + + - - m5gr84i9 - 316 - success - ken99@yahoo.com + + Empty slot - - - 3u1reuv4 - 242 - success - Abe45@gmail.com - - - - derv1ws0 - 837 - processing - Monserrat44@gmail.com - - - - 5kma53ae - 874 - success - Silas22@gmail.com - - - - bhqecj4p - 721 - failed - carmella@hotmail.com - - " @@ -1303,6 +1288,44 @@ exports[`Table > renders with loading correctly 1`] = ` " `; +exports[`Table > renders with loading slot correctly 1`] = ` +"
+ + + + + + + + + + + + + + + + + + +
+
+
+ +
+
#DateStatus +
Amount
+
+ +
Loading slot
+
" +`; + exports[`Table > renders with sticky correctly 1`] = ` "
@@ -1417,7 +1440,7 @@ exports[`Table > renders without data correctly 1`] = ` - + diff --git a/test/components/__snapshots__/Table.spec.ts.snap b/test/components/__snapshots__/Table.spec.ts.snap index 2ee106ff..eb12408c 100644 --- a/test/components/__snapshots__/Table.spec.ts.snap +++ b/test/components/__snapshots__/Table.spec.ts.snap @@ -514,48 +514,33 @@ exports[`Table > renders with empty slot correctly 1`] = ` - - + + + - + + + - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
No data
IdAmount +
+
+ +
+
#Date StatusEmail +
Amount
+
+ +
m5gr84i9316successken99@yahoo.com
Empty slot
3u1reuv4242successAbe45@gmail.com
derv1ws0837processingMonserrat44@gmail.com
5kma53ae874successSilas22@gmail.com
bhqecj4p721failedcarmella@hotmail.com
" @@ -1303,6 +1288,44 @@ exports[`Table > renders with loading correctly 1`] = ` " `; +exports[`Table > renders with loading slot correctly 1`] = ` +"
+ + + + + + + + + + + + + + + + + + +
+
+
+ +
+
#DateStatus +
Amount
+
+ +
Loading slot
+
" +`; + exports[`Table > renders with sticky correctly 1`] = ` "
@@ -1417,7 +1440,7 @@ exports[`Table > renders without data correctly 1`] = ` - +
No data