@lingxiteam/ebe-utils 0.3.24 → 0.3.26
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/es/index.js
CHANGED
|
@@ -227,7 +227,7 @@ export var clearLXPagesDSL = function clearLXPagesDSL(pages) {
|
|
|
227
227
|
});
|
|
228
228
|
};
|
|
229
229
|
export var getSafeTypeName = function getSafeTypeName(name) {
|
|
230
|
-
return name.replaceAll(' ', '').replaceAll('/', '').replaceAll('-', '').replaceAll('(', '').replaceAll(',', '').replaceAll("'", '').replaceAll(',', '').replaceAll(')', '');
|
|
230
|
+
return name.replaceAll(' ', '').replaceAll('/', '').replaceAll('\\', '').replaceAll('-', '').replaceAll('(', '').replaceAll(',', '').replaceAll("'", '').replaceAll(',', '').replaceAll(')', '');
|
|
231
231
|
};
|
|
232
232
|
var workerJsUrl = '';
|
|
233
233
|
export var setWorkerJsUrl = function setWorkerJsUrl(url) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renameComponents(data: any): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
export function renameComponents(data) {
|
|
8
|
+
// 读取 JSON 文件
|
|
9
|
+
// const data: JsonData = JSON.parse(jsonContent);
|
|
10
|
+
|
|
11
|
+
// 用于存储已使用的名称计数
|
|
12
|
+
var nameCounters = {};
|
|
13
|
+
var renameObject = {};
|
|
14
|
+
|
|
15
|
+
// 递归处理组件
|
|
16
|
+
function processComponents(components) {
|
|
17
|
+
if (!Array.isArray(components)) return;
|
|
18
|
+
components.forEach(function (component) {
|
|
19
|
+
// 处理当前组件
|
|
20
|
+
if (component.id && /^[A-Za-z]+_\d+$/.test(component.id)) {
|
|
21
|
+
var baseName = component.id.split('_')[0];
|
|
22
|
+
// 生成新的有意义的名字
|
|
23
|
+
var newName = generateMeaningfulName(baseName, component.id, nameCounters);
|
|
24
|
+
component.id = newName;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 递归处理子组件
|
|
28
|
+
if (component.components) {
|
|
29
|
+
processComponents(component.components);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 生成有意义的名称
|
|
35
|
+
function generateMeaningfulName(baseName, label, counters) {
|
|
36
|
+
if (!counters[baseName]) {
|
|
37
|
+
counters[baseName] = 1;
|
|
38
|
+
} else {
|
|
39
|
+
counters[baseName] += 1;
|
|
40
|
+
}
|
|
41
|
+
// 从 Form1 开始,防止变量名和组件名相同
|
|
42
|
+
var rename = "".concat(baseName).concat(counters[baseName]);
|
|
43
|
+
renameObject[label] = rename;
|
|
44
|
+
return rename;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 处理所有组件
|
|
48
|
+
if (data.components) {
|
|
49
|
+
processComponents(data.components);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 将对象转换为字符串
|
|
53
|
+
var jsonString = JSON.stringify(data, null, 4);
|
|
54
|
+
|
|
55
|
+
// 全局替换所有引用
|
|
56
|
+
Object.entries(renameObject).forEach(function (_ref) {
|
|
57
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
58
|
+
oldName = _ref2[0],
|
|
59
|
+
newName = _ref2[1];
|
|
60
|
+
// 使用正则表达式确保只替换完整的匹配
|
|
61
|
+
var regex = oldName.trim();
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
jsonString = jsonString.replaceAll(regex, newName);
|
|
64
|
+
});
|
|
65
|
+
return JSON.parse(jsonString);
|
|
66
|
+
// 写回文件
|
|
67
|
+
// fs.writeFileSync('./Page_ceshi1.json', jsonString, 'utf8');
|
|
68
|
+
// console.log('组件重命名完成!');
|
|
69
|
+
// console.log('/重命名映射关系:', renameObject);
|
|
70
|
+
}
|
|
@@ -8,17 +8,20 @@ import React, { useMemo, useRef } from 'react';
|
|
|
8
8
|
import { DEFAULT_TOOLBARS, DEFAULT_TOOLBARS_GROUP } from './const';
|
|
9
9
|
import IdleContainer from '../utils/IdleContainer';
|
|
10
10
|
|
|
11
|
-
const LcdpUeditorMain: LingXiFC
|
|
11
|
+
const LcdpUeditorMain: LingXiFC<{ [key: string]: any }> = (props) => {
|
|
12
12
|
const { value, onChange, style, className, rootRef: ref, funcTypes, pasteplain = false, name } = props;
|
|
13
13
|
const editorRef = useRef<ILcdpUeditorInst | null>(null);
|
|
14
14
|
|
|
15
15
|
const engineApis = props.getEngineApis();
|
|
16
16
|
const { getLocale, lang } = useLocale(engineApis);
|
|
17
|
+
const { onlySyncValue } = engineApis;
|
|
17
18
|
|
|
18
19
|
const { disabled, required, readOnly, formFieldsRef } = useCommonImperativeHandle(ref, props, {
|
|
19
|
-
setValue: (val:string) => {
|
|
20
|
+
setValue: (val: string) => {
|
|
20
21
|
if (editorRef.current) {
|
|
21
22
|
editorRef.current.setContent(val);
|
|
23
|
+
// 同步 hoc vlaue使用,解决值不同步问题
|
|
24
|
+
onlySyncValue(val);
|
|
22
25
|
} else {
|
|
23
26
|
// 编辑器未挂载先设置到value
|
|
24
27
|
onChange(val);
|
|
@@ -75,7 +78,7 @@ const LcdpUeditorMain: LingXiFC <{[key: string]: any}> = (props => {
|
|
|
75
78
|
return 'zh-cn';
|
|
76
79
|
}
|
|
77
80
|
}, [lang]);
|
|
78
|
-
|
|
81
|
+
|
|
79
82
|
return (
|
|
80
83
|
<IdleContainer>
|
|
81
84
|
<FormFields
|
|
@@ -131,6 +134,6 @@ const LcdpUeditorMain: LingXiFC <{[key: string]: any}> = (props => {
|
|
|
131
134
|
</FormFields>
|
|
132
135
|
</IdleContainer>
|
|
133
136
|
);
|
|
134
|
-
}
|
|
137
|
+
};
|
|
135
138
|
|
|
136
139
|
export default LcdpUeditorMain;
|
|
@@ -86,6 +86,8 @@ export interface MyTreeProps {
|
|
|
86
86
|
nodeIconsType?: 'default' | 'forceDropdown',
|
|
87
87
|
style?: React.CSSProperties,
|
|
88
88
|
backgroundType?: any;
|
|
89
|
+
checkableName?: boolean;
|
|
90
|
+
disabledFatherNode?: boolean;
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
// const prefixCls = 'tree';
|
|
@@ -164,6 +166,8 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
|
|
|
164
166
|
// 当前操作字段key
|
|
165
167
|
const [editingKey, setEditingKey] = useState('');
|
|
166
168
|
|
|
169
|
+
const treeRef = useRef<any>();
|
|
170
|
+
|
|
167
171
|
// 强制菜单模式
|
|
168
172
|
const forceDrowdown = nodeIconsType === 'forceDropdown';
|
|
169
173
|
|
|
@@ -950,6 +954,13 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
|
|
|
950
954
|
? nodes.map((c, i) => {
|
|
951
955
|
const nodeWithParent = { ...c, data: { ...(c.data || {}), parentNode } };
|
|
952
956
|
const nodeProps: any = { dataRef: c };
|
|
957
|
+
// 父节点是否允许点击
|
|
958
|
+
const isCheckFather =
|
|
959
|
+
props.checkable &&
|
|
960
|
+
props.disabledFatherNode &&
|
|
961
|
+
c.children &&
|
|
962
|
+
Array.isArray(c.children) &&
|
|
963
|
+
c.children.length > 0;
|
|
953
964
|
return (
|
|
954
965
|
<TreeNode
|
|
955
966
|
key={c.key}
|
|
@@ -958,14 +969,16 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
|
|
|
958
969
|
isLeaf={c.isLeaf}
|
|
959
970
|
selectable={c.selectable}
|
|
960
971
|
disableCheckbox={
|
|
961
|
-
|
|
962
|
-
c.
|
|
963
|
-
|
|
972
|
+
isCheckFather ||
|
|
973
|
+
(c.disabled ??
|
|
974
|
+
c.disableCheckbox ??
|
|
975
|
+
(c.selectable !== undefined ? !c.selectable : undefined))
|
|
964
976
|
}
|
|
965
977
|
disabled={
|
|
966
|
-
|
|
967
|
-
c.
|
|
968
|
-
|
|
978
|
+
isCheckFather ||
|
|
979
|
+
(c.disabled ??
|
|
980
|
+
c.disableCheckbox ??
|
|
981
|
+
(c.selectable !== undefined ? !c.selectable : undefined))
|
|
969
982
|
}
|
|
970
983
|
className={classnames(
|
|
971
984
|
!c.children || !c.children.length ? 'ued-tree-node-leaf' : '',
|
|
@@ -1140,6 +1153,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
|
|
|
1140
1153
|
{!filterData || !filterData?.length ? renderEmpty : (
|
|
1141
1154
|
<Tree
|
|
1142
1155
|
{...resetProps}
|
|
1156
|
+
ref={treeRef}
|
|
1143
1157
|
className={classnames('ued-tree', !showLineIcon ? 'ued-tree-no-line-icon' : '')}
|
|
1144
1158
|
selectedKeys={selectedKeys}
|
|
1145
1159
|
checkedKeys={checkedKeys}
|
|
@@ -1186,6 +1200,9 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
|
|
|
1186
1200
|
if (onSelect) {
|
|
1187
1201
|
onSelect(keys, e, e?.node?.data?.parentNode?.key, e?.node?.data?.parentNode);
|
|
1188
1202
|
}
|
|
1203
|
+
if (!!props.checkable && !!props.checkableName) {
|
|
1204
|
+
(treeRef?.current as any)?.onNodeCheck({}, e?.node, !e?.node?.checked);
|
|
1205
|
+
}
|
|
1189
1206
|
}}
|
|
1190
1207
|
showIcon={showLineIcon}
|
|
1191
1208
|
icon={showLineIcon ? renderNodeIcon : undefined}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingxiteam/ebe-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.26",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@babel/types": "^7.12.12",
|
|
20
20
|
"cac": "^6.7.14",
|
|
21
21
|
"fs-extra": "9.x",
|
|
22
|
-
"@lingxiteam/ebe": "0.3.
|
|
22
|
+
"@lingxiteam/ebe": "0.3.26"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|