Skip to content

Commit 505de91

Browse files
committed
feat: ✨ exporte les symboles pour les clés d’injection
1 parent bbc4458 commit 505de91

File tree

8 files changed

+15
-9
lines changed

8 files changed

+15
-9
lines changed

ci/check-exports.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ const isCI = process.argv.includes('--ci')
1414
const getNormalizedDir = (relativeDir) => fileURLToPath(new URL(relativeDir, import.meta.url))
1515

1616
// const sfcs = await globby(fileURLToPath(new URL('../src/components/**/*.vue', import.meta.url)))
17-
const sfcs = (await globby('src/components/**/*.{vue,types.ts}'))
18-
.filter(path => !/Demo|Example/.test(path))
17+
const sfcs = (await globby('src/components/**/*.{vue,ts}'))
18+
.filter(path => !/Demo|Example|stories|spec\.ts|index\.ts/.test(path))
1919
.map(path => path.replace(/^(.*).types.ts$/, '$1.types'))
2020

21-
const projectFn = component => component.endsWith('types')
22-
? `export * from '${component.replace('src/components', '.')}'`
21+
const projectFn = component => (component.endsWith('types') || component.includes('injection-key.ts'))
22+
? `export * from '${component.replace('src/components', '.').replace(/\.ts$/, '')}'`
2323
: `export { default as ${path.basename(component, '.vue')} } from '${component.replace('src/components', '.')}'`
2424

2525
const correctComponentList = sfcs.map(projectFn).sort()

src/components/DsfrAccordion/DsfrAccordion.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ Ce composant peut être utilisé uniquement avec [`DsfrAccordionsGroup`](/compos
4848
::: code-group
4949
<<< DsfrAccordion.vue
5050
<<< DsfrAccordion.types.ts
51+
<<< injection-key.ts
5152
:::

src/components/DsfrAccordion/DsfrAccordion.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { inject, onMounted, ref, toRef, watch } from 'vue'
33
44
import { useCollapsable } from '../../composables'
55
import { getRandomId } from '../../utils/random-utils'
6-
import { registerTabKey } from './injection-key'
6+
import { registerAccordionKey } from './injection-key'
77
import type { DsfrAccordionProps } from './DsfrAccordion.types'
88
99
export type { DsfrAccordionProps }
@@ -27,7 +27,7 @@ const {
2727
2828
const isStandaloneActive = ref()
2929
30-
const useAccordion = inject(registerTabKey)!
30+
const useAccordion = inject(registerAccordionKey)!
3131
const { isActive, expand } = useAccordion?.(toRef(() => props.title)) ?? { isActive: isStandaloneActive, expand: () => isStandaloneActive.value = !isStandaloneActive.value }
3232
3333
onMounted(() => {

src/components/DsfrAccordion/DsfrAccordionsGroup.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { computed, onUnmounted, provide, ref, type Ref, watch } from 'vue'
33
4-
import { registerTabKey } from './injection-key'
4+
import { registerAccordionKey } from './injection-key'
55
66
const props = withDefaults(defineProps<{
77
modelValue?: number
@@ -21,7 +21,7 @@ const activeAccordion = computed({
2121
})
2222
const accordions = ref(new Map<number, string>())
2323
const currentId = ref(0)
24-
provide(registerTabKey, (title: Ref<string>) => {
24+
provide(registerAccordionKey, (title: Ref<string>) => {
2525
const myIndex = currentId.value++
2626
accordions.value.set(myIndex, title.value)
2727

src/components/DsfrAccordion/injection-key.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ type RegisterTab = (title: Ref<string>) => {
55
expand: () => void
66
}
77

8-
export const registerTabKey: InjectionKey<RegisterTab> = Symbol('accordions')
8+
export const registerAccordionKey: InjectionKey<RegisterTab> = Symbol('accordions')

src/components/DsfrHeader/DsfrHeader.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Exemple plus complet sur l’[application de demo](https://demo.vue-ds.fr/) (don
8080

8181
<<< DsfrHeader.vue
8282
<<< DsfrHeader.types.ts
83+
<<< injection-key.ts
8384

8485
:::
8586

src/components/DsfrTabs/DsfrTabs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ activeTab.value = tabTitles.length - 1 // active le dernier onglet
141141
<<< DsfrTabContent.vue
142142
<<< DsfrTabItem.vue
143143
<<< DsfrTabs.types.ts
144+
<<< injection-key.ts
144145
:::
145146

146147
<script setup lang="ts">

src/components/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './DsfrAccordion/DsfrAccordion.types'
2+
export * from './DsfrAccordion/injection-key'
23
export * from './DsfrAlert/DsfrAlert.types'
34
export * from './DsfrBackToTop/DsfrBackToTop.types'
45
export * from './DsfrBadge/DsfrBadge.types'
@@ -17,6 +18,7 @@ export * from './DsfrFollow/DsfrFollow.types'
1718
export * from './DsfrFooter/DsfrFooter.types'
1819
export * from './DsfrFranceConnect/DsfrFranceConnect.types'
1920
export * from './DsfrHeader/DsfrHeader.types'
21+
export * from './DsfrHeader/injection-key'
2022
export * from './DsfrHighlight/DsfrHighlight.types'
2123
export * from './DsfrInput/DsfrInput.types'
2224
export * from './DsfrLanguageSelector/DsfrLanguageSelector.types'
@@ -39,6 +41,7 @@ export * from './DsfrStepper/DsfrStepper.types'
3941
export * from './DsfrSummary/DsfrSummary.types'
4042
export * from './DsfrTable/DsfrTable.types'
4143
export * from './DsfrTabs/DsfrTabs.types'
44+
export * from './DsfrTabs/injection-key'
4245
export * from './DsfrTag/DsfrTags.types'
4346
export * from './DsfrTile/DsfrTiles.types'
4447
export * from './DsfrToggleSwitch/DsfrToggleSwitch.types'

0 commit comments

Comments
 (0)