|
1 | | -Formeo |
2 | | -=========== |
| 1 | +# Formeo |
3 | 2 |
|
4 | 3 | A zero dependency JavaScript module for drag and drop form creation. |
5 | 4 |
|
| 5 | +## [Demo](https://draggable.github.io/formeo/) |
| 6 | +[](https://draggable.github.io/formeo/) |
| 7 | + |
6 | 8 | ## Features |
| 9 | + |
| 10 | +- Drag & drop editing |
7 | 11 | - Extensible builder with plethora of options |
8 | | -- Simple drag & drop interface |
9 | | -- Column layouts |
| 12 | +- Column/inline fields |
10 | 13 | - Custom fields |
11 | 14 | - Preview mode |
12 | 15 | - i18n support |
13 | 16 |
|
14 | | -## Usage |
15 | | -To start building forms with this module include formeo.min.js and formeo.min.css in your project and call: |
16 | | -``` |
17 | | -new Formeo({ container: '.build-form' }); |
18 | | -``` |
| 17 | +## [Docs](https://github.com/Draggable/formeo/blob/master/docs/index.md) |
19 | 18 |
|
20 | | -## Options |
21 | | -### General |
22 | | -| Option | Type | Value(s) | Default | Description | |
23 | | -| ------------- | ------------- | ------------- | ------------- | ------------- | |
24 | | -| [allowEdit](#) | {Bool} | `true` \| `false` | `false` | When set to false, formData can only be rendered. | |
25 | | -| [debug](#) | {Bool} | `true` \| `false` | `false` | debug mode | |
26 | | -| [container](#) | {String\|Node} | '.editor-wrap' | '.formeo-wrap' | Define where this instance of Formeo will be added. | |
27 | | -| [svgSprite](#) | {String} | 'path/to/svsprite' | `null` | loads an svg sprite, leave blank if your sprite is already included in page. |
28 | | -| [style](#) | {String} | 'path/to/stylesheet' | `null` | loads a stylesheet to the page | |
29 | | -| [sessionStorage](#) | {Bool} | `true` \| `false` | `null` | loads a stylesheet to the page | |
30 | | -| [iconFontFallback](#) | {String} | 'glyphicons' | `null` | uses an existing font-icon when svg icon is not available | |
31 | | -| [config](#) | {Object} | {...} | {...} | disable, add, reorder and modify row, column and field action buttons | |
| 19 | +## Usage |
32 | 20 |
|
33 | | -### Events |
| 21 | +To start building forms with this module include formeo.min.js and formeo.min.css in your project and call: |
34 | 22 |
|
35 | | -| Option | Type | Value(s) | Default | Description | |
36 | | -| ------------- | ------------- | ------------- | ------------- | ------------- | |
37 | | -| [onAdd](#) | {Function} | `Event` | evt => {} | Fires when element is added to another element, returns evt details | |
38 | | -| [onSave](#) | {Function} | `Event` | evt => {} | Fires on full form save, returns full formData | |
39 | | -| [onUpdate](#) | {Function} | `Event` | evt => {} | Fires on individual updates, returns updated data | |
40 | | -| [confirmClearAll](#) | {Function} | `Event` | evt => {} | Fires when form clear button is clicked, returns evt details and `clearAllAction()` | |
| 23 | +```javascript |
| 24 | +import { FormeoEditor } from 'formeo' |
41 | 25 |
|
42 | | -### Actions |
43 | | -unlike events, action usually take place before an event has fired allowing you to modify how an action will complete. For example the default callback for adding an attribute is: |
44 | | -``` |
45 | | -evt => { |
46 | | - let attr = window.prompt(evt.message.attr); |
47 | | - let val; |
48 | | - if (attr) { |
49 | | - val = String(window.prompt(evt.message.value, '')); |
50 | | - evt.addAction(attr, val); |
51 | | - } |
52 | | -} |
| 26 | +const editor = new FormeoEditor() |
53 | 27 | ``` |
54 | | -By replacing the default callback you could use your own modal or prompt dialog and do some additional validation before calling `evt.addAction()`. |
55 | | - |
56 | | -| Option | Type | Value(s) | Default | Description | |
57 | | -| ------------- | ------------- | ------------- | ------------- | ------------- | |
58 | | -| [add.attr](#) | {Function} | `Event` | evt => {} | Fires when adding an attribute to an element, returns evt details and `addAction()` | |
59 | | -| [add.option](#) | {Function} | `Event` | evt => {} | Fires when adding nd option to a field, returns evt details and `addAction()` | |
60 | | -| [click.button](#) | {Function} | `Event` | evt => {} | Called when clicking a form action button | |
61 | | -| [save](#) | {Function} | `Event` | evt => {} | Fires on individual updates, returns updated data | |
62 | | - |
63 | | -### i18N |
64 | | -| Option | Type | Value(s) | Default | |
65 | | -| ------------- | ------------- |------------- | ------------- | |
66 | | -| [extension](#) | {String} | '' | '.lang' | |
67 | | -| [locale](#) | {String} | 'de-DE' | 'en-US' | |
68 | | -| [location](#) | {String} | 'path/to/language/files' | 'assets/lang/' | |
69 | | -| [langs](#) | {Array} | array of available locales | ['en-US'] | |
70 | | -| [preloaded](#) | {Object} | key/value pairs of strings | {en-US: {...}} | |
71 | | - |
72 | | - |
73 | | -## [Demo](https://Draggable.github.io/formeo) ## |
74 | | -[](https://draggable.github.io/formeo/) |
75 | 28 |
|
76 | | -## [Changelog](https://github.com/Draggable/formeo/blob/master/CHANGELOG.md) ## |
| 29 | +## [Changelog](https://github.com/Draggable/formeo/blob/master/CHANGELOG.md) |
0 commit comments