@zeng-alt/formkit-form-builder 1.0.0 → 1.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 +47 -0
- package/dist/builder.css +1 -1
- package/dist/builder.es.js +33941 -27233
- package/dist/builder.umd.js +81 -41
- package/dist/index.d.ts +82 -18
- package/package.json +32 -19
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
1
2
|
import { Component } from 'vue';
|
|
2
3
|
import { ComponentOptionsMixin } from 'vue';
|
|
3
4
|
import { ComponentProvideOptions } from 'vue';
|
|
@@ -29,16 +30,16 @@ declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, Comp
|
|
|
29
30
|
|
|
30
31
|
declare const __VLS_component_2: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
31
32
|
|
|
32
|
-
declare const __VLS_component_3: DefineComponent<
|
|
33
|
+
declare const __VLS_component_3: DefineComponent<__VLS_Props_5, {
|
|
33
34
|
submit: () => void | undefined;
|
|
34
35
|
reset: () => void | undefined;
|
|
35
36
|
loading: Ref<boolean, boolean>;
|
|
36
37
|
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
|
|
37
|
-
submit: (formData:
|
|
38
|
-
"update:modelValue": (value:
|
|
39
|
-
}, string, PublicProps, Readonly<
|
|
40
|
-
onSubmit?: ((formData:
|
|
41
|
-
"onUpdate:modelValue"?: ((value:
|
|
38
|
+
submit: (formData: ModelValue_3, id: string | undefined, version: number | undefined) => any;
|
|
39
|
+
"update:modelValue": (value: ModelValue_3) => any;
|
|
40
|
+
}, string, PublicProps, Readonly<__VLS_Props_5> & Readonly<{
|
|
41
|
+
onSubmit?: ((formData: ModelValue_3, id: string | undefined, version: number | undefined) => any) | undefined;
|
|
42
|
+
"onUpdate:modelValue"?: ((value: ModelValue_3) => any) | undefined;
|
|
42
43
|
}>, {
|
|
43
44
|
actions: boolean;
|
|
44
45
|
formClass: string;
|
|
@@ -97,13 +98,33 @@ declare type __VLS_Props_3 = {
|
|
|
97
98
|
};
|
|
98
99
|
|
|
99
100
|
declare type __VLS_Props_4 = {
|
|
101
|
+
/** 控制弹窗显隐 */
|
|
102
|
+
show?: boolean;
|
|
103
|
+
/** 弹窗标题 */
|
|
104
|
+
title?: string;
|
|
105
|
+
/** 版本化 DSL 表单定义(设计器导出的 JSON),内部 dslToSchema 转换 */
|
|
106
|
+
formDefinition: FormDefinition;
|
|
107
|
+
/** 初始表单数据 */
|
|
108
|
+
initialData?: ModelValue_2;
|
|
109
|
+
/** 渲染默认操作区(提交/重置两按钮) */
|
|
110
|
+
actions?: boolean;
|
|
111
|
+
formClass?: string;
|
|
112
|
+
interactiveContainers?: boolean;
|
|
113
|
+
/** 是否显示右侧数据面板 */
|
|
114
|
+
showDataPanel?: boolean;
|
|
115
|
+
/** 右侧数据面板宽度 */
|
|
116
|
+
dataPanelWidth?: string;
|
|
117
|
+
resetOnSubmit?: boolean;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
declare type __VLS_Props_5 = {
|
|
100
121
|
/** 主输入:版本化 DSL 表单定义(设计器导出的 JSON),内部 dslToSchema 转换 */
|
|
101
122
|
definition?: FormDefinition;
|
|
102
123
|
/** 备选输入:裸 FormKit schema 数组(灵活通道);与 definition 同传时优先 definition */
|
|
103
124
|
schema?: FormKitSchemaFormKit[];
|
|
104
125
|
/** 有 definition 时的数据输出结构:flat 扁平 | nested 容器转 group 嵌套 */
|
|
105
126
|
dataStructure?: 'flat' | 'nested';
|
|
106
|
-
modelValue?:
|
|
127
|
+
modelValue?: ModelValue_3;
|
|
107
128
|
/** 渲染默认操作区(提交/重置两按钮);false 则不显示,配合 #actions 槽自定义 */
|
|
108
129
|
actions?: boolean;
|
|
109
130
|
/** 默认提交按钮文案(缺省 i18n:提交 / Submit) */
|
|
@@ -122,8 +143,12 @@ declare type __VLS_Props_4 = {
|
|
|
122
143
|
labelWidth?: number;
|
|
123
144
|
schemaLibrary?: Record<string, Component>;
|
|
124
145
|
interactiveContainers?: boolean;
|
|
146
|
+
/** 本实例配置;传了则自给(registerElements + provide + locale/i18n),不传回落外层 Builder/BuilderProvider 注入 */
|
|
147
|
+
config?: FormBuilderConfig;
|
|
125
148
|
/** 自定义主题:内部映射到 naive-ui 的 darkTheme / lightTheme;缺省自动跟随系统 */
|
|
126
149
|
theme?: BuilderTheme;
|
|
150
|
+
/** 自定义 HTTP 请求库实例:供 JS 绑定代码里的 axios 变量使用;缺省使用内置 axios */
|
|
151
|
+
http?: AxiosInstance;
|
|
127
152
|
} & Omit<Partial<ConfigProviderProps>, 'theme'>;
|
|
128
153
|
|
|
129
154
|
declare function __VLS_template(): {
|
|
@@ -278,7 +303,7 @@ declare interface ChildrenConvertCtx {
|
|
|
278
303
|
children?: (sc?: SchemaNode[]) => FormNode[];
|
|
279
304
|
}
|
|
280
305
|
|
|
281
|
-
declare type ContainerDataShape = 'object' | 'arrayOfObjects' | 'objectOfObjects' | 'none';
|
|
306
|
+
declare type ContainerDataShape = 'object' | 'array' | 'arrayOfObjects' | 'objectOfObjects' | 'none';
|
|
282
307
|
|
|
283
308
|
declare type ContainerDefinition = {
|
|
284
309
|
id: string;
|
|
@@ -313,7 +338,9 @@ export declare type ContainerRenderer<T> = (node: ContainerNode, ctx: RenderCont
|
|
|
313
338
|
declare interface ContainerSpec {
|
|
314
339
|
/** 数据结构(用户记法 → 语义名):
|
|
315
340
|
* object({}) 单对象:children 是对象字段(group 原生;card/inputGroup 壳 + group 包一层)
|
|
316
|
-
*
|
|
341
|
+
* array([]) 动态数组:单条记录是标量/单字段(list),
|
|
342
|
+
* 或预置 group 的对象数组 [{...}](nestedList 便捷项)
|
|
343
|
+
* arrayOfObjects([{}]) 遗留别名:语义等同 array(历史数据/扩展注册兼容),渲染同 list
|
|
317
344
|
* objectOfObjects({{}}) 对象之对象:每个子节点一个 group(tabs panes)
|
|
318
345
|
* none(-) 无数据:纯展示壳(buttonGroup)
|
|
319
346
|
*/
|
|
@@ -430,6 +457,11 @@ export declare interface ElementTemplate {
|
|
|
430
457
|
value?: unknown;
|
|
431
458
|
options?: unknown[];
|
|
432
459
|
validation?: string;
|
|
460
|
+
/** 容器/布局新建节点时的默认子节点(DSL 形态);如 nestedList 预置一个内部 group */
|
|
461
|
+
defaultChildren?: () => FormNode[];
|
|
462
|
+
/** 便捷预置:新建节点改用指定类型(如 nestedList → presetOf:'list',仅比 list 多内置 group),
|
|
463
|
+
* 生成的 DSL / schema 类型即该类型,本目录项仅作面板展示用 */
|
|
464
|
+
presetOf?: string;
|
|
433
465
|
/** 自定义 DSL→schema;缺省按 category+renderAs 走内置转换 */
|
|
434
466
|
toSchema?: (node: FormNode, ctx: DslToSchemaCtx) => SchemaNode;
|
|
435
467
|
/** 自定义 schema→DSL;缺省按 category 走内置转换 */
|
|
@@ -494,6 +526,8 @@ export declare interface FieldNode extends BaseNode {
|
|
|
494
526
|
category: 'field';
|
|
495
527
|
/** 初始值 */
|
|
496
528
|
value?: FieldValue;
|
|
529
|
+
/** 表达式字符串(如 "$price * $count"),由运行时 watch 求值并写入 FormKit node */
|
|
530
|
+
expr?: string;
|
|
497
531
|
validation?: ValidationRule[];
|
|
498
532
|
/** select / radio / checkbox 等选项(静态数组,或 { dynamic, code } 动态字典) */
|
|
499
533
|
options?: OptionItem[] | DynamicOptionSource;
|
|
@@ -501,10 +535,8 @@ export declare interface FieldNode extends BaseNode {
|
|
|
501
535
|
|
|
502
536
|
export declare type FieldRenderer<T> = (node: FieldNode, ctx: RenderContext<T>, children?: T[]) => T;
|
|
503
537
|
|
|
504
|
-
/** 字段值:静态值
|
|
505
|
-
declare type FieldValue = StaticValue
|
|
506
|
-
$expr: Expr;
|
|
507
|
-
};
|
|
538
|
+
/** 字段值:静态值 */
|
|
539
|
+
declare type FieldValue = StaticValue;
|
|
508
540
|
|
|
509
541
|
/** #actions 槽作用域:可由外部自定义操作区按钮,复用表单提交/重置 */
|
|
510
542
|
declare type FormActionsScope = {
|
|
@@ -515,6 +547,9 @@ declare type FormActionsScope = {
|
|
|
515
547
|
|
|
516
548
|
export declare interface FormBuilderConfig {
|
|
517
549
|
apiKey?: string;
|
|
550
|
+
/** 自定义 HTTP 请求库实例:供 JS 绑定代码里的 axios 变量使用(画布预览 + 渲染器);
|
|
551
|
+
* 缺省使用内置 axios。FormRenderer 的 http prop 优先级更高。 */
|
|
552
|
+
http?: AxiosInstance;
|
|
518
553
|
locale?: string;
|
|
519
554
|
localeFallback?: string;
|
|
520
555
|
messages?: Record<string, any>;
|
|
@@ -565,10 +600,31 @@ export declare interface FormDefinition {
|
|
|
565
600
|
meta?: Record<string, unknown>;
|
|
566
601
|
}
|
|
567
602
|
|
|
603
|
+
export declare const FormDefinitionPreview: DefineComponent<__VLS_Props_4, {
|
|
604
|
+
open: () => void;
|
|
605
|
+
close: () => void;
|
|
606
|
+
reset: () => void;
|
|
607
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
|
|
608
|
+
submit: (formData: ModelValue_2, id: string | undefined, version: number | undefined) => any;
|
|
609
|
+
"update:show": (value: boolean) => any;
|
|
610
|
+
}, string, PublicProps, Readonly<__VLS_Props_4> & Readonly<{
|
|
611
|
+
onSubmit?: ((formData: ModelValue_2, id: string | undefined, version: number | undefined) => any) | undefined;
|
|
612
|
+
"onUpdate:show"?: ((value: boolean) => any) | undefined;
|
|
613
|
+
}>, {
|
|
614
|
+
title: string;
|
|
615
|
+
actions: boolean;
|
|
616
|
+
formClass: string;
|
|
617
|
+
interactiveContainers: boolean;
|
|
618
|
+
showDataPanel: boolean;
|
|
619
|
+
initialData: ModelValue_2;
|
|
620
|
+
resetOnSubmit: boolean;
|
|
621
|
+
dataPanelWidth: string;
|
|
622
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
623
|
+
|
|
568
624
|
declare interface FormDefinitionState {
|
|
569
625
|
formDefinition: Ref<FormDefinition>;
|
|
570
626
|
formSchema: ComputedRef<FormKitSchemaFormKit[]>;
|
|
571
|
-
commitSchemaChildren: (children: FormKitSchemaFormKit[], source?: Pick<FormDefinition,
|
|
627
|
+
commitSchemaChildren: (children: FormKitSchemaFormKit[], source?: Pick<FormDefinition, 'name' | 'settings'>) => FormDefinition;
|
|
572
628
|
}
|
|
573
629
|
|
|
574
630
|
declare type FormEvent = FormKitEvent | ElEvent;
|
|
@@ -591,9 +647,9 @@ declare type FormKitTypedProps = {
|
|
|
591
647
|
name?: string;
|
|
592
648
|
actions?: boolean;
|
|
593
649
|
formClass?: string;
|
|
594
|
-
modelValue?:
|
|
595
|
-
'onUpdate:modelValue'?: (value:
|
|
596
|
-
onSubmit?: (formData:
|
|
650
|
+
modelValue?: ModelValue_3;
|
|
651
|
+
'onUpdate:modelValue'?: (value: ModelValue_3) => void;
|
|
652
|
+
onSubmit?: (formData: ModelValue_3) => void;
|
|
597
653
|
};
|
|
598
654
|
|
|
599
655
|
export declare type FormNode = FieldNode | ContainerNode | LayoutNode | StaticNode;
|
|
@@ -630,12 +686,14 @@ export declare interface LayoutNode extends BaseNode {
|
|
|
630
686
|
|
|
631
687
|
declare type LayoutRenderer<T> = (node: LayoutNode, ctx: RenderContext<T>, children?: T[]) => T;
|
|
632
688
|
|
|
633
|
-
export declare type LayoutType = 'grid' | 'row' | 'column' | 'card' | 'tabs' | 'tabsPane';
|
|
689
|
+
export declare type LayoutType = 'grid' | 'row' | 'column' | 'card' | 'tabs' | 'tabsPane' | 'steps' | 'stepsPane';
|
|
634
690
|
|
|
635
691
|
declare type ModelValue = Record<string, unknown>;
|
|
636
692
|
|
|
637
693
|
declare type ModelValue_2 = Record<string, unknown>;
|
|
638
694
|
|
|
695
|
+
declare type ModelValue_3 = Record<string, unknown>;
|
|
696
|
+
|
|
639
697
|
export declare type NodeCategory = 'field' | 'container' | 'layout' | 'static';
|
|
640
698
|
|
|
641
699
|
declare interface NodeLayout {
|
|
@@ -743,6 +801,12 @@ declare interface SelectionState {
|
|
|
743
801
|
selectedIndex: Ref<number>;
|
|
744
802
|
selectedKey: Ref<string | null>;
|
|
745
803
|
selectedTarget: Ref<'field' | 'form'>;
|
|
804
|
+
/** 数据表格选中列下标(null = 未选中列;配合 selectedKey 定位所属数据表格节点) */
|
|
805
|
+
selectedColumnIndex: Ref<number | null>;
|
|
806
|
+
/** 元素属性编辑目标覆盖:列元素等非树节点复用标准字段编辑器时指向的工作节点 */
|
|
807
|
+
elementEditTarget: Ref<FormNode | null>;
|
|
808
|
+
/** 元素属性写回回调:工作节点变更后把结果落回(如 columns[i].element) */
|
|
809
|
+
elementEditCommit: Ref<((node: FormNode) => void) | null>;
|
|
746
810
|
}
|
|
747
811
|
|
|
748
812
|
export declare function setGlobalFormBuilderConfig(config?: FormBuilderConfig): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeng-alt/formkit-form-builder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A visual FormKit schema builder for Vue 3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "LGPL",
|
|
@@ -37,17 +37,39 @@
|
|
|
37
37
|
"sideEffects": [
|
|
38
38
|
"**/*.css"
|
|
39
39
|
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"dev": "vite",
|
|
42
|
+
"build": "run-p type-check \"build-only {@}\" --",
|
|
43
|
+
"preview": "vite preview",
|
|
44
|
+
"build-only": "vite build",
|
|
45
|
+
"type-check": "vue-tsc --build",
|
|
46
|
+
"lint": "run-s lint:*",
|
|
47
|
+
"lint:oxlint": "oxlint . --fix",
|
|
48
|
+
"lint:eslint": "eslint . --fix --cache",
|
|
49
|
+
"format": "oxfmt src/"
|
|
50
|
+
},
|
|
40
51
|
"peerDependencies": {
|
|
41
52
|
"@vueuse/core": "^14.2.1",
|
|
42
53
|
"naive-ui": "^2.44.0",
|
|
43
|
-
"vue": "^3.5.0"
|
|
54
|
+
"vue": "^3.5.0",
|
|
55
|
+
"@codemirror/autocomplete": "^6.20.1",
|
|
56
|
+
"@codemirror/commands": "^6.10.3",
|
|
57
|
+
"@codemirror/language": "^6.9.2",
|
|
58
|
+
"@codemirror/state": "^6.5.2",
|
|
59
|
+
"@codemirror/view": "^6.38.2",
|
|
60
|
+
"@codemirror/lang-javascript": "^6.2.4",
|
|
61
|
+
"@codemirror/theme-one-dark": "^6.1.3",
|
|
62
|
+
"@codemirror/lint": "^6.8.5"
|
|
44
63
|
},
|
|
45
64
|
"dependencies": {
|
|
46
|
-
"@codemirror/
|
|
47
|
-
"@codemirror/
|
|
65
|
+
"@codemirror/autocomplete": "^6.20.1",
|
|
66
|
+
"@codemirror/commands": "^6.10.3",
|
|
67
|
+
"@codemirror/language": "^6.9.2",
|
|
48
68
|
"@codemirror/state": "^6.5.2",
|
|
49
|
-
"@codemirror/theme-one-dark": "^6.1.3",
|
|
50
69
|
"@codemirror/view": "^6.38.2",
|
|
70
|
+
"@codemirror/lang-javascript": "^6.2.4",
|
|
71
|
+
"@codemirror/theme-one-dark": "^6.1.3",
|
|
72
|
+
"@codemirror/lint": "^6.8.5",
|
|
51
73
|
"@formkit/core": "^2.0.0",
|
|
52
74
|
"@formkit/drag-and-drop": "^0.5.0",
|
|
53
75
|
"@formkit/i18n": "^2.0.0",
|
|
@@ -86,8 +108,10 @@
|
|
|
86
108
|
"ts-node": "^10.9.2",
|
|
87
109
|
"tsx": "^4.21.0",
|
|
88
110
|
"typescript": "~6.0.0",
|
|
89
|
-
"unocss": "^66.
|
|
90
|
-
"unocss-
|
|
111
|
+
"unocss": "^66.7.0",
|
|
112
|
+
"@unocss/preset-rem-to-px": "^66.7.0",
|
|
113
|
+
"@unocss/eslint-config": "^66.7.0",
|
|
114
|
+
"@unocss/eslint-plugin": "^66.7.0",
|
|
91
115
|
"unplugin-auto-import": "^21.1.0",
|
|
92
116
|
"unplugin-vue-components": "^32.1.0",
|
|
93
117
|
"vite": "^8.0.3",
|
|
@@ -98,16 +122,5 @@
|
|
|
98
122
|
},
|
|
99
123
|
"engines": {
|
|
100
124
|
"node": "^20.19.0 || >=22.12.0"
|
|
101
|
-
},
|
|
102
|
-
"scripts": {
|
|
103
|
-
"dev": "vite",
|
|
104
|
-
"build": "run-p type-check \"build-only {@}\" --",
|
|
105
|
-
"preview": "vite preview",
|
|
106
|
-
"build-only": "vite build",
|
|
107
|
-
"type-check": "vue-tsc --build",
|
|
108
|
-
"lint": "run-s lint:*",
|
|
109
|
-
"lint:oxlint": "oxlint . --fix",
|
|
110
|
-
"lint:eslint": "eslint . --fix --cache",
|
|
111
|
-
"format": "oxfmt src/"
|
|
112
125
|
}
|
|
113
|
-
}
|
|
126
|
+
}
|