@mostajs/schema-form
v0.3.0
Published
Interface de SAISIE générique pilotée par schéma (zéro-dép) : sections + champs typés (text/textarea/number/boolean/select/color/date/localized/repeater), chemins imbriqués, multilingue AR/FR/EN. Rendu HTML (renderForm) + relecture (readValues). Réutilisa
Maintainers
Readme
@mostajs/schema-form
Auteur : Dr Hamid MADANI [email protected] · Licence : AGPL-3.0-or-later · Niveau : N2
Proposition : docs/00-CARTOGRAPHIE-ET-PROPOSITION.md (cas C, règle d'or §0)
Interface de saisie générique pilotée par schéma, zéro-dépendance (HTML-string) —
réutilisable par toute app @mostajs. Généralise le SchemaForm de TicketFlow :
sections, champs typés, chemins imbriqués, multilingue AR/FR/EN, repeater.
Installation
npm i @mostajs/schema-formExemple
import { renderForm, readValues } from '@mostajs/schema-form';
const schema = {
title: 'Fiche de recette',
sections: [
{ id: 'condition', label: 'Condition', fields: [
{ path: 'condition.env', type: 'text', label: 'Environnement', required: true },
] },
{ id: 'resultat', label: 'Logs & Résultats', fields: [
{ path: 'resultat.statut', type: 'select', label: 'Statut', options: [
{ value: 'valide', label: 'Validé' }, { value: 'non_valide', label: 'Non validé' },
{ value: 'en_cours', label: 'En cours' }, { value: 'interrompu', label: 'Interrompu' } ] },
{ path: 'resultat.logs', type: 'textarea', label: 'Logs JSON-lines' },
] },
],
};
el.innerHTML = renderForm(schema, { condition: { env: 'windows-11' } }, { id: 'f' });
form.onsubmit = (e) => { e.preventDefault(); const values = readValues(new FormData(form), schema); save(values); };Types de champs
text · textarea · number · boolean · select · color · date ·
localized (un input par locale, RTL pour ar) · repeater (liste d'objets, itemFields).
Positionnement
@mostajs/settings→ réglages clé-valeur plat (reste le bon choix pour ça).@mostajs/crud-ui→ formulaire+table d'entité CRUD.@mostajs/schema-form→ saisie riche générique (nested, repeater, localized, sections).
Démo & schéma d'exemple
examples/demo.html (schéma QatraxFlow : Condition→Exécution→Comportement→Logs/Résultats) ;
examples/qatraxflow-recette.schema.js. Tests : npm test → test-scripts/.out/report.html.
