@nocobase/utils 1.7.0-alpha.2 → 1.7.0-alpha.4
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.
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* 将多列布局转换为单列布局
|
|
11
11
|
* @param {Object} schema - 输入的 JSON Schema 对象
|
|
12
|
+
* @param {Function} [ignore] - 可选的忽略函数,用于判断是否忽略某个列
|
|
12
13
|
* @returns {Object} - 转换后的 JSON Schema 对象
|
|
13
14
|
*/
|
|
14
|
-
export declare const transformMultiColumnToSingleColumn: (schema: any) => any;
|
|
15
|
+
export declare const transformMultiColumnToSingleColumn: (schema: any, ignore?: (colSchema: any) => boolean) => any;
|
|
@@ -40,21 +40,24 @@ __export(transformMultiColumnToSingleColumn_exports, {
|
|
|
40
40
|
transformMultiColumnToSingleColumn: () => transformMultiColumnToSingleColumn
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(transformMultiColumnToSingleColumn_exports);
|
|
43
|
+
var import_json_schema = require("@formily/json-schema");
|
|
44
|
+
var import_lodash = __toESM(require("lodash"));
|
|
43
45
|
var import_uid = require("./uid");
|
|
44
46
|
var import_package = __toESM(require("../package.json"));
|
|
45
|
-
|
|
46
|
-
const transformMultiColumnToSingleColumn = /* @__PURE__ */ __name((schema) => {
|
|
47
|
+
const transformMultiColumnToSingleColumn = /* @__PURE__ */ __name((schema, ignore) => {
|
|
47
48
|
if (!schema) return schema;
|
|
48
|
-
if (schema.toJSON) {
|
|
49
|
-
schema = schema.toJSON();
|
|
50
|
-
}
|
|
51
49
|
if (schema["x-component"] !== "Grid") {
|
|
52
50
|
Object.keys(schema.properties || {}).forEach((key) => {
|
|
53
|
-
schema.properties[key] = transformMultiColumnToSingleColumn(schema.properties[key]);
|
|
51
|
+
schema.properties[key] = transformMultiColumnToSingleColumn(schema.properties[key], ignore);
|
|
54
52
|
});
|
|
55
53
|
return schema;
|
|
56
54
|
}
|
|
57
|
-
|
|
55
|
+
const parent = schema.parent;
|
|
56
|
+
if (schema.toJSON) {
|
|
57
|
+
schema = schema.toJSON();
|
|
58
|
+
} else {
|
|
59
|
+
schema = import_lodash.default.cloneDeep(schema);
|
|
60
|
+
}
|
|
58
61
|
const newProperties = {};
|
|
59
62
|
const { properties = {} } = schema;
|
|
60
63
|
let index = 0;
|
|
@@ -81,11 +84,25 @@ const transformMultiColumnToSingleColumn = /* @__PURE__ */ __name((schema) => {
|
|
|
81
84
|
newProperties[key] = row;
|
|
82
85
|
return;
|
|
83
86
|
}
|
|
87
|
+
if (ignore == null ? void 0 : ignore(column)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
84
90
|
delete row.properties[columnKey];
|
|
85
91
|
newProperties[`${(0, import_uid.uid)()}_${columnKey}`] = createRow(column, columnKey, ++index);
|
|
86
92
|
});
|
|
87
93
|
});
|
|
88
94
|
schema.properties = newProperties;
|
|
95
|
+
if (parent) {
|
|
96
|
+
const result = new import_json_schema.Schema(schema, parent);
|
|
97
|
+
if (parent.properties) {
|
|
98
|
+
Object.keys(parent.properties).forEach((key) => {
|
|
99
|
+
if (key === schema.name) {
|
|
100
|
+
parent.properties[key] = result;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
89
106
|
return schema;
|
|
90
107
|
}, "transformMultiColumnToSingleColumn");
|
|
91
108
|
function createRow(column, key, index) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/utils",
|
|
3
|
-
"version": "1.7.0-alpha.
|
|
3
|
+
"version": "1.7.0-alpha.4",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"multer": "^1.4.5-lts.1",
|
|
17
17
|
"object-path": "^0.11.8"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "e31c3136901b10ec7cbe4bbc8a22dc4cc7481f93"
|
|
20
20
|
}
|