ronds-metadata 1.0.88 → 1.0.91

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.
@@ -6,7 +6,7 @@ import _Input from "antd/es/input";
6
6
  /*
7
7
  * @Author: wangxian
8
8
  * @Date: 2022-03-04 14:53:50
9
- * @LastEditTime: 2022-03-10 14:38:32
9
+ * @LastEditTime: 2022-05-12 11:06:36
10
10
  */
11
11
  import React from 'react';
12
12
  import { EditableContext } from '../interface';
@@ -46,6 +46,7 @@ function Index(props) {
46
46
  }
47
47
  }, /*#__PURE__*/React.createElement(_Input, {
48
48
  ref: inputRef,
49
+ size: "small",
49
50
  disabled: editConfig.type === 'edit' ? disabled : false
50
51
  }));
51
52
  }
@@ -35,6 +35,7 @@ function Index(props) {
35
35
  margin: 0
36
36
  }
37
37
  }, /*#__PURE__*/React.createElement(_InputNumber, {
38
+ size: "small",
38
39
  ref: inputRef,
39
40
  disabled: editConfig.type === 'edit' ? disabled : false
40
41
  }));
@@ -8,7 +8,7 @@ var _excluded = ["dataIndex", "disabled"];
8
8
  /*
9
9
  * @Author: wangxian
10
10
  * @Date: 2022-03-04 14:53:50
11
- * @LastEditTime: 2022-03-08 14:14:18
11
+ * @LastEditTime: 2022-05-12 11:07:04
12
12
  */
13
13
  import React from 'react';
14
14
  import { EditableContext } from '../interface';
@@ -28,6 +28,7 @@ function Index(props) {
28
28
  }
29
29
  }, /*#__PURE__*/React.createElement(_Select, {
30
30
  disabled: editConfig.type === 'edit' ? disabled : false,
31
+ size: "small",
31
32
  style: {
32
33
  width: '100%'
33
34
  },
@@ -6,7 +6,7 @@ import _Switch from "antd/es/switch";
6
6
  /*
7
7
  * @Author: wangxian
8
8
  * @Date: 2022-03-04 14:53:50
9
- * @LastEditTime: 2022-03-08 14:14:22
9
+ * @LastEditTime: 2022-05-12 11:07:09
10
10
  */
11
11
  import React from 'react';
12
12
  import { EditableContext } from '../interface';
@@ -25,6 +25,7 @@ function Index(props) {
25
25
  margin: 0
26
26
  }
27
27
  }, /*#__PURE__*/React.createElement(_Switch, {
28
+ size: "small",
28
29
  disabled: editConfig.type === 'edit' ? disabled : false
29
30
  }));
30
31
  }
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import "antd/es/message/style";
3
3
  import _message from "antd/es/message";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["title", "isAddColumn", "editable", "record", "editableType", "dataIndex", "rowIndex", "children"];
5
+ var _excluded = ["title", "isAddColumn", "editable", "record", "editableType", "dataIndex", "rowIndex", "children", "className"];
6
6
  import React from 'react';
7
7
  import { EditableContext } from '../interface';
8
8
  import { getDataCell, isFreeEditCell, isFreeEditRow } from '../utils';
