Skip to content

Commit a8672e8

Browse files
authored
Merge pull request #529 from dnum-mi/develop
Develop
2 parents 7310253 + e685215 commit a8672e8

File tree

12 files changed

+88
-63
lines changed

12 files changed

+88
-63
lines changed

ci/check-exports.mjs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env node
2+
import { fileURLToPath, URL } from 'url'
23
import { readFile, writeFile } from 'fs/promises'
34
import inquirer from 'inquirer'
45
import chalk from 'chalk'
@@ -7,22 +8,25 @@ import path from 'path'
78

89
const isCI = process.argv.includes('--ci')
910

10-
const __dirname = path.dirname(new URL(import.meta.url).pathname)
11+
const getNormalizedDir = (relativeDir) => fileURLToPath(new URL(relativeDir, import.meta.url))
1112

12-
const sfcs = await globby([path.resolve(__dirname, '../src/components/**/*.vue')])
13-
const componentsDir = path.resolve(__dirname, '../src/components')
13+
// const sfcs = await globby(fileURLToPath(new URL('../src/components/**/*.vue', import.meta.url)))
14+
const sfcs = await globby('src/components/**/*.vue')
1415

15-
const projectFn = component => 'export { default as ' + path.basename(component, '.vue') + ' } from \'' + component.replace(componentsDir, '.') + '\''
16+
const projectFn = component => 'export { default as ' + path.basename(component, '.vue') + ' } from \'' + component.replace('src/components', '.') + '\''
1617

1718
const correctComponentList = sfcs.map(projectFn).sort()
1819
const correctString = correctComponentList.join('\n') + '\n'
1920

20-
const index = await readFile(path.resolve(__dirname, '../src/components/index.js'))
21+
const srcIndexFullpath = getNormalizedDir('../src/components') + path.sep + 'index.js'
22+
const typesIndexFullpath = getNormalizedDir('../types/components') + path.sep + 'index.d.ts'
23+
24+
const index = await readFile(getNormalizedDir('../src/components') + '/index.js')
2125
const currentFileContent = index.toString()
2226

