0.0.9 • Published 2 years ago
pw-components-js-dev-555 v0.0.9
pw-components-js-dev
Installation
Pour installer pw-components Package, exécutez simplement l'une ces commandes suivantes dans votre terminal :
- Avec yarn:
yarn add pw-components-js-dev
- Avec npm:
npm install pw-components-js-dev
Utilisation
Exemple d'utilisation
Pour utiliser pw-components Package dans votre projet, importez-le en utilisant la syntaxe suivante :
- Description.js
import {
Field,
VALIDATION,
RESTRICTION,
LIMITATION
} from "pw-validation";
import { getField } from "common/functions/getField.js";
function getValidation() {
return Field.getValidation()
}
function getRestriction() {
return Field.getRestriction()
}
function getLimitation() {
return Field.getLimitation()
}
function create(KEY) {
var FIELD = getField();
return Field.create({
STRUCTURE:FIELD[KEY],
VALIDATION:VALIDATION[KEY].INSCRIPTION,
RESTRICTION:RESTRICTION[KEY],
LIMITATION:LIMITATION[KEY],
});
}
export {
create
}
- Dans le main.js
import {
create
} from "common/structure/Description/Description.js";
function main() {
getConfig().component = {}
var email = create("EMAIL");
var lastname = create("LASTNAME");
var password = create("PASSWORD");
var firstname = create("FIRSTNAME");
var confirmPassword = create("CONFIRM_PASSWORD");
getConfig().component.email = email
getConfig().component.lastname = lastname
getConfig().component.password = password
getConfig().component.firstname = firstname
getConfig().component.confirmPassword = confirmPassword
setChildView(
"#app_body_wrapper",
Composant,
getConfig().component
);
email.instance = getConfig().component.instance
lastname.instance = getConfig().component.instance
password.instance = getConfig().component.instance
firstname.instance = getConfig().component.instance
confirmPassword.instance = getConfig().component.instance
}
- Dans le getField.js
import FIELDMG from "common/structure/FIELD/FIELD.mg.js"
import FIELDFR from "common/structure/FIELD/FIELD.fr.js"
import {Field} from "pw-validation";
function getField(){
Field.addLang("FR", FIELDFR)
Field.addLang("MG", FIELDMG)
var FIELD = Field.getLang(window.lang)
Object.keys(FIELD).map((field) => {
Field.add(field, FIELD[field])
})
return Field.get();
}
export { getField }
- Exemple pour FIELDFR
class FIELD {
static LASTNAME = {
NAME:"lastname",
TYPE:"text",
REQUIRED:true,
PLACEHOLDER:{
DEFAULT:"Votre nom de famille"
},
LABEL:{
DEFAULT:"Entrez votre nom de famille"
},
MINIMUM_ERROR_MESSAGE:{
DEFAULT:"Votre nom de famille doit contenir au moins 3 caractères"
},
MAXIMUM_ERROR_MESSAGE:{
DEFAULT:"Votre nom de famille doit contenir au plus 255 caractères"
},
MUST_NOT_CONTAIN_NUMBER:{
DEFAULT:"Votre nom de famille ne doit pas contenir de chiffre"
},
EMPTY_MESSAGE:{
DEFAULT:"Veuillez saisir votre nom de famille"
},
}
static FIRSTNAME = {
NAME:"firstname",
TYPE:"text",
REQUIRED:true,
PLACEHOLDER:{
DEFAULT:"Votre prénom"
},
LABEL:{
DEFAULT:"Entrez votre prénom"
},
MINIMUM_ERROR_MESSAGE:{
DEFAULT:"Votre prénom doit contenir au moins 3 caractères"
},
MAXIMUM_ERROR_MESSAGE:{
DEFAULT:"Votre prénom doit contenir au plus 255 caractères"
},
MUST_NOT_CONTAIN_NUMBER:{
DEFAULT:"Votre prénom ne doit pas contenir de chiffre"
},
EMPTY_MESSAGE:{
DEFAULT:"Veuillez saisir votre prénom"
},
}
}