openxiangda 1.0.46 → 1.0.47
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.
|
@@ -49036,14 +49036,77 @@ var isProcessKind = (kind, formType) => {
|
|
|
49036
49036
|
const raw = String(formType || "").toLowerCase();
|
|
49037
49037
|
return kind === "process-submit" || kind === "process-detail" || raw === "process" || raw === "flow";
|
|
49038
49038
|
};
|
|
49039
|
+
var normalizePlatformComponentName = (componentName) => {
|
|
49040
|
+
const value = String(componentName || "").trim();
|
|
49041
|
+
return value || "TextField";
|
|
49042
|
+
};
|
|
49043
|
+
var extractSlotNodes = (value) => {
|
|
49044
|
+
if (!value) return [];
|
|
49045
|
+
if (Array.isArray(value)) {
|
|
49046
|
+
return value.flatMap((item) => extractSlotNodes(item));
|
|
49047
|
+
}
|
|
49048
|
+
if (typeof value !== "object") return [];
|
|
49049
|
+
if (value.type === "JSSlot" && value.value) {
|
|
49050
|
+
return extractSlotNodes(value.value);
|
|
49051
|
+
}
|
|
49052
|
+
if (value.componentName || Array.isArray(value.children)) {
|
|
49053
|
+
return [value];
|
|
49054
|
+
}
|
|
49055
|
+
return Object.values(value).flatMap((item) => extractSlotNodes(item));
|
|
49056
|
+
};
|
|
49057
|
+
var extractFieldsFromComponentsTree = (componentsTree) => {
|
|
49058
|
+
const roots = Array.isArray(componentsTree) ? componentsTree : [componentsTree];
|
|
49059
|
+
const fields = [];
|
|
49060
|
+
const seen = /* @__PURE__ */ new Set();
|
|
49061
|
+
const walk = (components) => {
|
|
49062
|
+
if (!Array.isArray(components)) return;
|
|
49063
|
+
components.forEach((component) => {
|
|
49064
|
+
if (!component || typeof component !== "object") return;
|
|
49065
|
+
const props = component.props || {};
|
|
49066
|
+
const fieldId = String(props.fieldId || component.fieldId || component.id || "").trim();
|
|
49067
|
+
if (props.isFormComponent === true && fieldId && !seen.has(fieldId)) {
|
|
49068
|
+
seen.add(fieldId);
|
|
49069
|
+
fields.push({
|
|
49070
|
+
...props,
|
|
49071
|
+
id: props.id || component.id || fieldId,
|
|
49072
|
+
fieldId,
|
|
49073
|
+
componentName: normalizePlatformComponentName(
|
|
49074
|
+
props.componentName || component.componentName
|
|
49075
|
+
),
|
|
49076
|
+
label: props.label || component.title || props.title || fieldId,
|
|
49077
|
+
title: props.title || component.title || props.label || fieldId,
|
|
49078
|
+
required: props.required ?? component.required
|
|
49079
|
+
});
|
|
49080
|
+
}
|
|
49081
|
+
if (component.componentName === "SubFormField") return;
|
|
49082
|
+
if (Array.isArray(component.children)) {
|
|
49083
|
+
walk(component.children);
|
|
49084
|
+
}
|
|
49085
|
+
Object.values(props).forEach((propValue) => {
|
|
49086
|
+
walk(extractSlotNodes(propValue));
|
|
49087
|
+
});
|
|
49088
|
+
});
|
|
49089
|
+
};
|
|
49090
|
+
walk(roots);
|
|
49091
|
+
return fields;
|
|
49092
|
+
};
|
|
49093
|
+
var createDefaultLayout = (fields) => fields.map((field) => ({
|
|
49094
|
+
id: `layout_${field.fieldId}`,
|
|
49095
|
+
type: "field",
|
|
49096
|
+
fieldId: field.fieldId
|
|
49097
|
+
}));
|
|
49039
49098
|
var normalizeSchema = (payload, appType, formUuid) => {
|
|
49040
49099
|
const normalized = normalizeDataManagementFields(payload);
|
|
49041
49100
|
if (normalized.schema) return normalized.schema;
|
|
49042
49101
|
const body = payload?.data ?? payload?.result ?? payload;
|
|
49043
49102
|
const rawSchema = body?.schema || body?.formSchema || body?.publishedSchema || body;
|
|
49044
|
-
if (!rawSchema
|
|
49103
|
+
if (!rawSchema) return void 0;
|
|
49104
|
+
const fields = Array.isArray(rawSchema.fields) ? rawSchema.fields : extractFieldsFromComponentsTree(rawSchema.componentsTree);
|
|
49105
|
+
if (!Array.isArray(fields) || fields.length === 0) return void 0;
|
|
49045
49106
|
return {
|
|
49046
49107
|
...rawSchema,
|
|
49108
|
+
fields,
|
|
49109
|
+
layout: rawSchema.layout || createDefaultLayout(fields),
|
|
49047
49110
|
formMeta: {
|
|
49048
49111
|
appType,
|
|
49049
49112
|
formUuid,
|