https://github.com/codegouvfr/rjsf-dsfr
react-jsonschema-form for the DSFR
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.7%) to scientific vocabulary
Keywords
Repository
react-jsonschema-form for the DSFR
Basic Info
- Host: GitHub
- Owner: codegouvfr
- License: mit
- Language: TypeScript
- Default Branch: main
- Homepage: https://codegouvfr.github.io/rjsf-dsfr
- Size: 7.64 MB
Statistics
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 2
- Releases: 7
Topics
Metadata Files
README.md
React JSON Schema Form with the DSFR
This is a wrapper around the
react-jsonschema-form
with the components from
react-dsfr.
[!IMPORTANT] For now, this is simply extracted code from
catala-dsfr. Therefore, the API is not yet defined and and is likely to be not flexible enough for your use case.If you want to use this library, please open an issue to discuss your needs!
👉 See a demo at : https://codegouvfr.github.io/rjsf-dsfr
Installation
bash
yarn add @codegouvfr/rjsf-dsfr
Usage
For now, the API matches the one from react-jsonschema-form and you can
overrides some widgets (resp. templates) by specifying them in the props.
```tsx import { RJSFSchema } from '@rjsf/utils' import FormDSFR from '@codegouvfr/rjsf-dsfr' import { customizeValidator } from '@rjsf/validator-ajv8' import frenchLocalizer from 'ajv-i18n/localize/fr'
const validator = customizeValidator({}, frenchLocalizer)
const schema: RJSFSchema = { type: 'object', properties: { nom: { title: 'Nom', type: 'string', minLength: 2 }, prenom: { title: 'Prénom', type: 'string' }, ddn: { title: 'Date de naissance', type: 'string', format: 'date' }, }, required: ['nom'], }
export default function Form() {
return
Notes on writing schemas
Title
The titles must not be defined inside "kind" properties of the object
definition but just before the "$ref" of the calling parent:
json
"categorieEquivalenceLoyerD84216": {
"title": "Catégorie de personnes résidant en logement-foyer",
"$ref": "#/definitions/categorie_equivalence_loyer_allocation_logement_foyer"
}
UI Options
As described in the react-jsonschema-form
documentation,
you can customize the form by providing a uiSchema.
In addition to the standard options, you can use the following specific options
for rjsf-dsfr.
[!TIP] You can have a look to a real world example here
Global field options
The following options can be set for any field in the uiSchema:
ui:heading: set the heading level for the field's title (available values:h2,h3,h4,h5,h6)ui:hideTitle: hide the field's title.
Specific field options
Array fields
The following options can be set for fields of type array:
ui:addIcon: set the DSFR icon id for the Add buttonui:removeIcon: set the DSFR icon id for the Remove buttonui:tabLabel: set the label for the tab in the array field (it needs to be defined at the root of thearrayfield)
[!NOTE] By default, array fields are displayed in a
Tabscomponent. Each tab is labeled with theui:tabLabelvalue and the last tab contains the Add button.[!IMPORTANT] The
ui:hideTitleoption it's needed for items of typeobjectinside a field of typearrayto hide the unique title of the array's items.Example:
json "personnesACharge": { "ui:tabLabel": "Personne", "items": { "ui:hideTitle": true, ...
Development
Launch the playground to play with the DSFR theme :
sh
cd demo
yarn
yarn start
Owner
- Name: code.gouv.fr
- Login: codegouvfr
- Kind: organization
- Email: contact@code.gouv.fr
- Location: France
- Website: https://code.gouv.fr
- Twitter: codegouvfr
- Repositories: 44
- Profile: https://github.com/codegouvfr
Mission logiciels libres de la DINUM
GitHub Events
Total
Last Year
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Emile Rolley | e****y@t****o | 31 |
| Julien Bouquillon | j****n@b****r | 11 |
| Emile Rolley ⏚ | 4****y | 2 |
Committer Domains (Top 20 + Academic)
Dependencies
- actions/checkout v4 composite
- actions/setup-node v4 composite
- actions/checkout v4 composite
- actions/setup-node v4 composite
- bahmutov/npm-install v1 composite
- garronej/ts-ci v2.1.5 composite
- softprops/action-gh-release v2 composite
- @types/react ^18.3.3 development
- prettier ^3.3.2 development
- tsc ^2.0.4 development
- tsup ^8.1.0 development
- typescript ^5.4.5 development
- @codegouvfr/react-dsfr ^1.9.20
- @rjsf/core ^5.18.4
- @rjsf/utils ^5.18.4
- @rjsf/validator-ajv8 ^5.18.4
- react ^18.3.1
- 191 dependencies