-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
7,542 additions
and
9 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
presets: [ | ||
'@vue/app' | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.