1.0.26 • Published 2 years ago
@mvneerven/xo-form v1.0.26
Introduction
XO Form is a tiny web forms library that translates declarative JavaScript schemas to complex data-bound web forms.
XO Form is written as Web Components in pure ES6+ JavaScript modules, and has just one dependency: Lit.
Features
- Reactive rendering
- Full two-way databinding
- Multi-page forms/wizards
- Rules engine for conditional logic
- Supports all HTML elements, including Custom Elements (Web Components)
Setup
npm i @mvneerven/xo-form
How it works
<xo-form theme="material" src="/forms/my-form.js"></xo-form>
... where my-form.js looks like this:
export const form = {
model: {
instance: {
state: {},
data: {
name: "",
msg: "",
},
},
rules: {
"#/state/submit": [
{
value: (context) => {
alert(JSON.stringify(context.model.instance.data, null, 2));
},
},
],
},
},
pages: [
{
label: "My Form",
fields: [
{
type: "text",
bind: "#/data/name",
required: true,
label: "Your name",
placeholder: "Enter your name",
},
{
type: "textarea",
bind: "#/data/msg",
label: "Your message",
required: true,
placeholder: "Enter a message",
maxlength: 100,
rows: 6,
},
{
type: "button",
bind: "#/state/submit",
label: "Submit",
},
],
},
],
};
1.0.19
2 years ago
1.0.18
2 years ago
1.0.17
2 years ago
1.0.16
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.22
2 years ago
1.0.21
2 years ago
1.0.20
2 years ago
1.0.26
2 years ago
1.0.25
2 years ago
1.0.24
2 years ago
1.0.23
2 years ago
1.0.11
2 years ago
1.0.10
2 years ago
1.0.14
2 years ago
1.0.13
2 years ago
1.0.12
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago