Skip to content

Commit 580c8f3

Browse files
authored
Merge pull request #554 from dnum-mi/fix/fix-types-and-build-2
fix/fix types and build 2
2 parents 4611a33 + dfbdcc3 commit 580c8f3

File tree

9 files changed

+19
-13
lines changed

9 files changed

+19
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"semantic-release": "semantic-release",
6262
"typecheck": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
6363
"vite:build": "vite build && npm run typegen",
64-
"typegen": "vue-tsc --declaration --emitDeclarationOnly || exit 0"
64+
"typegen": "vue-tsc --declaration --emitDeclarationOnly"
6565
},
6666
"dependencies": {
6767
"@gouvfr/dsfr": "~1.9.3",

src/components/DsfrNavigation/DsfrNavigation.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ onUnmounted(() => {
8080
v-for="(navItem, idx) of navItems"
8181
:key="idx"
8282
>
83-
<!-- @vue-ignore -->
8483
<DsfrNavigationMenuLink
8584
v-if="navItem.to && navItem.text"
8685
v-bind="navItem"

src/components/DsfrNavigation/DsfrNavigationMenuLink.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { RouteLocationNormalized } from 'vue-router'
66
77
export type DsfrNavigationMenuLinkProps = {
88
id?: string,
9-
to: string | RouteLocationNormalized,
10-
text: string,
9+
to?: string | RouteLocationNormalized,
10+
text?: string,
1111
icon?: string,
1212
onClick?: ($event: MouseEvent) => void
1313
}
@@ -16,6 +16,8 @@ const props = withDefaults(defineProps<DsfrNavigationMenuLinkProps>(), {
1616
id: () => getRandomId('menu-link'),
1717
icon: undefined,
1818
onClick: () => undefined,
19+
text: '',
20+
to: '#',
1921
})
2022
2123
defineEmits<{(event: 'toggle-id', id: string): void}>()

src/components/DsfrRadioButton/DsfrRadioButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getRandomId } from '../../utils/random-utils'
44
55
export type DsfrRadioButtonProps = {
66
id?: string
7-
name: string
7+
name?: string
88
modelValue?: string | number
99
small?: boolean
1010
value: string | number

src/components/DsfrRadioButton/DsfrRadioButtonSet.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ const onChange = ($event: string) => {
7171
class="fr-fieldset__content"
7272
role="radiogroup"
7373
>
74-
<!-- @vue-ignore -->
7574
<DsfrRadioButton
7675
v-for="(option, i) of options"
7776
:key="option.value || i"

src/components/DsfrTable/DsfrTable.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ import { type DsfrTableHeaderProps } from './DsfrTableHeader.vue'
66
withDefaults(defineProps<{
77
title?: string
88
headers?:(DsfrTableHeaderProps | string)[]
9-
rows?: DsfrTableRowProps[]
9+
rows?: (DsfrTableRowProps | string)[]
1010
noCaption?: boolean
1111
}>(), {
1212
title: undefined,
1313
headers: () => [],
14+
rows: () => [],
1415
})
16+
17+
const getRowData = (row: (DsfrTableRowProps | string | ({component: string} & Record<string, any>))) => {
18+
// @ts-ignore TODO: find a way to improve types here
19+
return row.rowData || row
20+
}
1521
</script>
1622

1723
<template>
@@ -38,12 +44,11 @@ withDefaults(defineProps<{
3844
<!-- @slot Slot par défaut pour le corps du tableau. Sera dans `<tbody>` -->
3945
<slot />
4046
<template v-if="rows && rows.length">
41-
<!-- @vue-ignore -->
4247
<DsfrTableRow
4348
v-for="(row, i) of rows"
4449
:key="i"
45-
:row-data="row.rowData || row"
46-
:row-attrs="row.rowAttrs || {}"
50+
:row-data="getRowData(row)"
51+
:row-attrs="typeof row === 'string' ? {} : row.rowAttrs"
4752
/>
4853
</template>
4954
</tbody>

src/components/DsfrTable/DsfrTableHeaders.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ describe('DsfrTableHeaders', () => {
4040
expect(thEls).toHaveLength(headers.length)
4141
let i = 0
4242
for (const header of thEls) {
43-
expect(header).toContainHTML(headers[i].text || headers[i])
43+
// @ts-ignore text will be present
44+
expect(header).toContainHTML((headers[i]).text || headers[i])
4445
i++
4546
}
4647
expect(onClick).toHaveBeenCalledTimes(1)

src/components/DsfrTable/DsfrTableRow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { type HTMLAttributes } from 'vue'
33
import DsfrTableCell from './DsfrTableCell.vue'
44
55
export type DsfrTableRowProps = {
6-
rowData?: Record<string, any>[]
6+
rowData?: (string | Record<string, any>)[]
77
rowAttrs?: HTMLAttributes
88
}
99

tsconfig.app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"checkJs": true,
2929
"target": "ESNext",
3030
"paths": {
31-
"@/*": ["./src/*"]
31+
"@/*": ["./*"]
3232
},
3333
"lib": ["ES2020", "DOM"],
3434
"types": ["cypress", "node"]

0 commit comments

Comments
 (0)