@zeng-alt/formkit-form-builder 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -19
- package/package.json +8 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ pnpm i vue naive-ui @vueuse/core
|
|
|
17
17
|
## 样式引入
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
|
-
import
|
|
20
|
+
import "@zeng-alt/formkit-form-builder/style.css";
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 快速开始
|
|
@@ -28,25 +28,25 @@ import '@zeng-alt/formkit-form-builder/style.css'
|
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
30
|
// main.ts
|
|
31
|
-
import { createApp } from
|
|
32
|
-
import { plugin as formkitPlugin } from
|
|
33
|
-
import App from
|
|
34
|
-
import formkitConfig from
|
|
31
|
+
import { createApp } from "vue";
|
|
32
|
+
import { plugin as formkitPlugin } from "@formkit/vue";
|
|
33
|
+
import App from "./App.vue";
|
|
34
|
+
import formkitConfig from "./formkit.config";
|
|
35
35
|
|
|
36
|
-
createApp(App).use(formkitPlugin, formkitConfig).mount(
|
|
36
|
+
createApp(App).use(formkitPlugin, formkitConfig).mount("#app");
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
### 2) 使用 FormBuilder
|
|
40
40
|
|
|
41
41
|
```vue
|
|
42
42
|
<script setup lang="ts">
|
|
43
|
-
import { FormBuilder, BuilderProvider } from
|
|
44
|
-
import
|
|
43
|
+
import { FormBuilder, BuilderProvider } from "formkit-form-builder";
|
|
44
|
+
import "formkit-form-builder/style.css";
|
|
45
45
|
|
|
46
46
|
const config = {
|
|
47
|
-
locale:
|
|
48
|
-
apiKey:
|
|
49
|
-
}
|
|
47
|
+
locale: "zh-CN",
|
|
48
|
+
apiKey: "",
|
|
49
|
+
};
|
|
50
50
|
</script>
|
|
51
51
|
|
|
52
52
|
<template>
|
|
@@ -64,23 +64,43 @@ const config = {
|
|
|
64
64
|
import {
|
|
65
65
|
FormBuilder,
|
|
66
66
|
BuilderProvider,
|
|
67
|
+
BuilderPreview,
|
|
68
|
+
FormSchemaRenderer,
|
|
67
69
|
FormBuilderProvider,
|
|
68
70
|
useFormBuilderConfig,
|
|
69
71
|
provideFormBuilderConfig,
|
|
70
|
-
} from
|
|
72
|
+
} from "formkit-form-builder";
|
|
71
73
|
```
|
|
72
74
|
|
|
73
75
|
- `FormBuilder`:主组件(设计器 UI)。
|
|
74
76
|
- `BuilderProvider / FormBuilderProvider`:提供全局配置(同一个组件,两个别名)。
|
|
77
|
+
- `FormSchemaRenderer`:对外表单渲染组件(渲染 builder 产出的 schema)。
|
|
78
|
+
- `BuilderPreview`:对外可复用的弹窗渲染组件(基于 FormSchemaRenderer)。
|
|
75
79
|
- `useFormBuilderConfig / provideFormBuilderConfig`:低层配置注入工具(通常你只需要 `BuilderProvider`)。
|
|
76
80
|
|
|
81
|
+
### 表单渲染(对外)
|
|
82
|
+
|
|
83
|
+
```vue
|
|
84
|
+
<script setup lang="ts">
|
|
85
|
+
import { ref } from "vue";
|
|
86
|
+
import { FormSchemaRenderer } from "formkit-form-builder";
|
|
87
|
+
|
|
88
|
+
const schema = ref([]);
|
|
89
|
+
const data = ref({});
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<template>
|
|
93
|
+
<FormSchemaRenderer :schema="schema" v-model="data" @submit="(v) => console.log(v)" />
|
|
94
|
+
</template>
|
|
95
|
+
```
|
|
96
|
+
|
|
77
97
|
### FormBuilderConfig
|
|
78
98
|
|
|
79
99
|
```ts
|
|
80
100
|
export interface FormBuilderConfig {
|
|
81
|
-
apiKey?: string
|
|
82
|
-
locale?: string
|
|
83
|
-
messages?: Record<string, any
|
|
101
|
+
apiKey?: string;
|
|
102
|
+
locale?: string;
|
|
103
|
+
messages?: Record<string, any>;
|
|
84
104
|
}
|
|
85
105
|
```
|
|
86
106
|
|
|
@@ -92,15 +112,15 @@ export interface FormBuilderConfig {
|
|
|
92
112
|
|
|
93
113
|
```ts
|
|
94
114
|
const config = {
|
|
95
|
-
locale:
|
|
115
|
+
locale: "zh-CN",
|
|
96
116
|
messages: {
|
|
97
|
-
|
|
117
|
+
"zh-CN": {
|
|
98
118
|
builder: {
|
|
99
|
-
clearForm:
|
|
119
|
+
clearForm: "清空当前表单",
|
|
100
120
|
},
|
|
101
121
|
},
|
|
102
122
|
},
|
|
103
|
-
}
|
|
123
|
+
};
|
|
104
124
|
```
|
|
105
125
|
|
|
106
126
|
## 示例
|
|
@@ -143,4 +163,9 @@ pnpm publish --access public
|
|
|
143
163
|
```bash
|
|
144
164
|
pnpm install
|
|
145
165
|
pnpm dev
|
|
166
|
+
|
|
167
|
+
pnpm version patch # 1.0.0 → 1.0.1
|
|
168
|
+
pnpm version minor # 1.0.0 → 1.1.0
|
|
169
|
+
pnpm version major # 1.0.0 → 2.0.0
|
|
170
|
+
pnpm publish
|
|
146
171
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeng-alt/formkit-form-builder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "A visual FormKit schema builder for Vue 3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,11 +43,18 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@internationalized/date": "^3.12.0",
|
|
46
|
+
"@codemirror/commands": "^6.8.1",
|
|
47
|
+
"@codemirror/lang-javascript": "^6.2.4",
|
|
48
|
+
"@codemirror/state": "^6.5.2",
|
|
49
|
+
"@codemirror/theme-one-dark": "^6.1.3",
|
|
50
|
+
"@codemirror/view": "^6.38.2",
|
|
46
51
|
"class-variance-authority": "^0.7.1",
|
|
47
52
|
"clsx": "^2.1.1",
|
|
53
|
+
"axios": "^1.12.2",
|
|
48
54
|
"openai": "^6.34.0",
|
|
49
55
|
"vue-sonner": "^2.0.9",
|
|
50
56
|
"@formkit/core": "^2.0.0",
|
|
57
|
+
"@formkit/i18n": "^2.0.0",
|
|
51
58
|
"@formkit/vue": "^2.0.0",
|
|
52
59
|
"@formkit/drag-and-drop": "^0.5.0"
|
|
53
60
|
},
|