Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpy committed Jan 1, 2019
2 parents b5e21fd + 8ab8329 commit e839ad7
Show file tree
Hide file tree
Showing 21 changed files with 7,542 additions and 9 deletions.
Binary file added .github/preview.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 99 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,101 @@
# element-form-builder

Build form of element-ui using JSON configuration.
[![Version](https://img.shields.io/npm/v/element-form-builder.svg)](https://www.npmjs.com/package/element-form-builder)
[![License](https://img.shields.io/npm/l/element-form-builder.svg)](https://www.npmjs.com/package/element-form-builder)
[![Dependencies](https://img.shields.io/david/codetrial/element-form-builder.svg)](https://www.npmjs.com/package/element-form-builder)

Build element-ui forms with JSON schema.

:us: English | [:cn: 简体中文](README.zh-CN.md)

## Example

[:zap: Live Preview](https://element-form-builder.now.sh) | [:book: Docs](https://codetrial.github.io/element-form-builder)

![Screen Capture](.github/preview.gif)

## Quick Start

First you need to have an element-ui project. If not, it is recommended to create one quickly using the preset below.

```bash
vue create --preset codetrial/vue-cli-plugin-element your-project
```

### Install

```bash
yarn add element-form-builder
# OR
npm i element-form-builder
```

### Registry

```javascript
import FormBuilder from 'element-form-builder'

Vue.use(FormBuilder)
```

### Witness the miracle moment

Vue template:

```html
<el-form-builder :config="formConfig" v-model="formValues" label-width="80px">
</el-form-builder>
```

Vue component:

```javascript
export default {
data() {
return {
formValues: {
title: 'Some Awesome Title'
},

formConfig: {
rules: {
title: [{ required: true, message: 'Please enter the title' }]
},
elements: [
{
tag: 'el-input',
item: {
label: 'Title'
},
detail: {
name: 'title'
}
}
]
}
}
}
}
```

## Core Features

- :camera: Any Component
- :tv: Form Validation
- :watch: Form Model
- :radio: Custom Slot

## Contributing

Looking forward to your pull requests.

## Built With

- [Vue.js](https://github.com/vuejs/vue)
- [ElementUI](https://github.com/ElemeFE/element)

## License

[MIT](http://opensource.org/licenses/MIT)

Copyright (c) 2018 - present, Felix Yang
102 changes: 102 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# element-form-builder

[![Version](https://img.shields.io/npm/v/element-form-builder.svg)](https://www.npmjs.com/package/element-form-builder)
[![License](https://img.shields.io/npm/l/element-form-builder.svg)](https://www.npmjs.com/package/element-form-builder)
[![Dependencies](https://img.shields.io/david/codetrial/element-form-builder.svg)](https://www.npmjs.com/package/element-form-builder)

使用 JSON 配置构建 element-ui 动态表单.

:cn: 简体中文 | [:us: English](README.md)

## 在线示例

[:zap: 在线示例](https://element-form-builder.now.sh) | [:book: 参考文档](https://codetrial.github.io/element-form-builder)

![Screen Capture](.github/preview.gif)

## 快速开始

首先你需要有一个 element-ui 项目。如果没有,推荐使用下面的 preset 快速创建一个。

```bash
vue create --preset codetrial/vue-cli-plugin-element your-project
```

### 安装

```bash
yarn add element-form-builder
# OR
npm i element-form-builder
```

### 注册组件

```javascript
import FormBuilder from 'element-form-builder'

Vue.use(FormBuilder)
```

### 见证奇迹的时刻

Vue 模板:

```html
<el-form-builder :config="formConfig" v-model="formValues" label-width="80px">
</el-form-builder>
```

Vue 组件:

```javascript
export default {
name: 'some-component',
data() {
return {
formValues: {
title: 'Some Awesome Title'
},

formConfig: {
rules: {
title: [{ required: true, message: '请输入标题' }]
},
elements: [
{
tag: 'el-input',
item: {
label: '标题'
},
detail: {
name: 'title'
}
}
]
}
}
}
}
```

## 核心功能

- :camera: 支持任意组件
- :tv: 表单校验
- :watch: 表单数据模型
- :radio: 自定义插槽

## 贡献

期待你的 `pull requests`。如果你觉得有帮助,还请多多反馈!

## 技术栈

- [Vue.js](https://github.com/vuejs/vue)
- [ElementUI](https://github.com/ElemeFE/element)

## 许可

[MIT](http://opensource.org/licenses/MIT)

Copyright (c) 2018 - present, Felix Yang
11 changes: 7 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Element form-builder v0.1.0
* (c) 2018 Felix Yang
* Element form-builder v1.0.0
* (c) 2019 Felix Yang
*/
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
Expand Down Expand Up @@ -96,6 +96,9 @@ var FormBuilder = {
}
}, [].concat(toConsumableArray(vm.$slots.prepend || []), toConsumableArray(vm.renderFormItems(h) || []), toConsumableArray(vm.$slots.append || [])));
},
created: function created() {
this.$emit('input', this.formValues);
},


methods: {
Expand Down Expand Up @@ -125,8 +128,8 @@ var FormBuilder = {
},
renderFormItem: function renderFormItem(h, _ref2) {
var tag = _ref2.tag,
_ref2$label = _ref2.label,
label = _ref2$label === undefined ? {} : _ref2$label,
_ref2$item = _ref2.item,
label = _ref2$item === undefined ? {} : _ref2$item,
_ref2$detail = _ref2.detail,
detail = _ref2$detail === undefined ? {} : _ref2$detail;

Expand Down
5 changes: 5 additions & 0 deletions examples/simple-demo/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
22 changes: 22 additions & 0 deletions examples/simple-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.DS_Store
node_modules
/dist
package-lock.json

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
29 changes: 29 additions & 0 deletions examples/simple-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# simple-demo

## Project setup
```
yarn install
```

### Compiles and hot-reloads for development
```
yarn run serve
```

### Compiles and minifies for production
```
yarn run build
```

### Run your tests
```
yarn run test
```

### Lints and fixes files
```
yarn run lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
5 changes: 5 additions & 0 deletions examples/simple-demo/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/app'
]
}
17 changes: 17 additions & 0 deletions examples/simple-demo/now.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "element-form-builder",
"version": 2,
"alias": "element-form-builder",
"builds": [{ "src": "**", "use": "@now/static" }],
"routes": [
{ "src": "^/js/(.*)", "dest": "/js/$1" },
{ "src": "^/css/(.*)", "dest": "/css/$1" },
{ "src": "^/fonts/(.*)", "dest": "/fonts/$1" },
{ "src": "^/img/(.*)", "dest": "/img/$1" },
{
"src": "^/(favicon|manifest|precache|service-worker|robots)(.*)",
"dest": "/$1$2"
},
{ "src": ".*", "dest": "/index.html" }
]
}
51 changes: 51 additions & 0 deletions examples/simple-demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "simple-demo",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"deploy": "npm run build && now ./dist -A ../now.json && now alias"
},
"dependencies": {
"element-ui": "^2.4.11",
"vue": "^2.5.17"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.2.0",
"@vue/cli-plugin-eslint": "^3.2.0",
"@vue/cli-service": "^3.2.0",
"@vue/eslint-config-standard": "^4.0.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.8.0",
"eslint-plugin-vue": "^5.0.0-0",
"vue-template-compiler": "^2.5.17"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"@vue/standard"
],
"rules": {
"space-before-function-paren": "off"
},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
Binary file added examples/simple-demo/public/favicon.ico
Binary file not shown.
20 changes: 20 additions & 0 deletions examples/simple-demo/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title>ElementUI Form Builder</title>
</head>
<body>
<noscript>
<strong
>We're sorry but simple-demo doesn't work properly without JavaScript
enabled. Please enable it to continue.</strong
>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
Loading

0 comments on commit e839ad7

Please sign in to comment.