From 419d47a3d0b6bd6e3ed44af83da2d763a9508111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanislas=20Ormi=C3=A8res?= Date: Wed, 4 Sep 2024 18:07:14 +0200 Subject: [PATCH] =?UTF-8?q?docs(DsfrDataTable):=20=F0=9F=93=9D=20ajoute=20?= =?UTF-8?q?des=20pr=C3=A9cisions=20dans=20la=20doc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DsfrAccordion/DsfrAccordion.spec.ts | 1 - src/components/DsfrDataTable/DsfrDataTable.md | 8 ++++++++ src/components/DsfrDataTable/DsfrDataTable.vue | 10 ++++++---- src/components/DsfrMedia/DsfrVideo.spec.ts | 2 -- src/components/DsfrPagination/DsfrPagination.spec.ts | 4 ++-- src/components/DsfrRadioButton/DsfrRadioButton.spec.ts | 2 ++ src/components/DsfrTabs/DsfrTabs.spec.ts | 2 ++ tsconfig.app.json | 5 +++++ tsconfig.vitest.json | 2 +- 9 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/components/DsfrAccordion/DsfrAccordion.spec.ts b/src/components/DsfrAccordion/DsfrAccordion.spec.ts index 232f78ce..0706cc55 100644 --- a/src/components/DsfrAccordion/DsfrAccordion.spec.ts +++ b/src/components/DsfrAccordion/DsfrAccordion.spec.ts @@ -26,7 +26,6 @@ describe('DsfrAccordion', () => { props: { title, id: 'accordion-1', - expandedId: undefined, }, slots: { default: content, diff --git a/src/components/DsfrDataTable/DsfrDataTable.md b/src/components/DsfrDataTable/DsfrDataTable.md index 65dc4d2a..c0355eb3 100644 --- a/src/components/DsfrDataTable/DsfrDataTable.md +++ b/src/components/DsfrDataTable/DsfrDataTable.md @@ -4,6 +4,14 @@ Le composant `DsfrDataTable` est un élément puissant et polyvalent pour afficher des données sous forme de tableaux dans vos applications Vue. Utilisant une combinaison de slots, de props, et d'événements personnalisés, ce composant offre une flexibilité remarquable. Plongeons dans les détails ! +::: warning Prudence + +Ce composant est tout neuf et a besoin de vos retours. Son API ne devrait pas changer, elle devrait s’étoffer dans les prochaines semaines ou les prochains mois. + +Si vous avez des propositions, lancer une [**discussion**](https://github.com/dnum-mi/vue-dsfr/discussions) avant d’ouvrir une issue. + +::: + 🏅 La documentation sur le tableau sur le [DSFR](https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/tableau/) La story sur le tableau de données sur le storybook de [VueDsfr](https://storybook.vue-ds.fr/?path=/docs/composants-dsfrdatatable--docs) diff --git a/src/components/DsfrDataTable/DsfrDataTable.vue b/src/components/DsfrDataTable/DsfrDataTable.vue index 7d987157..0d7c12ae 100644 --- a/src/components/DsfrDataTable/DsfrDataTable.vue +++ b/src/components/DsfrDataTable/DsfrDataTable.vue @@ -64,12 +64,14 @@ const pages = computed(() => props.pages ?? Array.from({ length: pageCou const lowestLimit = computed(() => currentPage.value * rowsPerPage.value) const highestLimit = computed(() => (currentPage.value + 1) * rowsPerPage.value) -function defaultSortFn (a, b) { - const key = props.sorted - if ((a[key] ?? a) < (b[key] ?? b)) { +function defaultSortFn (a: string | DsfrDataTableRow, b: string | DsfrDataTableRow) { + const key = props.sorted as string + // @ts-expect-error TS7015 + if (((a as DsfrDataTableRow)[key] ?? a) < ((b as DsfrDataTableRow)[key] ?? b)) { return -1 } - if ((a[key] ?? a) > (b[key] ?? b)) { + // @ts-expect-error TS7015 + if (((a as DsfrDataTableRow)[key] ?? a) > ((b as DsfrDataTableRow)[key] ?? b)) { return 1 } return 0 diff --git a/src/components/DsfrMedia/DsfrVideo.spec.ts b/src/components/DsfrMedia/DsfrVideo.spec.ts index 34a34ae1..0b08ca55 100644 --- a/src/components/DsfrMedia/DsfrVideo.spec.ts +++ b/src/components/DsfrMedia/DsfrVideo.spec.ts @@ -8,7 +8,6 @@ describe('DsfrVideo', () => { it('should render a div with a small video with transcription', () => { // Given const size = 'small' - const format4x3 = false const src = 'https://www.youtube.com/embed/HyirpmPL43I' const legend = 'Vidéo de ouf' @@ -22,7 +21,6 @@ describe('DsfrVideo', () => { }, props: { size, - format4x3, src, legend, }, diff --git a/src/components/DsfrPagination/DsfrPagination.spec.ts b/src/components/DsfrPagination/DsfrPagination.spec.ts index cd0d1e27..2c79dd18 100644 --- a/src/components/DsfrPagination/DsfrPagination.spec.ts +++ b/src/components/DsfrPagination/DsfrPagination.spec.ts @@ -32,7 +32,7 @@ describe('DsfrPagination', () => { await fireEvent.click(thirdLink) // Then - expect(emitted()['update:currentPage']).toBeTruthy() - expect(emitted()['update:currentPage'][0][0]).toBe(2) + expect(emitted()['update:current-page']).toBeTruthy() + expect(emitted()['update:current-page'][0][0]).toBe(2) }) }) diff --git a/src/components/DsfrRadioButton/DsfrRadioButton.spec.ts b/src/components/DsfrRadioButton/DsfrRadioButton.spec.ts index bacbe26e..652e70a0 100644 --- a/src/components/DsfrRadioButton/DsfrRadioButton.spec.ts +++ b/src/components/DsfrRadioButton/DsfrRadioButton.spec.ts @@ -19,6 +19,7 @@ describe('DsfrRadioButton', () => { }, props: { label, + modelValue: undefined, value, name, }, @@ -50,6 +51,7 @@ describe('DsfrRadioButton', () => { props: { label, value, + modelValue: undefined, name, img, }, diff --git a/src/components/DsfrTabs/DsfrTabs.spec.ts b/src/components/DsfrTabs/DsfrTabs.spec.ts index c2554acc..db21c5a8 100644 --- a/src/components/DsfrTabs/DsfrTabs.spec.ts +++ b/src/components/DsfrTabs/DsfrTabs.spec.ts @@ -81,6 +81,7 @@ describe('DsfrTabs', () => { const title1 = 'Titre 1' const title2 = 'Titre 2' const title3 = 'Titre 3' + const modelValue = ref(0) const tabTitles = [ { title: title1 }, @@ -102,6 +103,7 @@ describe('DsfrTabs', () => { tabListName, tabTitles, tabContents, + modelValue: modelValue.value, }, }) diff --git a/tsconfig.app.json b/tsconfig.app.json index 07a32dda..d338df60 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -2,6 +2,11 @@ "extends": "@vue/tsconfig/tsconfig.dom.json", "compilerOptions": { "composite": true, + "lib": [ + "ES2022", + "DOM", + "DOM.Iterable" + ], "baseUrl": ".", "rootDir": "./src", "paths": { diff --git a/tsconfig.vitest.json b/tsconfig.vitest.json index 14a02cc7..95e3bf8e 100644 --- a/tsconfig.vitest.json +++ b/tsconfig.vitest.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.app.json", "compilerOptions": { "composite": true, - "lib": [], + "lib": ["ES2022"], "types": ["node", "jsdom"] }, "exclude": ["**/*.spec.ts", "**/*.stories.ts", "**/*.e2e.ts"]