ronds-metadata 1.1.83 → 1.1.85
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/Array.js +13 -3
- package/es/comps/MetadataForm/DataCell/Input.js +13 -4
- package/es/comps/MetadataForm/DataCell/Number.js +12 -3
- package/es/comps/MetadataForm/DataCell/Ref.js +11 -3
- package/es/comps/MetadataForm/DataCell/Select.js +12 -5
- package/es/comps/MetadataForm/DataCell/Switch.js +12 -5
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +11 -4
- package/es/comps/MetadataForm/constants.d.ts +6 -0
- package/es/comps/MetadataForm/constants.js +11 -0
- package/es/comps/MetadataForm/hooks/index.d.ts +2 -0
- package/es/comps/MetadataForm/hooks/index.js +67 -2
- package/es/comps/MetadataForm/index.js +26 -8
- package/es/comps/MetadataForm/interface.d.ts +9 -0
- package/es/comps/MetadataForm/interface.js +1 -1
- package/es/comps/MetadataForm/utils.js +1 -1
- package/es/theme.less +1 -1
- package/package.json +1 -1
@@ -12,19 +12,19 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
12
12
|
/*
|
13
13
|
* @Author: wangxian
|
14
14
|
* @Date: 2021-09-18 14:15:04
|
15
|
-
* @LastEditTime: 2023-02-
|
15
|
+
* @LastEditTime: 2023-02-04 09:02:03
|
16
16
|
*/
|
17
17
|
import React from 'react';
|
18
18
|
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
19
19
|
import { MetadataFormContext } from '../interface';
|
20
|
-
import { useGetExtraInfo } from '../hooks';
|
20
|
+
import { useGetExtraInfo, useWatchDepend } from '../hooks';
|
21
21
|
import { getDataCell } from '../utils';
|
22
22
|
import { deepClone } from '../../../utils';
|
23
23
|
import { tr } from '../../../framework/locale';
|
24
24
|
import TableArray from './layout/TableArray';
|
25
25
|
|
26
26
|
function Index(props) {
|
27
|
-
var _fieldRule$, _fieldRule$$value, _fieldRule$2, _fieldRule$2$value, _extraInfo$disabled;
|
27
|
+
var _extraInfo$depend, _fieldRule$, _fieldRule$$value, _fieldRule$2, _fieldRule$2$value, _extraInfo$disabled;
|
28
28
|
|
29
29
|
var id = props.id,
|
30
30
|
items = props.items,
|
@@ -41,6 +41,7 @@ function Index(props) {
|
|
41
41
|
help = _React$useState2[0],
|
42
42
|
setHelp = _React$useState2[1];
|
43
43
|
|
44
|
+
var depend = useWatchDepend(extraInfo.depend, formContext.stream$);
|
44
45
|
var myName = React.useMemo(function () {
|
45
46
|
var res = [];
|
46
47
|
|
@@ -59,6 +60,15 @@ function Index(props) {
|
|
59
60
|
setHelp(arr[arr.length - 1]);
|
60
61
|
}
|
61
62
|
}, [items]);
|
63
|
+
|
64
|
+
if (depend.hidden) {
|
65
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
66
|
+
}
|
67
|
+
|
68
|
+
if ((extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$depend = extraInfo.depend) === null || _extraInfo$depend === void 0 ? void 0 : _extraInfo$depend.show) && !depend.show) {
|
69
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
70
|
+
}
|
71
|
+
|
62
72
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Row, null, /*#__PURE__*/React.createElement(_Col, {
|
63
73
|
span: (formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan) && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan : 24
|
64
74
|
}, !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) && /*#__PURE__*/React.createElement("div", {
|
@@ -15,15 +15,17 @@ import _Input from "antd/es/input";
|
|
15
15
|
/*
|
16
16
|
* @Author: wangxian
|
17
17
|
* @Date: 2021-09-18 14:15:04
|
18
|
-
* @LastEditTime:
|
18
|
+
* @LastEditTime: 2023-02-04 09:02:14
|
19
19
|
*/
|
20
20
|
import React from 'react';
|
21
21
|
import { UploadOutlined } from '@ant-design/icons';
|
22
22
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
23
|
-
import { useGetExtraInfo } from '../hooks';
|
23
|
+
import { useGetExtraInfo, useWatchDepend } from '../hooks';
|
24
24
|
var TextArea = _Input.TextArea;
|
25
25
|
|
26
26
|
function Index(props) {
|
27
|
+
var _extraInfo$depend;
|
28
|
+
|
27
29
|
var id = props.id,
|
28
30
|
isRefForm = props.isRefForm,
|
29
31
|
disabled = props.disabled,
|
@@ -33,6 +35,7 @@ function Index(props) {
|
|
33
35
|
var formContext = React.useContext(MetadataFormContext) || {};
|
34
36
|
var formRefContext = React.useContext(MetadataRefContext);
|
35
37
|
var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form, props.type);
|
38
|
+
var depend = useWatchDepend(extraInfo.depend, formContext.stream$);
|
36
39
|
|
37
40
|
var _React$useState = React.useState([]),
|
38
41
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
@@ -102,6 +105,14 @@ function Index(props) {
|
|
102
105
|
}
|
103
106
|
};
|
104
107
|
|
108
|
+
if (depend.hidden) {
|
109
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
110
|
+
}
|
111
|
+
|
112
|
+
if ((extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$depend = extraInfo.depend) === null || _extraInfo$depend === void 0 ? void 0 : _extraInfo$depend.show) && !depend.show) {
|
113
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
114
|
+
}
|
115
|
+
|
105
116
|
if (isObj && isRefForm && field) {
|
106
117
|
return /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
|
107
118
|
style: {
|
@@ -110,7 +121,6 @@ function Index(props) {
|
|
110
121
|
},
|
111
122
|
label: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id,
|
112
123
|
name: [field === null || field === void 0 ? void 0 : field.name].concat(_toConsumableArray(name)),
|
113
|
-
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey],
|
114
124
|
rules: [{
|
115
125
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
116
126
|
}].concat(_toConsumableArray(rules)),
|
@@ -138,7 +148,6 @@ function Index(props) {
|
|
138
148
|
paddingRight: '10px'
|
139
149
|
},
|
140
150
|
name: [field === null || field === void 0 ? void 0 : field.name],
|
141
|
-
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey],
|
142
151
|
rules: [{
|
143
152
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
144
153
|
}].concat(_toConsumableArray(rules)),
|
@@ -9,14 +9,14 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
9
9
|
/*
|
10
10
|
* @Author: wangxian
|
11
11
|
* @Date: 2021-09-18 14:15:04
|
12
|
-
* @LastEditTime:
|
12
|
+
* @LastEditTime: 2023-02-04 09:03:08
|
13
13
|
*/
|
14
14
|
import React from 'react';
|
15
15
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
16
|
-
import { useGetExtraInfo } from '../hooks';
|
16
|
+
import { useGetExtraInfo, useWatchDepend } from '../hooks';
|
17
17
|
|
18
18
|
function Index(props) {
|
19
|
-
var _extraInfo$disabled2, _extraInfo$disabled3;
|
19
|
+
var _extraInfo$depend, _extraInfo$disabled2, _extraInfo$disabled3;
|
20
20
|
|
21
21
|
var id = props.id,
|
22
22
|
name = props.name,
|
@@ -33,6 +33,7 @@ function Index(props) {
|
|
33
33
|
rules = _React$useState2[0],
|
34
34
|
setRules = _React$useState2[1];
|
35
35
|
|
36
|
+
var depend = useWatchDepend(extraInfo.depend, formContext.stream$);
|
36
37
|
React.useEffect(function () {
|
37
38
|
var _rules = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.rules;
|
38
39
|
|
@@ -48,6 +49,14 @@ function Index(props) {
|
|
48
49
|
}
|
49
50
|
}, [extraInfo]);
|
50
51
|
|
52
|
+
if (depend.hidden) {
|
53
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
54
|
+
}
|
55
|
+
|
56
|
+
if ((extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$depend = extraInfo.depend) === null || _extraInfo$depend === void 0 ? void 0 : _extraInfo$depend.show) && !depend.show) {
|
57
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
58
|
+
}
|
59
|
+
|
51
60
|
if (isObj && isRefForm && field) {
|
52
61
|
var _extraInfo$disabled;
|
53
62
|
|
@@ -18,12 +18,12 @@ import React from 'react';
|
|
18
18
|
import { CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons';
|
19
19
|
import { MetadataService } from '../../../framework/metadata/MetadataService';
|
20
20
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
21
|
-
import { useGetExtraInfo } from '../hooks';
|
21
|
+
import { useGetExtraInfo, useWatchDepend } from '../hooks';
|
22
22
|
import { renderForm } from '../utils';
|
23
23
|
import { JsonMetadataProvider } from '../../../framework/metadata';
|
24
24
|
|
25
25
|
function Index(props) {
|
26
|
-
var _extraInfo$disabled, _extraInfo$disabled2;
|
26
|
+
var _extraInfo$depend, _extraInfo$disabled, _extraInfo$disabled2;
|
27
27
|
|
28
28
|
var id = props.id,
|
29
29
|
refId = props.refId,
|
@@ -63,6 +63,7 @@ function Index(props) {
|
|
63
63
|
help = _React$useState10[0],
|
64
64
|
setHelp = _React$useState10[1];
|
65
65
|
|
66
|
+
var depend = useWatchDepend(extraInfo.depend, formContext.stream$);
|
66
67
|
var onSearch = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
67
68
|
var param, server, res, _options, i, obj;
|
68
69
|
|
@@ -196,6 +197,14 @@ function Index(props) {
|
|
196
197
|
}
|
197
198
|
}, [refId]);
|
198
199
|
|
200
|
+
if (depend.hidden) {
|
201
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
202
|
+
}
|
203
|
+
|
204
|
+
if ((extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$depend = extraInfo.depend) === null || _extraInfo$depend === void 0 ? void 0 : _extraInfo$depend.show) && !depend.show) {
|
205
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
206
|
+
}
|
207
|
+
|
199
208
|
if (isRefForm && !field && schema.length > 0) {
|
200
209
|
var _fieldRule$, _fieldRule$$value, _fieldRule$2, _fieldRule$2$value, _fieldRule$2$value$co;
|
201
210
|
|
@@ -290,7 +299,6 @@ function Index(props) {
|
|
290
299
|
width: '100%'
|
291
300
|
},
|
292
301
|
name: [field === null || field === void 0 ? void 0 : field.name],
|
293
|
-
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey],
|
294
302
|
rules: [{
|
295
303
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
296
304
|
}],
|
@@ -26,11 +26,11 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
26
26
|
/*
|
27
27
|
* @Author:wangxian
|
28
28
|
* @Date: 2021-09-18 14:15:04
|
29
|
-
* @LastEditTime: 2023-
|
29
|
+
* @LastEditTime: 2023-02-04 08:51:33
|
30
30
|
*/
|
31
31
|
import React from 'react';
|
32
32
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
33
|
-
import { useGetExtraInfo } from '../hooks';
|
33
|
+
import { useGetExtraInfo, useWatchDepend } from '../hooks';
|
34
34
|
import { MetadataService } from '../../../framework/metadata/MetadataService';
|
35
35
|
import { deepClone } from '../../../utils';
|
36
36
|
import { useAsyncMemo } from '../../../framework/hooks/use-async-memo';
|
@@ -38,7 +38,7 @@ import { tr } from '../../../framework/locale';
|
|
38
38
|
import useObservable from '../../../framework/rxjs-hooks/useObservable';
|
39
39
|
|
40
40
|
function Index(props) {
|
41
|
-
var _extraInfo$http6, _extraInfo$http7, _extraInfo$http8, _extraInfo$http9;
|
41
|
+
var _extraInfo$depend, _extraInfo$http6, _extraInfo$http7, _extraInfo$http8, _extraInfo$http9;
|
42
42
|
|
43
43
|
var id = props.id,
|
44
44
|
name = props.name,
|
@@ -67,6 +67,7 @@ function Index(props) {
|
|
67
67
|
var watchValueRef = React.useRef();
|
68
68
|
var pageRef = React.useRef(1);
|
69
69
|
var totalRef = React.useRef();
|
70
|
+
var depend = useWatchDepend(extraInfo.depend, formContext.stream$);
|
70
71
|
|
71
72
|
var onSelect = function onSelect(value) {
|
72
73
|
formContext.stream$ && formContext.stream$.next({
|
@@ -361,6 +362,14 @@ function Index(props) {
|
|
361
362
|
}
|
362
363
|
};
|
363
364
|
|
365
|
+
if (depend.hidden) {
|
366
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
367
|
+
}
|
368
|
+
|
369
|
+
if ((extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$depend = extraInfo.depend) === null || _extraInfo$depend === void 0 ? void 0 : _extraInfo$depend.show) && !depend.show) {
|
370
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
371
|
+
}
|
372
|
+
|
364
373
|
if (isObj && isRefForm && field) {
|
365
374
|
var _extraInfo$http4, _extraInfo$http5;
|
366
375
|
|
@@ -371,7 +380,6 @@ function Index(props) {
|
|
371
380
|
},
|
372
381
|
label: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id,
|
373
382
|
name: [field === null || field === void 0 ? void 0 : field.name].concat(_toConsumableArray(name)),
|
374
|
-
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey],
|
375
383
|
rules: [{
|
376
384
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
377
385
|
}],
|
@@ -399,7 +407,6 @@ function Index(props) {
|
|
399
407
|
paddingRight: '10px'
|
400
408
|
},
|
401
409
|
name: [field === null || field === void 0 ? void 0 : field.name],
|
402
|
-
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey],
|
403
410
|
rules: [{
|
404
411
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
405
412
|
}],
|
@@ -8,14 +8,14 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
8
8
|
/*
|
9
9
|
* @Author: wangxian
|
10
10
|
* @Date: 2021-09-18 14:15:04
|
11
|
-
* @LastEditTime:
|
11
|
+
* @LastEditTime: 2023-02-04 09:04:51
|
12
12
|
*/
|
13
13
|
import React from 'react';
|
14
14
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
15
|
-
import { useGetExtraInfo } from '../hooks';
|
15
|
+
import { useGetExtraInfo, useWatchDepend } from '../hooks';
|
16
16
|
|
17
17
|
function Index(props) {
|
18
|
-
var _extraInfo$disabled2, _extraInfo$disabled3;
|
18
|
+
var _extraInfo$depend, _extraInfo$disabled2, _extraInfo$disabled3;
|
19
19
|
|
20
20
|
var id = props.id,
|
21
21
|
name = props.name,
|
@@ -26,6 +26,15 @@ function Index(props) {
|
|
26
26
|
var formContext = React.useContext(MetadataFormContext) || {};
|
27
27
|
var formRefContext = React.useContext(MetadataRefContext);
|
28
28
|
var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form, props.type);
|
29
|
+
var depend = useWatchDepend(extraInfo.depend, formContext.stream$);
|
30
|
+
|
31
|
+
if (depend.hidden) {
|
32
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
33
|
+
}
|
34
|
+
|
35
|
+
if ((extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$depend = extraInfo.depend) === null || _extraInfo$depend === void 0 ? void 0 : _extraInfo$depend.show) && !depend.show) {
|
36
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
37
|
+
}
|
29
38
|
|
30
39
|
if (isObj && isRefForm && field) {
|
31
40
|
var _extraInfo$disabled;
|
@@ -38,7 +47,6 @@ function Index(props) {
|
|
38
47
|
label: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id,
|
39
48
|
name: [field === null || field === void 0 ? void 0 : field.name].concat(_toConsumableArray(name)),
|
40
49
|
valuePropName: "checked",
|
41
|
-
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey],
|
42
50
|
rules: [{
|
43
51
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
44
52
|
}],
|
@@ -76,7 +84,6 @@ function Index(props) {
|
|
76
84
|
},
|
77
85
|
name: [field === null || field === void 0 ? void 0 : field.name],
|
78
86
|
valuePropName: "checked",
|
79
|
-
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey],
|
80
87
|
rules: [{
|
81
88
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
82
89
|
}],
|
@@ -14,6 +14,7 @@ import useObservable from '../../../../framework/rxjs-hooks/useObservable';
|
|
14
14
|
import { MetadataFormContext } from '../../interface';
|
15
15
|
import { getLabelByProps } from '../../utils';
|
16
16
|
import { deepClone } from '../../../../utils';
|
17
|
+
import { STREAM_EVENT_TYPE } from '../../constants';
|
17
18
|
|
18
19
|
var TableArray = function TableArray(props) {
|
19
20
|
var initValue = props.initValue,
|
@@ -63,11 +64,17 @@ var TableArray = function TableArray(props) {
|
|
63
64
|
if ((p === null || p === void 0 ? void 0 : p.type) === 'onValuesChange') {
|
64
65
|
var _p$payload;
|
65
66
|
|
67
|
+
var val = _defineProperty({}, "".concat(name), _objectSpread({
|
68
|
+
rowIdx: p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : _p$payload.rowIdx
|
69
|
+
}, p.payload.values));
|
70
|
+
|
71
|
+
var allVals = form.getFieldsValue();
|
66
72
|
formContext.stream$.next({
|
67
|
-
type:
|
68
|
-
payload:
|
69
|
-
|
70
|
-
|
73
|
+
type: STREAM_EVENT_TYPE.ON_VALUES_CHANGE,
|
74
|
+
payload: {
|
75
|
+
val: val,
|
76
|
+
allVals: allVals
|
77
|
+
}
|
71
78
|
});
|
72
79
|
}
|
73
80
|
}, [tblStream]);
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/*
|
2
|
+
* @Author: wangxian
|
3
|
+
* @Date: 2023-02-03 09:08:06
|
4
|
+
* @LastEditTime: 2023-02-03 09:10:19
|
5
|
+
*/
|
6
|
+
export var STREAM_EVENT_TYPE = {
|
7
|
+
ON_SELECT_CHANGE: 'onSelectChange',
|
8
|
+
ON_BUTTON_CELL_CLICK: 'onButtonCellClick',
|
9
|
+
ON_VALUES_CHANGE: 'onValuesChange',
|
10
|
+
ON_WATCH_DEPEND: 'onWatchDepend'
|
11
|
+
};
|
@@ -5,11 +5,12 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
5
|
/*
|
6
6
|
* @Author: your name
|
7
7
|
* @Date: 2021-09-18 14:15:04
|
8
|
-
* @LastEditTime: 2023-
|
8
|
+
* @LastEditTime: 2023-02-04 10:43:01
|
9
9
|
*/
|
10
10
|
import { getLocale } from '../../../framework/locale';
|
11
11
|
import moment from 'moment';
|
12
|
-
import React from 'react';
|
12
|
+
import React from 'react';
|
13
|
+
import { STREAM_EVENT_TYPE } from '../constants'; // 主题样式名映射
|
13
14
|
|
14
15
|
var languageMap = {
|
15
16
|
'zh-CN': 'common',
|
@@ -54,4 +55,68 @@ export var useGetExtraInfo = function useGetExtraInfo(fields, id, form, type) {
|
|
54
55
|
}
|
55
56
|
}, [fields, form, id]);
|
56
57
|
return extra;
|
58
|
+
}; // 处理depend联动
|
59
|
+
|
60
|
+
export var useWatchDepend = function useWatchDepend(_depends, stream$) {
|
61
|
+
var _React$useState3 = React.useState({}),
|
62
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
63
|
+
depends = _React$useState4[0],
|
64
|
+
setDepends = _React$useState4[1];
|
65
|
+
|
66
|
+
var dependsRef = React.useRef({});
|
67
|
+
React.useEffect(function () {
|
68
|
+
if (_depends && stream$) {
|
69
|
+
stream$.subscribe(function (p) {
|
70
|
+
if ((p === null || p === void 0 ? void 0 : p.type) === STREAM_EVENT_TYPE.ON_VALUES_CHANGE) {
|
71
|
+
if (_depends === null || _depends === void 0 ? void 0 : _depends.hidden) {
|
72
|
+
var _p$payload;
|
73
|
+
|
74
|
+
var _hidden = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.hidden, p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : _p$payload.allVals, stream$);
|
75
|
+
|
76
|
+
var _dr = dependsRef.current;
|
77
|
+
_dr.hidden = _hidden;
|
78
|
+
setDepends(_objectSpread({}, _dr));
|
79
|
+
dependsRef.current = _dr;
|
80
|
+
}
|
81
|
+
|
82
|
+
if (_depends === null || _depends === void 0 ? void 0 : _depends.show) {
|
83
|
+
var _p$payload2;
|
84
|
+
|
85
|
+
var _show = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.show, p === null || p === void 0 ? void 0 : (_p$payload2 = p.payload) === null || _p$payload2 === void 0 ? void 0 : _p$payload2.allVals, stream$);
|
86
|
+
|
87
|
+
var _dr2 = dependsRef.current;
|
88
|
+
_dr2.show = _show;
|
89
|
+
setDepends(_objectSpread({}, _dr2));
|
90
|
+
dependsRef.current = _dr2;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
});
|
94
|
+
}
|
95
|
+
}, [_depends, stream$]);
|
96
|
+
return depends;
|
97
|
+
};
|
98
|
+
|
99
|
+
var processDependHiddenOrShow = function processDependHiddenOrShow(depend, changeData, stream$) {
|
100
|
+
try {
|
101
|
+
var regex = /\w+(\.\w+)?[=<>!]{1}/g;
|
102
|
+
var keys = depend.trim().match(regex);
|
103
|
+
var expression = depend;
|
104
|
+
|
105
|
+
for (var i = 0; i < keys.length; i++) {
|
106
|
+
var key = keys[i].substring(0, keys[i].length - 1); // 处理.length 之类的状况
|
107
|
+
|
108
|
+
var _key = key.split('.');
|
109
|
+
|
110
|
+
if (changeData[_key[0]]) {
|
111
|
+
var r = key === _key[0] ? "'".concat(changeData[_key[0]], "'") : eval("changeData[_key[0]].".concat(_key[1]));
|
112
|
+
expression = expression.replace(key, r);
|
113
|
+
} else {
|
114
|
+
expression = expression.replace(key, undefined);
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
return eval(expression);
|
119
|
+
} catch (error) {
|
120
|
+
console.error("useWatchDepend.expression is error", error);
|
121
|
+
}
|
57
122
|
};
|
@@ -13,6 +13,7 @@ import useMemoSubject from '../../framework/rxjs-hooks/useMemoSubject';
|
|
13
13
|
import useObservable from '../../framework/rxjs-hooks/useObservable';
|
14
14
|
import moment from 'moment';
|
15
15
|
import { DEFAULT_DATE_FORMAT } from './DataCell/Input';
|
16
|
+
import { STREAM_EVENT_TYPE } from './constants';
|
16
17
|
|
17
18
|
var MetadataForm = function MetadataForm(props) {
|
18
19
|
var _Form$useForm = _Form.useForm(),
|
@@ -62,14 +63,25 @@ var MetadataForm = function MetadataForm(props) {
|
|
62
63
|
var firstLoadRef = React.useRef(true);
|
63
64
|
var firstLoadForm = React.useRef(true);
|
64
65
|
var stream$ = useMemoSubject();
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
66
|
+
var processStreamEvent = React.useCallback(function (p) {
|
67
|
+
var _p$payload, _p$payload2;
|
68
|
+
|
69
|
+
switch (p === null || p === void 0 ? void 0 : p.type) {
|
70
|
+
case STREAM_EVENT_TYPE.ON_SELECT_CHANGE:
|
71
|
+
onSelectChange && onSelectChange(p.payload);
|
72
|
+
break;
|
73
|
+
|
74
|
+
case STREAM_EVENT_TYPE.ON_BUTTON_CELL_CLICK:
|
75
|
+
onCellButtonClick && onCellButtonClick(p.payload);
|
76
|
+
break;
|
77
|
+
|
78
|
+
case STREAM_EVENT_TYPE.ON_VALUES_CHANGE:
|
79
|
+
onValuesChange && onValuesChange(p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : _p$payload.val, p === null || p === void 0 ? void 0 : (_p$payload2 = p.payload) === null || _p$payload2 === void 0 ? void 0 : _p$payload2.allVals);
|
80
|
+
break;
|
72
81
|
}
|
82
|
+
}, []);
|
83
|
+
useObservable(function (p) {
|
84
|
+
processStreamEvent(p);
|
73
85
|
}, [stream$]);
|
74
86
|
var options = React.useMemo(function () {
|
75
87
|
return {
|
@@ -174,7 +186,13 @@ var MetadataForm = function MetadataForm(props) {
|
|
174
186
|
allValues[key[0]] = moment(value[key[0]]).format((extra === null || extra === void 0 ? void 0 : (_extra$text3 = extra.text) === null || _extra$text3 === void 0 ? void 0 : _extra$text3.format) || DEFAULT_DATE_FORMAT);
|
175
187
|
}
|
176
188
|
|
177
|
-
|
189
|
+
stream$.next({
|
190
|
+
type: STREAM_EVENT_TYPE.ON_VALUES_CHANGE,
|
191
|
+
payload: {
|
192
|
+
val: value,
|
193
|
+
allVals: allValues
|
194
|
+
}
|
195
|
+
});
|
178
196
|
};
|
179
197
|
|
180
198
|
var onMyFinish = function onMyFinish(values) {
|
@@ -48,3 +48,12 @@ export interface IMetaFormProps {
|
|
48
48
|
refId?: string;
|
49
49
|
};
|
50
50
|
}
|
51
|
+
export declare type IFiledDepend = {
|
52
|
+
hidden: string;
|
53
|
+
show: string;
|
54
|
+
};
|
55
|
+
export declare type IStreamEventType = 'onSelectChange' | 'onButtonCellClick' | 'onValuesChange' | 'onWatchDepend' | string;
|
56
|
+
export declare type IStreamEvent = {
|
57
|
+
type: IStreamEventType;
|
58
|
+
payload: any;
|
59
|
+
};
|
@@ -9,7 +9,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
9
9
|
/*
|
10
10
|
* @Author: wangxian
|
11
11
|
* @Date: 2021-09-18 14:15:04
|
12
|
-
* @LastEditTime:
|
12
|
+
* @LastEditTime: 2023-02-03 08:40:14
|
13
13
|
*/
|
14
14
|
import React from 'react';
|
15
15
|
import Input from './DataCell/Input';
|
package/es/theme.less
CHANGED
@@ -37,7 +37,7 @@
|
|
37
37
|
|
38
38
|
.ronds-metadata-normal {
|
39
39
|
--ronds-metadata-color-border-1: #d9d9d9;
|
40
|
-
--ronds-metadata-color-bg-2:
|
40
|
+
--ronds-metadata-color-bg-2: #ffffff;
|
41
41
|
--ronds-metadata-color-bg-4: #ffffff;
|
42
42
|
--ronds-metadata-color-text-1: #1d2129;
|
43
43
|
--ronds-metadata-color-text-2: #24292f;
|