ronds-metadata 1.0.53 → 1.0.56

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.
@@ -11,9 +11,12 @@ import { useGetExtraInfo } from '../hooks';
11
11
  import { getDataCell } from '../utils';
12
12
 
13
13
  function Index(props) {
14
+ var _fields$0$value;
15
+
14
16
  var id = props.id,
15
17
  items = props.items,
16
18
  isRefForm = props.isRefForm,
19
+ fields = props.fields,
17
20
  initEnumValue = props.initEnumValue,
18
21
  disabled = props.disabled;
19
22
  var formContext = React.useContext(MetadataFormContext) || {};
@@ -30,6 +33,7 @@ function Index(props) {
30
33
  setHelp(arr[arr.length - 1]);
31
34
  }
32
35
  }, [items]);
36
+ debugger;
33
37
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
34
38
  style: {
35
39
  position: 'relative',
@@ -39,7 +43,7 @@ function Index(props) {
39
43
  className: "ant-form-item-label mt-1"
40
44
  }, /*#__PURE__*/React.createElement("label", {
41
45
  className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
42
- }, extraInfo.label || id)), formContext.isShowTypeInfo && /*#__PURE__*/React.createElement("div", {
46
+ }, extraInfo.label || ((_fields$0$value = fields[0].value) === null || _fields$0$value === void 0 ? void 0 : _fields$0$value.label) || id)), formContext.isShowTypeInfo && /*#__PURE__*/React.createElement("div", {
43
47
  style: {
44
48
  padding: '0 6px',
45
49
  position: 'absolute',
@@ -55,7 +59,8 @@ function Index(props) {
55
59
  borderRadius: '4px'
56
60
  }
57
61
  }, /*#__PURE__*/React.createElement(_Form.List, {
58
- name: id
62
+ name: id,
63
+ key: id
59
64
  }, function (fields, _ref) {
60
65
  var add = _ref.add,
61
66
  remove = _ref.remove;
@@ -10,6 +10,12 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
10
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
11
11
  import "antd/es/input/style";
12
12
  import _Input from "antd/es/input";
13
+
14
+ /*
15
+ * @Author: wangxian
16
+ * @Date: 2021-09-18 14:15:04
17
+ * @LastEditTime: 2022-04-02 17:18:27
18
+ */
13
19
  import React from 'react';
14
20
  import { BgColorsOutlined } from '@ant-design/icons';
15
21
  import { SketchPicker } from 'react-color';
@@ -1,20 +1,19 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import "antd/es/form/style";
3
3
  import _Form from "antd/es/form";
4
+ import "antd/es/select/style";
5
+ import _Select from "antd/es/select";
4
6
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
7
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
6
8
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
9
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
8
10
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
9
- import "antd/es/select/style";
10
- import _Select from "antd/es/select";
11
11
  import React from 'react';
12
12
  import { MetadataService } from '../../../framework/metadata/MetadataService';
13
13
  import { MetadataFormContext, MetadataRefContext } from '../interface';
14
14
  import { useGetExtraInfo } from '../hooks';
15
15
  import { renderForm } from '../utils';
16
16
  import { JsonMetadataProvider } from '../../../framework/metadata';
17
- var Option = _Select.Option;
18
17
 
19
18
  function Index(props) {
20
19
  var _extraInfo$disabled, _extraInfo$disabled2;
@@ -94,10 +93,10 @@ function Index(props) {
94
93
  }, _callee);
95
94
  })), []);
96
95
  React.useEffect(function () {
97
- if (refId) {
96
+ if (refId && isRefForm) {
98
97
  onSearch();
99
98
  }
100
- }, [refId, onSearch]);
99
+ }, [refId, isRefForm, onSearch]);
101
100
  var formOptions = React.useMemo(function () {
102
101
  return {
103
102
  disabled: disabled,
@@ -124,9 +123,21 @@ function Index(props) {
124
123
  refFieldsRef.current = _fields;
125
124
  setRefFields(_objectSpread({}, _fields));
126
125
  setSchema(_toConsumableArray(mySchema));
126
+ return function () {
127
+ provider = null;
128
+ };
127
129
  }
130
+
131
+ return function () {
132
+ provider = null;
133
+ };
128
134
  });
135
+ return function () {
136
+ server = null;
137
+ };
129
138
  }
139
+
140
+ return function () {};
130
141
  }, [refId]);
131
142
  React.useEffect(function () {
132
143
  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(),
@@ -5,7 +5,7 @@ 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: 2021-12-03 16:00:13
8
+ * @LastEditTime: 2022-04-02 16:44:45
9
9
  * @LastEditors: Please set LastEditors
10
10
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
11
11
  * @FilePath: \ronds.metadata\src\comps\MetadataForm\hooks\index.tsx
@@ -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
  }
@@ -3,6 +3,7 @@ import { FormInstance } from 'antd/lib/form/hooks/useForm';
3
3
  export interface IMetadataFormContextProps {
4
4
  fields: any;
5
5
  form: FormInstance;
6
+ stream$: any;
6
7
  initialValues: any;
7
8
  isShowTypeInfo: boolean;
8
9
  }
@@ -29,6 +30,7 @@ export interface IMetaFormProps {
29
30
  isRefForm?: boolean;
30
31
  initEnumValue?: any;
31
32
  field?: any;
33
+ fields?: any[];
32
34
  name?: string[];
33
35
  isObj?: boolean;
34
36
  refId?: string;
@@ -1,3 +1,8 @@
1
+ /*
2
+ * @Author:wangxian
3
+ * @Date: 2021-09-18 14:15:04
4
+ * @LastEditTime: 2022-04-02 17:06:28
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 17:19:55
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({}, item, {
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,
@@ -1,20 +1,16 @@
1
1
  /*
2
2
  * @Author: wangxian
3
3
  * @Date: 2022-03-30 10:12:11
4
- * @LastEditTime: 2022-03-31 19:23:32
4
+ * @LastEditTime: 2022-04-01 08:15:21
5
5
  */
6
6
  import React from 'react';
7
7
  import { BehaviorSubject } from 'rxjs';
8
8
 
9
9
  var useMemoSubject = function useMemoSubject() {
10
- var subjectRef$ = React.useRef();
11
- React.useEffect(function () {
12
- subjectRef$.current = new BehaviorSubject(undefined);
13
- return function () {
14
- subjectRef$.current.complete();
15
- };
10
+ var subject$ = React.useMemo(function () {
11
+ return new BehaviorSubject(undefined);
16
12
  }, []);
17
- return subjectRef$.current;
13
+ return subject$;
18
14
  };
19
15
 
20
16
  export default useMemoSubject;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.0.53",
4
+ "version": "1.0.56",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",