ronds-metadata 1.1.25 → 1.1.28
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/Editable/DataCell/ButtonCell.d.ts +5 -0
- package/es/comps/Editable/DataCell/ButtonCell.js +45 -0
- package/es/comps/Editable/DataCell/ColorPicker.js +1 -23
- package/es/comps/Editable/index.d.ts +4 -0
- package/es/comps/Editable/index.js +5 -0
- package/es/comps/Editable/utils.js +4 -2
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +9 -1
- package/es/comps/MetadataForm/index.d.ts +4 -0
- package/es/comps/MetadataForm/index.js +12 -3
- package/package.json +1 -1
@@ -0,0 +1,45 @@
|
|
1
|
+
import "antd/es/form/style";
|
2
|
+
import _Form from "antd/es/form";
|
3
|
+
import "antd/es/button/style";
|
4
|
+
import _Button from "antd/es/button";
|
5
|
+
|
6
|
+
/*
|
7
|
+
* @Author: wangxian
|
8
|
+
* @Date: 2022-03-04 14:53:50
|
9
|
+
* @LastEditTime: 2022-07-08 08:57:41
|
10
|
+
*/
|
11
|
+
import React from 'react';
|
12
|
+
import { SettingOutlined } from '@ant-design/icons';
|
13
|
+
import { EditableContext } from '../interface';
|
14
|
+
|
15
|
+
function Index(props) {
|
16
|
+
var dataIndex = props.dataIndex,
|
17
|
+
record = props.record,
|
18
|
+
disabled = props.disabled;
|
19
|
+
|
20
|
+
var _ref = React.useContext(EditableContext) || undefined,
|
21
|
+
editableStream = _ref.editableStream,
|
22
|
+
editConfig = _ref.editConfig;
|
23
|
+
|
24
|
+
var onClick = function onClick(e) {
|
25
|
+
e.stopPropagation();
|
26
|
+
editableStream && editableStream.next({
|
27
|
+
type: 'onButtonCellClick',
|
28
|
+
payload: record
|
29
|
+
});
|
30
|
+
};
|
31
|
+
|
32
|
+
return /*#__PURE__*/React.createElement(_Form.Item, {
|
33
|
+
name: dataIndex,
|
34
|
+
style: {
|
35
|
+
margin: 0
|
36
|
+
}
|
37
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
38
|
+
type: "link",
|
39
|
+
disabled: editConfig.type === 'edit' ? disabled : false,
|
40
|
+
onClick: onClick,
|
41
|
+
icon: /*#__PURE__*/React.createElement(SettingOutlined, null)
|
42
|
+
}));
|
43
|
+
}
|
44
|
+
|
45
|
+
export default /*#__PURE__*/React.memo(Index);
|
@@ -6,46 +6,24 @@ import _Input from "antd/es/input";
|
|
6
6
|
/*
|
7
7
|
* @Author: wangxian
|
8
8
|
* @Date: 2022-03-04 14:53:50
|
9
|
-
* @LastEditTime: 2022-07-
|
9
|
+
* @LastEditTime: 2022-07-07 08:45:08
|
10
10
|
*/
|
11
11
|
import React from 'react';
|
12
12
|
import { EditableContext } from '../interface';
|
13
13
|
|
14
14
|
function Index(props) {
|
15
15
|
var dataIndex = props.dataIndex,
|
16
|
-
rowIndex = props.rowIndex,
|
17
16
|
disabled = props.disabled;
|
18
17
|
|
19
18
|
var _ref = React.useContext(EditableContext) || undefined,
|
20
19
|
editConfig = _ref.editConfig;
|
21
20
|
|
22
|
-
var inputRef = React.useRef();
|
23
|
-
var firstLoadRef = React.useRef(true);
|
24
|
-
React.useEffect(function () {
|
25
|
-
var _editConfig$editCellK, _editConfig$editCellK2;
|
26
|
-
|
27
|
-
if (!inputRef.current) return;
|
28
|
-
|
29
|
-
if (((_editConfig$editCellK = editConfig.editCellKey) === null || _editConfig$editCellK === void 0 ? void 0 : _editConfig$editCellK.dataIndex) === dataIndex && ((_editConfig$editCellK2 = editConfig.editCellKey) === null || _editConfig$editCellK2 === void 0 ? void 0 : _editConfig$editCellK2.rowIndex) === rowIndex) {
|
30
|
-
if (firstLoadRef.current) {
|
31
|
-
var _inputRef$current$sta, _inputRef$current$sta2;
|
32
|
-
|
33
|
-
// 选中内容
|
34
|
-
inputRef.current.input.setSelectionRange(0, ((_inputRef$current$sta = inputRef.current.state) === null || _inputRef$current$sta === void 0 ? void 0 : (_inputRef$current$sta2 = _inputRef$current$sta.value) === null || _inputRef$current$sta2 === void 0 ? void 0 : _inputRef$current$sta2.length) || 0);
|
35
|
-
firstLoadRef.current = false;
|
36
|
-
} // 设置焦点
|
37
|
-
|
38
|
-
|
39
|
-
inputRef.current.focus();
|
40
|
-
}
|
41
|
-
}, [editConfig]);
|
42
21
|
return /*#__PURE__*/React.createElement(_Form.Item, {
|
43
22
|
name: dataIndex,
|
44
23
|
style: {
|
45
24
|
margin: 0
|
46
25
|
}
|
47
26
|
}, /*#__PURE__*/React.createElement(_Input, {
|
48
|
-
ref: inputRef,
|
49
27
|
type: "color",
|
50
28
|
size: "small",
|
51
29
|
disabled: editConfig.type === 'edit' ? disabled : false
|
@@ -34,6 +34,7 @@ var Editable = function Editable(props) {
|
|
34
34
|
isAddColumn = _props$isAddColumn === void 0 ? false : _props$isAddColumn,
|
35
35
|
tableProps = props.tableProps,
|
36
36
|
onRowClick = props.onRowClick,
|
37
|
+
onButtonCellClick = props.onButtonCellClick,
|
37
38
|
onRowConfirm = props.onRowConfirm,
|
38
39
|
onRowDelete = props.onRowDelete,
|
39
40
|
onMulChange = props.onMulChange,
|
@@ -125,6 +126,10 @@ var Editable = function Editable(props) {
|
|
125
126
|
onRowClick && onRowClick(data.payload);
|
126
127
|
break;
|
127
128
|
|
129
|
+
case 'onButtonCellClick':
|
130
|
+
onButtonCellClick && onButtonCellClick(data.payload);
|
131
|
+
break;
|
132
|
+
|
128
133
|
case 'onSingleSave':
|
129
134
|
if (lastValueRef.current && lastValueRef.current.rowIdx === data.payload._rowKey_) {
|
130
135
|
onRowConfirm && onRowConfirm({
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* @Author: wangxian
|
3
3
|
* @Date: 2022-03-04 14:59:04
|
4
|
-
* @LastEditTime: 2022-07-
|
4
|
+
* @LastEditTime: 2022-07-07 08:35:35
|
5
5
|
*/
|
6
6
|
import React from 'react';
|
7
7
|
import Input from './DataCell/Input';
|
@@ -9,12 +9,14 @@ import Number from './DataCell/Number';
|
|
9
9
|
import Select from './DataCell/Select';
|
10
10
|
import Switch from './DataCell/Switch';
|
11
11
|
import ColorPicker from './DataCell/ColorPicker';
|
12
|
+
import ButtonCell from './DataCell/ButtonCell';
|
12
13
|
var DataCellMap = {
|
13
14
|
text: Input,
|
14
15
|
number: Number,
|
15
16
|
enum: Select,
|
16
17
|
bool: Switch,
|
17
|
-
colorPicker: ColorPicker
|
18
|
+
colorPicker: ColorPicker,
|
19
|
+
buttonCell: ButtonCell
|
18
20
|
};
|
19
21
|
export function getDataCell(item) {
|
20
22
|
if (item.type && DataCellMap[item.type]) {
|
@@ -171,7 +171,7 @@ var TableArray = function TableArray(props) {
|
|
171
171
|
title: getLabelByProps(it),
|
172
172
|
key: it.id,
|
173
173
|
dataIndex: it.id,
|
174
|
-
width: 100,
|
174
|
+
width: processColumnType(it, extraInfo) === 'buttonCell' ? 60 : 100,
|
175
175
|
editable: true,
|
176
176
|
type: processColumnType(it, extraInfo),
|
177
177
|
enum: it.type === 'enum' ? processEnumData(it, extraInfo) : undefined
|
@@ -196,6 +196,13 @@ var TableArray = function TableArray(props) {
|
|
196
196
|
form.setFieldsValue(_objectSpread({}, _defineProperty({}, "".concat(name), values)));
|
197
197
|
};
|
198
198
|
|
199
|
+
var onButtonCellClick = function onButtonCellClick(record) {
|
200
|
+
formContext.stream$.next({
|
201
|
+
type: 'onButtonCellClick',
|
202
|
+
payload: record
|
203
|
+
});
|
204
|
+
};
|
205
|
+
|
199
206
|
return /*#__PURE__*/React.createElement("div", {
|
200
207
|
style: {
|
201
208
|
width: '100%',
|
@@ -213,6 +220,7 @@ var TableArray = function TableArray(props) {
|
|
213
220
|
columns: columns,
|
214
221
|
dataSource: list,
|
215
222
|
onMulChange: onTableChange,
|
223
|
+
onButtonCellClick: onButtonCellClick,
|
216
224
|
tableProps: {
|
217
225
|
scroll: {
|
218
226
|
x: '100%',
|
@@ -50,6 +50,10 @@ interface IMetadataFormProps {
|
|
50
50
|
* select选择的回调
|
51
51
|
*/
|
52
52
|
onSelectChange?: (changedValues: any) => void;
|
53
|
+
/**
|
54
|
+
* select选择的回调
|
55
|
+
*/
|
56
|
+
onCellButtonClick?: (changedValues: any) => void;
|
53
57
|
}
|
54
58
|
declare const MetadataForm: (props: IMetadataFormProps) => JSX.Element;
|
55
59
|
export default MetadataForm;
|
@@ -32,7 +32,8 @@ var MetadataForm = function MetadataForm(props) {
|
|
32
32
|
onFinish = props.onFinish,
|
33
33
|
getFormInstance = props.getFormInstance,
|
34
34
|
onValuesChange = props.onValuesChange,
|
35
|
-
onSelectChange = props.onSelectChange
|
35
|
+
onSelectChange = props.onSelectChange,
|
36
|
+
onCellButtonClick = props.onCellButtonClick;
|
36
37
|
|
37
38
|
var _React$useState = React.useState([]),
|
38
39
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
@@ -55,6 +56,8 @@ var MetadataForm = function MetadataForm(props) {
|
|
55
56
|
useObservable(function (p) {
|
56
57
|
if ((p === null || p === void 0 ? void 0 : p.type) === 'onSelectChange') {
|
57
58
|
onSelectChange && onSelectChange(p.payload);
|
59
|
+
} else if ((p === null || p === void 0 ? void 0 : p.type) === 'onButtonCellClick') {
|
60
|
+
onCellButtonClick && onCellButtonClick(p.payload);
|
58
61
|
}
|
59
62
|
}, [stream$]);
|
60
63
|
var options = React.useMemo(function () {
|
@@ -122,10 +125,16 @@ var MetadataForm = function MetadataForm(props) {
|
|
122
125
|
}, [mySchma]);
|
123
126
|
React.useEffect(function () {
|
124
127
|
if (initialValues && firstLoadRef.current) {
|
125
|
-
|
128
|
+
try {
|
126
129
|
form.setFieldsValue(_objectSpread({}, initialValues));
|
127
130
|
firstLoadRef.current = false;
|
128
|
-
}
|
131
|
+
} catch (ex) {
|
132
|
+
console.warn('init not sucess');
|
133
|
+
setTimeout(function () {
|
134
|
+
form.setFieldsValue(_objectSpread({}, initialValues));
|
135
|
+
firstLoadRef.current = false;
|
136
|
+
}, 500);
|
137
|
+
}
|
129
138
|
}
|
130
139
|
}, [initialValues]);
|
131
140
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MetadataFormContext.Provider, {
|