Skip to content

Commit bd697d4

Browse files
committed
first build, docs to come
1 parent 58e3d97 commit bd697d4

File tree

10 files changed

+10167
-48
lines changed

10 files changed

+10167
-48
lines changed

dist/1.vue-formly.js

Lines changed: 10089 additions & 7 deletions
Large diffs are not rendered by default.

dist/1.vue-formly.min.js

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-formly.js

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-formly v0.1.0
2+
* vue-formly v0.1.1
33
* https://github.com/matt-sanders/vue-formly
44
* Released under the MIT License.
55
*/
@@ -121,31 +121,27 @@ return /******/ (function(modules) { // webpackBootstrap
121121

122122
var _index2 = _interopRequireDefault(_index);
123123

124+
var _util = __webpack_require__(7);
125+
126+
var _util2 = _interopRequireDefault(_util);
127+
124128
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
125129

126130
var Formly = {
127-
addType: function addType(id, options) {
128-
Vue.$formlyFields[id] = options;
129-
},
130-
getTypes: function getTypes() {
131-
return Vue.$formlyFields;
132-
},
133131
install: function install(Vue, options) {
134132

135133
if (Formly.installed) {
136134
return;
137135
}
138136

139137
(0, _index2.default)(Vue);
140-
141-
Vue.$formlyFields = {};
142138
}
143139
};
144140

145141
if (typeof window !== 'undefined' && window.Vue) {
146142
window.Vue.use(Formly);
147143

148-
window.Vue.$formly = Formly;
144+
window.Vue.$formly = { getTypes: _util.getTypes, addType: _util.addType };
149145
}
150146
exports.default = Formly;
151147

@@ -219,6 +215,31 @@ return /******/ (function(modules) { // webpackBootstrap
219215

220216
module.exports = "\n<fieldset>\n <formly-field v-for=\"field in fields\" :field=\"field\" :model.sync=\"model[field.key]\" ></formly-field>\n</fieldset>\n";
221217

218+
/***/ },
219+
/* 5 */,
220+
/* 6 */,
221+
/* 7 */
222+
/***/ function(module, exports) {
223+
224+
"use strict";
225+
226+
Object.defineProperty(exports, "__esModule", {
227+
value: true
228+
});
229+
exports.addType = addType;
230+
exports.getTypes = getTypes;
231+
var _exports = {
232+
formlyFields: {}
233+
};
234+
exports.default = _exports;
235+
function addType(id, options) {
236+
_exports.formlyFields[id] = options;
237+
}
238+
239+
function getTypes() {
240+
return _exports.formlyFields;
241+
}
242+
222243
/***/ }
223244
/******/ ])
224245
});

dist/vue-formly.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-formly",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "A simple and extendable form builder for Vue.js",
55
"main": "dist/vue-formly.js",
66
"scripts": {

src/components/FormlyField.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<template>
2-
<component :is="field.type" :model="model"></component>
2+
<component :is="field.type" :model.sync="model" :field="field"></component>
33
</template>
44

55
<script>
6-
import VueFormly from '../index';
6+
const Vue = require('vue');
7+
import Util, {getTypes} from '../util';
78
export default {
89
props: ['field', 'model'],
9-
components: VueFormly.getTypes()
10-
}
10+
components: getTypes()
11+
}
1112
</script>

src/index.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
import Components from './components/index';
2+
import Util,{getTypes, addType} from './util';
23

34

45
let Formly = {
5-
/**
6-
* Allow additional templates to be added
7-
* @param {String} id
8-
* @param {Object} options
9-
*/
10-
addType(id, options){
11-
Vue.$formlyFields[id] = options;
12-
},
13-
14-
getTypes(){
15-
return Vue.$formlyFields;
16-
},
176

187
install(Vue, options){
198

209
if ( Formly.installed ){
2110
return;
2211
}
23-
12+
13+
//install our components
2414
Components(Vue);
25-
26-
Vue.$formlyFields = {};
2715

2816
}
2917
};
@@ -32,6 +20,6 @@ let Formly = {
3220
if (typeof window !== 'undefined' && window.Vue) {
3321
window.Vue.use(Formly);
3422
//expose formly functions if auto installed
35-
window.Vue.$formly = Formly;
23+
window.Vue.$formly = {getTypes, addType};
3624
}
3725
export default Formly;

src/util.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const exports = {
2+
formlyFields: {}
3+
};
4+
export default exports;
5+
6+
/**
7+
* Allow additional templates to be added
8+
* @param {String} id
9+
* @param {Object} options
10+
*/
11+
export function addType(id, options){
12+
exports.formlyFields[id] = options;
13+
}
14+
15+
export function getTypes(){
16+
return exports.formlyFields;
17+
}

test/unit/specs/FormlyField.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ describe('FormlyField', () => {
2424
it('should take on the type of another component', () => {
2525

2626
Vue.component('test', {
27-
template: '<div id="testComponent">Hello World</div>'
27+
props: ['field'],
28+
template: '<div id="testComponent">{{field.type}}</div>'
2829
});
2930

3031
let data = {
@@ -37,7 +38,7 @@ describe('FormlyField', () => {
3738

3839
let innerElem = vm.$el.querySelector('#testComponent');
3940

40-
expect(innerElem.textContent).to.contain('Hello World');
41+
expect(innerElem.textContent).to.contain(data.schema.type);
4142

4243
});
4344

test/unit/specs/index.spec.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import {expect} from 'chai';
22

33
import VueFormly from 'src/index';
4+
import Util, {addType, getTypes} from 'src/util';
45

56

67
describe('module', () => {
78

89
it('module props', () => {
910
expect(VueFormly).to.exist;
1011
expect(VueFormly.install).to.be.a('function');
11-
expect(VueFormly.addType).to.be.a('function');
12+
expect(addType).to.be.a('function');
13+
expect(getTypes).to.be.a('function');
14+
expect(Util.formlyFields).to.be.a('object');
1215
});
1316

1417
it('should add fields to Vue', () => {
@@ -18,13 +21,12 @@ describe('module', () => {
1821
component(){}
1922
};
2023
VueFormly.install(Vue);
21-
expect(Vue.$formlyFields).to.be.a('object');
2224

2325
let newField = {
2426
foo: 'bar'
2527
};
26-
VueFormly.addType('test', newField);
27-
expect(Vue.$formlyFields.test).to.deep.equal(newField);
28+
addType('test', newField);
29+
expect(getTypes().test).to.deep.equal(newField);
2830
});
2931

3032
});

0 commit comments

Comments
 (0)