package
An opinionated react form framework.
npm install formolGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Formol is a full featured object edition form framework for React.
yarn add formolTo use webpack code-splitting in formol, you will have to do these modifications to your webpack.config:
module: {
rules: [
{
test: /\.(mjs|jsx?)$/,
exclude: /node_modules\/(?!(formol)\/).*/, // <- this line allows formol
use: { // to be built alongside
loader: 'babel-loader', // your project
},
options: {
presets: [
'@babel/preset-react',
[
'@babel/preset-env',
{
targets: { browsers: 'last 1 version and > 3%' },
modules: false,
},
],
],
plugins: [ // <- these plugins are needed to build formol
'@babel/plugin-syntax-dynamic-import',
['@babel/plugin-proposal-decorators', { legacy: true }],
'add-react-static-displayname',
['@babel/plugin-proposal-class-properties', { loose: true }],
],
},
},
],
},
resolve: { // <- these extensions needed to be loaded by webpack
extensions: ['.mjs', '.js', '.jsx'],
},NB: It is also possible to use the prebuilt version of formol, in this case you will have to copy the javascript files in node_modules/formol/lib in your output.path instead of modifying your webpack config.
Now you are all set.
But before going too deep, let’s take a look at the two following exemples:
import 'formol/lib/default.css'
import Formol, {Field} from 'formol'
const onSubmit = ({ login, password }) =>
doLogin(login, password)
<Formol onSubmit={onSubmit}>
<Field>Login</Field>
<Field type="password-strength">Password</Field>
</Formol>const item = {
firstname: 'John',
lastname: 'Doe',
birth: '1988-04-12',
address: {
zip: '82937',
city: 'Los Angeles',
continent: 'North America',
},
fastShipping: true,
colors: ['#00ffff', '#008000'],
}
<Formol
item={item}
validator={({ firstname, lastname }) => ({
firstname:
(firstname ? firstname.length : 0) +
(lastname ? lastname.length : 0) <= 6
? 'Your full name must be greater than 6 characters.'
: null,
})}
// eslint-disable-next-line no-alert
onSubmit={item_ => alert(JSON.stringify(item_, null, 2))}
submitText="Show me the new item"
>
<Field name="firstname" required>
First Name
</Field>
<Field name="lastname" required minLength={3}>
Last Name
</Field>
<Field
name="birth"
type="calendar"
validator={v =>
The default theme is accessible by a simple css import (you will need the standard: css loader):
import 'formol/lib/default.css'similarly with the clean theme:
import 'formol/lib/clean.css'You can also use directly the sass import if you are using sass:
@import ~formol/src/sass/defaultwith the added benefit that you can override the formol variables:
$formol-color: #ce93d8
$formol-color-action: #ba68c8
$formol-color-inactive: #e1bee7
$formol-color-error: #f06292
$formol-background-color: #f3e5f5
$formol-font-size: 0.9em
$formol-big-field-size: 70em
$formol-medium-field-size: 50em
$formol-field-margin: 2em
$formol-field-padding: 1.5em
@import ~formol/src/sass/defaultGetting the code and running Formol locally requires a typical yarn‑based workflow:
Install dependencies
yarn installCheck code style
yarn lintFix issues automatically when possible:
yarn fixRun the unit tests
yarn testThis executes Jest with coverage enabled. You can inspect the HTML coverage report in coverage/lcov-report/index.html.
Check the live demos
yarn demosBuild the library
yarnversion in package.json according to semantic versioning rulesVersionHeader.jsxCHANGELOG.md (manually)v3.0.0git tag v3.0.0 and push it git push --tagsyarn prepublishnpm publish (requires being an npm package maintainer)yarn demos-deploygentooboontoo
julien.sanchez@gmail.com
The compiled production bundle is written to lib/.
Build the demos
yarn demos-buildThe compiled demo bundle is written to demos/dist/.
Estimated unpacked size across 52 packages.
117.3 MB
Includes dependencies.
12 direct · 8 outdated
^2.0.0
2.0.0
^2.0.1
2.0.1
^3.11.0
5.7.0
^1.3.5
2.0.0
^3.2.0
5.10.2
20.2.0
^3.1.3
3.1.3
^5.5.0
5.5.0
^3.8.0
9.1.0
^7.4.10
10.0.2