@zeng-alt/formkit-form-builder 0.1.0
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 +139 -0
- package/dist/index.cjs +422 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +10939 -0
- package/dist/src/builder/BuilderDropArea.d.ts +4 -0
- package/dist/src/builder/BuilderHeader.d.ts +17 -0
- package/dist/src/builder/BuilderMain.d.ts +68 -0
- package/dist/src/builder/BuilderPreview.d.ts +5 -0
- package/dist/src/builder/BuilderProvider.d.ts +21 -0
- package/dist/src/builder/ImportExportModal.d.ts +9 -0
- package/dist/src/components/ai-prompt/AiPrompt.d.ts +2 -0
- package/dist/src/components/sidebar-left/DraggableList.d.ts +8 -0
- package/dist/src/components/sidebar-left/NavMain.d.ts +2 -0
- package/dist/src/components/sidebar-left/SidebarLeft.d.ts +2 -0
- package/dist/src/components/sidebar-right/FormEditMain.d.ts +2 -0
- package/dist/src/components/sidebar-right/SidebarRight.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/EditsSection.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/ExpressionEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/common/EditsLayout.d.ts +21 -0
- package/dist/src/components/sidebar-right/edits/common/JsonTextarea.d.ts +14 -0
- package/dist/src/components/sidebar-right/edits/common/LabelHelpSection.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/common/NaiveBasicSection.d.ts +7 -0
- package/dist/src/components/sidebar-right/edits/common/NameInput.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/common/OptionsTagsSection.d.ts +5 -0
- package/dist/src/components/sidebar-right/edits/common/PlaceholderSection.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/common/RangeInputs.d.ts +16 -0
- package/dist/src/components/sidebar-right/edits/common/SelectInput.d.ts +15 -0
- package/dist/src/components/sidebar-right/edits/common/SelectSwitchesSection.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/common/SwitchInput.d.ts +12 -0
- package/dist/src/components/sidebar-right/edits/common/TagsInput.d.ts +11 -0
- package/dist/src/components/sidebar-right/edits/common/TextInput.d.ts +14 -0
- package/dist/src/components/sidebar-right/edits/common/ToggleInput.d.ts +15 -0
- package/dist/src/components/sidebar-right/edits/common/TreeOptionsJsonSection.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/CheckboxEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/ColorEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/DateLikeEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/DateTimeEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/FileEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/GroupEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveAvatarEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveBlockquoteEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveButtonEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveCascaderEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveCheckboxEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveDividerEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveH1Editor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveH2Editor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveH3Editor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveH4Editor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveH5Editor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveH6Editor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveHeaderEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveLiEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveLinkEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveMentionEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveOlEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveParagraphEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveRateEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveSwitchEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveTextEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveTreeSelectEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NaiveUlEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/NumberEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/RadioEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/RangeEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/SelectEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/SubmitEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/edits/editors/TextLikeEditor.d.ts +2 -0
- package/dist/src/components/sidebar-right/validations/DoubleParamValidation.d.ts +11 -0
- package/dist/src/components/sidebar-right/validations/SingleParamValidation.d.ts +8 -0
- package/dist/src/components/sidebar-right/validations/SingleValueValidation.d.ts +7 -0
- package/dist/src/components/sidebar-right/validations/ValidationSection.d.ts +2 -0
- package/dist/src/components/sidebar-right/validations/index.d.ts +3 -0
- package/dist/src/components/ui/sonner/Sonner.d.ts +3 -0
- package/dist/src/components/ui/sonner/index.d.ts +1 -0
- package/dist/src/components/ui/theme-switcher/ThemeSwitcher.d.ts +2 -0
- package/dist/src/components/ui/validation-card/ValidationCard.d.ts +21 -0
- package/dist/src/components/ui/validation-card/ValidationSwitch.d.ts +14 -0
- package/dist/src/components/ui/validation-card/index.d.ts +2 -0
- package/dist/src/composables/form-fields.d.ts +808 -0
- package/dist/src/composables/schema-history.d.ts +12 -0
- package/dist/src/composables/use-config.d.ts +5 -0
- package/dist/src/i18n/context.d.ts +12 -0
- package/dist/src/i18n/messages.d.ts +332 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/style-entry.d.ts +1 -0
- package/dist/src/types/env.d.ts +5 -0
- package/dist/src/utils/custom-insert-plugin.d.ts +17 -0
- package/dist/src/utils/default-form-elements.d.ts +1558 -0
- package/dist/src/utils/expression-eval.d.ts +10 -0
- package/dist/src/utils/field-props.d.ts +8 -0
- package/dist/src/utils/format-schema.d.ts +3 -0
- package/dist/src/utils/utils.d.ts +10 -0
- package/dist/style.cjs +0 -0
- package/dist/style.css +3 -0
- package/dist/style.d.ts +1 -0
- package/dist/style.mjs +0 -0
- package/package.json +100 -0
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# formkit-form-builder
|
|
2
|
+
|
|
3
|
+
基于 Vue 3 + FormKit 的可视化表单 Schema 设计器(左侧物料库 / 中间画布 / 右侧属性面板),支持拖拽搭建、校验配置、预览,以及可选的 AI 生成 Schema。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i formkit-form-builder
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
本库依赖以下 peer 依赖(需要你在项目里自行安装,版本按你项目实际选择即可):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm i vue @formkit/core @formkit/vue @formkit/drag-and-drop naive-ui
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 样式引入
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import 'formkit-form-builder/style.css'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 快速开始
|
|
24
|
+
|
|
25
|
+
### 1) 安装并注册 FormKit
|
|
26
|
+
|
|
27
|
+
示例(Vite + Vue 3):
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
// main.ts
|
|
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
|
+
|
|
36
|
+
createApp(App).use(formkitPlugin, formkitConfig).mount('#app')
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2) 使用 FormBuilder
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<script setup lang="ts">
|
|
43
|
+
import { FormBuilder, BuilderProvider } from 'formkit-form-builder'
|
|
44
|
+
import 'formkit-form-builder/style.css'
|
|
45
|
+
|
|
46
|
+
const config = {
|
|
47
|
+
locale: 'zh-CN',
|
|
48
|
+
apiKey: '',
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<template>
|
|
53
|
+
<BuilderProvider :config="config">
|
|
54
|
+
<FormBuilder />
|
|
55
|
+
</BuilderProvider>
|
|
56
|
+
</template>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## API
|
|
60
|
+
|
|
61
|
+
### 导出
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import {
|
|
65
|
+
FormBuilder,
|
|
66
|
+
BuilderProvider,
|
|
67
|
+
FormBuilderProvider,
|
|
68
|
+
useFormBuilderConfig,
|
|
69
|
+
provideFormBuilderConfig,
|
|
70
|
+
} from 'formkit-form-builder'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- `FormBuilder`:主组件(设计器 UI)。
|
|
74
|
+
- `BuilderProvider / FormBuilderProvider`:提供全局配置(同一个组件,两个别名)。
|
|
75
|
+
- `useFormBuilderConfig / provideFormBuilderConfig`:低层配置注入工具(通常你只需要 `BuilderProvider`)。
|
|
76
|
+
|
|
77
|
+
### FormBuilderConfig
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
export interface FormBuilderConfig {
|
|
81
|
+
apiKey?: string
|
|
82
|
+
locale?: string
|
|
83
|
+
messages?: Record<string, any>
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- `apiKey`:可选,AI 面板使用 OpenAI 时需要。
|
|
88
|
+
- `locale`:可选,默认 `zh-CN`。
|
|
89
|
+
- `messages`:可选,多语言覆写(结构与默认 messages 一致)。
|
|
90
|
+
|
|
91
|
+
## i18n 覆写
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
const config = {
|
|
95
|
+
locale: 'zh-CN',
|
|
96
|
+
messages: {
|
|
97
|
+
'zh-CN': {
|
|
98
|
+
builder: {
|
|
99
|
+
clearForm: '清空当前表单',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 发布到 npm(公共仓库)
|
|
107
|
+
|
|
108
|
+
1) 确认 `package.json`:
|
|
109
|
+
- `name` 是未被占用的包名
|
|
110
|
+
- `version` 已更新(遵循 semver)
|
|
111
|
+
- `publishConfig.access = "public"`
|
|
112
|
+
- `private` 已移除
|
|
113
|
+
|
|
114
|
+
2) 安装依赖并生成构建产物:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pnpm install --no-frozen-lockfile
|
|
118
|
+
pnpm build
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
3) 登录并发布:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npm login
|
|
125
|
+
npm publish --access public
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
如果你用 pnpm:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pnpm publish --access public
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## 开发(本仓库)
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
pnpm install
|
|
138
|
+
pnpm dev
|
|
139
|
+
```
|