2327
if (currentFileContent !== correctString) {
2428
if (process.argv.includes('--fix')) {
25-
await writeFile(path.resolve(__dirname, '../src/components/index.js'), correctString)
29+
await writeFile(srcIndexFullpath, correctString)
2630
console.log('Fixed')
2731
process.exit(0)
2832
}
@@ -51,14 +55,14 @@ if (currentFileContent !== correctString) {
5155
}
5256

5357
if (onlyInCorrectList.length || onlyInCurrentFileList.length) {
54-
console.log('dans ' + chalk.yellow.bold(path.resolve(__dirname, '../src/components/index.js')))
58+
console.log('dans ' + chalk.yellow.bold(srcIndexFullpath))
5559
}
5660

5761
if (!isCI) {
5862
await inquirer.prompt(questions).then(async answers => {
5963
if (answers.fix.toLocaleLowerCase() === 'y') {
60-
await writeFile(path.resolve(__dirname, '../src/components/index.js'), correctString)
61-
await writeFile(path.resolve(__dirname, '../types/components/index.d.ts'), correctString)
64+
await writeFile(srcIndexFullpath, correctString)
65+
await writeFile(typesIndexFullpath, correctString)
6266
console.log(chalk.green.bold('Fichier corrigé !'))
6367
process.exit(0)
6468
}

src/components/DsfrButton/DsfrButtonGroup.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { fireEvent } from '@testing-library/dom'
33
import { render } from '@testing-library/vue'
44

55
// import '@gouvfr/dsfr/dist/core/core.module.js'
6-
import { spy } from '@/../tests/unit/test-utils.js'
6+
import { spy } from '@tests/unit/test-utils.js'
77

88
import DsfrButtonGroup from './DsfrButtonGroup.vue'
99

src/components/DsfrCallout/DsfrCallout.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { OhVueIcon as VIcon } from 'oh-vue-icons'
22
import { fireEvent, render } from '@testing-library/vue'
33

4-
import { spy } from '@/../tests/unit/test-utils.js'
4+
import { spy } from '@tests/unit/test-utils.js'
55

66
// import '@gouvfr/dsfr/dist/core/core.module.js'
77

src/components/DsfrInput/DsfrInputGroup.stories.js

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import DsfrInputGroup from './DsfrInputGroup.vue'
55
* [Voir quand l’utiliser sur la documentation du DSFR](https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/champ-de-saisie)
66
*/
77
export default {
8-
component: DsfrInput,
8+
component: DsfrInputGroup,
99
title: 'Composants/Champ de saisie/Champ avec message associé - DsfrInputGroup',
1010
argTypes: {
1111
id: {
@@ -42,7 +42,7 @@ export default {
4242
},
4343
disabled: {
4444
control: 'boolean',
45-
description: 'Permet de désactiver le champ, la saisie sera impossible. Sera passé à DsfrInput si modelValue n’est pas `undefined`',
45+
description: 'Permet de désactiver le champ, la saisie sera impossible. Sera passé à DsfrInput s’il n’y a pas d’utilisation du slot par défaut',
4646
},
4747
errorMessage: {
4848
control: 'text',
@@ -52,17 +52,50 @@ export default {
5252
control: 'text',
5353
description: 'Message de validation',
5454
},
55-
isValid: {
56-
control: 'boolean',
57-
description: 'Signale si le champ est en état validé (`true`) ou non (`false`, par défaut)',
58-
},
59-
isInvalid: {
60-
control: 'boolean',
61-
description: 'Signale si le champ est en état d’erreur (`true`) ou non (`false`, par défaut)',
62-
},
6355
},
6456
}
6557

58+
export const GroupeDeChampAvecPersonnalisation = (args) => ({
59+
components: {
60+
DsfrInput,
61+
DsfrInputGroup,
62+
},
63+
data () {
64+
return {
65+
...args,
66+
}
67+
},
68+
template: `
69+
<DsfrInputGroup
70+
:error-message="errorMessage"
71+
:valid-message="validMessage"
72+
>
73+
<DsfrInput
74+
:id="id"
75+
:placeholder="placeholder"
76+
:readonly="readonly !== ''"
77+
:model-value="modelValue"
78+
:label="label"
79+
:type="type"
80+
:hint="hint"
81+
:label-visible="labelVisible"
82+
/>
83+
</DsfrInputGroup>
84+
`,
85+
})
86+
GroupeDeChampAvecPersonnalisation.args = {
87+
type: 'text',
88+
label: 'Label champ de saisie',
89+
labelVisible: true,
90+
placeholder: 'Yo',
91+
modelValue: '',
92+
validMessage: 'Message de validation',
93+
errorMessage: '',
94+
hint: 'Texte d’indice du champ',
95+
id: '',
96+
readonly: '',
97+
}
98+
6699
export const ChampEnErreur = (args) => ({
67100
components: {
68101
DsfrInput,
@@ -87,7 +120,6 @@ export const ChampEnErreur = (args) => ({
87120
:is-invalid="isInvalid"
88121
/>
89122
`,
90-
91123
})
92124
ChampEnErreur.args = {
93125
label: 'Label champ de saisie',

src/components/DsfrInput/DsfrInputGroup.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default defineComponent({
3434
labelVisible: Boolean,
3535
modelValue: {
3636
type: String,
37-
default: '',
37+
default: undefined,
3838
},
3939
placeholder: {
4040
type: String,
@@ -63,6 +63,11 @@ export default defineComponent({
6363
return this.errorMessage ? 'ri-alert-line' : 'ri-checkbox-circle-line'
6464
},
6565
},
66+
watch: {
67+
modelValue (nv, ov) {
68+
console.log({ nv, ov })
69+
},
70+
},
6671
6772
})
6873
</script>
@@ -75,9 +80,10 @@ export default defineComponent({
7580
'fr-input-group--valid': validMessage,
7681
}"
7782
>
83+
<slot name="before-input" />
7884
<slot />
7985
<DsfrInput
80-
v-if="modelValue !== undefined"
86+
v-if="!$slots.default"
8187
v-bind="$attrs"
8288
:is-valid="!!validMessage"
8389
:is-invalid="!!errorMessage"

src/components/DsfrNavigation/DsfrNavigation.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { render } from '@testing-library/vue'
44
import { createRouter, createWebHistory } from 'vue-router'
55
// import '@gouvfr/dsfr/dist/core/core.module.js'
66

7-
import { spy } from '@/../tests/unit/test-utils.js'
7+
import { spy } from '@tests/unit/test-utils.js'
88

99
import DsfrNavigation from './DsfrNavigation.vue'
1010

src/components/DsfrTable/DsfrTableCell.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { fireEvent, render } from '@testing-library/vue'
44
import DsfrTableCell from './DsfrTableCell.vue'
55
import DsfrTag from '../DsfrTag/DsfrTag.vue'
66

7-
import { spy } from '@/../tests/unit/test-utils.js'
7+
import { spy } from '@tests/unit/test-utils.js'
88

99
describe('DsfrTableCell', () => {
1010
it('should render simple cell', () => {

src/components/DsfrTable/DsfrTableHeader.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { fireEvent, render } from '@testing-library/vue'
33

44
import DsfrTableHeader from './DsfrTableHeader.vue'
55

6-
import { spy } from '@/../tests/unit/test-utils.js'
6+
import { spy } from '@tests/unit/test-utils.js'
77

88
describe('DsfrTableHeader', () => {
99
it('should render simple header cell', async () => {

src/components/DsfrTable/DsfrTableHeaders.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { fireEvent, render } from '@testing-library/vue'
33

44
import DsfrTableHeaders from './DsfrTableHeaders.vue'
55

6-
import { spy } from '@/../tests/unit/test-utils.js'
6+
import { spy } from '@tests/unit/test-utils.js'
77

88
describe('DsfrTableHeaders', () => {
99
it('should render simple header row', async () => {

src/components/DsfrTable/DsfrTableRow.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { fireEvent, render } from '@testing-library/vue'
22

33
import DsfrTableRow from './DsfrTableRow.vue'
44

5-
import { spy } from '@/../tests/unit/test-utils.js'
5+
import { spy } from '@tests/unit/test-utils.js'
66

77
describe('DsfrTableRow', () => {
88
it('should render simple row', () => {

0 commit comments

Comments
 (0)