Skip to content

Commit 660e4d5

Browse files
authored
Merge pull request #632 from dnum-mi/develop
Develop
2 parents 2370eeb + 5b92d7c commit 660e4d5

File tree

7 files changed

+43
-10
lines changed

7 files changed

+43
-10
lines changed

src/components/DsfrButton/DsfrButton.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script lang="ts" setup>
22
import { type Ref, computed, ref } from 'vue'
33
import { OhVueIcon as VIcon } from 'oh-vue-icons'
4-
import { type CustomizeIconType } from 'oh-vue-icons'
54
65
// import '@gouvfr/dsfr/dist/component/button/button.module.js'
76
@@ -14,7 +13,7 @@ export type DsfrButtonProps = {
1413
iconOnly?: boolean
1514
noOutline?: boolean
1615
size?: 'sm' | 'small' | 'lg' | 'large' | 'md' | 'medium' | '' | undefined
17-
icon?: string | CustomizeIconType
16+
icon?: string | InstanceType<typeof VIcon>['$props']
1817
onClick?: ($event: MouseEvent) => void
1918
}
2019

src/components/DsfrFooter/DsfrFooter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ const aLicenceHref = computed(() => {
142142
/>
143143
</RouterLink>
144144
<RouterLink
145+
v-if="operatorImgSrc"
145146
class="fr-footer__brand-link"
146147
:to="operatorTo"
147148
:title="operatorLinkText"
148149
>
149150
<img
150-
v-if="operatorImgSrc"
151151
class="fr-footer__logo fr-responsive-img"
152152
:style="[
153153
typeof operatorImgStyle === 'string' ? operatorImgStyle : '',

src/components/DsfrModal/DsfrModal.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ import { FocusTrap } from 'focus-trap-vue'
55
66
import DsfrButtonGroup from '../DsfrButton/DsfrButtonGroup.vue'
77
import { onMounted, onBeforeUnmount, computed, ref, nextTick, watch, Ref } from 'vue'
8+
import { getRandomId } from '@/utils/random-utils'
89
910
const props = withDefaults(defineProps<{
11+
modalId?: string
1012
opened?: boolean
1113
actions?: Record<string, any>[]
1214
isAlert?: boolean
1315
origin?: {focus:() => void}
1416
title: string
1517
icon?: string
1618
}>(), {
19+
modalId: () => getRandomId('modal', 'dialog'),
1720
actions: () => [],
1821
origin: () => ({ focus () {} }), // eslint-disable-line @typescript-eslint/no-empty-function
1922
icon: undefined,
@@ -35,14 +38,18 @@ const closeBtn: Ref<HTMLButtonElement | null> = ref(null)
3538
watch(() => props.opened, (newValue) => {
3639
if (newValue) {
3740
document.body.classList.add('modal-open')
41+
modal.value?.showModal()
3842
setTimeout(() => {
3943
closeBtn.value?.focus()
4044
}, 100)
4145
} else {
4246
document.body.classList.remove('modal-open')
47+
modal.value?.close()
4348
}
4449
})
4550
51+
const modal = ref()
52+
4653
onMounted(() => {
4754
startListeningToEscape()
4855
})
@@ -72,10 +79,12 @@ async function close () {
7279
>
7380
<dialog
7481
id="fr-modal-1"
75-
aria-labelledby="fr-modal-title-modal-1"
82+
ref="modal"
83+
:aria-labelledby="modalId"
7684
:role="role"
7785
class="fr-modal"
7886
:class="{'fr-modal--opened': opened}"
87+
:open="opened"
7988
>
8089
<div class="fr-container fr-container--fluid fr-container-md">
8190
<div class="fr-grid-row fr-grid-row--center">
@@ -97,7 +106,7 @@ async function close () {
97106
</div>
98107
<div class="fr-modal__content">
99108
<h1
100-
id="fr-modal-title-modal-1"
109+
:id="modalId"
101110
class="fr-modal__title"
102111
>
103112
<span

src/components/DsfrTable/DsfrTable.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import DsfrTableHeaders from './DsfrTableHeaders.vue'
55
import { type DsfrTableHeadersProps } from './DsfrTableHeaders.vue'
66
77
const props = withDefaults(defineProps<{
8-
title?: string
8+
title: string
99
headers?: DsfrTableHeadersProps
1010
rows?:(DsfrTableRowProps | string[])[]
1111
noCaption?: boolean
1212
pagination?: boolean
1313
defaultCurrentPage?: number
1414
defaultOptionSelected?: number
1515
}>(), {
16-
title: undefined,
1716
headers: () => [],
1817
rows: () => [],
1918
defaultCurrentPage: 1,

src/components/DsfrTable/DsfrTableHeader.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script lang="ts" setup>
22
import { type ThHTMLAttributes } from 'vue'
3-
import { type CustomizeIconType, OhVueIcon as VIcon } from 'oh-vue-icons'
3+
import { OhVueIcon as VIcon } from 'oh-vue-icons'
44
55
export type DsfrTableHeaderProps = {
66
header?: string
77
headerAttrs?: ThHTMLAttributes & { onClick?: (e: MouseEvent) => void }
8-
icon?: CustomizeIconType
8+
icon?: InstanceType<typeof VIcon>['$props']
99
}
1010
1111
withDefaults(defineProps<DsfrTableHeaderProps>(), {

src/components/DsfrTabs/DsfrTabs.stories.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from '@storybook/jest'
22
import { within, userEvent } from '@storybook/testing-library'
3+
import DsfrButton from '../DsfrButton/DsfrButton.vue'
34
import DsfrTabs from './DsfrTabs.vue'
45
import DsfrTabContent from './DsfrTabContent.vue'
56

@@ -130,7 +131,7 @@ const customTabTitles = [
130131
]
131132

132133
export const OngletsComplexes = (args) => ({
133-
components: { DsfrTabs, DsfrTabContent },
134+
components: { DsfrTabs, DsfrTabContent, DsfrButton },
134135
data () {
135136
return {
136137
...args,
@@ -140,6 +141,7 @@ export const OngletsComplexes = (args) => ({
140141

141142
template: `
142143
<DsfrTabs
144+
ref="tabs"
143145
:tab-list-name="tabListName"
144146
:tab-titles="tabTitles"
145147
:initial-selected-index="initialSelectedIndex"
@@ -181,6 +183,24 @@ export const OngletsComplexes = (args) => ({
181183
<div>Contenu 4 avec d'autres composants</div>
182184
</DsfrTabContent>
183185
</DsfrTabs>
186+
<div style="display: flex; gap: 1rem; margin-block: 1rem;">
187+
<DsfrButton
188+
label="Activer le 1er onglet"
189+
@click="() => { $refs.tabs.selectFirst() }"
190+
/>
191+
<DsfrButton
192+
label="Activer le 2è onglet"
193+
@click="() => { $refs.tabs.selectIndex(1) }"
194+
/>
195+
<DsfrButton
196+
label="Activer le 3è onglet"
197+
@click="() => { $refs.tabs.selectIndex(2) }"
198+
/>
199+
<DsfrButton
200+
label="Activer le dernier onglet"
201+
@click="() => { $refs.tabs.selectLast() }"
202+
/>
203+
</div>
184204
`,
185205

186206
methods: {

src/components/DsfrTabs/DsfrTabs.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ const selectFirst = async () => {
105105
const selectLast = async () => {
106106
await selectIndex(props.tabTitles.length - 1)
107107
}
108+
109+
defineExpose({
110+
selectIndex,
111+
selectFirst,
112+
selectLast,
113+
})
108114
</script>
109115

110116
<template>

0 commit comments

Comments
 (0)