diff --git a/.changeset/strange-teachers-hope.md b/.changeset/strange-teachers-hope.md new file mode 100644 index 000000000..41f36c141 --- /dev/null +++ b/.changeset/strange-teachers-hope.md @@ -0,0 +1,5 @@ +--- +"sit-onyx": patch +--- + +Added empty slot to DataGrid to be able to pass custom empty content diff --git a/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGrid.stories.ts b/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGrid.stories.ts index 0bdd671fd..926c045c9 100644 --- a/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGrid.stories.ts +++ b/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGrid.stories.ts @@ -3,6 +3,7 @@ import pin from "@sit-onyx/icons/pin.svg?raw"; import trash from "@sit-onyx/icons/trash.svg?raw"; import type { Meta, StoryObj } from "@storybook/vue3"; import { h } from "vue"; +import OnyxEmpty from "../OnyxEmpty/OnyxEmpty.vue"; import OnyxIcon from "../OnyxIcon/OnyxIcon.vue"; import OnyxMenuItem from "../OnyxNavBar/modules/OnyxMenuItem/OnyxMenuItem.vue"; import OnyxSystemButton from "../OnyxSystemButton/OnyxSystemButton.vue"; @@ -72,3 +73,11 @@ export const HeaderInteractions = { ], }, } satisfies Story; + +export const CustomEmptyState = { + args: { + columns: ["name", "age", "birthday"], + data: undefined, + empty: () => h(OnyxEmpty, null, { default: "DataGrid is empty" }), + }, +} satisfies Story; diff --git a/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGrid.vue b/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGrid.vue index 92bdafc24..e1561b019 100644 --- a/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGrid.vue +++ b/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGrid.vue @@ -16,6 +16,15 @@ const props = withDefaults(defineProps>(), const { t } = injectI18n(); +defineSlots<{ + /** + * Optional slot to customize the empty state when no data exist. + * + * If unset, the default empty content of OnyxTable will be displayed. + */ + empty?(): unknown; +}>(); + // Using Ref types to avoid `UnwrapRef` issues const renderColumns: Ref[]> = ref([]); const renderRows: Ref[]> = ref([]); @@ -53,5 +62,9 @@ watch( diff --git a/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGridRenderer/OnyxDataGridRenderer.vue b/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGridRenderer/OnyxDataGridRenderer.vue index 0a7aa8317..2a09c1a85 100644 --- a/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGridRenderer/OnyxDataGridRenderer.vue +++ b/packages/sit-onyx/src/components/OnyxDataGrid/OnyxDataGridRenderer/OnyxDataGridRenderer.vue @@ -9,6 +9,15 @@ const props = withDefaults(defineProps(); + +