ronds-metadata 1.2.51 → 1.2.53
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/comps/MetadataForm/DataCell/Select.js +6 -4
- package/es/comps/MetadataForm/constants.d.ts +1 -0
- package/es/comps/MetadataForm/constants.js +3 -2
- package/es/comps/MetadataForm/index.d.ts +8 -1
- package/es/comps/MetadataForm/index.js +4 -0
- package/es/comps/MetadataForm/utils.d.ts +3 -0
- package/es/comps/MetadataForm/utils.js +67 -2
- package/package.json +1 -1
|
@@ -37,7 +37,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
37
37
|
/*
|
|
38
38
|
* @Author:wangxian
|
|
39
39
|
* @Date: 2021-09-18 14:15:04
|
|
40
|
-
* @LastEditTime: 2023-05-18
|
|
40
|
+
* @LastEditTime: 2023-05-18 15:32:01
|
|
41
41
|
*/
|
|
42
42
|
import React from 'react';
|
|
43
43
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
|
@@ -47,7 +47,7 @@ import { deepClone } from '../../../utils';
|
|
|
47
47
|
import { useAsyncMemo } from '../../../framework/hooks/use-async-memo';
|
|
48
48
|
import { tr } from '../../../framework/locale';
|
|
49
49
|
import useObservable from '../../../framework/rxjs-hooks/useObservable';
|
|
50
|
-
import { assignReplace } from '../utils';
|
|
50
|
+
import { assignReplace, findTopParentIndex } from '../utils';
|
|
51
51
|
function Index(props) {
|
|
52
52
|
var _extraInfo$http9, _extraInfo$http10, _extraInfo$http11, _extraInfo$http12, _extraInfo$http13, _extraInfo$http14;
|
|
53
53
|
var id = props.id,
|
|
@@ -381,10 +381,11 @@ function Index(props) {
|
|
|
381
381
|
};
|
|
382
382
|
var onDropdownVisibleChange = function onDropdownVisibleChange(_open) {
|
|
383
383
|
setTreeselectOpen(_open);
|
|
384
|
-
if (_open && expandedKeys.length > 0 && treeRef.current) {
|
|
384
|
+
if (_open && expandedKeys.length > 0 && treeRef.current && treeData.length > 0) {
|
|
385
385
|
setTimeout(function () {
|
|
386
|
+
var idx = findTopParentIndex(treeData, expandedKeys[0]);
|
|
386
387
|
treeRef.current.scrollTo({
|
|
387
|
-
|
|
388
|
+
index: idx,
|
|
388
389
|
align: 'top',
|
|
389
390
|
offset: 40
|
|
390
391
|
});
|
|
@@ -407,6 +408,7 @@ function Index(props) {
|
|
|
407
408
|
return /*#__PURE__*/React.createElement(_TreeSelect, {
|
|
408
409
|
showSearch: true,
|
|
409
410
|
ref: treeRef,
|
|
411
|
+
virtual: true,
|
|
410
412
|
filterTreeNode: function filterTreeNode(input, treeNode) {
|
|
411
413
|
var _treeNode$label;
|
|
412
414
|
return (treeNode === null || treeNode === void 0 ? void 0 : (_treeNode$label = treeNode.label) === null || _treeNode$label === void 0 ? void 0 : _treeNode$label.toString().indexOf(input)) >= 0;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: wangxian
|
|
3
3
|
* @Date: 2023-02-03 09:08:06
|
|
4
|
-
* @LastEditTime: 2023-
|
|
4
|
+
* @LastEditTime: 2023-05-18 13:50:43
|
|
5
5
|
*/
|
|
6
6
|
export var STREAM_EVENT_TYPE = {
|
|
7
7
|
ON_SELECT_CHANGE: 'onSelectChange',
|
|
8
8
|
ON_BUTTON_CELL_CLICK: 'onButtonCellClick',
|
|
9
9
|
ON_VALUES_CHANGE: 'onValuesChange',
|
|
10
|
-
ON_WATCH_DEPEND: 'onWatchDepend'
|
|
10
|
+
ON_WATCH_DEPEND: 'onWatchDepend',
|
|
11
|
+
ON_DROPDOWN_VISIBLE_CHANGE: 'onDropdownVisibleChange'
|
|
11
12
|
};
|
|
@@ -67,7 +67,14 @@ interface IMetadataFormProps {
|
|
|
67
67
|
*/
|
|
68
68
|
onSelectChange?: (changedValues: any) => void;
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* TreeSelect展开下拉菜单的回调
|
|
71
|
+
*/
|
|
72
|
+
onDropdownVisibleChange?: (data: {
|
|
73
|
+
treeRef: any;
|
|
74
|
+
key: string;
|
|
75
|
+
}) => void;
|
|
76
|
+
/**
|
|
77
|
+
* 有按钮的表格点击事件
|
|
71
78
|
*/
|
|
72
79
|
onCellButtonClick?: (changedValues: any) => void;
|
|
73
80
|
}
|
|
@@ -41,6 +41,7 @@ var MetadataForm = function MetadataForm(props) {
|
|
|
41
41
|
getFormInstance = props.getFormInstance,
|
|
42
42
|
onValuesChange = props.onValuesChange,
|
|
43
43
|
onSelectChange = props.onSelectChange,
|
|
44
|
+
onDropdownVisibleChange = props.onDropdownVisibleChange,
|
|
44
45
|
onCellButtonClick = props.onCellButtonClick;
|
|
45
46
|
var _React$useState = React.useState([]),
|
|
46
47
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -68,6 +69,9 @@ var MetadataForm = function MetadataForm(props) {
|
|
|
68
69
|
case STREAM_EVENT_TYPE.ON_SELECT_CHANGE:
|
|
69
70
|
onSelectChange && onSelectChange(p.payload);
|
|
70
71
|
break;
|
|
72
|
+
case STREAM_EVENT_TYPE.ON_DROPDOWN_VISIBLE_CHANGE:
|
|
73
|
+
onDropdownVisibleChange && onDropdownVisibleChange(p.payload);
|
|
74
|
+
break;
|
|
71
75
|
case STREAM_EVENT_TYPE.ON_BUTTON_CELL_CLICK:
|
|
72
76
|
onCellButtonClick && onCellButtonClick(p.payload);
|
|
73
77
|
break;
|
|
@@ -15,3 +15,6 @@ export declare function renderForm(schemaRef: any[], options: IFormOptions, colS
|
|
|
15
15
|
export declare function getLabelByProps(data: any): any;
|
|
16
16
|
export declare function assign(pathArr: string[], val: any, obj: any): void;
|
|
17
17
|
export declare function assignReplace(pathArr: string[], val: any, obj: any): void;
|
|
18
|
+
export declare function flattenTreeData(treeData: any[]): any;
|
|
19
|
+
export declare function findTopParent(treeData: any[], value: string): any;
|
|
20
|
+
export declare const findTopParentIndex: (treeData: any[], key: string) => number;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
1
5
|
import "antd/es/row/style";
|
|
2
6
|
import _Row from "antd/es/row";
|
|
3
7
|
import "antd/es/spin/style";
|
|
4
8
|
import _Spin from "antd/es/spin";
|
|
5
9
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
10
|
+
var _excluded = ["children"];
|
|
6
11
|
/*
|
|
7
12
|
* @Author: wangxian
|
|
8
13
|
* @Date: 2021-09-18 14:15:04
|
|
9
|
-
* @LastEditTime: 2023-
|
|
14
|
+
* @LastEditTime: 2023-05-18 16:25:00
|
|
10
15
|
*/
|
|
11
16
|
import React from 'react';
|
|
12
17
|
import Input from './DataCell/Input';
|
|
@@ -113,4 +118,64 @@ export function assignReplace(pathArr, val, obj) {
|
|
|
113
118
|
}
|
|
114
119
|
return cur[key];
|
|
115
120
|
}, obj);
|
|
116
|
-
}
|
|
121
|
+
}
|
|
122
|
+
export function flattenTreeData(treeData) {
|
|
123
|
+
return treeData.reduce(function (acc, _ref) {
|
|
124
|
+
var children = _ref.children,
|
|
125
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
126
|
+
var flatItem = _objectSpread({}, rest);
|
|
127
|
+
acc.push(flatItem);
|
|
128
|
+
if (children) {
|
|
129
|
+
acc.push.apply(acc, _toConsumableArray(flattenTreeData(children)));
|
|
130
|
+
}
|
|
131
|
+
return acc;
|
|
132
|
+
}, []);
|
|
133
|
+
}
|
|
134
|
+
export function findTopParent(treeData, value) {
|
|
135
|
+
var topNode = null;
|
|
136
|
+
function traverse(node, depth) {
|
|
137
|
+
if (node.value === value && (!topNode || depth < topNode.depth)) {
|
|
138
|
+
topNode = {
|
|
139
|
+
node: node,
|
|
140
|
+
depth: depth
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if ((node === null || node === void 0 ? void 0 : node.children) && (node === null || node === void 0 ? void 0 : node.children.length) > 0) {
|
|
144
|
+
var _iterator = _createForOfIteratorHelper(node.children),
|
|
145
|
+
_step;
|
|
146
|
+
try {
|
|
147
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
148
|
+
var child = _step.value;
|
|
149
|
+
traverse(child, depth + 1);
|
|
150
|
+
}
|
|
151
|
+
} catch (err) {
|
|
152
|
+
_iterator.e(err);
|
|
153
|
+
} finally {
|
|
154
|
+
_iterator.f();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
traverse({
|
|
159
|
+
children: treeData
|
|
160
|
+
}, 0);
|
|
161
|
+
return topNode ? topNode.node : null;
|
|
162
|
+
}
|
|
163
|
+
export var findTopParentIndex = function findTopParentIndex(treeData, key) {
|
|
164
|
+
var topNodeIndex = -1;
|
|
165
|
+
function traverse(node, parentIndexes) {
|
|
166
|
+
if (node.value === key) {
|
|
167
|
+
topNodeIndex = parentIndexes.reduce(function (total, number) {
|
|
168
|
+
return total + number;
|
|
169
|
+
}, 0);
|
|
170
|
+
}
|
|
171
|
+
if ((node === null || node === void 0 ? void 0 : node.children) && node.children.length > 0) {
|
|
172
|
+
node.children.forEach(function (child, idx) {
|
|
173
|
+
return traverse(child, [].concat(_toConsumableArray(parentIndexes), [idx]));
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
treeData.forEach(function (node, index) {
|
|
178
|
+
return traverse(node, [index]);
|
|
179
|
+
});
|
|
180
|
+
return topNodeIndex;
|
|
181
|
+
};
|