zova-module-a-form 5.1.43 → 5.1.44
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/dist/component/form/controller.d.ts +9 -3
- package/dist/component/form/controller.d.ts.map +1 -1
- package/dist/component/form/render.d.ts +1 -0
- package/dist/component/form/render.d.ts.map +1 -1
- package/dist/component/formField/controller.d.ts.map +1 -1
- package/dist/index.js +148 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/formLayout.d.ts +4 -0
- package/dist/lib/formLayout.d.ts.map +1 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/types/formField.d.ts +4 -4
- package/dist/types/formField.d.ts.map +1 -1
- package/dist/types/formLayout.d.ts +47 -0
- package/dist/types/formLayout.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/component/form/controller.tsx +44 -3
- package/src/component/form/render.tsx +22 -4
- package/src/component/formField/controller.tsx +3 -2
- package/src/lib/formLayout.ts +203 -0
- package/src/lib/index.ts +1 -0
- package/src/types/formField.ts +7 -4
- package/src/types/formLayout.ts +59 -0
- package/src/types/index.ts +1 -0
|
@@ -4,14 +4,14 @@ import { SchemaObject } from 'openapi3-ts/oas31';
|
|
|
4
4
|
import { VNode } from 'vue';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { ZovaJsx } from 'zova-jsx';
|
|
7
|
-
import { IFormMeta, IFormProvider, IResourceFormFieldLayoutOptions, ISchemaObjectExtensionField, ScopeModuleAOpenapi, TypeFormFieldRenderComponent, TypeFormFieldRenderComponentProvider, TypeFormSchemaScene } from 'zova-module-a-openapi';
|
|
7
|
+
import { IFormMeta, IFormProvider, IResourceFormFieldLayoutOptions, IResourceRenderBlockOptionsBlock, ISchemaObjectExtensionField, ScopeModuleAOpenapi, TypeFormFieldRenderComponent, TypeFormFieldRenderComponentProvider, TypeFormSchemaScene } from 'zova-module-a-openapi';
|
|
8
|
+
import type { IResolvedFormLayoutNode, IResolvedFormLayoutTab } from '../../types/formLayout.js';
|
|
8
9
|
import { BeanControllerFormBase } from '../../lib/beanControllerFormBase.js';
|
|
9
10
|
import { IFormScope, RevalidateLogicProps, TypeFormOnShowError, TypeFormOnSubmit, TypeFormOnSubmitInvalid } from '../../types/form.js';
|
|
10
|
-
import { IFormFieldOptions, IFormFieldRenderContextPropsBucket, IFormFieldScope, IJsxRenderContextFormField } from '../../types/formField.js';
|
|
11
|
+
import { IFormFieldOptions, IFormFieldRenderContextPropsBucket, IFormFieldScope, IJsxRenderContextForm, IJsxRenderContextFormField } from '../../types/formField.js';
|
|
11
12
|
import { ControllerFormField } from '../formField/controller.jsx';
|
|
12
13
|
export interface ControllerFormProps<TFormData extends {} = {}, TSubmitMeta = never> {
|
|
13
14
|
formTag?: string;
|
|
14
|
-
inline?: boolean;
|
|
15
15
|
data?: TFormData;
|
|
16
16
|
schema?: SchemaObject;
|
|
17
17
|
schemaScene?: TypeFormSchemaScene;
|
|
@@ -22,6 +22,7 @@ export interface ControllerFormProps<TFormData extends {} = {}, TSubmitMeta = ne
|
|
|
22
22
|
formProvider?: IFormProvider;
|
|
23
23
|
formScope?: IFormScope;
|
|
24
24
|
formFieldLayout?: IResourceFormFieldLayoutOptions;
|
|
25
|
+
blocks?: IResourceRenderBlockOptionsBlock[];
|
|
25
26
|
onFormSubmit?: (e: SubmitEvent, form: ControllerForm<TFormData, TSubmitMeta>) => any;
|
|
26
27
|
onSubmitInvalid?: TypeFormOnSubmitInvalid<TFormData, TSubmitMeta>;
|
|
27
28
|
onSubmitData?: TypeFormOnSubmit<TFormData, TSubmitMeta>;
|
|
@@ -51,13 +52,17 @@ export declare class ControllerForm<TFormData extends {} = {}, TSubmitMeta = nev
|
|
|
51
52
|
keepDefaultValues?: boolean;
|
|
52
53
|
}): TFormData;
|
|
53
54
|
get formMeta(): IFormMeta | undefined;
|
|
55
|
+
hasErrors(node: IResolvedFormLayoutNode | IResolvedFormLayoutTab): boolean;
|
|
56
|
+
getErrorFieldCount(node: IResolvedFormLayoutNode | IResolvedFormLayoutTab): any;
|
|
54
57
|
getFieldValue<K extends DeepKeys<TFormData>>(name: K): any;
|
|
55
58
|
setFieldValue<K extends DeepKeys<TFormData>>(name: K, value: any, disableNotifyChanged?: boolean): void;
|
|
56
59
|
getFieldProperty<K extends DeepKeys<TFormData>>(name: K): ISchemaObjectExtensionField | undefined;
|
|
57
60
|
getFieldZodSchema<K extends DeepKeys<TFormData>>(name: K): z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | undefined;
|
|
58
61
|
private _getFieldCelEnv;
|
|
59
62
|
getFieldScope<K extends DeepKeys<TFormData>>(name: K, scopeExtra?: {}): IFormFieldScope<TFormData>;
|
|
63
|
+
getFormScope(scopeExtra?: {}): IFormScope;
|
|
60
64
|
getFieldJsxRenderContext($$formField: ControllerFormField<TFormData> | undefined, celScope: IFormFieldScope<TFormData>): IJsxRenderContextFormField<TFormData, TSubmitMeta>;
|
|
65
|
+
getFormJsxRenderContext(celScope: IFormScope): IJsxRenderContextForm<TFormData, TSubmitMeta>;
|
|
61
66
|
getFieldComponentPropsTop<K extends DeepKeys<TFormData>>(name: K, celScope: IFormFieldScope<TFormData>, jsxRenderContext: {}): IFormFieldRenderContextPropsBucket;
|
|
62
67
|
private _getFieldComponentPropsTopInner;
|
|
63
68
|
getRenderProvider(render: TypeFormFieldRenderComponent): TypeFormFieldRenderComponentProvider;
|
|
@@ -76,6 +81,7 @@ export declare class ControllerForm<TFormData extends {} = {}, TSubmitMeta = nev
|
|
|
76
81
|
}>[] | undefined;
|
|
77
82
|
private _getFieldComponentOptionsTop;
|
|
78
83
|
isComponentFormField(renderProvider?: TypeFormFieldRenderComponentProvider): boolean;
|
|
84
|
+
private _getFormLayoutErrorFieldCount;
|
|
79
85
|
private _handleError422;
|
|
80
86
|
}
|
|
81
87
|
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/component/form/controller.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAwB,MAAM,eAAe,CAAC;AAE7E,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/component/form/controller.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAwB,MAAM,eAAe,CAAC;AAE7E,OAAO,EACL,QAAQ,EAQT,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAkB,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnD,OAAO,EACL,SAAS,EACT,aAAa,EACb,+BAA+B,EAC/B,gCAAgC,EAChC,2BAA2B,EAE3B,mBAAmB,EACnB,4BAA4B,EAC5B,oCAAoC,EACpC,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEjG,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,iBAAiB,EACjB,kCAAkC,EAClC,eAAe,EACf,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,MAAM,WAAW,mBAAmB,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,EAAE,WAAW,GAAG,KAAK;IACjF,OAAO,CAAC,E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AO,CAAC,4BAA4B;IAW7B,oBAAoB,CAAC,cAAc,CAAC,EAAE,oCAAoC;IAIjF,OAAO,CAAC,6BAA6B;IASrC,OAAO,CAAC,eAAe;CAiGxB"}
|
|
@@ -3,6 +3,7 @@ import { BeanRenderBase } from 'zova';
|
|
|
3
3
|
export declare class RenderForm extends BeanRenderBase {
|
|
4
4
|
private _renderSchema;
|
|
5
5
|
private _renderChildren;
|
|
6
|
+
private _renderFromBlocks;
|
|
6
7
|
private _renderBodyInner;
|
|
7
8
|
private _renderProps;
|
|
8
9
|
render(): VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/component/form/render.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAGtC,qBACa,UAAW,SAAQ,cAAc;IAC5C,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,YAAY;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/component/form/render.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAGtC,qBACa,UAAW,SAAQ,cAAc;IAC5C,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,YAAY;IAiBb,MAAM;;;CASd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/component/formField/controller.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRo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AAC,0BAA0B;IAOlC,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,yBAAyB;IAMjC,OAAO,CAAC,+BAA+B;IAevC,OAAO,CAAC,oBAAoB;IAqB5B,OAAO,CAAC,8BAA8B;CAoBvC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BeanControllerBase, BeanControllerPageBase, BeanInfo, BeanRenderBase, BeanScopeBase, SymbolController, Use, UseScope, cast, deepEqual, deepExtend, objectAssignReactive, prepareComponentOptions, useController } from "zova";
|
|
2
2
|
import { catchError, celEnvBase, isEmptyObject, isNil } from "@cabloy/utils";
|
|
3
3
|
import { ZodMetadata } from "@cabloy/zod-openapi";
|
|
4
|
-
import { determineFormLevelErrorSourceAndValue, getBy, isGlobalFormValidationError, revalidateLogic, useField, useForm
|
|
4
|
+
import { determineFormLevelErrorSourceAndValue, getBy, isGlobalFormValidationError, revalidateLogic, useField, useForm } from "@tanstack/vue-form";
|
|
5
|
+
import { useSelector } from "@tanstack/vue-store";
|
|
5
6
|
import { ZovaJsx, isJsxComponent } from "zova-jsx";
|
|
6
7
|
import { Controller, Render, Scope } from "zova-module-a-bean";
|
|
7
8
|
import { renderFormFieldTopPropsSystem } from "zova-module-a-openapi";
|
|
@@ -61,7 +62,7 @@ var ControllerForm$1 = (_dec$6 = Controller(), _dec2$6 = BeanInfo({ module: "a-f
|
|
|
61
62
|
async __init__() {
|
|
62
63
|
this.bean._setBean("$$form", this);
|
|
63
64
|
this.form = this._createForm();
|
|
64
|
-
this.formState =
|
|
65
|
+
this.formState = useSelector(this.form.store, (state) => state);
|
|
65
66
|
this.formProvider = this.$computed(() => {
|
|
66
67
|
const formProvider = this.$$scopeOpenapi.config.formProvider;
|
|
67
68
|
return this.$props.formProvider ? deepExtend({}, formProvider, this.$props.formProvider) : formProvider;
|
|
@@ -96,6 +97,12 @@ var ControllerForm$1 = (_dec$6 = Controller(), _dec2$6 = BeanInfo({ module: "a-f
|
|
|
96
97
|
get formMeta() {
|
|
97
98
|
return this.$props.formMeta;
|
|
98
99
|
}
|
|
100
|
+
hasErrors(node) {
|
|
101
|
+
return this.getErrorFieldCount(node) > 0;
|
|
102
|
+
}
|
|
103
|
+
getErrorFieldCount(node) {
|
|
104
|
+
return this._getFormLayoutErrorFieldCount(node);
|
|
105
|
+
}
|
|
99
106
|
getFieldValue(name) {
|
|
100
107
|
return getBy(this.formState.values, name) ?? null;
|
|
101
108
|
}
|
|
@@ -131,6 +138,9 @@ var ControllerForm$1 = (_dec$6 = Controller(), _dec2$6 = BeanInfo({ module: "a-f
|
|
|
131
138
|
...scopeExtra
|
|
132
139
|
});
|
|
133
140
|
}
|
|
141
|
+
getFormScope(scopeExtra) {
|
|
142
|
+
return objectAssignReactive({}, this.$props.formScope, { ...scopeExtra });
|
|
143
|
+
}
|
|
134
144
|
getFieldJsxRenderContext($$formField, celScope) {
|
|
135
145
|
return {
|
|
136
146
|
app: this.app,
|
|
@@ -143,6 +153,17 @@ var ControllerForm$1 = (_dec$6 = Controller(), _dec2$6 = BeanInfo({ module: "a-f
|
|
|
143
153
|
$$form: this
|
|
144
154
|
};
|
|
145
155
|
}
|
|
156
|
+
getFormJsxRenderContext(celScope) {
|
|
157
|
+
return {
|
|
158
|
+
app: this.app,
|
|
159
|
+
ctx: this.ctx,
|
|
160
|
+
$scene: "form",
|
|
161
|
+
$host: this,
|
|
162
|
+
$celScope: celScope,
|
|
163
|
+
$jsx: this.zovaJsx,
|
|
164
|
+
$$form: this
|
|
165
|
+
};
|
|
166
|
+
}
|
|
146
167
|
getFieldComponentPropsTop(name, celScope, jsxRenderContext) {
|
|
147
168
|
return this._getFieldComponentPropsTopInner(name, celScope, jsxRenderContext);
|
|
148
169
|
}
|
|
@@ -240,6 +261,12 @@ var ControllerForm$1 = (_dec$6 = Controller(), _dec2$6 = BeanInfo({ module: "a-f
|
|
|
240
261
|
isComponentFormField(renderProvider) {
|
|
241
262
|
return typeof renderProvider === "string" && renderProvider.includes(":formField");
|
|
242
263
|
}
|
|
264
|
+
_getFormLayoutErrorFieldCount(node) {
|
|
265
|
+
if (node.type === "field") return this.formState.fieldMeta[node.name]?.errors?.length ? 1 : 0;
|
|
266
|
+
return node.children.reduce((count, child) => {
|
|
267
|
+
return count + this._getFormLayoutErrorFieldCount(child);
|
|
268
|
+
}, 0);
|
|
269
|
+
}
|
|
243
270
|
_handleError422(error, cause = "submit") {
|
|
244
271
|
const formApi = this.form;
|
|
245
272
|
let hasErrored = false;
|
|
@@ -442,7 +469,7 @@ var ControllerFormField = (_dec$5 = Controller(), _dec2$5 = BeanInfo({ module: "
|
|
|
442
469
|
}
|
|
443
470
|
_createField() {
|
|
444
471
|
const field = markRaw(useField(this._getFormFieldOptions()));
|
|
445
|
-
const fieldState =
|
|
472
|
+
const fieldState = useSelector(field.api.store, (state) => state);
|
|
446
473
|
return {
|
|
447
474
|
api: field.api,
|
|
448
475
|
state: fieldState
|
|
@@ -641,9 +668,24 @@ var RenderForm = (_dec$2 = Render(), _dec2$2 = BeanInfo({ module: "a-form" }), _
|
|
|
641
668
|
children.push(this.$props.slotFooter?.(this));
|
|
642
669
|
return children;
|
|
643
670
|
}
|
|
671
|
+
_renderFromBlocks() {
|
|
672
|
+
const blocks = this.$props.blocks;
|
|
673
|
+
if (!blocks || blocks.length === 0) return this._renderSchema();
|
|
674
|
+
const celScope = this.getFormScope();
|
|
675
|
+
const jsxRenderContext = this.getFormJsxRenderContext(celScope);
|
|
676
|
+
const domBlocks = [];
|
|
677
|
+
blocks.forEach((block, index) => {
|
|
678
|
+
const options = Object.assign({ key: index }, block.options);
|
|
679
|
+
const domBlock = this.zovaJsx.render(block.render, options, celScope, jsxRenderContext);
|
|
680
|
+
if (!domBlock) return;
|
|
681
|
+
if (Array.isArray(domBlock)) domBlocks.push(...domBlock);
|
|
682
|
+
else domBlocks.push(domBlock);
|
|
683
|
+
});
|
|
684
|
+
return domBlocks;
|
|
685
|
+
}
|
|
644
686
|
_renderBodyInner() {
|
|
645
687
|
const FormTag = this.$props.formTag;
|
|
646
|
-
return this.$slotDefault ? this.$slotDefault(this) : createVNode(Fragment, null, [this._renderSchema(), FormTag === "form" && createVNode("button", {
|
|
688
|
+
return this.$slotDefault ? this.$slotDefault(this) : createVNode(Fragment, null, [this.$props.blocks ? this._renderFromBlocks() : this._renderSchema(), FormTag === "form" && createVNode("button", {
|
|
647
689
|
"type": "submit",
|
|
648
690
|
"style": { display: "none" }
|
|
649
691
|
}, null)]);
|
|
@@ -651,7 +693,6 @@ var RenderForm = (_dec$2 = Render(), _dec2$2 = BeanInfo({ module: "a-form" }), _
|
|
|
651
693
|
_renderProps() {
|
|
652
694
|
const FormTag = this.$props.formTag;
|
|
653
695
|
const props = {};
|
|
654
|
-
if (this.$props.inline) props.class = "inline";
|
|
655
696
|
if (FormTag === "form") props.onSubmit = (e) => {
|
|
656
697
|
if (this.$props.onFormSubmit) this.$props.onFormSubmit(e, this);
|
|
657
698
|
else {
|
|
@@ -774,6 +815,107 @@ function formSceneFromFormMeta(formMeta) {
|
|
|
774
815
|
if (formMeta.formMode === "edit" && formMeta.editMode === void 0) return "edit";
|
|
775
816
|
}
|
|
776
817
|
//#endregion
|
|
777
|
-
|
|
818
|
+
//#region src/lib/formLayout.ts
|
|
819
|
+
function resolveFormLayout(layout, properties) {
|
|
820
|
+
const propertyNames = new Set(properties?.filter((item) => item.rest?.visible !== false).map((item) => item.key).filter(Boolean));
|
|
821
|
+
const fieldNames = /* @__PURE__ */ new Set();
|
|
822
|
+
const nodeIds = /* @__PURE__ */ new Set();
|
|
823
|
+
const diagnostics = [];
|
|
824
|
+
const fieldTabPaths = {};
|
|
825
|
+
const children = layout.children.map((node, index) => resolveNode(node, [index], [], propertyNames, fieldNames, nodeIds, diagnostics, fieldTabPaths)).filter(Boolean);
|
|
826
|
+
for (const property of properties ?? []) {
|
|
827
|
+
const name = property.key;
|
|
828
|
+
if (!name || !propertyNames.has(name) || fieldNames.has(name)) continue;
|
|
829
|
+
fieldNames.add(name);
|
|
830
|
+
children.push({
|
|
831
|
+
type: "field",
|
|
832
|
+
name
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
return {
|
|
836
|
+
children,
|
|
837
|
+
fieldTabPaths,
|
|
838
|
+
diagnostics
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
function resolveNode(node, indexPath, tabPath, propertyNames, fieldNames, nodeIds, diagnostics, fieldTabPaths) {
|
|
842
|
+
if (node.type === "field") return resolveField(node, tabPath, propertyNames, fieldNames, diagnostics, fieldTabPaths);
|
|
843
|
+
if (node.type === "tabs") return resolveTabs(node, indexPath, propertyNames, fieldNames, nodeIds, diagnostics, fieldTabPaths);
|
|
844
|
+
const id = resolveId(node, indexPath);
|
|
845
|
+
if (!registerId(id, nodeIds, diagnostics)) return;
|
|
846
|
+
if (node.type === "section") {
|
|
847
|
+
const children = node.children.map((item) => resolveField(item, tabPath, propertyNames, fieldNames, diagnostics, fieldTabPaths)).filter(Boolean);
|
|
848
|
+
return children.length ? {
|
|
849
|
+
...node,
|
|
850
|
+
id,
|
|
851
|
+
children
|
|
852
|
+
} : void 0;
|
|
853
|
+
}
|
|
854
|
+
const children = node.children.map((item, index) => resolveNode(item, [...indexPath, index], tabPath, propertyNames, fieldNames, nodeIds, diagnostics, fieldTabPaths)).filter(Boolean);
|
|
855
|
+
return children.length ? {
|
|
856
|
+
...node,
|
|
857
|
+
id,
|
|
858
|
+
children
|
|
859
|
+
} : void 0;
|
|
860
|
+
}
|
|
861
|
+
function resolveTabs(node, indexPath, propertyNames, fieldNames, nodeIds, diagnostics, fieldTabPaths) {
|
|
862
|
+
const id = resolveId(node, indexPath);
|
|
863
|
+
if (!registerId(id, nodeIds, diagnostics)) return;
|
|
864
|
+
const children = node.children.map((tab, index) => resolveTab(tab, [...indexPath, index], id, propertyNames, fieldNames, nodeIds, diagnostics, fieldTabPaths)).filter(Boolean);
|
|
865
|
+
return children.length ? {
|
|
866
|
+
...node,
|
|
867
|
+
id,
|
|
868
|
+
children
|
|
869
|
+
} : void 0;
|
|
870
|
+
}
|
|
871
|
+
function resolveTab(node, indexPath, tabsId, propertyNames, fieldNames, nodeIds, diagnostics, fieldTabPaths) {
|
|
872
|
+
const id = resolveId(node, indexPath);
|
|
873
|
+
if (!registerId(id, nodeIds, diagnostics)) return;
|
|
874
|
+
const tabPath = [{
|
|
875
|
+
tabsId,
|
|
876
|
+
tabId: id
|
|
877
|
+
}];
|
|
878
|
+
const children = node.children.map((item, index) => resolveNode(item, [...indexPath, index], tabPath, propertyNames, fieldNames, nodeIds, diagnostics, fieldTabPaths)).filter(Boolean);
|
|
879
|
+
return children.length ? {
|
|
880
|
+
...node,
|
|
881
|
+
id,
|
|
882
|
+
children
|
|
883
|
+
} : void 0;
|
|
884
|
+
}
|
|
885
|
+
function resolveField(node, tabPath, propertyNames, fieldNames, diagnostics, fieldTabPaths) {
|
|
886
|
+
if (!propertyNames.has(node.name)) {
|
|
887
|
+
diagnostics.push({
|
|
888
|
+
type: "unknownField",
|
|
889
|
+
value: node.name
|
|
890
|
+
});
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
if (fieldNames.has(node.name)) {
|
|
894
|
+
diagnostics.push({
|
|
895
|
+
type: "duplicateField",
|
|
896
|
+
value: node.name
|
|
897
|
+
});
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
fieldNames.add(node.name);
|
|
901
|
+
fieldTabPaths[node.name] = tabPath;
|
|
902
|
+
return node;
|
|
903
|
+
}
|
|
904
|
+
function resolveId(node, indexPath) {
|
|
905
|
+
return node.id || `${node.type}-${indexPath.join("-")}`;
|
|
906
|
+
}
|
|
907
|
+
function registerId(id, ids, diagnostics) {
|
|
908
|
+
if (!ids.has(id)) {
|
|
909
|
+
ids.add(id);
|
|
910
|
+
return true;
|
|
911
|
+
}
|
|
912
|
+
diagnostics.push({
|
|
913
|
+
type: "duplicateId",
|
|
914
|
+
value: id
|
|
915
|
+
});
|
|
916
|
+
return false;
|
|
917
|
+
}
|
|
918
|
+
//#endregion
|
|
919
|
+
export { BeanControllerFormBase, BeanControllerPageFormBase, ControllerForm$1 as ControllerForm, ControllerFormField, ControllerFormFieldBlank, ControllerFormFieldPreset, RenderForm, RenderFormField, ScopeModuleAForm, ZForm, ZFormField, ZFormFieldBlank, ZFormFieldPreset, components, config, constFieldProps, formMetaFromFormScene, formSceneFromFormMeta, resolveFormLayout };
|
|
778
920
|
|
|
779
921
|
//# sourceMappingURL=index.js.map
|