ronds-metadata 1.1.23 → 1.1.26

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.
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { EditableCellProps } from '../interface';
3
+ declare function Index(props: EditableCellProps): JSX.Element;
4
+ declare const _default: React.MemoExoticComponent<typeof Index>;
5
+ export default _default;
@@ -0,0 +1,44 @@
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-07 08:46:45
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() {
25
+ editableStream && editableStream.next({
26
+ type: 'onButtonCellClick',
27
+ payload: record
28
+ });
29
+ };
30
+
31
+ return /*#__PURE__*/React.createElement(_Form.Item, {
32
+ name: dataIndex,
33
+ style: {
34
+ margin: 0
35
+ }
36
+ }, /*#__PURE__*/React.createElement(_Button, {
37
+ type: "link",
38
+ disabled: editConfig.type === 'edit' ? disabled : false,
39
+ onClick: onClick,
40
+ icon: /*#__PURE__*/React.createElement(SettingOutlined, null)
41
+ }));
42
+ }
43
+
44
+ export default /*#__PURE__*/React.memo(Index);
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { EditableCellProps } from '../interface';
3
+ declare function Index(props: EditableCellProps): JSX.Element;
4
+ declare const _default: React.MemoExoticComponent<typeof Index>;
5
+ export default _default;
@@ -0,0 +1,33 @@
1
+ import "antd/es/form/style";
2
+ import _Form from "antd/es/form";
3
+ import "antd/es/input/style";
4
+ import _Input from "antd/es/input";
5
+
6
+ /*
7
+ * @Author: wangxian
8
+ * @Date: 2022-03-04 14:53:50
9
+ * @LastEditTime: 2022-07-07 08:45:08
10
+ */
11
+ import React from 'react';
12
+ import { EditableContext } from '../interface';
13
+
14
+ function Index(props) {
15
+ var dataIndex = props.dataIndex,
16
+ disabled = props.disabled;
17
+
18
+ var _ref = React.useContext(EditableContext) || undefined,
19
+ editConfig = _ref.editConfig;
20
+
21
+ return /*#__PURE__*/React.createElement(_Form.Item, {
22
+ name: dataIndex,
23
+ style: {
24
+ margin: 0
25
+ }
26
+ }, /*#__PURE__*/React.createElement(_Input, {
27
+ type: "color",
28
+ size: "small",
29
+ disabled: editConfig.type === 'edit' ? disabled : false
30
+ }));
31
+ }
32
+
33
+ export default /*#__PURE__*/React.memo(Index);
@@ -50,9 +50,9 @@ var EditableHeardCell = function EditableHeardCell(props) {
50
50
  var myStyle = React.useMemo(function () {
51
51
  var res = {};
52
52
 
53
- if (style) {
53
+ if (style === null || style === void 0 ? void 0 : style.right) {
54
54
  res = _objectSpread(_objectSpread({}, style), {}, {
55
- right: style.right - 6
55
+ right: (style === null || style === void 0 ? void 0 : style.right) - 6
56
56
  });
57
57
  }
58
58
 
@@ -41,6 +41,10 @@ interface IEditableProps<R = any> {
41
41
  * 每行确认回调函数
42
42
  */
43
43
  onRowClick?: (record: any) => void;
44
+ /**
45
+ * 表格按钮点击事件
46
+ */
47
+ onButtonCellClick?: (record: any) => void;
44
48
  /**
45
49
  * 每行确认回调函数
46
50
  */
@@ -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,18 +1,22 @@
1
1
  /*
2
2
  * @Author: wangxian
3
3
  * @Date: 2022-03-04 14:59:04
4
- * @LastEditTime: 2022-03-09 10:42:38
4
+ * @LastEditTime: 2022-07-07 08:35:35
5
5
  */
6
6
  import React from 'react';
7
7
  import Input from './DataCell/Input';
8
8
  import Number from './DataCell/Number';
9
9
  import Select from './DataCell/Select';
10
10
  import Switch from './DataCell/Switch';
11
+ import ColorPicker from './DataCell/ColorPicker';
12
+ import ButtonCell from './DataCell/ButtonCell';
11
13
  var DataCellMap = {
12
14
  text: Input,
13
15
  number: Number,
14
16
  enum: Select,
15
- bool: Switch
17
+ bool: Switch,
18
+ colorPicker: ColorPicker,
19
+ buttonCell: ButtonCell
16
20
  };
17
21
  export function getDataCell(item) {
18
22
  if (item.type && DataCellMap[item.type]) {
@@ -13,6 +13,7 @@ import Editable from '../../../../comps/Editable';
13
13
  import useObservable from '../../../../framework/rxjs-hooks/useObservable';
14
14
  import { MetadataFormContext } from '../../interface';
15
15
  import { getLabelByProps } from '../../utils';
16
+ import { deepClone } from '../../../../utils';
16
17
 
17
18
  var TableArray = function TableArray(props) {
18
19
  var initValue = props.initValue,
@@ -124,24 +125,56 @@ var TableArray = function TableArray(props) {
124
125
  firstLoadRef.current = false;
125
126
  }
126
127
  }, [initValue, form]);
128
+ var processEnumData = React.useCallback(function (data, _extraInfo) {
129
+ var _extraInfo$enum;
130
+
131
+ var _options = [];
132
+
133
+ var _enum = deepClone(data.enum || []); // 扩展规则的value
134
+
135
+
136
+ if (_extraInfo === null || _extraInfo === void 0 ? void 0 : (_extraInfo$enum = _extraInfo.enum) === null || _extraInfo$enum === void 0 ? void 0 : _extraInfo$enum.value) {
137
+ var _extraInfo$enum2;
138
+
139
+ _enum = deepClone(_extraInfo === null || _extraInfo === void 0 ? void 0 : (_extraInfo$enum2 = _extraInfo.enum) === null || _extraInfo$enum2 === void 0 ? void 0 : _extraInfo$enum2.value);
140
+ }
141
+
142
+ _enum.forEach(function (it) {
143
+ var obj = {
144
+ label: it.value,
145
+ value: (it === null || it === void 0 ? void 0 : it.key) || (it === null || it === void 0 ? void 0 : it.value)
146
+ };
147
+
148
+ _options.push(obj);
149
+ });
150
+
151
+ return _options;
152
+ }, []);
153
+ var processColumnType = React.useCallback(function (data, _extraInfo) {
154
+ var _extraInfo$text;
155
+
156
+ if (data.type === 'text' && ((_extraInfo$text = _extraInfo.text) === null || _extraInfo$text === void 0 ? void 0 : _extraInfo$text.type)) {
157
+ var _extraInfo$text2;
158
+
159
+ return (_extraInfo$text2 = _extraInfo.text) === null || _extraInfo$text2 === void 0 ? void 0 : _extraInfo$text2.type;
160
+ }
161
+
162
+ return data.type;
163
+ }, []);
127
164
  var processSchemaToColumns = React.useCallback(function (_properties) {
128
165
  var _columns = [];
129
166
 
130
167
  for (var i = 0; i < _properties.length; i++) {
131
168
  var it = _properties[i];
169
+ var extraInfo = refFieldsRef.current.get(it.id);
132
170
  var obj = {
133
171
  title: getLabelByProps(it),
134
172
  key: it.id,
135
173
  dataIndex: it.id,
136
- width: 100,
174
+ width: processColumnType(it, extraInfo) === 'buttonCell' ? 60 : 100,
137
175
  editable: true,
138
- type: it.type,
139
- enum: it.type === 'enum' ? it.enum.map(function (v) {
140
- return {
141
- label: v.value,
142
- value: v.value
143
- };
144
- }) : undefined
176
+ type: processColumnType(it, extraInfo),
177
+ enum: it.type === 'enum' ? processEnumData(it, extraInfo) : undefined
145
178
  };
146
179
 
147
180
  _columns.push(obj);
@@ -5,10 +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-21 08:51:08
9
- * @LastEditors: Please set LastEditors
10
- * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
11
- * @FilePath: \ronds.metadata\src\comps\MetadataForm\hooks\index.tsx
8
+ * @LastEditTime: 2022-07-06 14:02:17
12
9
  */
13
10
  import { getLocale } from '../../../framework/locale';
14
11
  import moment from 'moment';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.1.23",
4
+ "version": "1.1.26",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",