
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
mgr-form-react
Advanced tools
Simple react form component. Generates a form based on json description
npm install mgr-form-react --save
Since it is a React module, I suppose you have the webpack and bable configured.
import Form from 'mgr-form-react';
export default TestComponent = () => {
const controls = [
{
element: 'input',
id: 'Signup.Client.Form.Control.Name',
label: 'Client name',
type: 'text'
}, {
element: 'select',
id: 'Signup.Client.Form.Control.Language',
label: 'Client language',
options: ['en', 'fr', 'it', 'de', 'ru', 'es']
}
];
const submit = {
text: 'Submit button text',
cb: (data) => {
console.log(data);
}
};
const editable = true;
return <Form controls={controls}
submit={submit}
errors={errors}
editable={editable} />;
}
import Form from 'mgr-form-react';
export default TestComponent = () => {
const controls = [
{
element: 'input',
id: 'Signup.Client.Form.Control.Name',
label: 'Client name',
placeholder: 'Client name',
default: 'Default name value',
type: 'text',
data: 'name',
validator: /^[A-Za-z0-9\s]{3,30}$/,
formatError: 'Wrong name format',
class: 'custom-input-class'
}, {
element: 'select',
id: 'Signup.Client.Form.Control.Language',
label: 'Client language',
options: ['en', 'fr', 'it', 'de', 'ru', 'es'],
default: 'en',
data: 'language',
class: 'custom-select-class'
}
];
const submit = {
text: 'Submit button text',
cb: (data) => {
console.log(data);
}
};
const errors = {
'Signup.Client.Form.Control.Name': 'Name field error that is generated by someone outside of the form (e.g. server response error)',
general: 'A general error that will be shown under the form itself'
};
const editable = true;
return <Form controls={controls}
submit={submit}
errors={errors}
editable={editable} />;
}
controls
: PropTypes.array.isRequired
:
An ordered array of controls that should be rendered inside the form.
Every array element should be an object containing following fields:
'input'
, 'select'
.
Defines the form control element.null
for element = 'input'
, options[0]
for element = 'select'
.
Defines the default value of the form control.id
field
Defines the key name which will be used in the data object passed to the submit callback function.element = 'select'
.null
Defines the placeholder.
Applicable only when element = 'input'
.text
.
Defines the input type attribute.
Applicable only when element = 'input'
.element = 'input'
.'Wrong format'
.
Defines the error message that will be shown if the form control value is not validated by the validator RegExp.
Applicable only when element = 'input'
.submit
: PropTypes.object.isRequired
An object defining the look and behavior of the submit button.
Should contain following fields:
data
, which is an object containing form values associated to the control's id or to the data field's value of the control.errors
: PropTypes.object
An object containing errors that should be shown on the form.
You can define one error per one control by putting this error into your errors object under the control's id key.
Also you can defina a global form error under the general
key which will be rendered near the submit button.
Example:{
'Signup.Client.Form.Control.Name': 'Name field error that is generated by someone outside of the form (e.g. server response error)',
general: 'A general error that will be shown under the form itself'
}
editable
: PropTypes.bool
Defines if the form is editable or not.The form has the following structure in CSS:
.mgrform-form
: wrapper class.
.mgrform-form-control
: one control wrapper class.
Can be suffixed by the .mgrform-has-error
class in case of having erro for this control and by user defined class in the controls array.
label
element that contains label text for the form control.input
or select
element.label
element that is shown only if there is an error for this form control..mgrform-submit-btn
: submit button class. Can be suffixed by the user defined class..mgrform-error
: general error div class.FAQs
Simple react form component. Generates a form based on json description
The npm package mgr-form-react receives a total of 6 weekly downloads. As such, mgr-form-react popularity was classified as not popular.
We found that mgr-form-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.