Skip to content

Commit

Permalink
docs(DsfrDataTable): 📝 ajoute des précisions dans la doc
Browse files Browse the repository at this point in the history
  • Loading branch information
laruiss committed Sep 4, 2024
1 parent 8da2d8b commit 419d47a
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/components/DsfrAccordion/DsfrAccordion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('DsfrAccordion', () => {
props: {
title,
id: 'accordion-1',
expandedId: undefined,
},
slots: {
default: content,
Expand Down
8 changes: 8 additions & 0 deletions src/components/DsfrDataTable/DsfrDataTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

<VIcon name="vi-file-type-storybook" /> La story sur le tableau de données sur le storybook de [VueDsfr](https://storybook.vue-ds.fr/?path=/docs/composants-dsfrdatatable--docs)
Expand Down
10 changes: 6 additions & 4 deletions src/components/DsfrDataTable/DsfrDataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ const pages = computed<Page[]>(() => 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
Expand Down
2 changes: 0 additions & 2 deletions src/components/DsfrMedia/DsfrVideo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -22,7 +21,6 @@ describe('DsfrVideo', () => {
},
props: {
size,
format4x3,
src,
legend,
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/DsfrPagination/DsfrPagination.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
2 changes: 2 additions & 0 deletions src/components/DsfrRadioButton/DsfrRadioButton.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('DsfrRadioButton', () => {
},
props: {
label,
modelValue: undefined,
value,
name,
},
Expand Down Expand Up @@ -50,6 +51,7 @@ describe('DsfrRadioButton', () => {
props: {
label,
value,
modelValue: undefined,
name,
img,
},
Expand Down
2 changes: 2 additions & 0 deletions src/components/DsfrTabs/DsfrTabs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -102,6 +103,7 @@ describe('DsfrTabs', () => {
tabListName,
tabTitles,
tabContents,
modelValue: modelValue.value,
},
})

Expand Down
5 changes: 5 additions & 0 deletions tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"extends": "@vue/tsconfig/tsconfig.dom.json",
"compilerOptions": {
"composite": true,
"lib": [
"ES2022",
"DOM",
"DOM.Iterable"
],
"baseUrl": ".",
"rootDir": "./src",
"paths": {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.vitest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.app.json",
"compilerOptions": {
"composite": true,
"lib": [],
"lib": ["ES2022"],
"types": ["node", "jsdom"]
},
"exclude": ["**/*.spec.ts", "**/*.stories.ts", "**/*.e2e.ts"]
Expand Down

0 comments on commit 419d47a

Please sign in to comment.