Skip to content

Commit 8851d63

Browse files
author
Duncan Lock
committed
Merge branch 'master' into better-accessibility-labels
2 parents c727d7a + a6aaf1b commit 8851d63

File tree

100 files changed

+3977
-3519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3977
-3519
lines changed

.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"presets": ["es2015", "stage-2"],
3-
"plugins": ["transform-runtime"],
3+
"plugins": ["transform-runtime", "lodash"],
44
"comments": false
55
}

.eslintrc.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ module.exports = {
55
"commonjs": true,
66
"es6": true,
77
"jquery": false,
8-
mocha: true
8+
"mocha": true
99
},
1010
"extends": "eslint:recommended",
1111
"parserOptions": {
12-
"sourceType": "module"
12+
"sourceType": "module",
13+
"ecmaVersion": 6,
14+
"ecmaFeatures": {
15+
"experimentalObjectRestSpread": true
16+
}
1317
},
1418
"plugins": [
1519
"html"

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ selenium-debug.log
77
test/unit/coverage
88
test/e2e/reports
99
stats.json
10+
typings/
11+
typings.json

.travis.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
language: node_js
2-
cache:
3-
directories:
4-
- node_modules
2+
#cache:
3+
# directories:
4+
# - node_modules
55
node_js:
6+
- "7"
67
- "6"
7-
- "5"
8-
- "4"
98
after_success:
109
- npm run coverall

CHANGELOG.md

+219-58
Large diffs are not rendered by default.

README.md

+76-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# vue-form-generator [![NPM version](https://img.shields.io/npm/v/vue-form-generator.svg)](https://www.npmjs.com/package/vue-form-generator)
2-
A schema-based form generator component for Vue.js v1.x.x
1+
# vue-form-generator [![NPM version](https://img.shields.io/npm/v/vue-form-generator.svg)](https://www.npmjs.com/package/vue-form-generator) ![VueJS v2.x compatible](https://img.shields.io/badge/vue%202.x-compatible-green.svg)
2+
A schema-based form generator component for Vue.js.
33

44
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/912039aa815e40de8315032519aa7e6c)](https://www.codacy.com/app/mereg-norbert/vue-form-generator?utm_source=github.com&utm_medium=referral&utm_content=icebob/vue-form-generator&utm_campaign=Badge_Grade)
55
[![Build Status](https://travis-ci.org/icebob/vue-form-generator.svg?branch=master)](https://travis-ci.org/icebob/vue-form-generator)
@@ -11,45 +11,74 @@ A schema-based form generator component for Vue.js v1.x.x
1111
[![devDependency Status](https://david-dm.org/icebob/vue-form-generator/dev-status.svg)](https://david-dm.org/icebob/vue-form-generator#info=devDependencies)
1212
[![Downloads](https://img.shields.io/npm/dt/vue-form-generator.svg)](https://www.npmjs.com/package/vue-form-generator)
1313

14-
**Vue v2.x support is under development!**
15-
1614
## Demo
1715
[JSFiddle simple example](https://jsfiddle.net/icebob/0mg1v81e/)
1816

1917
[![Screenshot](https://icebob.gitbooks.io/vueformgenerator/content/assets/vfg-example1.png)](https://jsfiddle.net/icebob/0mg1v81e/)
2018

2119
## Features
22-
- multiple objects editing
23-
- 27 field types
20+
- reactive forms based on schemas
21+
- multiple object editing
22+
- 21 field types
2423
- built-in validators
24+
- core & full bundles (11kb and 19kb gzipped)
2525
- Bootstrap friendly templates
2626
- customizable styles
27+
- can be extended easily with custom fields
2728
- ...etc
2829

2930
## Documentation
3031
[Online documentation on Gitbook](https://icebob.gitbooks.io/vueformgenerator/content/)
3132

3233
## Dependencies
33-
vue-form-generator use [Moment.js](http://momentjs.com/) and [lodash](https://lodash.com/) internally.
34+
vue-form-generator uses [fecha](https://github.com/taylorhakes/fecha) and [lodash](https://lodash.com/) internally.
3435

3536
While built-in fields don't need external dependencies, optional fields may need other libraries.
36-
These dependency fall in two camp: jQuery or Vanilla. You can find almost the same functionality in both flavor.
37-
That way, it's your choice to depend on jQuery or not.
37+
These dependencies fall into two camps: jQuery or Vanilla. You can find almost the same functionality in both flavors.
38+
In the end, it's your choice to depend on jQuery or not.
3839

39-
You can find details about dependencies in [documentation](https://icebob.gitbooks.io/vueformgenerator/content/).
40+
You can find details about dependencies in the official [documentation](https://icebob.gitbooks.io/vueformgenerator/content/) under each specific component.
4041

4142
## Installation
4243
### NPM
43-
You can install it via [NPM](http://npmjs.org/).
44+
You can install it via [NPM](http://npmjs.org/) or [yarn](https://yarnpkg.com/).
45+
46+
#### Latest version for Vue 2.x
4447
```
4548
$ npm install vue-form-generator
4649
```
50+
51+
#### Legacy version for Vue 1.0.x
52+
```
53+
$ npm install [email protected]
54+
```
55+
4756
### Manual
48-
Download zip package and unpack and add the `vue-form-generator.css` and `vue-form-generator.js` file to your project from dist folder.
57+
Download zip package and unpack and add the vfg.css and vfg.js file to your project from dist folder.
4958
```
5059
https://github.com/icebob/vue-form-generator/archive/master.zip
5160
```
5261

62+
### Core vs Full version
63+
64+
VueFormGenerator come in two version : `core` and `full`.
65+
Core is a more minimal version with only half the fields.
66+
Full is core + other fields.
67+
68+
* Full bundle: 75 kB (gzipped: 19 kB)
69+
* Core bundle: 39 kB (gzipped: 11 kB)
70+
71+
If you don't know what to choose, don't worry, the full is the default version.
72+
If you want the slim down version, here is the changes:
73+
74+
```js
75+
// the "core" way
76+
<script>
77+
import VueFormGenerator from "vue-form-generator/dist/vfg-core.js";
78+
import "vue-form-generator/dist/vfg-core.css";
79+
</script>
80+
```
81+
5382
## Usage
5483
```html
5584
<template>
@@ -77,33 +106,37 @@ export default {
77106
78107
schema: {
79108
fields: [{
80-
type: "text",
109+
type: "input",
110+
inputType: "text",
81111
label: "ID (disabled text field)",
82112
model: "id",
83113
readonly: true,
84114
disabled: true
85115
},{
86-
type: "text",
116+
type: "input",
117+
inputType: "text",
87118
label: "Name",
88119
model: "name",
89120
placeholder: "Your name",
90121
featured: true,
91122
required: true
92123
},{
93-
type: "password",
124+
type: "input",
125+
inputType: "password",
94126
label: "Password",
95127
model: "password",
96128
min: 6,
97129
required: true,
98130
hint: "Minimum 6 characters",
99-
validator: validators.string
131+
validator: VueFormGenerator.validators.string
100132
},{
101133
type: "select",
102-
label: "skills",
103-
model: "type",
134+
label: "Skills",
135+
model: "skills",
104136
values: ["Javascript", "VueJS", "CSS3", "HTML5"]
105137
},{
106-
type: "email",
138+
type: "input",
139+
inputType: "email",
107140
label: "E-mail",
108141
model: "email",
109142
placeholder: "User's e-mail address"
@@ -124,6 +157,17 @@ export default {
124157
</script>
125158
```
126159

160+
Usage in local components
161+
```js
162+
import VueFormGenerator from "vue-form-generator";
163+
164+
//component javascript
165+
export default{
166+
components:{
167+
"vue-form-generator": VueFormGenerator.component
168+
}
169+
}
170+
```
127171
## Development
128172
This command will start a `webpack-dev-server` with content of `dev` folder.
129173
```bash
@@ -140,8 +184,19 @@ npm run build
140184
```bash
141185
npm test
142186
```
187+
or
188+
```bash
189+
npm run ci
190+
```
191+
192+
## More fields *new*
193+
VueFormGenerator supports custom fields. If you decide to release your custom field into the wild, please open a new issue so we can add you to a list here! Please try to use this naming convention for your custom field : vfg-field-* Example :
194+
195+
- `vfg-field-myfield`
196+
- `vfg-field-calendar`
197+
- `vfg-field-awesome-dropdown`
143198

144-
See: https://github.com/icebob/vue-form-generator/projects/1
199+
This way, it will be easier for everyone to find it. Thank you !
145200

146201
## Contribution
147202
Please send pull requests improving the usage and fixing bugs, improving documentation and providing better examples, or providing some testing, because these things are important.
@@ -151,6 +206,6 @@ vue-form-generator is available under the [MIT license](https://tldrlegal.com/li
151206

152207
## Contact
153208

154-
Copyright (C) 2016 Icebob
209+
Copyright (C) 2017 Icebob
155210

156211
[![@icebob](https://img.shields.io/badge/github-icebob-green.svg)](https://github.com/icebob) [![@icebob](https://img.shields.io/badge/twitter-Icebobcsi-blue.svg)](https://twitter.com/Icebobcsi)

bower.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "vue-form-generator",
3-
"version": "2.0.0-beta1",
3+
"version": "2.0.0-beta6",
44
"homepage": "https://github.com/icebob/vue-form-generator",
55
"authors": [
66
"Icebob"
77
],
88
"description": "A schema-based form generator component for Vue.js",
99
"main": [
10-
"dist/vue-form-generator.js",
11-
"dist/vue-form-generator.css"
10+
"dist/vfg.js",
11+
"dist/vfg.css"
1212
],
1313
"moduleType": [
1414
"amd"

dev/app.vue renamed to dev/full/app.vue

+12-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<div class="errors text-center">
1616
<div v-for="(item, index) in validationErrors" track-by="index" class="alert alert-danger">{{ item.field.label}}: <strong>{{ item.error }}</strong></div>
1717
</div>
18-
<vue-form-generator :schema="schema" :model="model" :options="formOptions" :multiple="selected.length > 1" ref="form" :is-new-model="isNewModel" @model-updated="modelUpdated"></vue-form-generator>
18+
<vue-form-generator :schema="schema" :model="model" :options="formOptions" :multiple="selected.length > 1" ref="form" :is-new-model="isNewModel" @model-updated="modelUpdated" @validated="onValidated"></vue-form-generator>
1919
</div>
2020
<div class="col-md-6">
2121
<pre v-if="model" v-html="prettyModel"></pre>
@@ -27,14 +27,17 @@
2727

2828
<script>
2929
import Vue from "vue";
30-
import VueFormGenerator from "../src";
30+
import VueFormGenerator from "../../src";
3131
import DataTable from "./dataTable.vue";
3232
import Fakerator from "fakerator";
3333
3434
import Schema from "./schema";
3535
import { users } from "./data";
3636
import { filters } from "./utils";
3737
38+
import Multiselect from "vue-multiselect"
39+
Vue.component("multiselect", Multiselect);
40+
3841
// Test custom field
3942
import FieldAwesome from "./fieldAwesome.vue";
4043
Vue.component("fieldAwesome", FieldAwesome);
@@ -66,7 +69,7 @@
6669
6770
formOptions: {
6871
validateAfterLoad: true,
69-
validateAfterChanged: false,
72+
validateAfterChanged: true,
7073
validateBeforeSave: true
7174
}
7275
}
@@ -110,7 +113,11 @@
110113
clearSelection() {
111114
this.selected.splice(0);
112115
this.generateModel();
113-
},
116+
},
117+
118+
onValidated(res, errors) {
119+
console.log("VFG validated:", res, errors);
120+
},
114121
115122
generateModel() {
116123
if (this.selected.length == 1) {
@@ -182,13 +189,12 @@
182189
},
183190
184191
validate() {
185-
console.log("validate", this.$refs.form, this.$refs.form.validate());
192+
//console.log("validate", this.$refs.form, this.$refs.form.validate());
186193
return this.$refs.form.validate();
187194
},
188195
189196
modelUpdated(newVal, schema) {
190197
console.log("main model has updated", newVal, schema);
191-
// this.model[schema] = newVal;
192198
}
193199
194200

dev/data.js renamed to dev/full/data.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Fakerator from "fakerator";
2-
import moment from "moment";
2+
import fecha from "fecha";
33

44
let fakerator = new Fakerator();
55

@@ -26,8 +26,8 @@ module.exports = {
2626
user.bio = fakerator.lorem.paragraph();
2727
let dob = fakerator.date.past(40, "1998-01-01");
2828
user.dob = dob.valueOf();
29-
user.time = moment().format("hh:mm:ss");
30-
user.age = moment().year() - moment(dob).year();
29+
user.time = fecha.format(new Date(), "hh:mm:ss");
30+
user.age = fecha.format(new Date().getFullYear() - dob, "YY");
3131
user.rank = fakerator.random.number(1, 10);
3232
user.role = fakerator.random.arrayElement(roles).id;
3333
//user.mobile = fakerator.phone.phoneNumber();

dev/dataTable.vue renamed to dev/full/dataTable.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<template lang="jade">
1+
<template lang="pug">
22
table.table.table-hover.table-bordered
33
thead
44
tr
@@ -25,7 +25,7 @@
2525

2626
<script>
2727
import Vue from "vue";
28-
import VueFormGenerator from "../src";
28+
import VueFormGenerator from "../../src";
2929
import Schema from "./schema";
3030
import { find } from "lodash";
3131
import { users, roles } from "./data";

dev/fieldAwesome.vue renamed to dev/full/fieldAwesome.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<template lang="jade">
1+
<template lang="pug">
22
input.form-control(type="text", v-model="value", :maxlength="schema.max", :readonly="schema.readonly", :disabled="disabled", :placeholder="schema.placeholder")
33
</template>
44

55
<script>
6-
import VueFormGenerator from "../src";
6+
import VueFormGenerator from "../../src";
77
88
export default {
99
mixins: [ VueFormGenerator.abstractField ]

dev/index.html renamed to dev/full/index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@
2020
<!-- jQuery dependent -->
2121
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
2222
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.11.2/js/bootstrap-select.min.js"></script>
23-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.43/js/bootstrap-datetimepicker.min.js"></script>
23+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.45/js/bootstrap-datetimepicker.min.js"></script>
2424
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js"></script>
2525
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js"></script>
2626
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js"></script>
2727
<!-- Vanilla libs -->
28-
<script type="text/javascript" src="https://rawgit.com/monterail/vue-multiselect/2.0/lib/vue-multiselect.min.js"></script>
28+
<script type="text/javascript" src="https://unpkg.com/vue-multiselect@2.0.0-beta.13"></script>
2929
<script type="text/javascript" src="https://rawgit.com/nosir/cleave.js/master/dist/cleave.min.js"></script>
3030
<script type="text/javascript" src="https://nosir.github.io/cleave.js/lib/cleave-phone.i18n.js"></script>
3131
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/9.0.0/nouislider.js"></script>
32-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.4.0/pikaday.min.js"></script>
32+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.5.1/pikaday.min.js"></script>
3333
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCEz-sX9bRJorDS-D_JL0JkZVZe2gzoUMw&amp;libraries=places"></script>
3434

3535
</head>
3636
<body>
3737
<div class="container-fluid"></div>
3838
<div id="app"></div>
39-
<script src="/app.js"></script>
39+
<script src="/full.js"></script>
4040
</body>
4141
</html>
File renamed without changes.

0 commit comments

Comments
 (0)