openxiangda 1.0.46 → 1.0.48
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/package.json +1 -1
- package/packages/sdk/dist/components/index.cjs +5 -0
- package/packages/sdk/dist/components/index.cjs.map +1 -1
- package/packages/sdk/dist/components/index.mjs +5 -0
- package/packages/sdk/dist/components/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/index.cjs +69 -1
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.mjs +69 -1
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
|
@@ -44846,6 +44846,11 @@ var normalizeBasePath = (basePath) => {
|
|
|
44846
44846
|
var inferBasePath = (appType) => {
|
|
44847
44847
|
if (typeof window === "undefined") return "";
|
|
44848
44848
|
const pathname = window.location?.pathname || "";
|
|
44849
|
+
const submitMarker = `/submit/${appType}/`;
|
|
44850
|
+
const submitMarkerIndex = pathname.indexOf(submitMarker);
|
|
44851
|
+
if (submitMarkerIndex > 0) {
|
|
44852
|
+
return pathname.slice(0, submitMarkerIndex);
|
|
44853
|
+
}
|
|
44849
44854
|
const marker = `/${appType}/`;
|
|
44850
44855
|
const markerIndex = pathname.indexOf(marker);
|
|
44851
44856
|
if (markerIndex <= 0) return "";
|
|
@@ -49925,14 +49930,77 @@ var isProcessKind = (kind, formType) => {
|
|
|
49925
49930
|
const raw = String(formType || "").toLowerCase();
|
|
49926
49931
|
return kind === "process-submit" || kind === "process-detail" || raw === "process" || raw === "flow";
|
|
49927
49932
|
};
|
|
49933
|
+
var normalizePlatformComponentName = (componentName) => {
|
|
49934
|
+
const value = String(componentName || "").trim();
|
|
49935
|
+
return value || "TextField";
|
|
49936
|
+
};
|
|
49937
|
+
var extractSlotNodes = (value) => {
|
|
49938
|
+
if (!value) return [];
|
|
49939
|
+
if (Array.isArray(value)) {
|
|
49940
|
+
return value.flatMap((item) => extractSlotNodes(item));
|
|
49941
|
+
}
|
|
49942
|
+
if (typeof value !== "object") return [];
|
|
49943
|
+
if (value.type === "JSSlot" && value.value) {
|
|
49944
|
+
return extractSlotNodes(value.value);
|
|
49945
|
+
}
|
|
49946
|
+
if (value.componentName || Array.isArray(value.children)) {
|
|
49947
|
+
return [value];
|
|
49948
|
+
}
|
|
49949
|
+
return Object.values(value).flatMap((item) => extractSlotNodes(item));
|
|
49950
|
+
};
|
|
49951
|
+
var extractFieldsFromComponentsTree = (componentsTree) => {
|
|
49952
|
+
const roots = Array.isArray(componentsTree) ? componentsTree : [componentsTree];
|
|
49953
|
+
const fields = [];
|
|
49954
|
+
const seen = /* @__PURE__ */ new Set();
|
|
49955
|
+
const walk = (components) => {
|
|
49956
|
+
if (!Array.isArray(components)) return;
|
|
49957
|
+
components.forEach((component) => {
|
|
49958
|
+
if (!component || typeof component !== "object") return;
|
|
49959
|
+
const props = component.props || {};
|
|
49960
|
+
const fieldId = String(props.fieldId || component.fieldId || component.id || "").trim();
|
|
49961
|
+
if (props.isFormComponent === true && fieldId && !seen.has(fieldId)) {
|
|
49962
|
+
seen.add(fieldId);
|
|
49963
|
+
fields.push({
|
|
49964
|
+
...props,
|
|
49965
|
+
id: props.id || component.id || fieldId,
|
|
49966
|
+
fieldId,
|
|
49967
|
+
componentName: normalizePlatformComponentName(
|
|
49968
|
+
props.componentName || component.componentName
|
|
49969
|
+
),
|
|
49970
|
+
label: props.label || component.title || props.title || fieldId,
|
|
49971
|
+
title: props.title || component.title || props.label || fieldId,
|
|
49972
|
+
required: props.required ?? component.required
|
|
49973
|
+
});
|
|
49974
|
+
}
|
|
49975
|
+
if (component.componentName === "SubFormField") return;
|
|
49976
|
+
if (Array.isArray(component.children)) {
|
|
49977
|
+
walk(component.children);
|
|
49978
|
+
}
|
|
49979
|
+
Object.values(props).forEach((propValue) => {
|
|
49980
|
+
walk(extractSlotNodes(propValue));
|
|
49981
|
+
});
|
|
49982
|
+
});
|
|
49983
|
+
};
|
|
49984
|
+
walk(roots);
|
|
49985
|
+
return fields;
|
|
49986
|
+
};
|
|
49987
|
+
var createDefaultLayout = (fields) => fields.map((field) => ({
|
|
49988
|
+
id: `layout_${field.fieldId}`,
|
|
49989
|
+
type: "field",
|
|
49990
|
+
fieldId: field.fieldId
|
|
49991
|
+
}));
|
|
49928
49992
|
var normalizeSchema = (payload, appType, formUuid) => {
|
|
49929
49993
|
const normalized = normalizeDataManagementFields(payload);
|
|
49930
49994
|
if (normalized.schema) return normalized.schema;
|
|
49931
49995
|
const body = payload?.data ?? payload?.result ?? payload;
|
|
49932
49996
|
const rawSchema = body?.schema || body?.formSchema || body?.publishedSchema || body;
|
|
49933
|
-
if (!rawSchema
|
|
49997
|
+
if (!rawSchema) return void 0;
|
|
49998
|
+
const fields = Array.isArray(rawSchema.fields) ? rawSchema.fields : extractFieldsFromComponentsTree(rawSchema.componentsTree);
|
|
49999
|
+
if (!Array.isArray(fields) || fields.length === 0) return void 0;
|
|
49934
50000
|
return {
|
|
49935
50001
|
...rawSchema,
|
|
50002
|
+
fields,
|
|
50003
|
+
layout: rawSchema.layout || createDefaultLayout(fields),
|
|
49936
50004
|
formMeta: {
|
|
49937
50005
|
appType,
|
|
49938
50006
|
formUuid,
|