@zeng-alt/formkit-form-builder 0.1.4 → 1.0.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/LICENSE +168 -0
- package/README.md +236 -61
- package/dist/builder.css +2 -0
- package/dist/builder.es.js +40324 -0
- package/dist/builder.umd.js +496 -0
- package/dist/index.d.ts +807 -1
- package/package.json +33 -26
- package/dist/index.cjs +0 -422
- package/dist/index.mjs +0 -9403
- package/dist/src/builder/BuilderDropArea.d.ts +0 -4
- package/dist/src/builder/BuilderHeader.d.ts +0 -17
- package/dist/src/builder/BuilderMain.d.ts +0 -68
- package/dist/src/builder/BuilderPreview.d.ts +0 -5
- package/dist/src/builder/BuilderProvider.d.ts +0 -21
- package/dist/src/builder/ImportExportModal.d.ts +0 -9
- package/dist/src/components/ai-prompt/AiPrompt.d.ts +0 -2
- package/dist/src/components/sidebar-left/DraggableList.d.ts +0 -8
- package/dist/src/components/sidebar-left/NavMain.d.ts +0 -2
- package/dist/src/components/sidebar-left/SidebarLeft.d.ts +0 -2
- package/dist/src/components/sidebar-right/FormEditMain.d.ts +0 -2
- package/dist/src/components/sidebar-right/SidebarRight.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/EditsSection.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/ExpressionEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/common/EditsLayout.d.ts +0 -21
- package/dist/src/components/sidebar-right/edits/common/JsonTextarea.d.ts +0 -14
- package/dist/src/components/sidebar-right/edits/common/LabelHelpSection.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/common/NaiveBasicSection.d.ts +0 -7
- package/dist/src/components/sidebar-right/edits/common/NameInput.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/common/OptionsTagsSection.d.ts +0 -5
- package/dist/src/components/sidebar-right/edits/common/PlaceholderSection.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/common/RangeInputs.d.ts +0 -16
- package/dist/src/components/sidebar-right/edits/common/SelectInput.d.ts +0 -15
- package/dist/src/components/sidebar-right/edits/common/SelectSwitchesSection.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/common/SwitchInput.d.ts +0 -12
- package/dist/src/components/sidebar-right/edits/common/TagsInput.d.ts +0 -11
- package/dist/src/components/sidebar-right/edits/common/TextInput.d.ts +0 -14
- package/dist/src/components/sidebar-right/edits/common/ToggleInput.d.ts +0 -15
- package/dist/src/components/sidebar-right/edits/common/TreeOptionsJsonSection.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/CheckboxEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/ColorEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/DateLikeEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/DateTimeEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/FileEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/GroupEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveAvatarEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveBlockquoteEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveButtonEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveCascaderEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveCheckboxEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveDividerEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveH1Editor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveH2Editor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveH3Editor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveH4Editor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveH5Editor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveH6Editor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveHeaderEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveLiEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveLinkEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveMentionEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveOlEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveParagraphEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveRateEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveSwitchEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveTextEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveTreeSelectEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NaiveUlEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/NumberEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/RadioEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/RangeEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/SelectEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/SubmitEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/edits/editors/TextLikeEditor.d.ts +0 -2
- package/dist/src/components/sidebar-right/validations/DoubleParamValidation.d.ts +0 -11
- package/dist/src/components/sidebar-right/validations/SingleParamValidation.d.ts +0 -8
- package/dist/src/components/sidebar-right/validations/SingleValueValidation.d.ts +0 -7
- package/dist/src/components/sidebar-right/validations/ValidationSection.d.ts +0 -2
- package/dist/src/components/sidebar-right/validations/index.d.ts +0 -3
- package/dist/src/components/ui/button/CustomButton.d.ts +0 -5
- package/dist/src/components/ui/formkit/NaiveAvatar.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveCascader.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveCheckbox.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveCheckboxGroup.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveColorPicker.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveDatePicker.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveDivider.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveMention.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveNumberInput.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveRadioGroup.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveRate.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveSelect.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveSlider.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveSwitch.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTextInput.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTextarea.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTimePicker.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTreeSelect.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTypographyA.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTypographyBlockquote.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTypographyHeader.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTypographyHr.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTypographyLi.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTypographyOl.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTypographyP.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTypographyText.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveTypographyUl.d.ts +0 -6
- package/dist/src/components/ui/formkit/NaiveUpload.d.ts +0 -6
- package/dist/src/components/ui/sonner/Sonner.d.ts +0 -3
- package/dist/src/components/ui/sonner/index.d.ts +0 -1
- package/dist/src/components/ui/theme-switcher/ThemeSwitcher.d.ts +0 -2
- package/dist/src/components/ui/validation-card/ValidationCard.d.ts +0 -21
- package/dist/src/components/ui/validation-card/ValidationSwitch.d.ts +0 -14
- package/dist/src/components/ui/validation-card/index.d.ts +0 -2
- package/dist/src/composables/form-fields.d.ts +0 -809
- package/dist/src/composables/schema-history.d.ts +0 -12
- package/dist/src/composables/use-config.d.ts +0 -5
- package/dist/src/formkit.config.d.ts +0 -11
- package/dist/src/formkit.theme.d.ts +0 -26
- package/dist/src/i18n/context.d.ts +0 -12
- package/dist/src/i18n/messages.d.ts +0 -332
- package/dist/src/index.d.ts +0 -7
- package/dist/src/style-entry.d.ts +0 -1
- package/dist/src/types/env.d.ts +0 -5
- package/dist/src/utils/custom-insert-plugin.d.ts +0 -17
- package/dist/src/utils/default-form-elements.d.ts +0 -1558
- package/dist/src/utils/expression-eval.d.ts +0 -10
- package/dist/src/utils/field-props.d.ts +0 -8
- package/dist/src/utils/format-schema.d.ts +0 -3
- package/dist/src/utils/utils.d.ts +0 -10
- package/dist/style.cjs +0 -0
- package/dist/style.css +0 -2
- package/dist/style.d.ts +0 -1
- package/dist/style.mjs +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,807 @@
|
|
|
1
|
-
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
3
|
+
import { ComponentProvideOptions } from 'vue';
|
|
4
|
+
import { ComputedOptions } from 'vue';
|
|
5
|
+
import { ComputedRef } from 'vue';
|
|
6
|
+
import { ConfigProviderProps } from 'naive-ui';
|
|
7
|
+
import { CreateComponentPublicInstanceWithMixins } from 'vue';
|
|
8
|
+
import { createInput } from '@formkit/vue';
|
|
9
|
+
import { defaultConfig } from '@formkit/vue';
|
|
10
|
+
import { DefineComponent } from 'vue';
|
|
11
|
+
import { FormKitConfig } from '@formkit/core';
|
|
12
|
+
import { FormKitContext } from '@formkit/core';
|
|
13
|
+
import { FormKitNode } from '@formkit/core';
|
|
14
|
+
import { FormKitPlugin } from '@formkit/core';
|
|
15
|
+
import { FormKitProps } from '@formkit/core';
|
|
16
|
+
import { FormKitSchemaFormKit } from '@formkit/core';
|
|
17
|
+
import { GlobalComponents } from 'vue';
|
|
18
|
+
import { GlobalDirectives } from 'vue';
|
|
19
|
+
import { MethodOptions } from 'vue';
|
|
20
|
+
import { Plugin as Plugin_2 } from 'vue';
|
|
21
|
+
import { PublicProps } from 'vue';
|
|
22
|
+
import { Ref } from 'vue';
|
|
23
|
+
|
|
24
|
+
declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
|
|
25
|
+
"update:modelValue": (value: FormDefinition) => any;
|
|
26
|
+
}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
27
|
+
"onUpdate:modelValue"?: ((value: FormDefinition) => any) | undefined;
|
|
28
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
29
|
+
|
|
30
|
+
declare const __VLS_component_2: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
|
|
32
|
+
declare const __VLS_component_3: DefineComponent<__VLS_Props_4, {
|
|
33
|
+
submit: () => void | undefined;
|
|
34
|
+
reset: () => void | undefined;
|
|
35
|
+
loading: Ref<boolean, boolean>;
|
|
36
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
|
|
37
|
+
submit: (formData: ModelValue_2, id: string | undefined, version: number | undefined) => any;
|
|
38
|
+
"update:modelValue": (value: ModelValue_2) => any;
|
|
39
|
+
}, string, PublicProps, Readonly<__VLS_Props_4> & Readonly<{
|
|
40
|
+
onSubmit?: ((formData: ModelValue_2, id: string | undefined, version: number | undefined) => any) | undefined;
|
|
41
|
+
"onUpdate:modelValue"?: ((value: ModelValue_2) => any) | undefined;
|
|
42
|
+
}>, {
|
|
43
|
+
actions: boolean;
|
|
44
|
+
formClass: string;
|
|
45
|
+
dataStructure: "flat" | "nested";
|
|
46
|
+
actionsJustify: "start" | "center" | "end" | "space-between";
|
|
47
|
+
interactiveContainers: boolean;
|
|
48
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
49
|
+
formKitRef: CreateComponentPublicInstanceWithMixins<Readonly<FormKitTypedProps>, {}, {}, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {}, true, {}, {}, GlobalComponents, GlobalDirectives, string, {}, any, ComponentProvideOptions, {
|
|
50
|
+
P: {};
|
|
51
|
+
B: {};
|
|
52
|
+
D: {};
|
|
53
|
+
C: {};
|
|
54
|
+
M: {};
|
|
55
|
+
Defaults: {};
|
|
56
|
+
}, Readonly<FormKitTypedProps>, {}, {}, ComputedOptions, MethodOptions, {}> | null;
|
|
57
|
+
}, any>;
|
|
58
|
+
|
|
59
|
+
declare type __VLS_Props = {
|
|
60
|
+
/** 表单定义:v-model 双向绑定,预载已有表单并实时吐出编辑结果 */
|
|
61
|
+
modelValue?: FormDefinition;
|
|
62
|
+
/** 本实例配置;传了则自给(registerElements + provide),不传回落外层 BuilderProvider 注入 */
|
|
63
|
+
config?: FormBuilderConfig;
|
|
64
|
+
/** 自定义主题:内部映射到 naive-ui 的 darkTheme / lightTheme;缺省自动跟随系统 */
|
|
65
|
+
theme?: BuilderTheme;
|
|
66
|
+
} & Omit<Partial<ConfigProviderProps>, 'theme'>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 全局配置提供者:作为唯一的 n-config-provider(主题)来源。
|
|
70
|
+
* 主题 + 其余 ConfigProviderProps(themeOverrides / breakpoints 等)在此统一控制,
|
|
71
|
+
* 子树内的 FormBuilder / FormRenderer 继承(多实例时主题一致)。
|
|
72
|
+
* 缺省 theme 由 useColorMode() 决定(含 ThemeSwitcher / 系统偏好)。
|
|
73
|
+
*/
|
|
74
|
+
declare type __VLS_Props_2 = {
|
|
75
|
+
config: FormBuilderConfig;
|
|
76
|
+
/** 自定义主题:内部映射到 naive-ui 的 darkTheme / lightTheme;缺省自动跟随系统 */
|
|
77
|
+
theme?: BuilderTheme;
|
|
78
|
+
themeOverrides?: ConfigProviderProps['themeOverrides'];
|
|
79
|
+
breakpoints?: ConfigProviderProps['breakpoints'];
|
|
80
|
+
clsPrefix?: string;
|
|
81
|
+
inlineThemeDisabled?: boolean;
|
|
82
|
+
preflightStyleDisabled?: boolean;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
declare type __VLS_Props_3 = {
|
|
86
|
+
show?: boolean;
|
|
87
|
+
schema?: FormKitSchemaFormKit[];
|
|
88
|
+
title?: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
showDataPanel?: boolean;
|
|
91
|
+
initialData?: ModelValue;
|
|
92
|
+
view?: CanvasView;
|
|
93
|
+
actions?: boolean;
|
|
94
|
+
formClass?: string;
|
|
95
|
+
interactiveContainers?: boolean;
|
|
96
|
+
resetOnSubmit?: boolean;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
declare type __VLS_Props_4 = {
|
|
100
|
+
/** 主输入:版本化 DSL 表单定义(设计器导出的 JSON),内部 dslToSchema 转换 */
|
|
101
|
+
definition?: FormDefinition;
|
|
102
|
+
/** 备选输入:裸 FormKit schema 数组(灵活通道);与 definition 同传时优先 definition */
|
|
103
|
+
schema?: FormKitSchemaFormKit[];
|
|
104
|
+
/** 有 definition 时的数据输出结构:flat 扁平 | nested 容器转 group 嵌套 */
|
|
105
|
+
dataStructure?: 'flat' | 'nested';
|
|
106
|
+
modelValue?: ModelValue_2;
|
|
107
|
+
/** 渲染默认操作区(提交/重置两按钮);false 则不显示,配合 #actions 槽自定义 */
|
|
108
|
+
actions?: boolean;
|
|
109
|
+
/** 默认提交按钮文案(缺省 i18n:提交 / Submit) */
|
|
110
|
+
submitLabel?: string;
|
|
111
|
+
/** 默认重置按钮文案(缺省 i18n:重置 / Reset) */
|
|
112
|
+
resetLabel?: string;
|
|
113
|
+
/** 默认提交按钮透传属性(naive NButton props) */
|
|
114
|
+
submitAttrs?: Record<string, unknown>;
|
|
115
|
+
/** 默认重置按钮透传属性(naive NButton props) */
|
|
116
|
+
resetAttrs?: Record<string, unknown>;
|
|
117
|
+
/** 默认操作区按钮对齐方式 */
|
|
118
|
+
actionsJustify?: 'start' | 'center' | 'end' | 'space-between';
|
|
119
|
+
formClass?: string;
|
|
120
|
+
formName?: string;
|
|
121
|
+
labelPosition?: 'top' | 'left';
|
|
122
|
+
labelWidth?: number;
|
|
123
|
+
schemaLibrary?: Record<string, Component>;
|
|
124
|
+
interactiveContainers?: boolean;
|
|
125
|
+
/** 自定义主题:内部映射到 naive-ui 的 darkTheme / lightTheme;缺省自动跟随系统 */
|
|
126
|
+
theme?: BuilderTheme;
|
|
127
|
+
} & Omit<Partial<ConfigProviderProps>, 'theme'>;
|
|
128
|
+
|
|
129
|
+
declare function __VLS_template(): {
|
|
130
|
+
attrs: Partial<{}>;
|
|
131
|
+
slots: Readonly<{
|
|
132
|
+
/** 整个顶栏(含默认内容) */
|
|
133
|
+
header?: () => unknown;
|
|
134
|
+
/** 顶栏左侧区(清除 / 预览),不传则用默认 */
|
|
135
|
+
'header-left'?: () => unknown;
|
|
136
|
+
/** 顶栏中间区(AI 提示),不传则用默认 */
|
|
137
|
+
'header-center'?: () => unknown;
|
|
138
|
+
/** 顶栏右侧区(undo/redo / 主题),不传则用默认 */
|
|
139
|
+
'header-right'?: () => unknown;
|
|
140
|
+
/** 画布空状态,不传则用默认 NEmpty */
|
|
141
|
+
empty?: () => unknown;
|
|
142
|
+
/** 右侧操作列(导入导出 / 语言切换),不传则用默认 */
|
|
143
|
+
toolbar?: () => unknown;
|
|
144
|
+
}> & {
|
|
145
|
+
/** 整个顶栏(含默认内容) */
|
|
146
|
+
header?: () => unknown;
|
|
147
|
+
/** 顶栏左侧区(清除 / 预览),不传则用默认 */
|
|
148
|
+
'header-left'?: () => unknown;
|
|
149
|
+
/** 顶栏中间区(AI 提示),不传则用默认 */
|
|
150
|
+
'header-center'?: () => unknown;
|
|
151
|
+
/** 顶栏右侧区(undo/redo / 主题),不传则用默认 */
|
|
152
|
+
'header-right'?: () => unknown;
|
|
153
|
+
/** 画布空状态,不传则用默认 NEmpty */
|
|
154
|
+
empty?: () => unknown;
|
|
155
|
+
/** 右侧操作列(导入导出 / 语言切换),不传则用默认 */
|
|
156
|
+
toolbar?: () => unknown;
|
|
157
|
+
};
|
|
158
|
+
refs: {};
|
|
159
|
+
rootEl: any;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
declare function __VLS_template_2(): {
|
|
163
|
+
attrs: Partial<{}>;
|
|
164
|
+
slots: {
|
|
165
|
+
default?(_: {}): any;
|
|
166
|
+
};
|
|
167
|
+
refs: {};
|
|
168
|
+
rootEl: any;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
declare function __VLS_template_3(): {
|
|
172
|
+
attrs: Partial<{}>;
|
|
173
|
+
slots: Readonly<{
|
|
174
|
+
/** 自定义操作区(覆盖默认提交/重置两按钮)。作用域提供 submit / reset / loading */
|
|
175
|
+
actions?: (props: FormActionsScope) => unknown;
|
|
176
|
+
}> & {
|
|
177
|
+
/** 自定义操作区(覆盖默认提交/重置两按钮)。作用域提供 submit / reset / loading */
|
|
178
|
+
actions?: (props: FormActionsScope) => unknown;
|
|
179
|
+
};
|
|
180
|
+
refs: {
|
|
181
|
+
formKitRef: CreateComponentPublicInstanceWithMixins<Readonly<FormKitTypedProps>, {}, {}, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {}, true, {}, {}, GlobalComponents, GlobalDirectives, string, {}, any, ComponentProvideOptions, {
|
|
182
|
+
P: {};
|
|
183
|
+
B: {};
|
|
184
|
+
D: {};
|
|
185
|
+
C: {};
|
|
186
|
+
M: {};
|
|
187
|
+
Defaults: {};
|
|
188
|
+
}, Readonly<FormKitTypedProps>, {}, {}, ComputedOptions, MethodOptions, {}> | null;
|
|
189
|
+
};
|
|
190
|
+
rootEl: any;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
194
|
+
|
|
195
|
+
declare type __VLS_TemplateResult_2 = ReturnType<typeof __VLS_template_2>;
|
|
196
|
+
|
|
197
|
+
declare type __VLS_TemplateResult_3 = ReturnType<typeof __VLS_template_3>;
|
|
198
|
+
|
|
199
|
+
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
200
|
+
new (): {
|
|
201
|
+
$slots: S;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
declare type __VLS_WithTemplateSlots_2<T, S> = T & {
|
|
206
|
+
new (): {
|
|
207
|
+
$slots: S;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
declare type __VLS_WithTemplateSlots_3<T, S> = T & {
|
|
212
|
+
new (): {
|
|
213
|
+
$slots: S;
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
declare interface BaseNode {
|
|
218
|
+
/** 稳定唯一 id(前端生成,用于树操作 / 选中 / 绑定) */
|
|
219
|
+
id: string;
|
|
220
|
+
/** 画布 DnD 身份(映射 legacy schema 的 __key;非画布场景可省略) */
|
|
221
|
+
key?: string;
|
|
222
|
+
/** 字段名(提交到后端的数据 key);容器 / 布局 / 静态节点可不填 */
|
|
223
|
+
name?: string;
|
|
224
|
+
label?: string;
|
|
225
|
+
/** 组件类型标识(见注册表:field / container / layout / static 各自的 type) */
|
|
226
|
+
type: string;
|
|
227
|
+
category: NodeCategory;
|
|
228
|
+
/** 渲染原语:formkit → $formkit: type;cmp → $cmp: target;el → $el: target */
|
|
229
|
+
renderAs: RenderKind;
|
|
230
|
+
/** 渲染目标:renderAs='cmp' 时为 $cmp 组件名,'el' 时为标签名;'formkit' 时缺省即 type */
|
|
231
|
+
target?: string;
|
|
232
|
+
/** 类型级扩展点:各 type 专有属性 */
|
|
233
|
+
props?: Record<string, unknown>;
|
|
234
|
+
/** 条件显示:布尔表达式 AST */
|
|
235
|
+
visibleIf?: Expr;
|
|
236
|
+
/** 布局信息(colspan / rowspan) */
|
|
237
|
+
layout?: NodeLayout;
|
|
238
|
+
/** 原始 outerClass(含 pt-2 等附加类;与 layout 同时保留保证往返无损) */
|
|
239
|
+
outerClass?: string;
|
|
240
|
+
events?: EventBinding[];
|
|
241
|
+
/** 任意业务元数据,Java 原样透传 */
|
|
242
|
+
meta?: Record<string, unknown>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export declare function buildElementSchemaLibrary(): Record<string, Component>;
|
|
246
|
+
|
|
247
|
+
export declare const BuilderPreview: DefineComponent<__VLS_Props_3, {
|
|
248
|
+
open: () => void;
|
|
249
|
+
close: () => void;
|
|
250
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
|
|
251
|
+
submit: (formData: ModelValue, id: string | undefined, version: number | undefined) => any;
|
|
252
|
+
"update:show": (value: boolean) => any;
|
|
253
|
+
}, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{
|
|
254
|
+
onSubmit?: ((formData: ModelValue, id: string | undefined, version: number | undefined) => any) | undefined;
|
|
255
|
+
"onUpdate:show"?: ((value: boolean) => any) | undefined;
|
|
256
|
+
}>, {
|
|
257
|
+
actions: boolean;
|
|
258
|
+
formClass: string;
|
|
259
|
+
interactiveContainers: boolean;
|
|
260
|
+
showDataPanel: boolean;
|
|
261
|
+
resetOnSubmit: boolean;
|
|
262
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
263
|
+
|
|
264
|
+
export declare type BuilderTheme = 'light' | 'dark';
|
|
265
|
+
|
|
266
|
+
export declare function buildFormkitInputs(): Record<string, ReturnType<typeof createInput>>;
|
|
267
|
+
|
|
268
|
+
export declare const CanvasActionsBar: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
269
|
+
|
|
270
|
+
declare interface CanvasUiState {
|
|
271
|
+
canvasView: Ref<CanvasView>;
|
|
272
|
+
isLoading: Ref<boolean>;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
declare type CanvasView = 'desktop' | 'tablet' | 'mobile';
|
|
276
|
+
|
|
277
|
+
declare interface ChildrenConvertCtx {
|
|
278
|
+
children?: (sc?: SchemaNode[]) => FormNode[];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
declare type ContainerDataShape = 'object' | 'arrayOfObjects' | 'objectOfObjects' | 'none';
|
|
282
|
+
|
|
283
|
+
declare type ContainerDefinition = {
|
|
284
|
+
id: string;
|
|
285
|
+
match: (node: unknown) => boolean;
|
|
286
|
+
canvas?: {
|
|
287
|
+
libraryKey: string;
|
|
288
|
+
component: Component;
|
|
289
|
+
};
|
|
290
|
+
preview?: {
|
|
291
|
+
libraryKey: string;
|
|
292
|
+
component: Component;
|
|
293
|
+
};
|
|
294
|
+
normalize?: (node: SchemaNode_2) => SchemaNode_2;
|
|
295
|
+
formatPreview?: (node: SchemaNode_2, ctx: ContainerFormatCtx) => FormKitSchemaFormKit;
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
declare type ContainerFormatCtx = {
|
|
299
|
+
key?: string;
|
|
300
|
+
isPlaceholder: boolean;
|
|
301
|
+
format: (node: FormKitSchemaFormKit, index: number) => FormKitSchemaFormKit;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
export declare interface ContainerNode extends BaseNode {
|
|
305
|
+
category: 'container';
|
|
306
|
+
/** object → group(嵌套对象);array → list / repeater / inputGroup */
|
|
307
|
+
dataType?: 'object' | 'array';
|
|
308
|
+
children: FormNode[];
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export declare type ContainerRenderer<T> = (node: ContainerNode, ctx: RenderContext<T>, children?: T[]) => T;
|
|
312
|
+
|
|
313
|
+
declare interface ContainerSpec {
|
|
314
|
+
/** 数据结构(用户记法 → 语义名):
|
|
315
|
+
* object({}) 单对象:children 是对象字段(group 原生;card/inputGroup 壳 + group 包一层)
|
|
316
|
+
* arrayOfObjects([{}]) 对象数组:每条记录一个 group(list)
|
|
317
|
+
* objectOfObjects({{}}) 对象之对象:每个子节点一个 group(tabs panes)
|
|
318
|
+
* none(-) 无数据:纯展示壳(buttonGroup)
|
|
319
|
+
*/
|
|
320
|
+
dataShape: ContainerDataShape;
|
|
321
|
+
/** DnD 画布身份键(props.<keyProp>),如 listKey / cardKey / groupKey 等 */
|
|
322
|
+
keyProp: string;
|
|
323
|
+
/** schema 输出主键:'group'(原生 $formkit:group)| 'cmp'($cmp:<type>) */
|
|
324
|
+
primitive: 'group' | 'cmp';
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** 创建独立的 FormBuilder 状态实例。 */
|
|
328
|
+
export declare function createFormBuilderState(): FormBuilderState;
|
|
329
|
+
|
|
330
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
331
|
+
export { _default as FormBuilder }
|
|
332
|
+
export { _default as FormKitFormBuilder }
|
|
333
|
+
|
|
334
|
+
declare const _default_2: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, __VLS_TemplateResult_2["slots"]>;
|
|
335
|
+
export { _default_2 as BuilderProvider }
|
|
336
|
+
export { _default_2 as FormBuilderProvider }
|
|
337
|
+
|
|
338
|
+
declare const _default_3: __VLS_WithTemplateSlots_3<typeof __VLS_component_3, __VLS_TemplateResult_3["slots"]>;
|
|
339
|
+
export { _default_3 as FormRenderer }
|
|
340
|
+
export { _default_3 as FormSchemaRenderer }
|
|
341
|
+
|
|
342
|
+
declare type DefSnapshot = FormDefinition;
|
|
343
|
+
|
|
344
|
+
/** 字典定义(分页搜索返回的一行) */
|
|
345
|
+
declare interface DictionaryDefinition {
|
|
346
|
+
code: string;
|
|
347
|
+
label: string;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** 字典项(单选/多选/下拉等渲染选项用) */
|
|
351
|
+
declare interface DictionaryOption {
|
|
352
|
+
label: string;
|
|
353
|
+
value: string | number;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
declare interface DictionaryPageQuery {
|
|
357
|
+
/** 按 code 模糊过滤 */
|
|
358
|
+
code?: string;
|
|
359
|
+
/** 按 label 模糊过滤 */
|
|
360
|
+
label?: string;
|
|
361
|
+
pageNum: number;
|
|
362
|
+
pageSize: number;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
declare interface DictionaryPageResult {
|
|
366
|
+
pageNum: number;
|
|
367
|
+
pageSize: number;
|
|
368
|
+
total: number;
|
|
369
|
+
data: DictionaryDefinition[];
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** 公开 API:将 DSL 转为含 Group 包裹的 FormKit schema,子节点嵌套为 JSON object 数据 */
|
|
373
|
+
export declare function dslToOutputSchema(form: FormDefinition): FormKitSchemaFormKit[];
|
|
374
|
+
|
|
375
|
+
export declare function dslToSchema(form: FormDefinition): FormKitSchemaFormKit[];
|
|
376
|
+
|
|
377
|
+
export declare interface DslToSchemaCtx {
|
|
378
|
+
form?: FormDefinition;
|
|
379
|
+
children?: SchemaNode[];
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** 动态字典来源:options 为对象 { dynamic, code, label? },运行时用 config.fetchDictionary 拉取 */
|
|
383
|
+
declare interface DynamicOptionSource {
|
|
384
|
+
/** 标记为动态字典来源(区别于静态 OptionItem[]) */
|
|
385
|
+
dynamic: true;
|
|
386
|
+
/** 字典编码 */
|
|
387
|
+
code: string;
|
|
388
|
+
/** 可选标签 */
|
|
389
|
+
label?: string;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** 元素目录条目(elements/definitions/* 的纯数据形态,注册表据此派生 ElementTypeDef) */
|
|
393
|
+
export declare interface ElementCatalogEntry {
|
|
394
|
+
type: string;
|
|
395
|
+
category: NodeCategory;
|
|
396
|
+
icon?: string;
|
|
397
|
+
tooltipKey?: string;
|
|
398
|
+
editor?: () => Promise<{
|
|
399
|
+
default: Component;
|
|
400
|
+
}>;
|
|
401
|
+
schema: ElementTemplate;
|
|
402
|
+
/** 容器元素的数据结构规格(list/card/group/inputGroup/buttonGroup/tabs;字段/静态/纯布局缺省) */
|
|
403
|
+
container?: ContainerSpec;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export declare type ElementCategory = NodeCategory;
|
|
407
|
+
|
|
408
|
+
export declare type ElementDefinition = ElementCatalogEntry;
|
|
409
|
+
|
|
410
|
+
export declare interface ElementPaletteProp {
|
|
411
|
+
name: string;
|
|
412
|
+
tooltip: string;
|
|
413
|
+
icon: string;
|
|
414
|
+
category: NodeCategory;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/** 元素默认模板(DSL 形态,纯数据):palette 建节点 / 画布默认 schema 的唯一来源 */
|
|
418
|
+
export declare interface ElementTemplate {
|
|
419
|
+
renderAs: RenderKind;
|
|
420
|
+
/** $cmp 组件名 / $el 标签名;缺省即 type(el 的 HTML 标签通常需要显式指定) */
|
|
421
|
+
target?: string;
|
|
422
|
+
/** 组件配置($cmp/$el 收进 props/attrs;formkit 时按 FIELD_TOP_PROPS 拆分) */
|
|
423
|
+
props?: Record<string, unknown>;
|
|
424
|
+
outerClass?: string;
|
|
425
|
+
nameKey: string;
|
|
426
|
+
labelKey?: string;
|
|
427
|
+
placeholderKey?: string;
|
|
428
|
+
helpKey?: string;
|
|
429
|
+
descriptionKey: string;
|
|
430
|
+
value?: unknown;
|
|
431
|
+
options?: unknown[];
|
|
432
|
+
validation?: string;
|
|
433
|
+
/** 自定义 DSL→schema;缺省按 category+renderAs 走内置转换 */
|
|
434
|
+
toSchema?: (node: FormNode, ctx: DslToSchemaCtx) => SchemaNode;
|
|
435
|
+
/** 自定义 schema→DSL;缺省按 category 走内置转换 */
|
|
436
|
+
fromSchema?: (schema: SchemaNode, ctx: ChildrenConvertCtx) => FormNode | null;
|
|
437
|
+
/** 自定义反向识别;缺省按 renderAs+type 推断(含 legacy $cmp 别名) */
|
|
438
|
+
match?: (schema: SchemaNode) => boolean;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export declare interface ElementTypeDef {
|
|
442
|
+
type: string;
|
|
443
|
+
category: NodeCategory;
|
|
444
|
+
/** 渲染原语 */
|
|
445
|
+
renderAs: RenderKind;
|
|
446
|
+
/** $cmp 组件名 / $el 标签名 */
|
|
447
|
+
target?: string;
|
|
448
|
+
/** 默认模板(palette / 新建节点) */
|
|
449
|
+
template?: ElementTemplate;
|
|
450
|
+
/** 容器元素的数据结构规格(见 container-spec.ts) */
|
|
451
|
+
container?: ContainerSpec;
|
|
452
|
+
/** 新建节点默认 DSL */
|
|
453
|
+
defaults: () => FormNode;
|
|
454
|
+
toSchema: (node: FormNode, ctx: DslToSchemaCtx) => SchemaNode;
|
|
455
|
+
/** 反向识别:schema 是否属于该类型 */
|
|
456
|
+
match?: (schema: SchemaNode) => boolean;
|
|
457
|
+
fromSchema?: (schema: SchemaNode, ctx: ChildrenConvertCtx) => FormNode | null;
|
|
458
|
+
normalize?: (schema: SchemaNode) => SchemaNode;
|
|
459
|
+
editor?: () => Promise<{
|
|
460
|
+
default: Component;
|
|
461
|
+
}>;
|
|
462
|
+
icon?: string;
|
|
463
|
+
tooltipKey?: string;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
declare type ElEvent = 'click' | 'dblclick' | 'mouseenter' | 'mouseleave' | 'keydown' | 'keyup' | 'keypress' | 'submit';
|
|
467
|
+
|
|
468
|
+
declare interface EventBinding {
|
|
469
|
+
event: FormEvent;
|
|
470
|
+
handler: string;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
declare type Expr = ExprLiteral | ExprField | ExprCall;
|
|
474
|
+
|
|
475
|
+
declare interface ExprCall {
|
|
476
|
+
type: 'call';
|
|
477
|
+
/** 内置函数名,见 src/dsl/expr-builtins.ts;前后端共用同一份清单 */
|
|
478
|
+
fn: string;
|
|
479
|
+
args: Expr[];
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
declare interface ExprField {
|
|
483
|
+
type: 'field';
|
|
484
|
+
/** 引用表单数据里的字段名(提交给后端的数据 key) */
|
|
485
|
+
name: string;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
declare interface ExprLiteral {
|
|
489
|
+
type: 'literal';
|
|
490
|
+
value: StaticValue;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export declare interface FieldNode extends BaseNode {
|
|
494
|
+
category: 'field';
|
|
495
|
+
/** 初始值 */
|
|
496
|
+
value?: FieldValue;
|
|
497
|
+
validation?: ValidationRule[];
|
|
498
|
+
/** select / radio / checkbox 等选项(静态数组,或 { dynamic, code } 动态字典) */
|
|
499
|
+
options?: OptionItem[] | DynamicOptionSource;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export declare type FieldRenderer<T> = (node: FieldNode, ctx: RenderContext<T>, children?: T[]) => T;
|
|
503
|
+
|
|
504
|
+
/** 字段值:静态值 或 表达式({ $expr: AST }) */
|
|
505
|
+
declare type FieldValue = StaticValue | {
|
|
506
|
+
$expr: Expr;
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
/** #actions 槽作用域:可由外部自定义操作区按钮,复用表单提交/重置 */
|
|
510
|
+
declare type FormActionsScope = {
|
|
511
|
+
submit: () => void;
|
|
512
|
+
reset: () => void;
|
|
513
|
+
loading: boolean;
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
export declare interface FormBuilderConfig {
|
|
517
|
+
apiKey?: string;
|
|
518
|
+
locale?: string;
|
|
519
|
+
localeFallback?: string;
|
|
520
|
+
messages?: Record<string, any>;
|
|
521
|
+
/** 可用语言列表,默认 ['zh-CN', 'en'] */
|
|
522
|
+
availableLocales?: string[];
|
|
523
|
+
/** 扩展元素(配置式注册:DSL + FormKit input + 容器画布/预览 一次打通) */
|
|
524
|
+
elements?: RegisterElementInput[];
|
|
525
|
+
/** 字典查询:按 code 取字典项 [{label,value}](动态字段渲染时调用) */
|
|
526
|
+
fetchDictionary?: (code: string) => Promise<DictionaryOption[]>;
|
|
527
|
+
/** 字典分页搜索:编辑面板弹窗查找字典定义用 */
|
|
528
|
+
fetchDictionaryPage?: (params: DictionaryPageQuery) => Promise<DictionaryPageResult>;
|
|
529
|
+
/** 树型字典查询:按 code 取树型字典项 [{label,key,children?}](树选择/级联选择渲染时调用) */
|
|
530
|
+
fetchTreeDictionary?: (code: string) => Promise<TreeDictionaryOption[]>;
|
|
531
|
+
/** 树型字典分页搜索:编辑面板弹窗查找树型字典定义用 */
|
|
532
|
+
fetchTreeDictionaryPage?: (params: TreeDictionaryPageQuery) => Promise<TreeDictionaryPageResult>;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* 一键接入插件:安装 FormKit + 元素注册 + 全局配置一次完成。
|
|
537
|
+
* 之后可直接用 `<FormBuilder :config v-model="def"/>` 与 `<FormRenderer :definition="def"/>`,
|
|
538
|
+
* 无需再手动 app.use(plugin, formkitConfig()) 或套 BuilderProvider。
|
|
539
|
+
*/
|
|
540
|
+
export declare const FormBuilderPlugin: Plugin_2;
|
|
541
|
+
|
|
542
|
+
export declare interface FormBuilderPluginOptions {
|
|
543
|
+
/** 全局配置(apiKey / locale / messages / elements 扩展) */
|
|
544
|
+
config?: FormBuilderConfig;
|
|
545
|
+
/** 自定义 FormKit defaultConfig 工厂;默认 formkitConfig(config.elements) */
|
|
546
|
+
formkitConfig?: (elements?: RegisterElementInput[]) => ReturnType<typeof defaultConfig>;
|
|
547
|
+
/** 是否自动安装 FormKit 插件;应用已装过 @formkit/vue 时设 false 防重复 */
|
|
548
|
+
installFormKit?: boolean;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/** 单个 FormBuilder 实例的全部状态(表单定义 + 选中 + 画布 UI + 历史漏斗)。 */
|
|
552
|
+
export declare interface FormBuilderState extends FormDefinitionState, SelectionState, CanvasUiState, SchemaHistory {
|
|
553
|
+
/** 实例标识:用于 DnD 根 drop-area 选择器作用域(多设计器并存)。 */
|
|
554
|
+
instanceId: string;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
export declare interface FormDefinition {
|
|
558
|
+
version: number;
|
|
559
|
+
id: string;
|
|
560
|
+
name: string;
|
|
561
|
+
description?: string;
|
|
562
|
+
/** 表单树根节点:必须是容器,字段只能挂在容器 / 布局内 */
|
|
563
|
+
root: ContainerNode;
|
|
564
|
+
settings: FormSettings;
|
|
565
|
+
meta?: Record<string, unknown>;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
declare interface FormDefinitionState {
|
|
569
|
+
formDefinition: Ref<FormDefinition>;
|
|
570
|
+
formSchema: ComputedRef<FormKitSchemaFormKit[]>;
|
|
571
|
+
commitSchemaChildren: (children: FormKitSchemaFormKit[], source?: Pick<FormDefinition, "name" | "settings">) => FormDefinition;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
declare type FormEvent = FormKitEvent | ElEvent;
|
|
575
|
+
|
|
576
|
+
export declare function formkitConfig(elements?: RegisterElementInput[]): Partial<Omit<FormKitContext, "children" | "config" | "plugins" | "hook"> & {
|
|
577
|
+
config: Partial<FormKitConfig>;
|
|
578
|
+
props: Partial<FormKitProps>;
|
|
579
|
+
children: FormKitNode[] | Set<FormKitNode>;
|
|
580
|
+
index?: number;
|
|
581
|
+
sync: boolean;
|
|
582
|
+
plugins: FormKitPlugin[];
|
|
583
|
+
alias: string;
|
|
584
|
+
schemaAlias: string;
|
|
585
|
+
}>;
|
|
586
|
+
|
|
587
|
+
declare type FormKitEvent = 'change' | 'input' | 'blur' | 'focus';
|
|
588
|
+
|
|
589
|
+
declare type FormKitTypedProps = {
|
|
590
|
+
type?: string;
|
|
591
|
+
name?: string;
|
|
592
|
+
actions?: boolean;
|
|
593
|
+
formClass?: string;
|
|
594
|
+
modelValue?: ModelValue_2;
|
|
595
|
+
'onUpdate:modelValue'?: (value: ModelValue_2) => void;
|
|
596
|
+
onSubmit?: (formData: ModelValue_2) => void;
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
export declare type FormNode = FieldNode | ContainerNode | LayoutNode | StaticNode;
|
|
600
|
+
|
|
601
|
+
export declare interface FormSettings {
|
|
602
|
+
/** 布局方向 */
|
|
603
|
+
layout: 'vertical' | 'horizontal' | 'inline';
|
|
604
|
+
labelWidth?: number;
|
|
605
|
+
labelAlign?: 'left' | 'right' | 'top';
|
|
606
|
+
/** 根栅格列数(默认 12) */
|
|
607
|
+
columns?: number;
|
|
608
|
+
fullWidth?: boolean;
|
|
609
|
+
submit?: string;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/** 取元素 $cmp 渲染名(统一为 type;兼容旧 libraryName) */
|
|
613
|
+
export declare function getElementCmpName(type: string): string;
|
|
614
|
+
|
|
615
|
+
export declare interface IRendererEngine<T = any> {
|
|
616
|
+
use(plugin: RendererPlugin<T>): this;
|
|
617
|
+
registerField(type: string, fn: FieldRenderer<T>): void;
|
|
618
|
+
registerContainer(type: string, fn: ContainerRenderer<T>): void;
|
|
619
|
+
registerLayout(type: string, fn: LayoutRenderer<T>): void;
|
|
620
|
+
registerStatic(type: string, fn: StaticRenderer<T>): void;
|
|
621
|
+
render(node: FormNode, ctx?: Partial<RenderContext<T>>): T;
|
|
622
|
+
renderForm(form: FormDefinition): any;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
export declare interface LayoutNode extends BaseNode {
|
|
626
|
+
category: 'layout';
|
|
627
|
+
type: LayoutType;
|
|
628
|
+
children: FormNode[];
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
declare type LayoutRenderer<T> = (node: LayoutNode, ctx: RenderContext<T>, children?: T[]) => T;
|
|
632
|
+
|
|
633
|
+
export declare type LayoutType = 'grid' | 'row' | 'column' | 'card' | 'tabs' | 'tabsPane';
|
|
634
|
+
|
|
635
|
+
declare type ModelValue = Record<string, unknown>;
|
|
636
|
+
|
|
637
|
+
declare type ModelValue_2 = Record<string, unknown>;
|
|
638
|
+
|
|
639
|
+
export declare type NodeCategory = 'field' | 'container' | 'layout' | 'static';
|
|
640
|
+
|
|
641
|
+
declare interface NodeLayout {
|
|
642
|
+
/** 栅格占位(基于 settings.columns,默认 12) */
|
|
643
|
+
colspan?: number;
|
|
644
|
+
rowspan?: number;
|
|
645
|
+
/** 显式宽度(px / 百分比),grid 模式下忽略 */
|
|
646
|
+
width?: number | string;
|
|
647
|
+
order?: number;
|
|
648
|
+
/** 响应式断点覆盖 */
|
|
649
|
+
responsive?: {
|
|
650
|
+
sm?: NodeLayout;
|
|
651
|
+
md?: NodeLayout;
|
|
652
|
+
lg?: NodeLayout;
|
|
653
|
+
xl?: NodeLayout;
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
declare interface OptionItem {
|
|
658
|
+
label: string;
|
|
659
|
+
value: StaticValue;
|
|
660
|
+
disabled?: boolean;
|
|
661
|
+
children?: OptionItem[];
|
|
662
|
+
[key: string]: unknown;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
export declare function provideFormBuilderConfig(config: FormBuilderConfig): void;
|
|
666
|
+
|
|
667
|
+
/** 为当前组件子树提供 FormBuilder 状态。 */
|
|
668
|
+
export declare function provideFormBuilderState(state?: FormBuilderState): FormBuilderState;
|
|
669
|
+
|
|
670
|
+
export declare function registerElement(input: RegisterElementInput): void;
|
|
671
|
+
|
|
672
|
+
export declare interface RegisterElementInput extends Omit<ElementCatalogEntry, 'schema'> {
|
|
673
|
+
/** DSL 默认模板(含可选 toSchema/fromSchema/match 钩子) */
|
|
674
|
+
schema: ElementTemplate;
|
|
675
|
+
/** FormKit 输入组件(field/static 必填;renderAs:'cmp' 时经 schema 库渲染) */
|
|
676
|
+
component?: Component;
|
|
677
|
+
/** 容器画布组件(category==='container' 时可选) */
|
|
678
|
+
canvas?: Component;
|
|
679
|
+
/** 容器预览组件(category==='container' 时可选) */
|
|
680
|
+
preview?: Component;
|
|
681
|
+
/** 容器归一化 / 预览格式化(缺省走通用 listKey/modelValue 约定) */
|
|
682
|
+
normalize?: ContainerDefinition['normalize'];
|
|
683
|
+
formatPreview?: ContainerDefinition['formatPreview'];
|
|
684
|
+
/** 允许覆盖已注册类型(含内置) */
|
|
685
|
+
overwrite?: boolean;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
export declare function registerElements(inputs: RegisterElementInput[] | undefined): void;
|
|
689
|
+
|
|
690
|
+
export declare interface RenderContext<T = any> {
|
|
691
|
+
form: FormDefinition;
|
|
692
|
+
engine: IRendererEngine<T>;
|
|
693
|
+
render(node: FormNode): T;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export declare interface RendererPlugin<T = any> {
|
|
697
|
+
name: string;
|
|
698
|
+
install(engine: IRendererEngine<T>): void;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export declare type RenderKind = 'formkit' | 'cmp' | 'el';
|
|
702
|
+
|
|
703
|
+
/** 历史漏斗返回值(commit/undo/redo + 外部应用)。 */
|
|
704
|
+
declare interface SchemaHistory {
|
|
705
|
+
canUndo: ComputedRef<boolean>;
|
|
706
|
+
canRedo: ComputedRef<boolean>;
|
|
707
|
+
commitFormDefinition: (nextDef: DefSnapshot, options?: {
|
|
708
|
+
reason?: string;
|
|
709
|
+
merge?: boolean;
|
|
710
|
+
}) => void;
|
|
711
|
+
commitSchema: (nextSchema: FormKitSchemaFormKit[], options?: {
|
|
712
|
+
reason?: string;
|
|
713
|
+
merge?: boolean;
|
|
714
|
+
name?: string;
|
|
715
|
+
settings?: FormDefinition['settings'];
|
|
716
|
+
}) => void;
|
|
717
|
+
commitSchemaReconcile: (nextSchema: FormKitSchemaFormKit[], options?: {
|
|
718
|
+
reason?: string;
|
|
719
|
+
merge?: boolean;
|
|
720
|
+
}) => void;
|
|
721
|
+
undo: () => void;
|
|
722
|
+
redo: () => void;
|
|
723
|
+
resetHistory: () => void;
|
|
724
|
+
/** 外部应用(如 v-model 预载 / 父级替换表单):直接落真源、不推历史。
|
|
725
|
+
* 默认重置内部 undo 栈(父级权威),可传 { resetHistory: false } 保留。 */
|
|
726
|
+
setFormDefinition: (nextDef: DefSnapshot, opts?: {
|
|
727
|
+
resetHistory?: boolean;
|
|
728
|
+
}) => void;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
declare type SchemaNode = FormKitSchemaFormKit & Record<string, unknown>;
|
|
732
|
+
|
|
733
|
+
declare type SchemaNode_2 = FormKitSchemaFormKit & Record<string, unknown>;
|
|
734
|
+
|
|
735
|
+
export declare function schemaToDsl(schema: FormKitSchemaFormKit[], options?: SchemaToDslOptions): FormDefinition;
|
|
736
|
+
|
|
737
|
+
declare interface SchemaToDslOptions {
|
|
738
|
+
id?: string;
|
|
739
|
+
name?: string;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
declare interface SelectionState {
|
|
743
|
+
selectedIndex: Ref<number>;
|
|
744
|
+
selectedKey: Ref<string | null>;
|
|
745
|
+
selectedTarget: Ref<'field' | 'form'>;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
export declare function setGlobalFormBuilderConfig(config?: FormBuilderConfig): void;
|
|
749
|
+
|
|
750
|
+
export declare interface StaticNode extends BaseNode {
|
|
751
|
+
category: 'static';
|
|
752
|
+
/** 文本内容(text / 标题 / 分割线) */
|
|
753
|
+
text?: string;
|
|
754
|
+
/** 图片地址 */
|
|
755
|
+
src?: string;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
export declare type StaticRenderer<T> = (node: StaticNode, ctx: RenderContext<T>, children?: T[]) => T;
|
|
759
|
+
|
|
760
|
+
declare type StaticValue = any;
|
|
761
|
+
|
|
762
|
+
/** 树型字典定义(分页搜索返回的一行) */
|
|
763
|
+
declare interface TreeDictionaryDefinition {
|
|
764
|
+
value: string;
|
|
765
|
+
label: string;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/** 树型字典项(树选择/级联选择用) */
|
|
769
|
+
declare interface TreeDictionaryOption {
|
|
770
|
+
label: string;
|
|
771
|
+
value: string | number;
|
|
772
|
+
children?: TreeDictionaryOption[];
|
|
773
|
+
disabled?: boolean;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
declare interface TreeDictionaryPageQuery {
|
|
777
|
+
/** 按 code 模糊过滤 */
|
|
778
|
+
value?: string;
|
|
779
|
+
/** 按 label 模糊过滤 */
|
|
780
|
+
label?: string;
|
|
781
|
+
pageNum: number;
|
|
782
|
+
pageSize: number;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
declare interface TreeDictionaryPageResult {
|
|
786
|
+
pageNum: number;
|
|
787
|
+
pageSize: number;
|
|
788
|
+
total: number;
|
|
789
|
+
data: TreeDictionaryDefinition[];
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
export declare function useFormBuilderConfig(): FormBuilderConfig;
|
|
793
|
+
|
|
794
|
+
/** 读取所在 FormBuilder 实例的状态;子树外(如独立使用的 BuilderPreview)回落到默认实例。 */
|
|
795
|
+
export declare function useFormBuilderState(): FormBuilderState;
|
|
796
|
+
|
|
797
|
+
declare interface ValidationRule {
|
|
798
|
+
rule: string;
|
|
799
|
+
args?: StaticValue[];
|
|
800
|
+
message?: string;
|
|
801
|
+
debounce?: number;
|
|
802
|
+
empty?: boolean;
|
|
803
|
+
force?: boolean;
|
|
804
|
+
optional?: boolean;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
export { }
|