Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
revolunet committed Jul 6, 2024
1 parent 57803f6 commit 3a7b50b
Show file tree
Hide file tree
Showing 18 changed files with 221 additions and 2,079 deletions.
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"node": ">=18"
},
"dependencies": {
"@codegouvfr/react-dsfr": "^1.9.20",
"@codegouvfr/react-dsfr": "^1.9.22",
"@codegouvfr/rjsf-dsfr": "^0.1.4",
"@rjsf/bootstrap-4": "^5.18.5",
"@rjsf/core": "^5.18.4",
Expand Down
91 changes: 0 additions & 91 deletions demo/src/samples/customObject.tsx

This file was deleted.

74 changes: 36 additions & 38 deletions demo/src/samples/index.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
import arrays from './arrays';
import anyOf from './anyOf';
import oneOf from './oneOf';
import allOf from './allOf';
import enumObjects from './enumObjects';
import nested from './nested';
import numbers from './numbers';
import simple from './simple';
import widgets from './widgets';
import ordering from './ordering';
import references from './references';
import custom from './custom';
import errors from './errors';
import examples from './examples';
import large from './large';
import date from './date';
import validation from './validation';
import files from './files';
import single from './single';
import customArray from './customArray';
import customFieldAnyOf from './customFieldAnyOf';
import customObject from './customObject';
import alternatives from './alternatives';
import propertyDependencies from './propertyDependencies';
import schemaDependencies from './schemaDependencies';
import additionalProperties from './additionalProperties';
import nullable from './nullable';
import nullField from './null';
import errorSchema from './errorSchema';
import defaults from './defaults';
import options from './options';
import ifThenElse from './ifThenElse';
import customField from './customField';
import { Sample } from './Sample';
import deepFreeze from 'deep-freeze-es6';
import arrays from './arrays'
import anyOf from './anyOf'
import oneOf from './oneOf'
import allOf from './allOf'
import enumObjects from './enumObjects'
import nested from './nested'
import numbers from './numbers'
import simple from './simple'
import widgets from './widgets'
import ordering from './ordering'
import references from './references'
import custom from './custom'
import errors from './errors'
import examples from './examples'
import large from './large'
import date from './date'
import validation from './validation'
import files from './files'
import single from './single'
import customArray from './customArray'
import customFieldAnyOf from './customFieldAnyOf'
import alternatives from './alternatives'
import propertyDependencies from './propertyDependencies'
import schemaDependencies from './schemaDependencies'
import additionalProperties from './additionalProperties'
import nullable from './nullable'
import nullField from './null'
import errorSchema from './errorSchema'
import defaults from './defaults'
import options from './options'
import ifThenElse from './ifThenElse'
import customField from './customField'
import { Sample } from './Sample'
import deepFreeze from 'deep-freeze-es6'

const _samples: Record<string, Sample> = {
Blank: { schema: {}, uiSchema: {}, formData: {} },
Expand All @@ -53,7 +52,6 @@ const _samples: Record<string, Sample> = {
Files: files,
Single: single,
'Custom Array': customArray,
'Custom Object': customObject,
Alternatives: alternatives,
'Property dependencies': propertyDependencies,
'Schema dependencies': schemaDependencies,
Expand All @@ -69,6 +67,6 @@ const _samples: Record<string, Sample> = {
ErrorSchema: errorSchema,
Defaults: defaults,
'Custom Field': customField,
};
}

export const samples = deepFreeze(_samples);
export const samples = deepFreeze(_samples)
52 changes: 17 additions & 35 deletions demo/src/samples/options.ts
Original file line number Diff line number Diff line change
@@ -1,74 +1,56 @@
import { Sample } from './Sample';
import { fr } from '@codegouvfr/react-dsfr'
import { Sample } from './Sample'

const optionsSample: Sample = {
schema: {
title: 'A registration form',
description: 'A simple form example. Demonstrating ui options',
title: 'Un formulaire avec des ui:options',
description: 'Description du formulaire',
type: 'object',
required: ['firstName', 'lastName'],
required: ['firstName', 'lastName', 'telephone'],
properties: {
firstName: {
type: 'string',
title: 'First name',
default: 'Chuck',
title: 'Prénom',
default: 'Louise',
},
lastName: {
type: 'string',
title: 'Last name',
title: 'Nom',
},
telephone: {
type: 'string',
title: 'Telephone',
title: 'Téléphone',
minLength: 10,
},
},
},
uiSchema: {
'ui:submitButtonOptions': {
submitText: 'Confirm Details',
norender: false,
submitText: 'Confirmer les détails',
props: {
disabled: false,
className: 'btn btn-info',
style: { color: 'yellow' },
iconId: 'fr-icon-account-circle-line',
},
},
firstName: {
'ui:autofocus': true,
'ui:emptyValue': '',
'ui:autocomplete': 'family-name',
},
lastName: {
'ui:title': 'Surname',
'ui:emptyValue': '',
'ui:autofocus': true,
'ui:title': 'Override du prénom',
'ui:autocomplete': 'given-name',
},
age: {
'ui:widget': 'updown',
'ui:title': 'Age of person',
'ui:description': '(earthian year)',
},
bio: {
'ui:widget': 'textarea',
},
password: {
'ui:widget': 'password',
'ui:help': 'Hint: Make it strong!',
},
date: {
'ui:widget': 'alt-datetime',
},
telephone: {
'ui:options': {
inputType: 'tel',
},
},
},
formData: {
lastName: 'Norris',
lastName: 'Michel',
age: 75,
bio: 'Roundhouse kicking asses since 1940',
password: 'noneed',
},
};
}

export default optionsSample;
export default optionsSample
45 changes: 21 additions & 24 deletions demo/src/samples/simple.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Sample } from './Sample';
import { Sample } from './Sample'

