10 |
11 |
Simplicity First
12 |
Generate complex dynamic forms and validations through standard JSON Schema & Ajv Validator, fast, concise and efficient.
13 |
14 |
15 |
Reusability
16 |
The form template is generated in the form of JSON, which can be reused in multiple places by simply modifying it! It enables you to quickly develop form pages. Compared with writing traditional html forms, using JSON defined forms can greatly improve development efficiency.
17 |
18 |
19 |
Vue-Powered
20 |
Currently support for Vue 2.x & Ant Design of Vue v1, other UI libraries (AntDv v3, ElementUI, etc.) support for Vue 2.x and Vue 3.x are under development. . .
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/examples/ant-design-vue.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import {
3 | Card,
4 | Button,
5 | FormModel,
6 | Tooltip,
7 | Icon,
8 | Input,
9 | Row,
10 | Col,
11 | Switch,
12 | AutoComplete,
13 | Select,
14 | Checkbox,
15 | DatePicker,
16 | InputNumber,
17 | Menu,
18 | Layout,
19 | Breadcrumb,
20 | TimePicker,
21 | Radio,
22 | Rate,
23 | Tag,
24 | Slider,
25 | Space,
26 | Divider,
27 | Spin,
28 | Upload,
29 | Cascader,
30 | } from "ant-design-vue";
31 |
32 | Vue.use(Card);
33 | Vue.use(Button);
34 | Vue.use(FormModel);
35 | Vue.use(Tooltip);
36 | Vue.use(Icon);
37 | Vue.use(Input);
38 | Vue.use(Row);
39 | Vue.use(Col);
40 | Vue.use(Switch);
41 | Vue.use(AutoComplete);
42 | Vue.use(Select);
43 | Vue.use(Checkbox);
44 | Vue.use(DatePicker);
45 | Vue.use(InputNumber);
46 | Vue.use(Menu);
47 | Vue.use(Layout);
48 | Vue.use(Breadcrumb);
49 | Vue.use(TimePicker);
50 | Vue.use(Radio);
51 | Vue.use(Slider);
52 | Vue.use(Rate);
53 | Vue.use(Tag);
54 | Vue.use(Spin);
55 | Vue.use(Space);
56 | Vue.use(Divider);
57 | Vue.use(Upload);
58 | Vue.use(Cascader);
59 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import path from "path";
2 | import { nodeResolve } from "@rollup/plugin-node-resolve";
3 | import vue from "rollup-plugin-vue";
4 | import babel from "@rollup/plugin-babel";
5 | import commonjs from "@rollup/plugin-commonjs";
6 | import alias from "@rollup/plugin-alias";
7 | import postcss from "rollup-plugin-postcss";
8 | import { uglify } from "rollup-plugin-uglify";
9 |
10 | const config = {
11 | input: "./src/formly.js",
12 | output: {
13 | file: "./lib/v-formly.umd.js",
14 | exports: "named",
15 | format: "umd",
16 | name: "v-formly",
17 | globals: {
18 | vue: "Vue",
19 | },
20 | },
21 | external: ["ajv", "vue", "core-js", "ant-design-vue", /@babel\/runtime/],
22 | plugins: [
23 | nodeResolve(),
24 | postcss(),
25 | vue(),
26 | alias({
27 | entries: {
28 | ["@"]: path.resolve(__dirname, "src"),
29 | },
30 | }),
31 | babel({
32 | exclude: "**/node_modules/**",
33 | babelHelpers: "runtime",
34 | }),
35 | commonjs(),
36 | uglify(),
37 | ],
38 | };
39 |
40 | export default config;
41 |
--------------------------------------------------------------------------------
/src/meta/object.meta.js:
--------------------------------------------------------------------------------
1 | class ObjectMeta {
2 | constructor(state, id, meta) {
3 | this.state = state;
4 | this.id = id;
5 | this.meta = meta;
6 | this.childMetaPairs = this.buildChildMetaPairs(id, meta);
7 |
8 | state.context.addContext(id, this);
9 | }
10 |
11 | set value(val) {
12 | this.childMetaPairs.forEach(({ key, propertyName }) => {
13 | const ctx = this.state.context.getContext(key);
14 | ctx.value = (val || {})[propertyName];
15 | });
16 | }
17 |
18 | /**
19 | * 构造结构数据给Object循环使用
20 | * @param {String} id 每个组件实例的唯一id,构造成json-schema中的`instancePath + '/' + params.missingProperty`
21 | * @param {Object} meta json-schema的某个层级的schema
22 | * @returns 返回构造后的数据给Object使用
23 | */
24 | buildChildMetaPairs(id, meta) {
25 | let results = [];
26 | for (let [key, value] of Object.entries(meta.properties || {})) {
27 | let keyVal = id === "/" ? `/${key}` : `${id}/${key}`;
28 | results.push({ key: keyVal, propertyName: key, meta: value });
29 | }
30 |
31 | return results;
32 | }
33 | }
34 |
35 | export { ObjectMeta };
36 |
--------------------------------------------------------------------------------
/src/examples/components/chk-input/ChkInput.vue:
--------------------------------------------------------------------------------
1 |