ronds-metadata 1.0.52 → 1.0.55
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/Ref.js +12 -0
- package/es/comps/MetadataForm/DataCell/Select.js +18 -0
- package/es/comps/MetadataForm/HOC/index.js +9 -0
- package/es/comps/MetadataForm/index.d.ts +4 -0
- package/es/comps/MetadataForm/index.js +16 -1
- package/es/comps/MetadataForm/interface.d.ts +1 -0
- package/es/comps/MetadataForm/interface.js +5 -0
- package/es/comps/MetadataForm/utils.js +9 -1
- package/es/framework/rxjs-hooks/useMemoSubject.js +1 -1
- package/package.json +1 -1
@@ -124,9 +124,21 @@ function Index(props) {
|
|
124
124
|
refFieldsRef.current = _fields;
|
125
125
|
setRefFields(_objectSpread({}, _fields));
|
126
126
|
setSchema(_toConsumableArray(mySchema));
|
127
|
+
return function () {
|
128
|
+
provider = null;
|
129
|
+
};
|
127
130
|
}
|
131
|
+
|
132
|
+
return function () {
|
133
|
+
provider = null;
|
134
|
+
};
|
128
135
|
});
|
136
|
+
return function () {
|
137
|
+
server = null;
|
138
|
+
};
|
129
139
|
}
|
140
|
+
|
141
|
+
return function () {};
|
130
142
|
}, [refId]);
|
131
143
|
React.useEffect(function () {
|
132
144
|
if (refId) {
|
@@ -4,6 +4,13 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import "antd/es/select/style";
|
5
5
|
import _Select from "antd/es/select";
|
6
6
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
8
|
+
|
9
|
+
/*
|
10
|
+
* @Author:wangxian
|
11
|
+
* @Date: 2021-09-18 14:15:04
|
12
|
+
* @LastEditTime: 2022-04-01 17:07:41
|
13
|
+
*/
|
7
14
|
import React from 'react';
|
8
15
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
9
16
|
import { useGetExtraInfo } from '../hooks';
|
@@ -22,6 +29,14 @@ function Index(props) {
|
|
22
29
|
var formContext = React.useContext(MetadataFormContext) || {};
|
23
30
|
var formRefContext = React.useContext(MetadataRefContext);
|
24
31
|
var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form);
|
32
|
+
|
33
|
+
var onSelect = function onSelect(value) {
|
34
|
+
formContext.stream$ && formContext.stream$.next({
|
35
|
+
type: 'onSelectChange',
|
36
|
+
payload: _defineProperty({}, id, value)
|
37
|
+
});
|
38
|
+
};
|
39
|
+
|
25
40
|
var options = React.useMemo(function () {
|
26
41
|
var _options = [];
|
27
42
|
|
@@ -69,6 +84,7 @@ function Index(props) {
|
|
69
84
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
70
85
|
}), /*#__PURE__*/React.createElement(_Select, {
|
71
86
|
mode: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.mode,
|
87
|
+
onSelect: onSelect,
|
72
88
|
disabled: (_extraInfo$disabled = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled !== void 0 ? _extraInfo$disabled : disabled,
|
73
89
|
placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
|
74
90
|
options: options,
|
@@ -86,6 +102,7 @@ function Index(props) {
|
|
86
102
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
87
103
|
}, /*#__PURE__*/React.createElement(_Select, {
|
88
104
|
mode: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.mode,
|
105
|
+
onSelect: onSelect,
|
89
106
|
disabled: (_extraInfo$disabled2 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled2 !== void 0 ? _extraInfo$disabled2 : disabled,
|
90
107
|
placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
|
91
108
|
options: options,
|
@@ -104,6 +121,7 @@ function Index(props) {
|
|
104
121
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
105
122
|
}), /*#__PURE__*/React.createElement(_Select, {
|
106
123
|
mode: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.mode,
|
124
|
+
onSelect: onSelect,
|
107
125
|
disabled: (_extraInfo$disabled3 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled3 !== void 0 ? _extraInfo$disabled3 : disabled,
|
108
126
|
placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
|
109
127
|
options: options,
|
@@ -1,5 +1,11 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
3
|
+
|
4
|
+
/*
|
5
|
+
* @Author: wangxian
|
6
|
+
* @Date: 2021-09-18 14:15:04
|
7
|
+
* @LastEditTime: 2022-04-01 16:48:49
|
8
|
+
*/
|
3
9
|
import React from 'react';
|
4
10
|
import { deepClone } from '../../../utils';
|
5
11
|
import "./index.css";
|
@@ -24,6 +30,8 @@ export function withAddOnAfter(WrappedComponent) {
|
|
24
30
|
var arr = refId.split(':');
|
25
31
|
setHelp(arr[arr.length - 1]);
|
26
32
|
}
|
33
|
+
|
34
|
+
return function () {};
|
27
35
|
}, [refId]);
|
28
36
|
|
29
37
|
var _name = React.useMemo(function () {
|
@@ -37,6 +45,7 @@ export function withAddOnAfter(WrappedComponent) {
|
|
37
45
|
}, [id, name]);
|
38
46
|
|
39
47
|
return /*#__PURE__*/React.createElement("div", {
|
48
|
+
key: "".concat(_name.toString(), "_div"),
|
40
49
|
className: "with-add-on-after"
|
41
50
|
}, /*#__PURE__*/React.createElement(WrappedComponent, _extends({
|
42
51
|
key: _name.toString(),
|
@@ -42,6 +42,10 @@ interface IMetadataFormProps {
|
|
42
42
|
* 表单值的改变回调
|
43
43
|
*/
|
44
44
|
onValuesChange?: (changedValues: any, allValues: any) => void;
|
45
|
+
/**
|
46
|
+
* select选择的回调
|
47
|
+
*/
|
48
|
+
onSelectChange?: (changedValues: any) => void;
|
45
49
|
}
|
46
50
|
declare const MetadataForm: (props: IMetadataFormProps) => JSX.Element;
|
47
51
|
export default MetadataForm;
|
@@ -8,6 +8,8 @@ import "./index.css";
|
|
8
8
|
import { MetadataFormContext } from './interface';
|
9
9
|
import { JsonMetadataProvider } from '../../framework/metadata';
|
10
10
|
import { MetadataService } from '../../framework/metadata/MetadataService';
|
11
|
+
import useMemoSubject from '../../framework/rxjs-hooks/useMemoSubject';
|
12
|
+
import useObservable from '../../framework/rxjs-hooks/useObservable';
|
11
13
|
|
12
14
|
var MetadataForm = function MetadataForm(props) {
|
13
15
|
var _Form$useForm = _Form.useForm(),
|
@@ -26,7 +28,8 @@ var MetadataForm = function MetadataForm(props) {
|
|
26
28
|
initEnumValue = props.initEnumValue,
|
27
29
|
onFinish = props.onFinish,
|
28
30
|
getFormInstance = props.getFormInstance,
|
29
|
-
onValuesChange = props.onValuesChange
|
31
|
+
onValuesChange = props.onValuesChange,
|
32
|
+
onSelectChange = props.onSelectChange;
|
30
33
|
|
31
34
|
var _React$useState = React.useState([]),
|
32
35
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
@@ -38,6 +41,12 @@ var MetadataForm = function MetadataForm(props) {
|
|
38
41
|
fields = _React$useState4[0],
|
39
42
|
setFields = _React$useState4[1];
|
40
43
|
|
44
|
+
var stream$ = useMemoSubject();
|
45
|
+
useObservable(function (p) {
|
46
|
+
if ((p === null || p === void 0 ? void 0 : p.type) === 'onSelectChange') {
|
47
|
+
onSelectChange && onSelectChange(p.payload);
|
48
|
+
}
|
49
|
+
}, [stream$]);
|
41
50
|
var options = React.useMemo(function () {
|
42
51
|
return {
|
43
52
|
disabled: disabled,
|
@@ -78,12 +87,18 @@ var MetadataForm = function MetadataForm(props) {
|
|
78
87
|
var formCls = new FormCls();
|
79
88
|
var _fields = formCls.__type__.__fields__;
|
80
89
|
setFields(_fields);
|
90
|
+
return function () {
|
91
|
+
provider = null;
|
92
|
+
};
|
81
93
|
}
|
94
|
+
|
95
|
+
return function () {};
|
82
96
|
}, [mySchma]);
|
83
97
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MetadataFormContext.Provider, {
|
84
98
|
value: {
|
85
99
|
fields: fields,
|
86
100
|
form: form,
|
101
|
+
stream$: stream$,
|
87
102
|
initialValues: initialValues,
|
88
103
|
isShowTypeInfo: isShowTypeInfo
|
89
104
|
}
|
@@ -1,3 +1,8 @@
|
|
1
|
+
/*
|
2
|
+
* @Author:wangxian
|
3
|
+
* @Date: 2021-09-18 14:15:04
|
4
|
+
* @LastEditTime: 2022-04-01 16:58:54
|
5
|
+
*/
|
1
6
|
import React from 'react';
|
2
7
|
export var MetadataFormContext = /*#__PURE__*/React.createContext(null);
|
3
8
|
export var MetadataRefContext = /*#__PURE__*/React.createContext(null);
|
@@ -1,6 +1,12 @@
|
|
1
1
|
import "antd/es/spin/style";
|
2
2
|
import _Spin from "antd/es/spin";
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
4
|
+
|
5
|
+
/*
|
6
|
+
* @Author: wangxian
|
7
|
+
* @Date: 2021-09-18 14:15:04
|
8
|
+
* @LastEditTime: 2022-04-02 15:10:04
|
9
|
+
*/
|
4
10
|
import React from 'react';
|
5
11
|
import Input from './DataCell/Input';
|
6
12
|
import Number from './DataCell/Number';
|
@@ -20,7 +26,9 @@ var DataCellMap = {
|
|
20
26
|
export function getDataCell(item, options) {
|
21
27
|
if (item.type && DataCellMap[item.type]) {
|
22
28
|
var Comm = DataCellMap[item.type];
|
23
|
-
return /*#__PURE__*/React.createElement(Comm, _extends({
|
29
|
+
return /*#__PURE__*/React.createElement(Comm, _extends({
|
30
|
+
key: item.id
|
31
|
+
}, item, {
|
24
32
|
disabled: options.disabled,
|
25
33
|
isRefForm: options.isRefForm,
|
26
34
|
isShowTypeInfo: options.isShowTypeInfo,
|