const simple: Sample = {
schema: {
title: 'A registration form',
description: 'A simple form example.',
title: 'Un formulaire simple',
description: 'La description du formulaire.',
type: 'object',
required: ['firstName', 'lastName'],
properties: {
firstName: {
type: 'string',
title: 'First name',
default: 'Chuck',
title: 'Prénom',
default: 'Louise',
},
lastName: {
type: 'string',
title: 'Last name',
title: 'Nom',
},
age: {
type: 'integer',
Expand All @@ -26,43 +26,40 @@ const simple: Sample = {
},
password: {
type: 'string',
title: 'Password',
title: 'Mot de passe',
minLength: 3,
},
telephone: {
type: 'string',
title: 'Telephone',
title: 'Téléphone',
minLength: 10,
},
},
},
uiSchema: {
firstName: {
'ui:autofocus': true,
'ui:emptyValue': '',
'ui:placeholder': 'ui:emptyValue causes this field to always be valid despite being required',
'ui:placeholder': 'Ex: Louise',
'ui:autocomplete': 'family-name',
'ui:enableMarkdownInDescription': true,
'ui:description':
'Make text **bold** or *italic*. Take a look at other options [here](https://markdown-to-jsx.quantizor.dev/).',
'ui:enableMarkdownInDescription': true, // todo
'ui:description': 'Description du champ firstName',
},
lastName: {
'ui:autocomplete': 'given-name',
'ui:enableMarkdownInDescription': true,
'ui:description':
'Make things **bold** or *italic*. Embed snippets of `code`. <small>And this is a small texts.</small> ',
'ui:enableMarkdownInDescription': true, // todo
'ui:description': 'Description du champ lastName',
},
age: {
'ui:widget': 'updown',
'ui:title': 'Age of person',
'ui:description': '(earth year)',
'ui:title': 'Age de la personne',
'ui:description': 'En années',
},
bio: {
'ui:widget': 'textarea',
},
password: {
'ui:widget': 'password',
'ui:help': 'Hint: Make it strong!',
'ui:help': 'Créez un mot de passe unique pour chaque service !',
},
telephone: {
'ui:options': {
Expand All @@ -71,12 +68,12 @@ const simple: Sample = {
},
},
formData: {
lastName: 'Norris',
lastName: 'Michel',
age: 75,
bio: 'Roundhouse kicking asses since 1940',
bio: 'Roundhouse kicking asses since 1830',
password: 'noneed',
telephone: '1-800-KICKASS',
telephone: '1-800-000',
},
};
}

export default simple;
export default simple
Loading

0 comments on commit 3a7b50b

Please sign in to comment.