@@ -19,6 +19,7 @@ var EditableCell = function EditableCell(props) {
19
19
  dataIndex = props.dataIndex,
20
20
  rowIndex = props.rowIndex,
21
21
  children = props.children,
22
+ className = props.className,
22
23
  restProps = _objectWithoutProperties(props, _excluded);
23
24
 
24
25
  var _ref = React.useContext(EditableContext) || undefined,
@@ -62,7 +63,7 @@ var EditableCell = function EditableCell(props) {
62
63
 
63
64
  if (restProps === null || restProps === void 0 ? void 0 : restProps.colSpan) {
64
65
  return /*#__PURE__*/React.createElement("td", _extends({}, restProps, {
65
- className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " "),
66
+ className: "".concat(className, " ").concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " "),
66
67
  style: {
67
68
  border: 0
68
69
  }
@@ -71,7 +72,7 @@ var EditableCell = function EditableCell(props) {
71
72
 
72
73
  if (editableType === 'single') {
73
74
  return /*#__PURE__*/React.createElement("td", _extends({}, restProps, {
74
- className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
75
+ className: "".concat(className, " ").concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
75
76
  }), editable && editConfig.curRow === rowIndex ? getDataCell(props) : /*#__PURE__*/React.createElement(Texty, {
76
77
  tooltipStyle: {
77
78
  wordWrap: 'break-word'
@@ -85,7 +86,7 @@ var EditableCell = function EditableCell(props) {
85
86
  onDoubleClick: onCellDoubleClick,
86
87
  onClick: onCellClick
87
88
  }, restProps, {
88
- className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
89
+ className: "".concat(className, " ").concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
89
90
  }), editable && (isFreeEditRow(editConfig.curRow, rowIndex) || isFreeEditCell(editConfig.editCellKey, dataIndex, rowIndex)) ? getDataCell(props) : /*#__PURE__*/React.createElement(Texty, {
90
91
  tooltipStyle: {
91
92
  wordWrap: 'break-word'
@@ -95,7 +96,7 @@ var EditableCell = function EditableCell(props) {
95
96
  }
96
97
 
97
98
  return /*#__PURE__*/React.createElement("td", _extends({}, restProps, {
98
- className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
99
+ className: "".concat(className, " ").concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
99
100
  }), editable ? getDataCell(props) : /*#__PURE__*/React.createElement(Texty, {
100
101
  tooltipStyle: {
101
102
  wordWrap: 'break-word'
@@ -10,7 +10,7 @@ import _Input from "antd/es/input";
10
10
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
11
11
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
12
12
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
13
- var _excluded = ["title", "dataIndex", "isAddColumn", "children"];
13
+ var _excluded = ["title", "dataIndex", "isAddColumn", "children", "className"];
14
14
  import { PlusSquareOutlined, DeleteOutlined } from '@ant-design/icons';
15
15
  import React from 'react';
16
16
  import { EditableContext } from '../interface';
@@ -23,6 +23,7 @@ var EditableHeardCell = function EditableHeardCell(props) {
23
23
  dataIndex = props.dataIndex,
24
24
  isAddColumn = props.isAddColumn,
25
25
  children = props.children,
26
+ className = props.className,
26
27
  restProps = _objectWithoutProperties(props, _excluded);
27
28
 
28
29
  var _ref = React.useContext(EditableContext) || undefined,
@@ -129,7 +130,7 @@ var EditableHeardCell = function EditableHeardCell(props) {
129
130
  };
130
131
 
131
132
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("th", _extends({}, restProps, {
132
- className: "ant-table-th font-bold ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right ' : '', " ")
133
+ className: "".concat(className, " ant-table-th font-bold ").concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right ' : '', " ")
133
134
  }), isAddColumn && /*#__PURE__*/React.createElement(_Popover, {
134
135
  placement: "rightTop",
135
136
  content: content,
@@ -2,6 +2,9 @@
2
2
  width: 100%;
3
3
  height: 100%;
4
4
  }
5
+ .ronds-edit-table table {
6
+ border-collapse: collapse !important;
7
+ }
5
8
  .ronds-edit-table .ant-spin-nested-loading,
6
9
  .ronds-edit-table .ant-spin-container,
7
10
  .ronds-edit-table .ant-table,
@@ -15,7 +18,12 @@
15
18
  height: 30px;
16
19
  padding: 0px 8px !important;
17
20
  }
21
+ .ronds-edit-table .ant-table-cell-fix-right {
22
+ position: sticky !important;
23
+ right: 0 !important;
24
+ }
18
25
  .ronds-edit-table .ant-table-body {
26
+ height: 100%;
19
27
  overflow-y: auto !important;
20
28
  }
21
29
  .ronds-edit-table .ant-table.ant-table-small .ant-table-thead > tr > th {
@@ -37,3 +45,26 @@
37
45
  padding: 0% !important;
38
46
  margin: 0% !important;
39
47
  }
48
+ .ronds-edit-table .ant-table.ant-table-bordered > .ant-table-container > .ant-table-body > table > tbody > tr > td > .ant-table-expanded-row-fixed::after {
49
+ border-right: 0 !important;
50
+ }
51
+ .ronds-metadata-normal .ant-table {
52
+ border-right: 1px solid #f0f0f0 !important;
53
+ }
54
+ .ronds-metadata-normal .ant-table .ant-table-row--odd {
55
+ background-color: #ebebeb !important;
56
+ }
57
+ .ronds-metadata-normal .ant-table .ant-table-row--odd .ant-table-cell {
58
+ background-color: #ebebeb !important;
59
+ }
60
+ .ronds-metadata-normal .ant-table .ant-table-expanded-row-fixed::after {
61
+ border: 0 !important;
62
+ }
63
+ .ronds-metadata-normal .ant-table .ant-table-placeholder {
64
+ pointer-events: none;
65
+ background-color: #fff !important;
66
+ }
67
+ .ronds-metadata-normal .ant-table .ant-table-placeholder .ant-table-cell {
68
+ padding: 0 !important;
69
+ background-color: #fff !important;
70
+ }
@@ -169,6 +169,7 @@ var Editable = function Editable(props) {
169
169
 
170
170
  setRecords(_toConsumableArray(_records3));
171
171
  recordsRef.current = _records3;
172
+ onMulChange && onMulChange(_records3);
172
173
  }
173
174
 
174
175
  if (type === 'freedom') {
@@ -276,9 +277,7 @@ var Editable = function Editable(props) {
276
277
  rowIndex: rowIndex
277
278
  });
278
279
  };
279
- }
280
280
 
281
- if (isAddColumn) {
282
281
  _column.onHeaderCell = function (col) {
283
282
  return _objectSpread({
284
283
  width: col.width,
@@ -299,9 +298,9 @@ var Editable = function Editable(props) {
299
298
  var _aciton_ = {
300
299
  dataKey: '_aciton_',
301
300
  title: tr('操作'),
302
- width: 40,
301
+ width: type === 'multiple' ? 50 : 100,
303
302
  ellipsis: true,
304
- fixed: 'left',
303
+ fixed: 'right',
305
304
  render: function render(val, record) {
306
305
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditableAction, {
307
306
  type: type,
@@ -288,7 +288,7 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
288
288
  var _defaultValues$index;
289
289
 
290
290
  return /*#__PURE__*/React.createElement("div", {
291
- key: field.key
291
+ key: "".concat(field.key)
292
292
  }, /*#__PURE__*/React.createElement("div", {
293
293
  style: {
294
294
  display: 'flex',
@@ -388,13 +388,14 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
388
388
  }
389
389
  }))), (refIds[index] || refSchema[index]) && /*#__PURE__*/React.createElement("div", {
390
390
  style: {
391
- border: 'var(--ronds-metadata-color-border-1)',
391
+ border: '1px solid var(--ronds-metadata-color-border-1)',
392
392
  padding: '10px',
393
393
  marginBottom: '10px'
394
394
  }
395
395
  }, /*#__PURE__*/React.createElement(MetadataForm, {
396
396
  initialValues: defaultValues && defaultValues.length > 0 && ((_defaultValues$index = defaultValues[index]) === null || _defaultValues$index === void 0 ? void 0 : _defaultValues$index.value),
397
397
  refId: refIds[index],
398
+ isFoldForm: true,
398
399
  schema: refSchema[index],
399
400
  onValuesChange: function onValuesChange(values, allValues) {
400
401
  onRefRulesValuesChange(allValues, index);
@@ -62,6 +62,7 @@ var MetaPropsEdit = function MetaPropsEdit(props) {
62
62
  alignItems: 'flex-end'
63
63
  }
64
64
  }, /*#__PURE__*/React.createElement(_Form.Item, _extends({
65
+ key: field.key,
65
66
  className: "pr-10"
66
67
  }, field, {
67
68
  label: "\u5C5E\u6027\u540D\u79F0",
@@ -70,7 +71,9 @@ var MetaPropsEdit = function MetaPropsEdit(props) {
70
71
  rules: [{
71
72
  required: true
72
73
  }]
73
- }), /*#__PURE__*/React.createElement(_Input, null)), /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
74
+ }), /*#__PURE__*/React.createElement(_Input, null)), /*#__PURE__*/React.createElement(_Form.Item, _extends({
75
+ key: field.key
76
+ }, field, {
74
77
  label: "\u5C5E\u6027\u7C7B\u578B",
75
78
  name: [field.name, 'type'],
76
79
  fieldKey: [field.fieldKey, 'type'],
@@ -8,7 +8,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
8
8
  /*
9
9
  * @Author: wangxian
10
10
  * @Date: 2021-09-18 14:15:04
11
- * @LastEditTime: 2022-05-11 10:59:56
11
+ * @LastEditTime: 2022-05-14 08:29:16
12
12
  */
13
13
  import React from 'react';
14
14
  import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
@@ -16,7 +16,8 @@ import { MetadataFormContext } from '../interface';
16
16
  import { useGetExtraInfo } from '../hooks';
17
17
  import { getDataCell } from '../utils';
18
18
  import { deepClone } from '../../../utils';
19
- import { tr } from '@/framework/locale';
19
+ import { tr } from '../../../framework/locale';
20
+ import TableArray from './layout/TableArray';
20
21
 
21
22
  function Index(props) {
22
23
  var _fieldRule$, _fieldRule$$value;
@@ -71,7 +72,12 @@ function Index(props) {
71
72
  top: '19px',
72
73
  background: '#fff'
73
74
  }
74
- }, help || (items === null || items === void 0 ? void 0 : items.type))), /*#__PURE__*/React.createElement("div", {
75
+ }, help || (items === null || items === void 0 ? void 0 : items.type))), extraInfo.layout === 'table' && items.type === 'ref' ? /*#__PURE__*/React.createElement(TableArray, {
76
+ initValue: formContext.initialValues,
77
+ refId: items.refId,
78
+ form: formContext.form,
79
+ name: id
80
+ }) : /*#__PURE__*/React.createElement("div", {
75
81
  style: {
76
82
  padding: '10px',
77
83
  border: '1px solid var(--ronds-metadata-color-border-1)',
@@ -8,21 +8,15 @@ import "antd/es/button/style";
8
8
  import _Button from "antd/es/button";
9
9
  import "antd/es/date-picker/style";
10
10
  import _DatePicker from "antd/es/date-picker";
11
- import "antd/es/popover/style";
12
- import _Popover from "antd/es/popover";
13
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
14
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
15
11
  import "antd/es/input/style";
16
12
  import _Input from "antd/es/input";
17
13
 
18
14
  /*
19
15
  * @Author: wangxian
20
16
  * @Date: 2021-09-18 14:15:04
21
- * @LastEditTime: 2022-05-05 09:34:40
17
+ * @LastEditTime: 2022-05-16 09:24:21
22
18
  */
23
19
  import React from 'react';
24
- import { BgColorsOutlined } from '@ant-design/icons';
25
- import { SketchPicker } from 'react-color';
26
20
  import { UploadOutlined } from '@ant-design/icons';
27
21
  import { MetadataFormContext, MetadataRefContext } from '../interface';
28
22
  import { useGetExtraInfo } from '../hooks';
@@ -39,27 +33,6 @@ function Index(props) {
39
33
  var formRefContext = React.useContext(MetadataRefContext);
40
34
  var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form, props.type);
41
35
 
42
- var _React$useState = React.useState(''),
43
- _React$useState2 = _slicedToArray(_React$useState, 2),
44
- color = _React$useState2[0],
45
- setColor = _React$useState2[1];
46
-
47
- React.useEffect(function () {
48
- if ((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.type) === 'colorPicker') {
49
- setColor(formContext.form.getFieldValue(id));
50
- }
51
- }, [extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.type, formContext.form]);
52
-
53
- var onColorChange = function onColorChange(e) {
54
- formContext.form.setFieldsValue(_defineProperty({}, id, e.hex));
55
- setColor(e.hex);
56
- };
57
-
58
- var colorPicker = /*#__PURE__*/React.createElement(SketchPicker, {
59
- color: color,
60
- onChange: onColorChange
61
- });
62
-
63
36
  var processInputType = function processInputType(_type) {
64
37
  var _extraInfo$disabled, _extraInfo$disabled2, _extraInfo$disabled3, _extraInfo$disabled4, _extraInfo$disabled5;
65
38
 
@@ -78,22 +51,11 @@ function Index(props) {
78
51
  });
79
52
 
80
53
  case 'colorPicker':
81
- return /*#__PURE__*/React.createElement("div", {
82
- className: "flex relative"
83
- }, /*#__PURE__*/React.createElement(_Input, {
84
- value: color,
54
+ return /*#__PURE__*/React.createElement(_Input, {
55
+ type: "color",
85
56
  disabled: (_extraInfo$disabled3 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled3 !== void 0 ? _extraInfo$disabled3 : disabled,
86
57
  placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder
87
- }), /*#__PURE__*/React.createElement("div", {
88
- style: {
89
- position: 'absolute',
90
- right: '5px',
91
- top: '5px',
92
- zIndex: 888
93
- }
94
- }, /*#__PURE__*/React.createElement(_Popover, {
95
- content: colorPicker
96
- }, /*#__PURE__*/React.createElement(BgColorsOutlined, null))));
58
+ });
97
59
 
98
60
  case 'datePicker':
99
61
  return /*#__PURE__*/React.createElement(_DatePicker, {
@@ -136,6 +98,11 @@ function Index(props) {
136
98
  }
137
99
 
138
100
  return !field ? /*#__PURE__*/React.createElement(_Form.Item, {
101
+ key: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
102
+ initialValue: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
103
+ style: {
104
+ display: "".concat(extraInfo.hidden ? 'none' : 'block')
105
+ },
139
106
  label: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id,
140
107
  name: name,
141
108
  rules: [{
@@ -44,6 +44,11 @@ function Index(props) {
44
44
  }
45
45
 
46
46
  return !field ? /*#__PURE__*/React.createElement(_Form.Item, {
47
+ key: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
48
+ initialValue: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
49
+ style: {
50
+ display: "".concat(extraInfo.hidden ? 'none' : 'block')
51
+ },
47
52
  label: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id,
48
53
  name: name,
49
54
  rules: [{
@@ -3,12 +3,15 @@ import "antd/es/form/style";
3
3
  import _Form from "antd/es/form";
4
4
  import "antd/es/select/style";
5
5
  import _Select from "antd/es/select";
6
+ import "antd/es/button/style";
7
+ import _Button from "antd/es/button";
6
8
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
7
9
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
8
10
  import _regeneratorRuntime from "@babel/runtime/regenerator";
9
11
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
10
12
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
11
13
  import React from 'react';
14
+ import { CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons';
12
15
  import { MetadataService } from '../../../framework/metadata/MetadataService';
13
16
  import { MetadataFormContext, MetadataRefContext } from '../interface';
14
17
  import { useGetExtraInfo } from '../hooks';
@@ -26,29 +29,34 @@ function Index(props) {
26
29
  field = props.field,
27
30
  name = props.name;
28
31
  var formContext = React.useContext(MetadataFormContext) || {};
29
- var extraInfo = useGetExtraInfo(formContext.fields, id, formContext.form, props.type);
32
+ var extraInfo = useGetExtraInfo(formContext.fields, id, formContext.form, props.type); // 是否折叠
30
33
 
31
- var _React$useState = React.useState([]),
34
+ var _React$useState = React.useState(true),
32
35
  _React$useState2 = _slicedToArray(_React$useState, 2),
33
- schema = _React$useState2[0],
34
- setSchema = _React$useState2[1];
36
+ isFold = _React$useState2[0],
37
+ setIsFold = _React$useState2[1];
35
38
 
36
- var _React$useState3 = React.useState({}),
39
+ var _React$useState3 = React.useState([]),
37
40
  _React$useState4 = _slicedToArray(_React$useState3, 2),
38
- refFields = _React$useState4[0],
39
- setRefFields = _React$useState4[1];
41
+ schema = _React$useState4[0],
42
+ setSchema = _React$useState4[1];
40
43
 
41
- var refFieldsRef = React.useRef(refFields);
42
-
43
- var _React$useState5 = React.useState([]),
44
+ var _React$useState5 = React.useState({}),
44
45
  _React$useState6 = _slicedToArray(_React$useState5, 2),
45
- options = _React$useState6[0],
46
- setOptions = _React$useState6[1];
46
+ refFields = _React$useState6[0],
47
+ setRefFields = _React$useState6[1];
47
48
 
48
- var _React$useState7 = React.useState(''),
49
+ var refFieldsRef = React.useRef(refFields);
50
+
51
+ var _React$useState7 = React.useState([]),
49
52
  _React$useState8 = _slicedToArray(_React$useState7, 2),
50
- help = _React$useState8[0],
51
- setHelp = _React$useState8[1];
53
+ options = _React$useState8[0],
54
+ setOptions = _React$useState8[1];
55
+
56
+ var _React$useState9 = React.useState(''),
57
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
58
+ help = _React$useState10[0],
59
+ setHelp = _React$useState10[1];
52
60
 
53
61
  var onSearch = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
54
62
  var param, server, res, _options, i, obj;
@@ -148,19 +156,32 @@ function Index(props) {
148
156
 
149
157
  if (isRefForm && !field && schema.length > 0) {
150
158
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
159
+ style: {
160
+ display: 'flex',
161
+ alignItems: 'center'
162
+ }
163
+ }, /*#__PURE__*/React.createElement("div", {
151
164
  className: "ant-form-item-label",
152
165
  style: {
153
166
  width: '100%',
154
- textAlign: 'left'
167
+ textAlign: 'left',
168
+ flex: '1'
155
169
  }
156
170
  }, /*#__PURE__*/React.createElement("label", {
157
171
  className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
158
- }, extraInfo.label || id)), /*#__PURE__*/React.createElement("div", {
172
+ }, extraInfo.label || id)), formContext.isFoldForm && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, {
173
+ type: "link",
174
+ onClick: function onClick() {
175
+ setIsFold(!isFold);
176
+ },
177
+ icon: isFold ? /*#__PURE__*/React.createElement(CaretDownOutlined, null) : /*#__PURE__*/React.createElement(CaretUpOutlined, null)
178
+ }))), /*#__PURE__*/React.createElement("div", {
159
179
  style: {
160
180
  padding: '10px',
161
181
  border: '1px solid var(--ronds-metadata-color-border-1)',
162
182
  width: '100%',
163
- borderRadius: '4px'
183
+ borderRadius: '4px',
184
+ display: "".concat(isFold ? 'none' : 'block')
164
185
  }
165
186
  }, /*#__PURE__*/React.createElement(MetadataRefContext.Provider, {
166
187
  value: {
@@ -185,7 +206,12 @@ function Index(props) {
185
206
  }
186
207
 
187
208
  return !field ? /*#__PURE__*/React.createElement(_Form.Item, {
209
+ key: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
188
210
  label: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id,
211
+ initialValue: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
212
+ style: {
213
+ display: "".concat(extraInfo.hidden ? 'none' : 'block')
214
+ },
189
215
  name: id,
190
216
  rules: [{
191
217
  required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
@@ -9,7 +9,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
9
  /*
10
10
  * @Author:wangxian
11
11
  * @Date: 2021-09-18 14:15:04
12
- * @LastEditTime: 2022-05-10 16:14:43
12
+ * @LastEditTime: 2022-05-11 16:41:22
13
13
  */
14
14
  import React from 'react';
15
15
  import { MetadataFormContext, MetadataRefContext } from '../interface';
@@ -93,6 +93,11 @@ function Index(props) {
93
93
  }
94
94
 
95
95
  return !field ? /*#__PURE__*/React.createElement(_Form.Item, {
96
+ key: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
97
+ initialValue: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
98
+ style: {
99
+ display: "".concat(extraInfo.hidden ? 'none' : 'block')
100
+ },
96
101
  label: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id,
97
102
  name: name,
98
103
  rules: [{
@@ -8,7 +8,7 @@ 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: 2022-05-05 09:37:53
11
+ * @LastEditTime: 2022-05-11 16:41:29
12
12
  */
13
13
  import React from 'react';
14
14
  import { MetadataFormContext, MetadataRefContext } from '../interface';
@@ -53,6 +53,11 @@ function Index(props) {
53
53
 
54
54
  return !field ? /*#__PURE__*/React.createElement(_Form.Item, {
55
55
  label: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id,
56
+ key: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
57
+ initialValue: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
58
+ style: {
59
+ display: "".concat(extraInfo.hidden ? 'none' : 'block')
60
+ },
56
61
  name: name,
57
62
  valuePropName: "checked",
58
63
  rules: [{
@@ -0,0 +1,9 @@
1
+ import { FormInstance } from 'antd';
2
+ interface ITableArrayProps {
3
+ name: string;
4
+ form: FormInstance;
5
+ refId: string;
6
+ initValue: any;
7
+ }
8
+ declare const TableArray: (props: ITableArrayProps) => JSX.Element;
9
+ export default TableArray;
@@ -0,0 +1,146 @@
1
+ import "antd/es/form/style";
2
+ import _Form from "antd/es/form";
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
6
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
7
+ import React, { useRef } from 'react';
8
+ import { MetadataService } from '../../../../framework/metadata/MetadataService';
9
+ import { JsonMetadataProvider } from '../../../../framework/metadata';
10
+ import Editable from '../../../../comps/Editable';
11
+
12
+ var TableArray = function TableArray(props) {
13
+ var initValue = props.initValue,
14
+ name = props.name,
15
+ form = props.form,
16
+ refId = props.refId;
17
+
18
+ var _React$useState = React.useState([]),
19
+ _React$useState2 = _slicedToArray(_React$useState, 2),
20
+ schema = _React$useState2[0],
21
+ setSchema = _React$useState2[1];
22
+
23
+ var _React$useState3 = React.useState({}),
24
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
25
+ defaultValue = _React$useState4[0],
26
+ setDefaultValue = _React$useState4[1];
27
+
28
+ var _React$useState5 = React.useState({}),
29
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
30
+ refFields = _React$useState6[0],
31
+ setRefFields = _React$useState6[1];
32
+
33
+ var refFieldsRef = React.useRef(refFields);
34
+ var firstLoadRef = useRef(true);
35
+
36
+ var _React$useState7 = React.useState([]),
37
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
38
+ list = _React$useState8[0],
39
+ setList = _React$useState8[1];
40
+
41
+ React.useEffect(function () {
42
+ if (refId) {
43
+ var server = new MetadataService();
44
+ server.GetMetadataDetailById(refId).then(function (res) {
45
+ var provider = new JsonMetadataProvider();
46
+
47
+ if (res === null || res === void 0 ? void 0 : res.schema) {
48
+ var mySchema = JSON.parse(res.schema);
49
+ provider.add_types(mySchema);
50
+ var FormCls = provider.get_type(mySchema[0].id);
51
+ var formCls = new FormCls();
52
+ var _fields = formCls.__type__.__fields__;
53
+ refFieldsRef.current = _fields;
54
+ setRefFields(_objectSpread({}, _fields));
55
+ setSchema(_toConsumableArray(mySchema));
56
+ setDefaultValue(_objectSpread({}, JSON.parse(JSON.stringify(formCls))));
57
+ return function () {
58
+ provider = null;
59
+ };
60
+ }
61
+
62
+ return function () {
63
+ provider = null;
64
+ };
65
+ });
66
+ return function () {
67
+ server = null;
68
+ };
69
+ }
70
+
71
+ return function () {};
72
+ }, [refId]);
73
+ React.useEffect(function () {
74
+ if (initValue && firstLoadRef.current) {
75
+ setList(_toConsumableArray(initValue[name]));
76
+ firstLoadRef.current = false;
77
+ }
78
+ }, [initValue, form]);
79
+ var processSchemaToColumns = React.useCallback(function (_properties) {
80
+ var _columns = [];
81
+
82
+ for (var i = 0; i < _properties.length; i++) {
83
+ var _it$fields$0$value, _it$fields$0$value$co, _it$fields$0$value2;
84
+
85
+ var it = _properties[i];
86
+ var obj = {
87
+ title: (it === null || it === void 0 ? void 0 : (_it$fields$0$value = it.fields[0].value) === null || _it$fields$0$value === void 0 ? void 0 : (_it$fields$0$value$co = _it$fields$0$value.common) === null || _it$fields$0$value$co === void 0 ? void 0 : _it$fields$0$value$co.label) || (it === null || it === void 0 ? void 0 : (_it$fields$0$value2 = it.fields[0].value) === null || _it$fields$0$value2 === void 0 ? void 0 : _it$fields$0$value2.label) || it.id,
88
+ key: it.id,
89
+ dataIndex: it.id,
90
+ width: 100,
91
+ editable: true,
92
+ type: it.type,
93
+ enum: it.type === 'enum' ? it.enum.map(function (v) {
94
+ return {
95
+ label: v.value,
96
+ value: v.value
97
+ };
98
+ }) : undefined
99
+ };
100
+
101
+ _columns.push(obj);
102
+ }
103
+
104
+ return _columns;
105
+ }, []);
106
+ var columns = React.useMemo(function () {
107
+ var _columns = [];
108
+
109
+ if (schema.length > 0) {
110
+ _columns = processSchemaToColumns(schema[0].properties);
111
+ }
112
+
113
+ return _columns;
114
+ }, [schema, processSchemaToColumns]);
115
+
116
+ var onTableChange = function onTableChange(values) {
117
+ form.setFieldsValue(_objectSpread({}, _defineProperty({}, "".concat(name), values)));
118
+ };
119
+
120
+ return /*#__PURE__*/React.createElement("div", {
121
+ style: {
122
+ width: '100%',
123
+ height: '340px'
124
+ }
125
+ }, /*#__PURE__*/React.createElement(_Form.Item, {
126
+ name: name,
127
+ style: {
128
+ margin: 0
129
+ }
130
+ }, /*#__PURE__*/React.createElement(Editable, {
131
+ type: "multiple",
132
+ defaultValue: defaultValue,
133
+ addPosition: "bottom",
134
+ columns: columns,
135
+ dataSource: list,
136
+ onMulChange: onTableChange,
137
+ tableProps: {
138
+ scroll: {
139
+ x: '100%',
140
+ y: '300px'
141
+ }
142
+ }
143
+ })));
144
+ };
145
+
146
+ export default TableArray;
@@ -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: 2022-05-11 10:36:05
8
+ * @LastEditTime: 2022-05-11 16:07:30
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
@@ -37,7 +37,12 @@ export var useGetExtraInfo = function useGetExtraInfo(fields, id, form, type) {
37
37
  }
38
38
 
39
39
  // 兼容 common公共的属性
40
- _extraInfo = _objectSpread(_objectSpread(_objectSpread({}, _extraInfo), _extraInfo[languageMap[getLocale()]]), _extraInfo[type]);
40
+ if (_extraInfo['common-en-US']) {
41
+ _extraInfo = _objectSpread(_objectSpread(_objectSpread({}, _extraInfo), _extraInfo[languageMap[getLocale()]]), _extraInfo[type]);
42
+ } else {
43
+ _extraInfo = _objectSpread(_objectSpread(_objectSpread({}, _extraInfo), _extraInfo.common), _extraInfo[type]);
44
+ }
45
+
41
46
  delete _extraInfo.common;
42
47
  delete _extraInfo['common-en-US'];
43
48
  delete _extraInfo[type];
@@ -14,6 +14,10 @@ interface IMetadataFormProps {
14
14
  * 是否展示类型得提示信息
15
15
  */
16
16
  isShowTypeInfo?: boolean;
17
+ /**
18
+ * 是否折叠ref类型的表单
19
+ */
20
+ isFoldForm?: boolean;
17
21
  /**
18
22
  * 初始化值
19
23
  */
@@ -24,6 +24,8 @@ var MetadataForm = function MetadataForm(props) {
24
24
  disabled = _props$disabled === void 0 ? false : _props$disabled,
25
25
  _props$isRefForm = props.isRefForm,
26
26
  isRefForm = _props$isRefForm === void 0 ? true : _props$isRefForm,
27
+ _props$isFoldForm = props.isFoldForm,
28
+ isFoldForm = _props$isFoldForm === void 0 ? false : _props$isFoldForm,
27
29
  _props$isShowTypeInfo = props.isShowTypeInfo,
28
30
  isShowTypeInfo = _props$isShowTypeInfo === void 0 ? false : _props$isShowTypeInfo,
29
31
  initEnumValue = props.initEnumValue,
@@ -42,6 +44,7 @@ var MetadataForm = function MetadataForm(props) {
42
44
  fields = _React$useState4[0],
43
45
  setFields = _React$useState4[1];
44
46
 
47
+ var firstLoadRef = React.useRef(true);
45
48
  var stream$ = useMemoSubject();
46
49
  useObservable(function (p) {
47
50
  if ((p === null || p === void 0 ? void 0 : p.type) === 'onSelectChange') {
@@ -98,9 +101,10 @@ var MetadataForm = function MetadataForm(props) {
98
101
  return function () {};
99
102
  }, [mySchma]);
100
103
  React.useEffect(function () {
101
- if (initialValues) {
104
+ if (initialValues && firstLoadRef.current) {
102
105
  setTimeout(function () {
103
106
  form.setFieldsValue(_objectSpread({}, initialValues));
107
+ firstLoadRef.current = false;
104
108
  }, 500);
105
109
  }
106
110
  }, [initialValues]);
@@ -110,7 +114,8 @@ var MetadataForm = function MetadataForm(props) {
110
114
  form: form,
111
115
  stream$: stream$,
112
116
  initialValues: initialValues,
113
- isShowTypeInfo: isShowTypeInfo
117
+ isShowTypeInfo: isShowTypeInfo,
118
+ isFoldForm: isFoldForm
114
119
  }
115
120
  }, /*#__PURE__*/React.createElement(_Form, {
116
121
  className: "metadata-form",
@@ -120,8 +125,7 @@ var MetadataForm = function MetadataForm(props) {
120
125
  },
121
126
  layout: "horizontal",
122
127
  form: form,
123
- name: "control-hooks" // initialValues={initialValues}
124
- ,
128
+ name: "control-hooks",
125
129
  onFinish: onFinish,
126
130
  onValuesChange: onValuesChange
127
131
  }, renderForm(mySchma, options, stream$))));
@@ -6,6 +6,7 @@ export interface IMetadataFormContextProps {
6
6
  stream$: any;
7
7
  initialValues: any;
8
8
  isShowTypeInfo: boolean;
9
+ isFoldForm: boolean;
9
10
  }
10
11
  export declare const MetadataFormContext: React.Context<IMetadataFormContextProps>;
11
12
  export interface IMetadataRefContextProps {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author:wangxian
3
3
  * @Date: 2021-09-18 14:15:04
4
- * @LastEditTime: 2022-04-02 17:06:28
4
+ * @LastEditTime: 2022-05-11 11:55:02
5
5
  */
6
6
  import React from 'react';
7
7
  export var MetadataFormContext = /*#__PURE__*/React.createContext(null);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.0.88",
4
+ "version": "1.0.91",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",
@@ -45,7 +45,6 @@
45
45
  "markdown-it-emoji": "^2.0.0",
46
46
  "qs": "^6.10.1",
47
47
  "react": "^17.0.2",
48
- "react-color": "^2.19.3",
49
48
  "react-markdown-editor-lite": "^1.3.2",
50
49
  "react-popper": "^2.2.3",
51
50
  "rxjs": "^7.5.4"