ronds-metadata 1.0.55 → 1.0.58

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.
@@ -5,8 +5,11 @@ import _Button from "antd/es/button";
5
5
  import { EditOutlined, CloseOutlined, CheckOutlined, DeleteOutlined } from '@ant-design/icons';
6
6
  import React from 'react';
7
7
  import { EditableContext } from '../interface';
8
+ import { isFreeEditRow } from '../utils';
8
9
 
9
10
  var EditableAction = function EditableAction(props) {
11
+ var _editConfig$editCellK;
12
+
10
13
  var type = props.type,
11
14
  record = props.record;
12
15
 
@@ -35,6 +38,13 @@ var EditableAction = function EditableAction(props) {
35
38
  type: 'onSingleSave',
36
39
  payload: record
37
40
  });
41
+ editableStream.next({
42
+ type: 'editCellKey',
43
+ payload: {
44
+ dataIndex: undefined,
45
+ rowIndex: undefined
46
+ }
47
+ });
38
48
  };
39
49
 
40
50
  var onDelete = function onDelete() {
@@ -69,7 +79,15 @@ var EditableAction = function EditableAction(props) {
69
79
  title: '取消'
70
80
  }), /*#__PURE__*/React.createElement(_Divider, {
71
81
  type: "vertical"
72
- })))), /*#__PURE__*/React.createElement(_Button, {
82
+ })))), type === 'freedom' && /*#__PURE__*/React.createElement(React.Fragment, null, (record._rowKey_ === (editConfig === null || editConfig === void 0 ? void 0 : (_editConfig$editCellK = editConfig.editCellKey) === null || _editConfig$editCellK === void 0 ? void 0 : _editConfig$editCellK.rowIndex) || isFreeEditRow(editConfig.curRow, record._rowKey_)) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Button, {
83
+ type: "link",
84
+ size: "small",
85
+ icon: /*#__PURE__*/React.createElement(CheckOutlined, null),
86
+ onClick: onSave,
87
+ title: '确定'
88
+ }), /*#__PURE__*/React.createElement(_Divider, {
89
+ type: "vertical"
90
+ }))), /*#__PURE__*/React.createElement(_Button, {
73
91
  type: "link",
74
92
  size: "small",
75
93
  icon: /*#__PURE__*/React.createElement(DeleteOutlined, null),
@@ -24,6 +24,8 @@ var EditableCell = function EditableCell(props) {
24
24
 
25
25
 
26
26
  var onCellDoubleClick = function onCellDoubleClick() {
27
+ var _editConfig$editCellK, _editConfig$editCellK2;
28
+
27
29
  if ((editConfig === null || editConfig === void 0 ? void 0 : editConfig.curRow) && (editConfig === null || editConfig === void 0 ? void 0 : editConfig.curRow) !== 'undefined') {
28
30
  if (isFreeEditRow(editConfig.curRow, rowIndex)) return;
29
31
 
@@ -32,6 +34,12 @@ var EditableCell = function EditableCell(props) {
32
34
  return;
33
35
  }
34
36
 
37
+ if (((editConfig === null || editConfig === void 0 ? void 0 : (_editConfig$editCellK = editConfig.editCellKey) === null || _editConfig$editCellK === void 0 ? void 0 : _editConfig$editCellK.rowIndex) || (editConfig === null || editConfig === void 0 ? void 0 : (_editConfig$editCellK2 = editConfig.editCellKey) === null || _editConfig$editCellK2 === void 0 ? void 0 : _editConfig$editCellK2.rowIndex) === 0) && rowIndex !== editConfig.editCellKey.rowIndex) {
38
+ _message.warning('请先保存正在编辑的行');
39
+
40
+ return;
41
+ }
42
+
35
43
  editableStream.next({
36
44
  type: 'editCellKey',
37
45
  payload: {
@@ -42,16 +50,9 @@ var EditableCell = function EditableCell(props) {
42
50
  };
43
51
 
44
52
  var onCellClick = function onCellClick() {
45
- if (!isFreeEditCell(editConfig.editCellKey, dataIndex, rowIndex)) {
46
- editableStream.next({
47
- type: 'editCellKey',
48
- payload: {
49
- dataIndex: undefined,
50
- rowIndex: undefined
51
- }
52
- });
53
- }
54
-
53
+ // if (!isFreeEditCell(editConfig.editCellKey, dataIndex, rowIndex)) {
54
+ // editableStream.next({ type: 'editCellKey', payload: { dataIndex: undefined, rowIndex: undefined } });
55
+ // }
55
56
  if (isAddColumn) {
56
57
  editableStream.next({
57
58
  type: 'editHeardCellKey',
@@ -17,13 +17,7 @@ var EditableRow = function EditableRow(props) {
17
17
  React.useEffect(function () {
18
18
  if (!form) return;
19
19
  form.setFieldsValue(record);
20
- }, [record]); // 编辑的时候初始化值
21
- // React.useEffect(() => {
22
- // const subscription = editableStream.pipe(filter((p: any) => p?.type === 'editRowKey')).subscribe((p: IEditableStream) => {
23
- // form.setFieldsValue(p.payload);
24
- // });
25
- // return () => subscription.unsubscribe();
26
- // }, [editableStream]);
20
+ }, [record]);
27
21
 
28
22
  var onValuesChange = function onValuesChange(values, allValues) {
29
23
  if (editableStream) {
@@ -270,10 +270,10 @@ var Editable = function Editable(props) {
270
270
  var _aciton_ = {
271
271
  dataKey: '_aciton_',
272
272
  title: '操作',
273
- width: 60,
274
- maxWidth: 60,
273
+ width: 50,
274
+ maxWidth: 50,
275
275
  export: false,
276
- minWidth: 60,
276
+ minWidth: 50,
277
277
  frozen: 'right',
278
278
  render: function render(val, record) {
279
279
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditableAction, {
@@ -311,6 +311,12 @@ var Editable = function Editable(props) {
311
311
 
312
312
  var onAddRow = function onAddRow() {
313
313
  if (defaultValue) {
314
+ if (type === 'freedom' && editRowKey) {
315
+ _message.warn('请先保存正在编辑的行');
316
+
317
+ return;
318
+ }
319
+
314
320
  var _records = recordsRef.current;
315
321
 
316
322
  if (addPosition === 'top') {
@@ -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,
@@ -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
@@ -30,6 +30,7 @@ export interface IMetaFormProps {
30
30
  isRefForm?: boolean;
31
31
  initEnumValue?: any;
32
32
  field?: any;
33
+ fields?: any[];
33
34
  name?: string[];
34
35
  isObj?: boolean;
35
36
  refId?: string;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author:wangxian
3
3
  * @Date: 2021-09-18 14:15:04
4
- * @LastEditTime: 2022-04-01 16:58:54
4
+ * @LastEditTime: 2022-04-02 17:06:28
5
5
  */
6
6
  import React from 'react';
7
7
  export var MetadataFormContext = /*#__PURE__*/React.createContext(null);
@@ -5,7 +5,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
5
5
  /*
6
6
  * @Author: wangxian
7
7
  * @Date: 2021-09-18 14:15:04
8
- * @LastEditTime: 2022-04-02 15:10:04
8
+ * @LastEditTime: 2022-04-02 17:19:55
9
9
  */
10
10
  import React from 'react';
11
11
  import Input from './DataCell/Input';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.0.55",
4
+ "version": "1.0.58",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",