openxiangda 1.0.45 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openxiangda",
3
- "version": "1.0.45",
3
+ "version": "1.0.47",
4
4
  "description": "OpenXiangda CLI, workspace build tools, runtime SDK, and form components.",
5
5
  "private": false,
6
6
  "bin": {
@@ -49925,14 +49925,77 @@ var isProcessKind = (kind, formType) => {
49925
49925
  const raw = String(formType || "").toLowerCase();
49926
49926
  return kind === "process-submit" || kind === "process-detail" || raw === "process" || raw === "flow";
49927
49927
  };
49928
+ var normalizePlatformComponentName = (componentName) => {
49929
+ const value = String(componentName || "").trim();
49930
+ return value || "TextField";
49931
+ };
49932
+ var extractSlotNodes = (value) => {
49933
+ if (!value) return [];
49934
+ if (Array.isArray(value)) {
49935
+ return value.flatMap((item) => extractSlotNodes(item));
49936
+ }
49937
+ if (typeof value !== "object") return [];
49938
+ if (value.type === "JSSlot" && value.value) {
49939
+ return extractSlotNodes(value.value);
49940
+ }
49941
+ if (value.componentName || Array.isArray(value.children)) {
49942
+ return [value];
49943
+ }
49944
+ return Object.values(value).flatMap((item) => extractSlotNodes(item));
49945
+ };
49946
+ var extractFieldsFromComponentsTree = (componentsTree) => {
49947
+ const roots = Array.isArray(componentsTree) ? componentsTree : [componentsTree];
49948
+ const fields = [];
49949
+ const seen = /* @__PURE__ */ new Set();
49950
+ const walk = (components) => {
49951
+ if (!Array.isArray(components)) return;
49952
+ components.forEach((component) => {
49953
+ if (!component || typeof component !== "object") return;
49954
+ const props = component.props || {};
49955
+ const fieldId = String(props.fieldId || component.fieldId || component.id || "").trim();
49956
+ if (props.isFormComponent === true && fieldId && !seen.has(fieldId)) {
49957
+ seen.add(fieldId);
49958
+ fields.push({
49959
+ ...props,
49960
+ id: props.id || component.id || fieldId,
49961
+ fieldId,
49962
+ componentName: normalizePlatformComponentName(
49963
+ props.componentName || component.componentName
49964
+ ),
49965
+ label: props.label || component.title || props.title || fieldId,
49966
+ title: props.title || component.title || props.label || fieldId,
49967
+ required: props.required ?? component.required
49968
+ });
49969
+ }
49970
+ if (component.componentName === "SubFormField") return;
49971
+ if (Array.isArray(component.children)) {
49972
+ walk(component.children);
49973
+ }
49974
+ Object.values(props).forEach((propValue) => {
49975
+ walk(extractSlotNodes(propValue));
49976
+ });
49977
+ });
49978
+ };
49979
+ walk(roots);
49980
+ return fields;
49981
+ };
49982
+ var createDefaultLayout = (fields) => fields.map((field) => ({
49983
+ id: `layout_${field.fieldId}`,
49984
+ type: "field",
49985
+ fieldId: field.fieldId
49986
+ }));
49928
49987
  var normalizeSchema = (payload, appType, formUuid) => {
49929
49988
  const normalized = normalizeDataManagementFields(payload);
49930
49989
  if (normalized.schema) return normalized.schema;
49931
49990
  const body = payload?.data ?? payload?.result ?? payload;
49932
49991
  const rawSchema = body?.schema || body?.formSchema || body?.publishedSchema || body;
49933
- if (!rawSchema || !Array.isArray(rawSchema.fields)) return void 0;
49992
+ if (!rawSchema) return void 0;
49993
+ const fields = Array.isArray(rawSchema.fields) ? rawSchema.fields : extractFieldsFromComponentsTree(rawSchema.componentsTree);
49994
+ if (!Array.isArray(fields) || fields.length === 0) return void 0;
49934
49995
  return {
49935
49996
  ...rawSchema,
49997
+ fields,
49998
+ layout: rawSchema.layout || createDefaultLayout(fields),
49936
49999
  formMeta: {
49937
50000
  appType,
49938
50001
  formUuid,