@boteteam/utils 0.0.31 → 0.0.32
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/cjs/file.js +4 -4
- package/dist/cjs/file.js.map +2 -2
- package/dist/cjs/formatModule/formatModuleData.d.ts +3 -1
- package/dist/cjs/formatModule/formatModuleData.js +102 -17
- package/dist/cjs/formatModule/formatModuleData.js.map +3 -3
- package/dist/cjs/formatModule/helpers/checkDataSourceOfFn.d.ts +2 -0
- package/dist/cjs/formatModule/helpers/checkDataSourceOfFn.js +33 -0
- package/dist/cjs/formatModule/helpers/checkDataSourceOfFn.js.map +7 -0
- package/dist/cjs/formatModule/helpers/cssToJson.d.ts +22 -0
- package/dist/cjs/formatModule/helpers/cssToJson.js +78 -0
- package/dist/cjs/formatModule/helpers/cssToJson.js.map +7 -0
- package/dist/cjs/formatModule/helpers/formatDataProps.d.ts +19 -0
- package/dist/cjs/formatModule/helpers/formatDataProps.js +65 -0
- package/dist/cjs/formatModule/helpers/formatDataProps.js.map +7 -0
- package/dist/cjs/formatModule/helpers/formatFormProps.js +7 -0
- package/dist/cjs/formatModule/helpers/formatFormProps.js.map +3 -3
- package/dist/cjs/formatModule/helpers/formatListProps.js +25 -9
- package/dist/cjs/formatModule/helpers/formatListProps.js.map +3 -3
- package/dist/cjs/formatModule/helpers/formatLoopProps.d.ts +1 -4
- package/dist/cjs/formatModule/helpers/formatLoopProps.js +20 -8
- package/dist/cjs/formatModule/helpers/formatLoopProps.js.map +3 -3
- package/dist/cjs/formatModule/helpers/formatStepsProps.js +49 -32
- package/dist/cjs/formatModule/helpers/formatStepsProps.js.map +3 -3
- package/dist/cjs/formatModule/helpers/formatStyleProps.d.ts +16 -3
- package/dist/cjs/formatModule/helpers/formatStyleProps.js +100 -37
- package/dist/cjs/formatModule/helpers/formatStyleProps.js.map +3 -3
- package/dist/cjs/formatModule/helpers/formatTableProps.d.ts +7 -1
- package/dist/cjs/formatModule/helpers/formatTableProps.js +46 -11
- package/dist/cjs/formatModule/helpers/formatTableProps.js.map +3 -3
- package/dist/cjs/formatModule/helpers/formatTabsProps.d.ts +15 -0
- package/dist/cjs/formatModule/helpers/formatTabsProps.js +49 -0
- package/dist/cjs/formatModule/helpers/formatTabsProps.js.map +7 -0
- package/dist/cjs/formatModule/helpers/formatVideoProps.d.ts +12 -0
- package/dist/cjs/formatModule/helpers/formatVideoProps.js +45 -0
- package/dist/cjs/formatModule/helpers/formatVideoProps.js.map +7 -0
- package/dist/cjs/formatModule/helpers/index.d.ts +6 -1
- package/dist/cjs/formatModule/helpers/index.js +15 -0
- package/dist/cjs/formatModule/helpers/index.js.map +3 -3
- package/dist/cjs/formatModule/helpers/stringScriptExecution.js +1 -1
- package/dist/cjs/formatModule/helpers/stringScriptExecution.js.map +1 -1
- package/dist/cjs/http.d.ts +17 -0
- package/dist/cjs/http.js +123 -1
- package/dist/cjs/http.js.map +2 -2
- package/dist/cjs/index.d.ts +5 -4
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/treeUtils.d.ts +31 -3
- package/dist/cjs/treeUtils.js +53 -10
- package/dist/cjs/treeUtils.js.map +3 -3
- package/dist/cjs/watermark.d.ts +80 -0
- package/dist/cjs/watermark.js +350 -0
- package/dist/cjs/watermark.js.map +7 -0
- package/dist/esm/file.js +5 -4
- package/dist/esm/file.js.map +1 -1
- package/dist/esm/formatModule/formatModuleData.d.ts +3 -1
- package/dist/esm/formatModule/formatModuleData.js +121 -40
- package/dist/esm/formatModule/formatModuleData.js.map +1 -1
- package/dist/esm/formatModule/helpers/checkDataSourceOfFn.d.ts +2 -0
- package/dist/esm/formatModule/helpers/checkDataSourceOfFn.js +9 -0
- package/dist/esm/formatModule/helpers/checkDataSourceOfFn.js.map +1 -0
- package/dist/esm/formatModule/helpers/cssToJson.d.ts +22 -0
- package/dist/esm/formatModule/helpers/cssToJson.js +103 -0
- package/dist/esm/formatModule/helpers/cssToJson.js.map +1 -0
- package/dist/esm/formatModule/helpers/formatDataProps.d.ts +19 -0
- package/dist/esm/formatModule/helpers/formatDataProps.js +26 -0
- package/dist/esm/formatModule/helpers/formatDataProps.js.map +1 -0
- package/dist/esm/formatModule/helpers/formatFormProps.js +6 -0
- package/dist/esm/formatModule/helpers/formatFormProps.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatListProps.js +26 -9
- package/dist/esm/formatModule/helpers/formatListProps.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatLoopProps.d.ts +1 -4
- package/dist/esm/formatModule/helpers/formatLoopProps.js +13 -12
- package/dist/esm/formatModule/helpers/formatLoopProps.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatStepsProps.js +38 -31
- package/dist/esm/formatModule/helpers/formatStepsProps.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatStyleProps.d.ts +16 -3
- package/dist/esm/formatModule/helpers/formatStyleProps.js +90 -43
- package/dist/esm/formatModule/helpers/formatStyleProps.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatTableProps.d.ts +7 -1
- package/dist/esm/formatModule/helpers/formatTableProps.js +57 -8
- package/dist/esm/formatModule/helpers/formatTableProps.js.map +1 -1
- package/dist/esm/formatModule/helpers/formatTabsProps.d.ts +15 -0
- package/dist/esm/formatModule/helpers/formatTabsProps.js +46 -0
- package/dist/esm/formatModule/helpers/formatTabsProps.js.map +1 -0
- package/dist/esm/formatModule/helpers/formatVideoProps.d.ts +12 -0
- package/dist/esm/formatModule/helpers/formatVideoProps.js +31 -0
- package/dist/esm/formatModule/helpers/formatVideoProps.js.map +1 -0
- package/dist/esm/formatModule/helpers/index.d.ts +6 -1
- package/dist/esm/formatModule/helpers/index.js +6 -1
- package/dist/esm/formatModule/helpers/index.js.map +1 -1
- package/dist/esm/formatModule/helpers/stringScriptExecution.js +1 -1
- package/dist/esm/formatModule/helpers/stringScriptExecution.js.map +1 -1
- package/dist/esm/http.d.ts +17 -0
- package/dist/esm/http.js +208 -43
- package/dist/esm/http.js.map +1 -1
- package/dist/esm/index.d.ts +5 -4
- package/dist/esm/index.js +4 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/treeUtils.d.ts +31 -3
- package/dist/esm/treeUtils.js +118 -15
- package/dist/esm/treeUtils.js.map +1 -1
- package/dist/esm/watermark.d.ts +80 -0
- package/dist/esm/watermark.js +487 -0
- package/dist/esm/watermark.js.map +1 -0
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/file.js
CHANGED
|
@@ -37,14 +37,14 @@ __export(file_exports, {
|
|
|
37
37
|
module.exports = __toCommonJS(file_exports);
|
|
38
38
|
var import_security = __toESM(require("@lingxiteam/security"));
|
|
39
39
|
var import_pathArgsUtils = require("./pathArgsUtils");
|
|
40
|
-
var
|
|
40
|
+
var import_http = require("./http");
|
|
41
41
|
var getFileUrlById = (fileId, {
|
|
42
42
|
prefix,
|
|
43
43
|
isSecurity = true,
|
|
44
44
|
params
|
|
45
45
|
} = {}) => {
|
|
46
46
|
var _a;
|
|
47
|
-
const baseUrl = prefix ? prefix.replace(/\/$/, "") :
|
|
47
|
+
const baseUrl = prefix ? prefix.replace(/\/$/, "") : import_http.request.getBaseUrl();
|
|
48
48
|
const token = ((_a = (0, import_pathArgsUtils.getSearchObj)()) == null ? void 0 : _a.token) || "";
|
|
49
49
|
const queryParams = {
|
|
50
50
|
fileId,
|
|
@@ -62,7 +62,7 @@ var getFileUrlByFileInfoId = (fileInfoId, {
|
|
|
62
62
|
isSecurity = true,
|
|
63
63
|
params
|
|
64
64
|
} = {}) => {
|
|
65
|
-
const baseUrl = prefix ? prefix.replace(/\/$/, "") :
|
|
65
|
+
const baseUrl = prefix ? prefix.replace(/\/$/, "") : import_http.request.getBaseUrl();
|
|
66
66
|
const { token, tenantId } = (0, import_pathArgsUtils.getSearchObj)() || {};
|
|
67
67
|
const queryParams = {
|
|
68
68
|
fileInfoId,
|
|
@@ -83,7 +83,7 @@ var getRemoteComponentUrl = ({
|
|
|
83
83
|
isSecurity = true,
|
|
84
84
|
params = {}
|
|
85
85
|
} = {}) => {
|
|
86
|
-
const baseUrl = prefix ? prefix.replace(/\/$/, "") :
|
|
86
|
+
const baseUrl = prefix ? prefix.replace(/\/$/, "") : import_http.request.getBaseUrl();
|
|
87
87
|
const query = (0, import_pathArgsUtils.argsToString)(params);
|
|
88
88
|
const url = `${baseUrl}/manager/skill/page/getRemoteComponent?${query}`;
|
|
89
89
|
return isSecurity ? import_security.default.autoSecurityWithUrl(url) : url;
|
package/dist/cjs/file.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/file.ts"],
|
|
4
|
-
"sourcesContent": ["import security from '@lingxiteam/security';\nimport { argsToString, getSearchObj } from './pathArgsUtils';\n\n// 暂时放到utils中,后续考虑独立在@boteteam/service包\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,2BAA2C;
|
|
4
|
+
"sourcesContent": ["import security from '@lingxiteam/security';\nimport { argsToString, getSearchObj } from './pathArgsUtils';\nimport { request } from './http';\n\n// 暂时放到utils中,后续考虑独立在@boteteam/service包\n\n// const DEFAULT_PREFIX = `${process.env.REACT_APP_REQ_PREFIX}/bote`;\n\n/**\n * 根据文件ID生成文件URL地址\n * @param fileId 文件ID\n * @param options 配置选项\n * @param options.prefix 自定义请求前缀(默认使用环境变量配置)\n * @param options.isSecurity 是否启用安全处理(默认true), 将对url地址参数加密或加签\n * @param options.params 自定义参数,将添加到query参数中\n * @returns 文件URL地址\n */\nexport const getFileUrlById = (\n fileId: string,\n {\n prefix,\n isSecurity = true,\n params,\n }: {\n prefix?: string;\n isSecurity?: boolean;\n params?: Record<string, any>;\n } = {},\n) => {\n const baseUrl = prefix ? prefix.replace(/\\/$/, '') : request.getBaseUrl();\n // 如果url中存在token,则把token添加到query参数中\n const token = getSearchObj()?.token || '';\n const queryParams:{[key:string]:any} = {\n fileId,\n ...params,\n };\n if (token) {\n queryParams.token = token;\n }\n const query = argsToString(queryParams);\n const url = `${baseUrl}/file/download?${query}`;\n return isSecurity ? security.autoSecurityWithUrl(url) : url;\n};\n\n/**\n * 根据文件ID生成文件URL地址\n * @param fileId 文件ID\n * @param options 配置选项\n * @param options.prefix 自定义请求前缀(默认使用环境变量配置)\n * @param options.isSecurity 是否启用安全处理(默认true), 将对url地址参数加密或加签\n * @param options.params 自定义参数,将添加到query参数中\n * @returns 文件URL地址\n */\nexport const getFileUrlByFileInfoId = (\n fileInfoId: string,\n {\n prefix,\n isSecurity = true,\n params,\n }: {\n prefix?: string;\n isSecurity?: boolean;\n params?: Record<string, any>;\n } = {},\n) => {\n const baseUrl = prefix ? prefix.replace(/\\/$/, '') : request.getBaseUrl();\n // 如果url中存在token,则把token添加到query参数中\n const { token, tenantId } = getSearchObj() || {};\n const queryParams:{[key:string]:any} = {\n fileInfoId,\n ...params,\n };\n if (token) {\n queryParams.token = token;\n }\n if (tenantId) {\n queryParams.tenantId = tenantId;\n }\n const query = argsToString(queryParams);\n const url = `${baseUrl}/file/downloadByFileInfoId?${query}`;\n return isSecurity ? security.autoSecurityWithUrl(url) : url;\n};\n\nconst getRemoteComponentUrl = ({\n prefix,\n isSecurity = true,\n params = {},\n}: {\n prefix?: string;\n isSecurity?: boolean;\n params?: Record<string, any>;\n} = {}) => {\n const baseUrl = prefix ? prefix.replace(/\\/$/, '') : request.getBaseUrl();\n const query = argsToString(params);\n const url = `${baseUrl}/manager/skill/page/getRemoteComponent?${query}`;\n return isSecurity ? security.autoSecurityWithUrl(url) : url;\n};\n\n/**\n * 根据页面编码生成远程组件URL地址\n * @param pageCode 页面编码\n * @param options 配置选项\n * @param options.prefix 自定义请求前缀(默认使用环境变量配置)\n * @param options.isSecurity 是否启用安全处理(默认true), 将对url地址参数加密或加签\n * @param options.params 自定义参数,将添加到query参数中\n * @returns 文件URL地址\n */\nexport const getRemoteComponentUrlByCode = (\n pageCode: string,\n options: Parameters<typeof getRemoteComponentUrl>[0],\n) => {\n return getRemoteComponentUrl({\n ...options,\n params: { botePageCode: pageCode, ...options?.params },\n });\n};\n\n/**\n * 根据文件ID生成远程组件URL地址\n * @param fileInfoId 文件ID\n * @param options 配置选项\n * @param options.prefix 自定义请求前缀(默认使用环境变量配置)\n * @param options.isSecurity 是否启用安全处理(默认true), 将对url地址参数加密或加签\n * @param options.params 自定义参数,将添加到query参数中\n * @returns 文件URL地址\n */\nexport const getRemoteComponentUrlById = (\n fileInfoId: string,\n options: Parameters<typeof getRemoteComponentUrl>[0],\n) => {\n return getRemoteComponentUrl({\n ...options,\n params: { fileInfoId, ...options?.params },\n });\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,2BAA2C;AAC3C,kBAAwB;AAejB,IAAM,iBAAiB,CAC5B,QACA;AAAA,EACE;AAAA,EACA,aAAa;AAAA,EACb;AACF,IAII,CAAC,MACF;AA5BL;AA6BE,QAAM,UAAU,SAAS,OAAO,QAAQ,OAAO,EAAE,IAAI,oBAAQ,WAAW;AAExE,QAAM,UAAQ,4CAAa,MAAb,mBAAgB,UAAS;AACvC,QAAM,cAAiC;AAAA,IACrC;AAAA,IACA,GAAG;AAAA,EACL;AACA,MAAI,OAAO;AACT,gBAAY,QAAQ;AAAA,EACtB;AACA,QAAM,YAAQ,mCAAa,WAAW;AACtC,QAAM,MAAM,GAAG,yBAAyB;AACxC,SAAO,aAAa,gBAAAA,QAAS,oBAAoB,GAAG,IAAI;AAC1D;AAWO,IAAM,yBAAyB,CACpC,YACA;AAAA,EACE;AAAA,EACA,aAAa;AAAA,EACb;AACF,IAII,CAAC,MACF;AACH,QAAM,UAAU,SAAS,OAAO,QAAQ,OAAO,EAAE,IAAI,oBAAQ,WAAW;AAExE,QAAM,EAAE,OAAO,SAAS,QAAI,mCAAa,KAAK,CAAC;AAC/C,QAAM,cAAiC;AAAA,IACrC;AAAA,IACA,GAAG;AAAA,EACL;AACA,MAAI,OAAO;AACT,gBAAY,QAAQ;AAAA,EACtB;AACA,MAAI,UAAU;AACZ,gBAAY,WAAW;AAAA,EACzB;AACA,QAAM,YAAQ,mCAAa,WAAW;AACtC,QAAM,MAAM,GAAG,qCAAqC;AACpD,SAAO,aAAa,gBAAAA,QAAS,oBAAoB,GAAG,IAAI;AAC1D;AAEA,IAAM,wBAAwB,CAAC;AAAA,EAC7B;AAAA,EACA,aAAa;AAAA,EACb,SAAS,CAAC;AACZ,IAII,CAAC,MAAM;AACT,QAAM,UAAU,SAAS,OAAO,QAAQ,OAAO,EAAE,IAAI,oBAAQ,WAAW;AACxE,QAAM,YAAQ,mCAAa,MAAM;AACjC,QAAM,MAAM,GAAG,iDAAiD;AAChE,SAAO,aAAa,gBAAAA,QAAS,oBAAoB,GAAG,IAAI;AAC1D;AAWO,IAAM,8BAA8B,CACzC,UACA,YACG;AACH,SAAO,sBAAsB;AAAA,IAC3B,GAAG;AAAA,IACH,QAAQ,EAAE,cAAc,UAAU,GAAG,mCAAS,OAAO;AAAA,EACvD,CAAC;AACH;AAWO,IAAM,4BAA4B,CACvC,YACA,YACG;AACH,SAAO,sBAAsB;AAAA,IAC3B,GAAG;AAAA,IACH,QAAQ,EAAE,YAAY,GAAG,mCAAS,OAAO;AAAA,EAC3C,CAAC;AACH;",
|
|
6
6
|
"names": ["security"]
|
|
7
7
|
}
|
|
@@ -11,12 +11,14 @@ type formatModuleProps = {
|
|
|
11
11
|
} | null;
|
|
12
12
|
parameters?: any;
|
|
13
13
|
loopItemData?: any;
|
|
14
|
+
loopIndex?: number;
|
|
15
|
+
parentNodeData?: any;
|
|
14
16
|
staticCodeList?: {
|
|
15
17
|
[key: string]: any;
|
|
16
18
|
} | null;
|
|
17
19
|
disabled?: boolean;
|
|
18
20
|
};
|
|
19
|
-
declare const formatModuleData: ({ moduleData, parentModuleData, parameters, loopItemData, staticCodeList, disabled, pageData, }: formatModuleProps) => {
|
|
21
|
+
declare const formatModuleData: ({ moduleData, parentModuleData, parameters, loopItemData, loopIndex, parentNodeData, staticCodeList, disabled, pageData, }: formatModuleProps) => {
|
|
20
22
|
[key: string]: any;
|
|
21
23
|
} | null;
|
|
22
24
|
export default formatModuleData;
|
|
@@ -26,11 +26,14 @@ var import_ses = require("ses");
|
|
|
26
26
|
var import_lodash = require("lodash");
|
|
27
27
|
var import_treeUtils = require("../treeUtils");
|
|
28
28
|
var import_helpers = require("./helpers");
|
|
29
|
+
var import_formatStyleProps = require("./helpers/formatStyleProps");
|
|
29
30
|
var formatModuleData = ({
|
|
30
31
|
moduleData,
|
|
31
32
|
parentModuleData,
|
|
32
33
|
parameters,
|
|
33
34
|
loopItemData,
|
|
35
|
+
loopIndex,
|
|
36
|
+
parentNodeData,
|
|
34
37
|
staticCodeList,
|
|
35
38
|
disabled,
|
|
36
39
|
pageData
|
|
@@ -39,8 +42,10 @@ var formatModuleData = ({
|
|
|
39
42
|
let moduleDataRes = {};
|
|
40
43
|
const allParametrs = {
|
|
41
44
|
...(0, import_lodash.cloneDeep)(parameters || {}),
|
|
45
|
+
loopIndex,
|
|
42
46
|
pageData: (0, import_lodash.cloneDeep)(pageData || {}),
|
|
43
|
-
loopItem: (0, import_lodash.cloneDeep)(loopItemData || {})
|
|
47
|
+
loopItem: (0, import_lodash.cloneDeep)(loopItemData || {}),
|
|
48
|
+
__parentNodeData__: (0, import_lodash.cloneDeep)(parentNodeData || {})
|
|
44
49
|
};
|
|
45
50
|
const {
|
|
46
51
|
staticCodeMap,
|
|
@@ -55,7 +60,9 @@ var formatModuleData = ({
|
|
|
55
60
|
moduleTitle,
|
|
56
61
|
moduleTitleIcon,
|
|
57
62
|
moduleDescribe,
|
|
63
|
+
loopItemProps,
|
|
58
64
|
controlBtns: moduleControlBtns,
|
|
65
|
+
controlBtnsStyle: moduleControlBtnsStyle,
|
|
59
66
|
id
|
|
60
67
|
} = moduleData;
|
|
61
68
|
moduleDataRes = {
|
|
@@ -84,12 +91,16 @@ var formatModuleData = ({
|
|
|
84
91
|
articleContent,
|
|
85
92
|
eventFlag,
|
|
86
93
|
events,
|
|
94
|
+
itemControlBtnsStyle,
|
|
87
95
|
...otherCompProps
|
|
88
96
|
// 无需处理的属性
|
|
89
97
|
} = compProps || {};
|
|
90
98
|
if (moduleTitle) {
|
|
91
99
|
moduleDataRes.moduleTitle = (0, import_helpers.stringPramarsValTransition)(moduleTitle, allParametrs);
|
|
92
100
|
}
|
|
101
|
+
if (moduleControlBtnsStyle) {
|
|
102
|
+
moduleDataRes.controlBtnsStyle = (0, import_formatStyleProps.getStylePainter)({ "flex-direction": "row", ...moduleControlBtnsStyle });
|
|
103
|
+
}
|
|
93
104
|
if (moduleTitleIcon) {
|
|
94
105
|
moduleDataRes.moduleTitleIcon = null;
|
|
95
106
|
if ((moduleTitleIcon == null ? void 0 : moduleTitleIcon.type) === "icon") {
|
|
@@ -162,13 +173,15 @@ var formatModuleData = ({
|
|
|
162
173
|
moduleDataRes.compProps.eventFlag = { checked: true };
|
|
163
174
|
}
|
|
164
175
|
}
|
|
165
|
-
if (["panel", "div", "
|
|
176
|
+
if (["page", "panel", "div", "tabs", "tabPanel", "data"].indexOf(compType) >= 0) {
|
|
166
177
|
const childs = Array.isArray(children) && children.length > 0 ? children.map((item) => {
|
|
167
178
|
return formatModuleData({
|
|
168
179
|
moduleData: item,
|
|
169
180
|
parentModuleData: moduleData,
|
|
181
|
+
parentNodeData,
|
|
170
182
|
parameters,
|
|
171
183
|
loopItemData,
|
|
184
|
+
loopIndex,
|
|
172
185
|
staticCodeList,
|
|
173
186
|
disabled,
|
|
174
187
|
pageData
|
|
@@ -183,6 +196,41 @@ var formatModuleData = ({
|
|
|
183
196
|
parameters: allParametrs
|
|
184
197
|
});
|
|
185
198
|
}
|
|
199
|
+
if (compType === "tabs") {
|
|
200
|
+
moduleDataRes.compProps = (0, import_helpers.formatTabsProps)({
|
|
201
|
+
key: id,
|
|
202
|
+
compProps: otherCompProps,
|
|
203
|
+
parameters: allParametrs
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
if (compType === "data") {
|
|
207
|
+
const dataProps = (0, import_helpers.formatDataProps)({
|
|
208
|
+
options: {
|
|
209
|
+
dataSource: compDataSource
|
|
210
|
+
},
|
|
211
|
+
parameters: allParametrs,
|
|
212
|
+
staticCodeMap
|
|
213
|
+
});
|
|
214
|
+
moduleDataRes.compProps = {
|
|
215
|
+
...(moduleDataRes == null ? void 0 : moduleDataRes.compProps) || {},
|
|
216
|
+
...dataProps,
|
|
217
|
+
children: Array.isArray(children) && children.length > 0 ? children.map((item) => {
|
|
218
|
+
const childInfo = formatModuleData({
|
|
219
|
+
moduleData: item,
|
|
220
|
+
parentModuleData: moduleData,
|
|
221
|
+
parentNodeData: {
|
|
222
|
+
...parentNodeData,
|
|
223
|
+
[moduleData == null ? void 0 : moduleData.id]: dataProps == null ? void 0 : dataProps.dataResult
|
|
224
|
+
},
|
|
225
|
+
parameters,
|
|
226
|
+
staticCodeList,
|
|
227
|
+
disabled,
|
|
228
|
+
pageData
|
|
229
|
+
});
|
|
230
|
+
return childInfo;
|
|
231
|
+
}) : []
|
|
232
|
+
};
|
|
233
|
+
}
|
|
186
234
|
} else {
|
|
187
235
|
if (otherCompProps && ((_a = Object == null ? void 0 : Object.keys(otherCompProps)) == null ? void 0 : _a.length) > 0) {
|
|
188
236
|
Object == null ? void 0 : Object.keys(otherCompProps).forEach((compPropKey) => {
|
|
@@ -205,7 +253,6 @@ var formatModuleData = ({
|
|
|
205
253
|
}
|
|
206
254
|
if (compType === "typography") {
|
|
207
255
|
if (articleContent) {
|
|
208
|
-
console.log("articleContent", articleContent, allParametrs);
|
|
209
256
|
moduleDataRes.compProps.articleContent = (0, import_helpers.stringPramarsValTransition)(articleContent, allParametrs);
|
|
210
257
|
}
|
|
211
258
|
}
|
|
@@ -240,7 +287,7 @@ var formatModuleData = ({
|
|
|
240
287
|
if (compType === "txt") {
|
|
241
288
|
moduleDataRes.compProps = {
|
|
242
289
|
...(moduleDataRes == null ? void 0 : moduleDataRes.compProps) || {},
|
|
243
|
-
content: (0, import_helpers.stringPramarsValTransition)(compProps == null ? void 0 : compProps.content, allParametrs)
|
|
290
|
+
content: (0, import_helpers.checkDataSourceOfFn)(compProps == null ? void 0 : compProps.content) ? (0, import_helpers.stringScriptExecution)(compProps == null ? void 0 : compProps.content, allParametrs) : (0, import_helpers.stringPramarsValTransition)(compProps == null ? void 0 : compProps.content, allParametrs)
|
|
244
291
|
};
|
|
245
292
|
}
|
|
246
293
|
if (compType === "image" && compDataSource && (compDataSource == null ? void 0 : compDataSource.dataType)) {
|
|
@@ -275,6 +322,7 @@ var formatModuleData = ({
|
|
|
275
322
|
tableBodyHeight
|
|
276
323
|
},
|
|
277
324
|
staticCodeMap,
|
|
325
|
+
staticOptionsMap,
|
|
278
326
|
parameters: allParametrs
|
|
279
327
|
});
|
|
280
328
|
moduleDataRes.compProps = {
|
|
@@ -320,22 +368,30 @@ var formatModuleData = ({
|
|
|
320
368
|
parameters: allParametrs,
|
|
321
369
|
staticCodeMap
|
|
322
370
|
});
|
|
371
|
+
const loopItemStyle = (0, import_formatStyleProps.getStylePainter)((loopItemProps == null ? void 0 : loopItemProps.style) || {});
|
|
323
372
|
const loopChilds = [];
|
|
324
373
|
if (Array.isArray(loopProps == null ? void 0 : loopProps.dataSource) && ((_c = loopProps == null ? void 0 : loopProps.dataSource) == null ? void 0 : _c.length) > 0 && Array.isArray(children) && children.length > 0) {
|
|
325
|
-
loopProps == null ? void 0 : loopProps.dataSource.forEach((dataItem) => {
|
|
374
|
+
loopProps == null ? void 0 : loopProps.dataSource.forEach((dataItem, index) => {
|
|
326
375
|
var _a2, _b2, _c2;
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
376
|
+
const dataItemIdxKey = `bubble_loop_item_${index}`;
|
|
377
|
+
const rawKey = ((_a2 = moduleDataRes == null ? void 0 : moduleDataRes.compProps) == null ? void 0 : _a2.rowKey) && (dataItem == null ? void 0 : dataItem[(_b2 = moduleDataRes == null ? void 0 : moduleDataRes.compProps) == null ? void 0 : _b2.rowKey]) ? String(dataItem == null ? void 0 : dataItem[(_c2 = moduleDataRes == null ? void 0 : moduleDataRes.compProps) == null ? void 0 : _c2.rowKey]) : "";
|
|
378
|
+
const itemKey = rawKey.replace(/[\u4e00-\u9fa5\s]/g, "") || dataItemIdxKey;
|
|
379
|
+
const loopItemData2 = {
|
|
380
|
+
id: itemKey,
|
|
381
|
+
key: itemKey,
|
|
331
382
|
compType: "loopItem",
|
|
332
|
-
compProps: {},
|
|
333
|
-
originItem: dataItem
|
|
383
|
+
compProps: { ...loopItemProps, style: loopItemStyle },
|
|
384
|
+
originItem: dataItem
|
|
385
|
+
};
|
|
386
|
+
loopChilds.push({
|
|
387
|
+
...loopItemData2,
|
|
334
388
|
children: children.map((item) => {
|
|
335
389
|
const loopChildInfo = formatModuleData({
|
|
336
390
|
moduleData: item,
|
|
337
|
-
parentModuleData:
|
|
391
|
+
parentModuleData: loopItemData2,
|
|
338
392
|
loopItemData: typeof dataItem === "object" ? dataItem : { item: dataItem },
|
|
393
|
+
loopIndex: index,
|
|
394
|
+
parentNodeData,
|
|
339
395
|
parameters,
|
|
340
396
|
staticCodeList,
|
|
341
397
|
disabled,
|
|
@@ -346,17 +402,22 @@ var formatModuleData = ({
|
|
|
346
402
|
});
|
|
347
403
|
});
|
|
348
404
|
} else if (Array.isArray(children) && children.length > 0) {
|
|
349
|
-
|
|
405
|
+
const loopItemData2 = {
|
|
350
406
|
id: "1",
|
|
351
407
|
key: "1",
|
|
352
408
|
compType: "loopItem",
|
|
353
|
-
compProps: {},
|
|
354
|
-
originItem: {}
|
|
409
|
+
compProps: { ...loopItemProps, style: loopItemStyle },
|
|
410
|
+
originItem: {}
|
|
411
|
+
};
|
|
412
|
+
loopChilds.push({
|
|
413
|
+
...loopItemData2,
|
|
355
414
|
children: children.map((item) => {
|
|
356
415
|
const loopChildInfo = formatModuleData({
|
|
357
416
|
moduleData: item,
|
|
358
|
-
parentModuleData:
|
|
417
|
+
parentModuleData: loopItemData2,
|
|
359
418
|
loopItemData: {},
|
|
419
|
+
loopIndex: 0,
|
|
420
|
+
parentNodeData,
|
|
360
421
|
parameters,
|
|
361
422
|
staticCodeList,
|
|
362
423
|
disabled,
|
|
@@ -372,6 +433,10 @@ var formatModuleData = ({
|
|
|
372
433
|
column,
|
|
373
434
|
children: loopChilds
|
|
374
435
|
};
|
|
436
|
+
moduleDataRes.loopItemProps = {
|
|
437
|
+
...loopItemProps,
|
|
438
|
+
style: loopItemStyle
|
|
439
|
+
};
|
|
375
440
|
}
|
|
376
441
|
if (["list", "card", "recommendList"].includes(compType)) {
|
|
377
442
|
const resProps = (0, import_helpers.formatListProps)({
|
|
@@ -444,13 +509,33 @@ var formatModuleData = ({
|
|
|
444
509
|
...stepsProps
|
|
445
510
|
};
|
|
446
511
|
}
|
|
512
|
+
if (compType === "video") {
|
|
513
|
+
const videoProps = (0, import_helpers.formatVideoProps)({
|
|
514
|
+
options: compProps,
|
|
515
|
+
parameters: allParametrs
|
|
516
|
+
});
|
|
517
|
+
moduleDataRes.compProps = {
|
|
518
|
+
...moduleDataRes.compProps || {},
|
|
519
|
+
...videoProps
|
|
520
|
+
};
|
|
521
|
+
}
|
|
447
522
|
if (Array.isArray(moduleControlBtns) && moduleControlBtns.length > 0) {
|
|
448
523
|
moduleDataRes.controlBtns = moduleControlBtns.map((btn) => (0, import_helpers.formatControlBtn)({
|
|
449
524
|
btnProps: btn,
|
|
450
525
|
parameters: allParametrs
|
|
451
526
|
}));
|
|
452
527
|
}
|
|
453
|
-
moduleDataRes.compProps.style = (0, import_helpers.formatStyleProps)(
|
|
528
|
+
moduleDataRes.compProps.style = (0, import_helpers.formatStyleProps)({
|
|
529
|
+
moduleData: moduleData || {},
|
|
530
|
+
parentModuleData: parentModuleData || {},
|
|
531
|
+
parameters: allParametrs
|
|
532
|
+
});
|
|
533
|
+
if (itemControlBtnsStyle) {
|
|
534
|
+
moduleDataRes.compProps.itemControlBtnsStyle = (0, import_formatStyleProps.getStylePainter)({
|
|
535
|
+
"flex-direction": "row",
|
|
536
|
+
...itemControlBtnsStyle
|
|
537
|
+
});
|
|
538
|
+
}
|
|
454
539
|
if ((moduleData == null ? void 0 : moduleData.compProps) && fieldName) {
|
|
455
540
|
moduleDataRes.compProps.fieldName = fieldName;
|
|
456
541
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/formatModule/formatModuleData.ts"],
|
|
4
|
-
"sourcesContent": ["import 'ses';\nimport { cloneDeep } from 'lodash';\nimport { getDataArr } from '../treeUtils';\nimport {\n urlPrefix,\n formatListProps,\n formatTableProps,\n formatPanelProps,\n formatCarouselProps,\n formatImageProps,\n formatFormProps,\n formatHighCodeProps,\n formatDescriptionsProps,\n formatLoopProps,\n formatStyleProps,\n formatEchartLineProps,\n formatEchartPieProps,\n formatChartsProps,\n formatStepsProps,\n formatIconProps,\n formatControlBtn,\n staticCodeAssemble,\n stringPramarsValTransition,\n stringScriptExecution,\n} from './helpers';\n\ntype formatModuleProps = {\n moduleData: { [key: string]: any } | null; // 页面配置数据\n parentModuleData?: { [key: string]: any } | null; // 父级配置数据\n pageData?: { [key: string]: any } | null; // 页面组件数据\n parameters?: any; // 入参上下文\n loopItemData?: any; // 循环体数据\n staticCodeList?: { [key: string]: any } | null; // 静态资源数据\n disabled?: boolean;\n};\n\nconst formatModuleData = ({\n moduleData,\n parentModuleData,\n parameters,\n loopItemData,\n staticCodeList,\n disabled,\n pageData,\n}: formatModuleProps): { [key: string]: any } | null => {\n let moduleDataRes: { [key: string]: any } = {};\n const allParametrs: { [key: string]: any } = {\n ...cloneDeep(parameters || {}),\n pageData: cloneDeep(pageData || {}),\n loopItem: cloneDeep(loopItemData || {}),\n }; // 把页面数据与入参组装到一起\n const {\n staticCodeMap,\n staticOptionsMap,\n } = staticCodeAssemble(staticCodeList);\n\n if (moduleData) {\n const {\n commonProps,\n compProps,\n compType,\n children,\n moduleTitle,\n moduleTitleIcon,\n moduleDescribe,\n controlBtns: moduleControlBtns,\n id,\n } = moduleData;\n // 组装静态数据映射\n moduleDataRes = {\n ...moduleData,\n key: id,\n disabled,\n compProps: {},\n commonProps: {},\n originModule: cloneDeep(moduleData), // 配置moduled的信息\n };\n const {\n itemLabel: listItemLabel,\n itemContent: listItemContent,\n itemDescribe: listItemDescribe,\n dataSource: compDataSource,\n columns: compColumns,\n tableBodyHeight,\n fileProps,\n attrs,\n rowSelection,\n hasSelectAll,\n rowKey,\n fieldName,\n column,\n articleContent,\n eventFlag,\n events,\n ...otherCompProps // 无需处理的属性\n } = compProps || {};\n if (moduleTitle) {\n moduleDataRes.moduleTitle = stringPramarsValTransition(moduleTitle, allParametrs);\n }\n if (moduleTitleIcon) {\n moduleDataRes.moduleTitleIcon = null;\n if (moduleTitleIcon?.type === 'icon') {\n const iconProps = formatIconProps({\n icon: moduleTitleIcon?.icon,\n parameters: allParametrs,\n });\n if (iconProps?.icon) {\n moduleDataRes.moduleTitleIcon = {\n type: 'icon',\n icon: iconProps,\n style: moduleTitleIcon?.style || {},\n className: moduleTitleIcon?.className || '',\n };\n } else {\n moduleDataRes.moduleTitleIcon = null;\n }\n } else if (moduleTitleIcon?.type === 'image') {\n const imageProps = formatImageProps({\n options: {\n dataSource: moduleTitleIcon?.image,\n },\n parameters: allParametrs,\n });\n if (imageProps?.src) {\n moduleDataRes.moduleTitleIcon = {\n type: 'image',\n image: imageProps,\n style: moduleTitleIcon?.style || {},\n className: moduleTitleIcon?.className || '',\n };\n } else {\n moduleDataRes.moduleTitleIcon = null;\n }\n }\n }\n if (moduleDescribe) {\n moduleDataRes.moduleDescribe = stringPramarsValTransition(moduleDescribe, allParametrs);\n }\n \n if (otherCompProps?.title) {\n moduleDataRes.compProps.title = stringPramarsValTransition(otherCompProps?.title, allParametrs);\n }\n\n if (commonProps && Object.keys(commonProps).length > 0) {\n Object.keys(commonProps).forEach(key => {\n if (key === 'hidden') {\n if (typeof commonProps[key] === 'boolean' || typeof commonProps[key] === 'string') {\n if (typeof commonProps[key] === 'boolean') {\n moduleDataRes.commonProps.hidden = commonProps[key];\n } else if (typeof commonProps[key] === 'string') {\n const hidden = stringScriptExecution(commonProps[key], allParametrs);\n moduleDataRes.commonProps.hidden = hidden;\n }\n }\n } else {\n moduleDataRes.commonProps[key] = commonProps[key];\n }\n });\n }\n\n moduleDataRes.parentCompProps = parentModuleData?.compProps || {};\n // 处理page组件的onLoad事件\n if (compType === 'page') {\n if (events && events?.length > 0) {\n const onLoadEvent = events.find(\n (item: any) => item?.key === 'pageLoad',\n );\n if (onLoadEvent) {\n moduleDataRes.compProps.onLoad = onLoadEvent?.event;\n }\n }\n if (eventFlag) {\n moduleDataRes.compProps.eventFlag = { checked: true };\n }\n }\n if (\n ['panel', 'div', 'page'].indexOf(compType) >= 0) {\n const childs = Array.isArray(children) &&\n children.length > 0 ? children.map((item) => {\n return formatModuleData({\n moduleData: item,\n parentModuleData: moduleData,\n parameters,\n loopItemData,\n staticCodeList,\n disabled,\n pageData,\n });\n }) : [];\n if (childs?.length > 0) {\n moduleDataRes.children = childs;\n }\n if (compType === 'panel') {\n moduleDataRes.compProps = formatPanelProps({\n compProps: otherCompProps,\n parameters: allParametrs,\n });\n }\n } else {\n if (otherCompProps && Object?.keys(otherCompProps)?.length > 0) {\n Object?.keys(otherCompProps).forEach(compPropKey => {\n if (otherCompProps?.[compPropKey] || typeof otherCompProps?.[compPropKey] === 'number') {\n moduleDataRes.compProps[compPropKey] = otherCompProps?.[compPropKey];\n }\n });\n }\n if (rowSelection) {\n moduleDataRes.compProps.rowSelection = rowSelection;\n if (hasSelectAll && rowSelection?.type === 'checkbox') {\n moduleDataRes.compProps.hasSelectAll = hasSelectAll;\n } else {\n delete moduleDataRes.compProps.hasSelectAll;\n }\n }\n const rowKeyIndexArr = getDataArr(rowKey);\n\n if (Array.isArray(rowKeyIndexArr) && rowKeyIndexArr.length > 0) {\n moduleDataRes.compProps.rowKey = rowKeyIndexArr.slice(-1)?.[0];\n }\n\n if (compType === 'typography') {\n if (articleContent) {\n console.log('articleContent', articleContent, allParametrs);\n moduleDataRes.compProps.articleContent = stringPramarsValTransition(articleContent, allParametrs);\n }\n }\n if (compType === 'iframe') {\n moduleDataRes.compProps.url = stringPramarsValTransition(\n otherCompProps?.url,\n allParametrs,\n );\n }\n\n if (compType === 'carousel' && compDataSource && compDataSource?.dataType) {\n const carouselProps = formatCarouselProps({\n options: {\n dataSource: compDataSource,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...carouselProps,\n };\n }\n if (compType === 'icon') {\n const iconProps = formatIconProps({\n icon: compProps?.icon,\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n icon: iconProps,\n };\n }\n if (compType === 'txt') {\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n content: stringPramarsValTransition(compProps?.content, allParametrs),\n };\n }\n if (compType === 'image' && compDataSource && compDataSource?.dataType) {\n const imageProps = formatImageProps({\n options: {\n dataSource: compDataSource,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...imageProps,\n };\n }\n\n if (compType === 'highCodeComp') {\n const highCodeCompProps = formatHighCodeProps({\n options: { fileProps },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...highCodeCompProps,\n };\n }\n\n if (compType === 'table') {\n const tableProps = formatTableProps({\n options: {\n ...otherCompProps,\n columns: compColumns,\n dataSource: compDataSource,\n attrs,\n tableBodyHeight,\n },\n staticCodeMap,\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...tableProps,\n };\n }\n if (compType === 'form') {\n const formProps = formatFormProps({\n options: {\n column,\n children,\n },\n parameters: allParametrs,\n staticCodeMap,\n staticOptionsMap,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...formProps,\n };\n }\n if (compType === 'descriptions') {\n const descriptionsProps = formatDescriptionsProps({\n options: {\n column,\n attrs,\n },\n parameters: allParametrs,\n staticCodeMap,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...descriptionsProps,\n };\n }\n if (compType === 'loop') {\n const loopProps = formatLoopProps({\n options: {\n dataSource: compDataSource,\n id,\n },\n parameters: allParametrs,\n staticCodeMap,\n });\n const loopChilds: ({ [key: string]: any } | null)[] = [];\n if (\n Array.isArray(loopProps?.dataSource) && loopProps?.dataSource?.length > 0 &&\n Array.isArray(children) && children.length > 0\n ) {\n loopProps?.dataSource.forEach((dataItem) => {\n const dataItemKey = moduleDataRes?.compProps?.rowKey && dataItem?.[moduleDataRes?.compProps?.rowKey] ?\n dataItem?.[moduleDataRes?.compProps?.rowKey] : '';\n loopChilds.push({\n id: dataItemKey,\n key: dataItemKey,\n compType: 'loopItem',\n compProps: {},\n originItem: dataItem,\n children: children.map((item: { [key: string]: any }) => {\n const loopChildInfo = formatModuleData({\n moduleData: item,\n parentModuleData: moduleData,\n loopItemData: typeof dataItem === 'object' ? dataItem : { item: dataItem },\n parameters,\n staticCodeList,\n disabled,\n pageData,\n });\n return loopChildInfo;\n }),\n });\n });\n } else if (Array.isArray(children) && children.length > 0) {\n loopChilds.push({\n id: '1',\n key: '1',\n compType: 'loopItem',\n compProps: {},\n originItem: {},\n children: children.map((item: { [key: string]: any }) => {\n const loopChildInfo = formatModuleData({\n moduleData: item,\n parentModuleData: moduleData,\n loopItemData: {},\n parameters,\n staticCodeList,\n disabled,\n pageData,\n });\n return loopChildInfo;\n }),\n });\n }\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...loopProps,\n column,\n children: loopChilds,\n };\n }\n if (['list', 'card', 'recommendList'].includes(compType)) {\n const resProps = formatListProps({\n options: {\n ...otherCompProps,\n rowKey,\n rowSelection,\n id,\n attrs,\n itemLabel: listItemLabel,\n itemContent: listItemContent,\n itemDescribe: listItemDescribe,\n dataSource: compDataSource,\n },\n urlPrefix,\n staticCodeMap,\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...resProps,\n };\n }\n if (['echartBar', 'echartLine'].includes(compType)) {\n const echartProps = formatEchartLineProps({\n options: { ...otherCompProps, dataSource: compDataSource },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...echartProps,\n };\n }\n if (compType === 'echartPie') {\n const echartProps = formatEchartPieProps({\n options: {\n dataSource: compDataSource,\n ...otherCompProps,\n },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...echartProps,\n };\n }\n if (compType === 'charts') {\n const chartsProps = formatChartsProps({\n options: {\n echartsOptions: compProps?.echartsOptions,\n },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...chartsProps,\n };\n }\n }\n if (compType === 'steps') {\n const stepsProps = formatStepsProps({\n options: {\n dataSource: compDataSource,\n ...otherCompProps,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...stepsProps,\n };\n }\n if (Array.isArray(moduleControlBtns) && moduleControlBtns.length > 0) {\n moduleDataRes.controlBtns = moduleControlBtns.map(btn => formatControlBtn({\n btnProps: btn,\n parameters: allParametrs,\n }));\n }\n moduleDataRes.compProps.style = formatStyleProps(moduleData, parentModuleData);\n // 所有的模版 拼一个组装数据的key值\n if (moduleData?.compProps && fieldName) {\n moduleDataRes.compProps.fieldName = fieldName;\n }\n }\n return moduleDataRes;\n};\n\nexport default formatModuleData;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAO;AACP,oBAA0B;AAC1B,uBAA2B;AAC3B,
|
|
6
|
-
"names": ["_a", "_b", "_c"]
|
|
4
|
+
"sourcesContent": ["import 'ses';\nimport { cloneDeep } from 'lodash';\nimport { getDataArr } from '../treeUtils';\nimport {\n urlPrefix,\n formatListProps,\n formatTableProps,\n formatPanelProps,\n formatCarouselProps,\n formatImageProps,\n formatFormProps,\n formatHighCodeProps,\n formatDescriptionsProps,\n formatLoopProps,\n formatStyleProps,\n formatEchartLineProps,\n formatEchartPieProps,\n formatChartsProps,\n formatStepsProps,\n formatIconProps,\n formatControlBtn,\n formatTabsProps,\n formatVideoProps,\n formatDataProps,\n staticCodeAssemble,\n stringPramarsValTransition,\n checkDataSourceOfFn,\n stringScriptExecution,\n} from './helpers';\nimport { getStylePainter } from './helpers/formatStyleProps';\n\ntype formatModuleProps = {\n moduleData: { [key: string]: any } | null; // 页面配置数据\n parentModuleData?: { [key: string]: any } | null; // 父级配置数据\n pageData?: { [key: string]: any } | null; // 页面组件数据\n parameters?: any; // 入参上下文\n loopItemData?: any; // 循环体数据\n loopIndex?: number; // 循环下标\n parentNodeData?: any; // 父级数据模块组件数据\n staticCodeList?: { [key: string]: any } | null; // 静态资源数据\n disabled?: boolean;\n};\n\nconst formatModuleData = ({\n moduleData,\n parentModuleData,\n parameters,\n loopItemData,\n loopIndex,\n parentNodeData,\n staticCodeList,\n disabled,\n pageData,\n}: formatModuleProps): { [key: string]: any } | null => {\n let moduleDataRes: { [key: string]: any } = {};\n const allParametrs: { [key: string]: any } = {\n ...cloneDeep(parameters || {}),\n loopIndex,\n pageData: cloneDeep(pageData || {}),\n loopItem: cloneDeep(loopItemData || {}),\n __parentNodeData__: cloneDeep(parentNodeData || {}),\n }; // 把页面数据与入参组装到一起\n const {\n staticCodeMap,\n staticOptionsMap,\n } = staticCodeAssemble(staticCodeList);\n\n if (moduleData) {\n const {\n commonProps,\n compProps,\n compType,\n children,\n moduleTitle,\n moduleTitleIcon,\n moduleDescribe,\n loopItemProps,\n controlBtns: moduleControlBtns,\n controlBtnsStyle: moduleControlBtnsStyle,\n id,\n } = moduleData;\n // 组装静态数据映射\n moduleDataRes = {\n ...moduleData,\n key: id,\n disabled,\n compProps: {},\n commonProps: {},\n originModule: cloneDeep(moduleData), // 配置moduled的信息\n };\n const {\n itemLabel: listItemLabel,\n itemContent: listItemContent,\n itemDescribe: listItemDescribe,\n dataSource: compDataSource,\n columns: compColumns,\n tableBodyHeight,\n fileProps,\n attrs,\n rowSelection,\n hasSelectAll,\n rowKey,\n fieldName,\n column,\n articleContent,\n eventFlag,\n events,\n itemControlBtnsStyle,\n ...otherCompProps // 无需处理的属性\n } = compProps || {};\n if (moduleTitle) {\n moduleDataRes.moduleTitle = stringPramarsValTransition(moduleTitle, allParametrs);\n }\n if (moduleControlBtnsStyle) {\n moduleDataRes.controlBtnsStyle = getStylePainter({ 'flex-direction': 'row', ...moduleControlBtnsStyle });\n }\n if (moduleTitleIcon) {\n moduleDataRes.moduleTitleIcon = null;\n if (moduleTitleIcon?.type === 'icon') {\n const iconProps = formatIconProps({\n icon: moduleTitleIcon?.icon,\n parameters: allParametrs,\n });\n if (iconProps?.icon) {\n moduleDataRes.moduleTitleIcon = {\n type: 'icon',\n icon: iconProps,\n style: moduleTitleIcon?.style || {},\n className: moduleTitleIcon?.className || '',\n };\n } else {\n moduleDataRes.moduleTitleIcon = null;\n }\n } else if (moduleTitleIcon?.type === 'image') {\n const imageProps = formatImageProps({\n options: {\n dataSource: moduleTitleIcon?.image,\n },\n parameters: allParametrs,\n });\n if (imageProps?.src) {\n moduleDataRes.moduleTitleIcon = {\n type: 'image',\n image: imageProps,\n style: moduleTitleIcon?.style || {},\n className: moduleTitleIcon?.className || '',\n };\n } else {\n moduleDataRes.moduleTitleIcon = null;\n }\n }\n }\n if (moduleDescribe) {\n moduleDataRes.moduleDescribe = stringPramarsValTransition(moduleDescribe, allParametrs);\n }\n \n if (otherCompProps?.title) {\n moduleDataRes.compProps.title = stringPramarsValTransition(otherCompProps?.title, allParametrs);\n }\n\n if (commonProps && Object.keys(commonProps).length > 0) {\n Object.keys(commonProps).forEach(key => {\n if (key === 'hidden') {\n if (typeof commonProps[key] === 'boolean' || typeof commonProps[key] === 'string') {\n if (typeof commonProps[key] === 'boolean') {\n moduleDataRes.commonProps.hidden = commonProps[key];\n } else if (typeof commonProps[key] === 'string') {\n const hidden = stringScriptExecution(commonProps[key], allParametrs);\n moduleDataRes.commonProps.hidden = hidden;\n }\n }\n } else {\n moduleDataRes.commonProps[key] = commonProps[key];\n }\n });\n }\n\n moduleDataRes.parentCompProps = parentModuleData?.compProps || {};\n // 处理page组件的onLoad事件\n if (compType === 'page') {\n if (events && events?.length > 0) {\n const onLoadEvent = events.find(\n (item: any) => item?.key === 'pageLoad',\n );\n if (onLoadEvent) {\n moduleDataRes.compProps.onLoad = onLoadEvent?.event;\n }\n }\n if (eventFlag) {\n moduleDataRes.compProps.eventFlag = { checked: true };\n }\n }\n if (\n ['page', 'panel', 'div', 'tabs', 'tabPanel', 'data'].indexOf(compType) >= 0) {\n const childs = Array.isArray(children) &&\n children.length > 0 ? children.map((item) => {\n return formatModuleData({\n moduleData: item,\n parentModuleData: moduleData,\n parentNodeData,\n parameters,\n loopItemData,\n loopIndex,\n staticCodeList,\n disabled,\n pageData,\n });\n }) : [];\n if (childs?.length > 0) {\n moduleDataRes.children = childs;\n }\n if (compType === 'panel') {\n moduleDataRes.compProps = formatPanelProps({\n compProps: otherCompProps,\n parameters: allParametrs,\n });\n }\n if (compType === 'tabs') {\n moduleDataRes.compProps = formatTabsProps({\n key: id,\n compProps: otherCompProps,\n parameters: allParametrs,\n });\n }\n if (compType === 'data') {\n const dataProps = formatDataProps({\n options: {\n dataSource: compDataSource,\n },\n parameters: allParametrs,\n staticCodeMap,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...dataProps,\n children: Array.isArray(children) && children.length > 0 ? children.map((item: { [key: string]: any }) => {\n const childInfo = formatModuleData({\n moduleData: item,\n parentModuleData: moduleData,\n parentNodeData: {\n ...parentNodeData,\n [moduleData?.id]: dataProps?.dataResult,\n },\n parameters,\n staticCodeList,\n disabled,\n pageData,\n });\n return childInfo;\n }) : [],\n };\n }\n } else {\n if (otherCompProps && Object?.keys(otherCompProps)?.length > 0) {\n Object?.keys(otherCompProps).forEach(compPropKey => {\n if (otherCompProps?.[compPropKey] || typeof otherCompProps?.[compPropKey] === 'number') {\n moduleDataRes.compProps[compPropKey] = otherCompProps?.[compPropKey];\n }\n });\n }\n if (rowSelection) {\n moduleDataRes.compProps.rowSelection = rowSelection;\n if (hasSelectAll && rowSelection?.type === 'checkbox') {\n moduleDataRes.compProps.hasSelectAll = hasSelectAll;\n } else {\n delete moduleDataRes.compProps.hasSelectAll;\n }\n }\n const rowKeyIndexArr = getDataArr(rowKey);\n\n if (Array.isArray(rowKeyIndexArr) && rowKeyIndexArr.length > 0) {\n moduleDataRes.compProps.rowKey = rowKeyIndexArr.slice(-1)?.[0];\n }\n\n if (compType === 'typography') {\n if (articleContent) {\n moduleDataRes.compProps.articleContent = stringPramarsValTransition(articleContent, allParametrs);\n }\n }\n if (compType === 'iframe') {\n moduleDataRes.compProps.url = stringPramarsValTransition(\n otherCompProps?.url,\n allParametrs,\n );\n }\n\n if (compType === 'carousel' && compDataSource && compDataSource?.dataType) {\n const carouselProps = formatCarouselProps({\n options: {\n dataSource: compDataSource,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...carouselProps,\n };\n }\n if (compType === 'icon') {\n const iconProps = formatIconProps({\n icon: compProps?.icon,\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n icon: iconProps,\n };\n }\n if (compType === 'txt') {\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n content: checkDataSourceOfFn(compProps?.content) ?\n stringScriptExecution(compProps?.content, allParametrs) :\n stringPramarsValTransition(compProps?.content, allParametrs),\n };\n }\n if (compType === 'image' && compDataSource && compDataSource?.dataType) {\n const imageProps = formatImageProps({\n options: {\n dataSource: compDataSource,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...imageProps,\n };\n }\n\n if (compType === 'highCodeComp') {\n const highCodeCompProps = formatHighCodeProps({\n options: { fileProps },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...highCodeCompProps,\n };\n }\n\n if (compType === 'table') {\n const tableProps = formatTableProps({\n options: {\n ...otherCompProps,\n columns: compColumns,\n dataSource: compDataSource,\n attrs,\n tableBodyHeight,\n },\n staticCodeMap,\n staticOptionsMap,\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...tableProps,\n };\n }\n if (compType === 'form') {\n const formProps = formatFormProps({\n options: {\n column,\n children,\n },\n parameters: allParametrs,\n staticCodeMap,\n staticOptionsMap,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...formProps,\n };\n }\n if (compType === 'descriptions') {\n const descriptionsProps = formatDescriptionsProps({\n options: {\n column,\n attrs,\n },\n parameters: allParametrs,\n staticCodeMap,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...descriptionsProps,\n };\n }\n if (compType === 'loop') {\n const loopProps = formatLoopProps({\n options: {\n dataSource: compDataSource,\n id,\n },\n parameters: allParametrs,\n staticCodeMap,\n });\n const loopItemStyle = getStylePainter(loopItemProps?.style || {});\n const loopChilds: ({ [key: string]: any } | null)[] = [];\n if (\n Array.isArray(loopProps?.dataSource) && loopProps?.dataSource?.length > 0 &&\n Array.isArray(children) && children.length > 0\n ) {\n loopProps?.dataSource.forEach((dataItem, index) => {\n const dataItemIdxKey = `bubble_loop_item_${index}`;\n const rawKey = moduleDataRes?.compProps?.rowKey && dataItem?.[moduleDataRes?.compProps?.rowKey] ?\n String(dataItem?.[moduleDataRes?.compProps?.rowKey]) : '';\n // 移除中文和空格\n const itemKey = rawKey.replace(/[\\u4e00-\\u9fa5\\s]/g, '') || dataItemIdxKey;\n const loopItemData = {\n id: itemKey,\n key: itemKey,\n compType: 'loopItem',\n compProps: { ...loopItemProps, style: loopItemStyle },\n originItem: dataItem,\n };\n loopChilds.push({\n ...loopItemData,\n children: children.map((item: { [key: string]: any }) => {\n const loopChildInfo = formatModuleData({\n moduleData: item,\n parentModuleData: loopItemData,\n loopItemData: typeof dataItem === 'object' ? dataItem : { item: dataItem },\n loopIndex: index,\n parentNodeData,\n parameters,\n staticCodeList,\n disabled,\n pageData,\n });\n return loopChildInfo;\n }),\n });\n });\n } else if (Array.isArray(children) && children.length > 0) {\n const loopItemData = {\n id: '1',\n key: '1',\n compType: 'loopItem',\n compProps: { ...loopItemProps, style: loopItemStyle },\n originItem: {},\n };\n loopChilds.push({\n ...loopItemData,\n children: children.map((item: { [key: string]: any }) => {\n const loopChildInfo = formatModuleData({\n moduleData: item,\n parentModuleData: loopItemData,\n loopItemData: {},\n loopIndex: 0,\n parentNodeData,\n parameters,\n staticCodeList,\n disabled,\n pageData,\n });\n return loopChildInfo;\n }),\n });\n }\n moduleDataRes.compProps = {\n ...(moduleDataRes?.compProps || {}),\n ...loopProps,\n column,\n children: loopChilds,\n };\n moduleDataRes.loopItemProps = {\n ...loopItemProps,\n style: loopItemStyle,\n };\n }\n if (['list', 'card', 'recommendList'].includes(compType)) {\n const resProps = formatListProps({\n options: {\n ...otherCompProps,\n rowKey,\n rowSelection,\n id,\n attrs,\n itemLabel: listItemLabel,\n itemContent: listItemContent,\n itemDescribe: listItemDescribe,\n dataSource: compDataSource,\n },\n urlPrefix,\n staticCodeMap,\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...resProps,\n };\n }\n if (['echartBar', 'echartLine'].includes(compType)) {\n const echartProps = formatEchartLineProps({\n options: { ...otherCompProps, dataSource: compDataSource },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...echartProps,\n };\n }\n if (compType === 'echartPie') {\n const echartProps = formatEchartPieProps({\n options: {\n dataSource: compDataSource,\n ...otherCompProps,\n },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...echartProps,\n };\n }\n if (compType === 'charts') {\n const chartsProps = formatChartsProps({\n options: {\n echartsOptions: compProps?.echartsOptions,\n },\n parameters: allParametrs,\n });\n\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...chartsProps,\n };\n }\n }\n if (compType === 'steps') {\n const stepsProps = formatStepsProps({\n options: {\n dataSource: compDataSource,\n ...otherCompProps,\n },\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...stepsProps,\n };\n }\n if (compType === 'video') {\n const videoProps = formatVideoProps({\n options: compProps,\n parameters: allParametrs,\n });\n moduleDataRes.compProps = {\n ...(moduleDataRes.compProps || {}),\n ...videoProps,\n };\n }\n if (Array.isArray(moduleControlBtns) && moduleControlBtns.length > 0) {\n moduleDataRes.controlBtns = moduleControlBtns.map(btn => formatControlBtn({\n btnProps: btn,\n parameters: allParametrs,\n }));\n }\n moduleDataRes.compProps.style = formatStyleProps({\n moduleData: moduleData || {},\n parentModuleData: parentModuleData || {},\n parameters: allParametrs,\n });\n if (itemControlBtnsStyle) {\n moduleDataRes.compProps.itemControlBtnsStyle = getStylePainter({\n 'flex-direction': 'row',\n ...itemControlBtnsStyle,\n });\n }\n // 所有的模版 拼一个组装数据的key值\n if (moduleData?.compProps && fieldName) {\n moduleDataRes.compProps.fieldName = fieldName;\n }\n }\n return moduleDataRes;\n};\n\nexport default formatModuleData;\n"],
|
|
5
|
+
"mappings": ";;;;;;;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AkB;AAAA,QAClB,GAAG;AAAA,MACL,CAAC;AAAA,IACH;AAEA,SAAI,yCAAY,cAAa,WAAW;AACtC,oBAAc,UAAU,YAAY;AAAA,IACtC;AAAA,EACF;AACA,SAAO;AACT;AAEA,IAAO,2BAAQ;",
|
|
6
|
+
"names": ["_a", "_b", "_c", "loopItemData"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/formatModule/helpers/checkDataSourceOfFn.ts
|
|
20
|
+
var checkDataSourceOfFn_exports = {};
|
|
21
|
+
__export(checkDataSourceOfFn_exports, {
|
|
22
|
+
default: () => checkDataSourceOfFn_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(checkDataSourceOfFn_exports);
|
|
25
|
+
var checkDataSourceOfFn = (dataSource) => {
|
|
26
|
+
if (typeof dataSource === "string" && dataSource) {
|
|
27
|
+
const dataSourceStr = dataSource.replace(/\s+/g, "");
|
|
28
|
+
return !dataSourceStr.startsWith("$") && dataSource.startsWith("(function()") && dataSourceStr.endsWith("})()");
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
};
|
|
32
|
+
var checkDataSourceOfFn_default = checkDataSourceOfFn;
|
|
33
|
+
//# sourceMappingURL=checkDataSourceOfFn.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/formatModule/helpers/checkDataSourceOfFn.ts"],
|
|
4
|
+
"sourcesContent": ["const checkDataSourceOfFn = (dataSource: string) => {\n if (typeof dataSource === 'string' && dataSource) {\n const dataSourceStr = dataSource.replace(/\\s+/g, '');\n return !dataSourceStr.startsWith('$') && dataSource.startsWith('(function()') && dataSourceStr.endsWith('})()');\n }\n return false;\n};\n\nexport default checkDataSourceOfFn;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,sBAAsB,CAAC,eAAuB;AAClD,MAAI,OAAO,eAAe,YAAY,YAAY;AAChD,UAAM,gBAAgB,WAAW,QAAQ,QAAQ,EAAE;AACnD,WAAO,CAAC,cAAc,WAAW,GAAG,KAAK,WAAW,WAAW,aAAa,KAAK,cAAc,SAAS,MAAM;AAAA,EAChH;AACA,SAAO;AACT;AAEA,IAAO,8BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将CSS语法转换成JSON对象
|
|
3
|
+
* @param cssText CSS字符串(可以是带选择器的规则、纯样式声明或CSS对象语法)
|
|
4
|
+
* @returns JSON对象,转换失败时返回空对象
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // 带选择器的CSS规则
|
|
8
|
+
* cssToJson('.class { color: red; font-size: 14px; }')
|
|
9
|
+
* // 返回: { '.class': { color: 'red', fontSize: '14px' } }
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // 纯样式声明
|
|
13
|
+
* cssToJson('color: red; font-size: 14px;')
|
|
14
|
+
* // 返回: { color: 'red', fontSize: '14px' }
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // CSS对象语法(直接以花括号包裹)
|
|
18
|
+
* cssToJson('{\n background: #000;\n display: flex;\n}')
|
|
19
|
+
* // 返回: { background: '#000', display: 'flex' }
|
|
20
|
+
*/
|
|
21
|
+
declare const cssToJson: (cssText: string) => Record<string, any>;
|
|
22
|
+
export default cssToJson;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/formatModule/helpers/cssToJson.ts
|
|
20
|
+
var cssToJson_exports = {};
|
|
21
|
+
__export(cssToJson_exports, {
|
|
22
|
+
default: () => cssToJson_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(cssToJson_exports);
|
|
25
|
+
var parseDeclarations = (declarations) => {
|
|
26
|
+
const styleObj = {};
|
|
27
|
+
const declarationRegex = /([^:;]+):([^;]+)/g;
|
|
28
|
+
let declMatch = declarationRegex.exec(declarations);
|
|
29
|
+
while (declMatch !== null) {
|
|
30
|
+
const property = declMatch[1].trim();
|
|
31
|
+
const value = declMatch[2].trim();
|
|
32
|
+
if (property && value) {
|
|
33
|
+
const camelProperty = property.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
34
|
+
styleObj[camelProperty] = value;
|
|
35
|
+
}
|
|
36
|
+
declMatch = declarationRegex.exec(declarations);
|
|
37
|
+
}
|
|
38
|
+
return styleObj;
|
|
39
|
+
};
|
|
40
|
+
var cssToJson = (cssText) => {
|
|
41
|
+
if (!cssText || typeof cssText !== "string") {
|
|
42
|
+
return {};
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const trimmedCss = cssText.trim();
|
|
46
|
+
let cleanedCss = trimmedCss.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
47
|
+
if (!cleanedCss.includes("{") && !cleanedCss.includes("}")) {
|
|
48
|
+
return parseDeclarations(cleanedCss);
|
|
49
|
+
}
|
|
50
|
+
if (cleanedCss.startsWith("{") && cleanedCss.endsWith("}")) {
|
|
51
|
+
const innerContent = cleanedCss.slice(1, -1).trim();
|
|
52
|
+
return parseDeclarations(innerContent);
|
|
53
|
+
}
|
|
54
|
+
const result = {};
|
|
55
|
+
cleanedCss = cleanedCss.replace(/@[^{]+\{[^{}]*\{[^}]*\}[^}]*\}/g, "");
|
|
56
|
+
cleanedCss = cleanedCss.replace(/@[^{]+\{[^}]*\}/g, "");
|
|
57
|
+
const ruleRegex = /([^{]+)\{([^}]+)\}/g;
|
|
58
|
+
let match = ruleRegex.exec(cleanedCss);
|
|
59
|
+
while (match !== null) {
|
|
60
|
+
const selector = match[1].trim();
|
|
61
|
+
const declarations = match[2].trim();
|
|
62
|
+
if (selector) {
|
|
63
|
+
const styleObj = parseDeclarations(declarations);
|
|
64
|
+
if (selector === "*" || selector === "body" || selector === "html") {
|
|
65
|
+
Object.assign(result, styleObj);
|
|
66
|
+
} else {
|
|
67
|
+
result[selector] = styleObj;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
match = ruleRegex.exec(cleanedCss);
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
return {};
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var cssToJson_default = cssToJson;
|
|
78
|
+
//# sourceMappingURL=cssToJson.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/formatModule/helpers/cssToJson.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * 解析CSS声明块为对象\n * @param declarations CSS声明字符串(如 \"color: red; font-size: 14px;\")\n * @returns 样式对象\n */\nconst parseDeclarations = (declarations: string): Record<string, string> => {\n const styleObj: Record<string, string> = {};\n const declarationRegex = /([^:;]+):([^;]+)/g;\n let declMatch = declarationRegex.exec(declarations);\n\n while (declMatch !== null) {\n const property = declMatch[1].trim();\n const value = declMatch[2].trim();\n\n if (property && value) {\n // 将CSS属性名转换为驼峰命名(如 background-color -> backgroundColor)\n const camelProperty = property.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n styleObj[camelProperty] = value;\n }\n declMatch = declarationRegex.exec(declarations);\n }\n\n return styleObj;\n};\n\n/**\n * 将CSS语法转换成JSON对象\n * @param cssText CSS字符串(可以是带选择器的规则、纯样式声明或CSS对象语法)\n * @returns JSON对象,转换失败时返回空对象\n *\n * @example\n * // 带选择器的CSS规则\n * cssToJson('.class { color: red; font-size: 14px; }')\n * // 返回: { '.class': { color: 'red', fontSize: '14px' } }\n *\n * @example\n * // 纯样式声明\n * cssToJson('color: red; font-size: 14px;')\n * // 返回: { color: 'red', fontSize: '14px' }\n *\n * @example\n * // CSS对象语法(直接以花括号包裹)\n * cssToJson('{\\n background: #000;\\n display: flex;\\n}')\n * // 返回: { background: '#000', display: 'flex' }\n */\nconst cssToJson = (cssText: string): Record<string, any> => {\n // 如果输入不是字符串或为空,返回空对象\n if (!cssText || typeof cssText !== 'string') {\n return {};\n }\n\n try {\n const trimmedCss = cssText.trim();\n \n // 移除CSS注释\n let cleanedCss = trimmedCss.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n \n // 如果输入不包含花括号,视为纯样式声明\n if (!cleanedCss.includes('{') && !cleanedCss.includes('}')) {\n return parseDeclarations(cleanedCss);\n }\n \n // 处理CSS对象语法:直接以 { 开头并以 } 结尾的样式块(无选择器)\n // 例如:{ background: #000; display: flex; }\n if (cleanedCss.startsWith('{') && cleanedCss.endsWith('}')) {\n // 提取花括号内的内容\n const innerContent = cleanedCss.slice(1, -1).trim();\n return parseDeclarations(innerContent);\n }\n \n const result: Record<string, any> = {};\n \n // 移除@规则(如@media, @keyframes等),这些通常不适合转换为简单的JSON对象\n cleanedCss = cleanedCss.replace(/@[^{]+\\{[^{}]*\\{[^}]*\\}[^}]*\\}/g, '');\n cleanedCss = cleanedCss.replace(/@[^{]+\\{[^}]*\\}/g, '');\n \n // 匹配CSS规则:选择器 { 属性: 值; ... }\n const ruleRegex = /([^{]+)\\{([^}]+)\\}/g;\n let match = ruleRegex.exec(cleanedCss);\n\n while (match !== null) {\n const selector = match[1].trim();\n const declarations = match[2].trim();\n\n // 如果选择器不为空,解析声明块\n if (selector) {\n // 解析声明块\n const styleObj = parseDeclarations(declarations);\n\n // 如果选择器是通配符或body/html,直接合并到根对象\n if (selector === '*' || selector === 'body' || selector === 'html') {\n Object.assign(result, styleObj);\n } else {\n // 否则以选择器为key\n result[selector] = styleObj;\n }\n }\n match = ruleRegex.exec(cleanedCss);\n }\n \n return result;\n } catch (error) {\n // 转换出错时返回空对象\n return {};\n }\n};\n\nexport default cssToJson;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAM,oBAAoB,CAAC,iBAAiD;AAC1E,QAAM,WAAmC,CAAC;A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