ronds-metadata 1.1.23 → 1.1.24

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,55 @@
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-06 14:32:00
10
+ */
11
+ import React from 'react';
12
+ import { EditableContext } from '../interface';
13
+
14
+ function Index(props) {
15
+ var dataIndex = props.dataIndex,
16
+ rowIndex = props.rowIndex,
17
+ disabled = props.disabled;
18
+
19
+ var _ref = React.useContext(EditableContext) || undefined,
20
+ editConfig = _ref.editConfig;
21
+
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
+ return /*#__PURE__*/React.createElement(_Form.Item, {
43
+ name: dataIndex,
44
+ style: {
45
+ margin: 0
46
+ }
47
+ }, /*#__PURE__*/React.createElement(_Input, {
48
+ ref: inputRef,
49
+ type: "color",
50
+ size: "small",
51
+ disabled: editConfig.type === 'edit' ? disabled : false
52
+ }));
53
+ }
54
+
55
+ 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
 
@@ -1,18 +1,20 @@
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-06 14:27:13
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';
11
12
  var DataCellMap = {
12
13
  text: Input,
13
14
  number: Number,
14
15
  enum: Select,
15
- bool: Switch
16
+ bool: Switch,
17
+ colorPicker: ColorPicker
16
18
  };
17
19
  export function getDataCell(item) {
18
20
  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,47 @@ var TableArray = function TableArray(props) {
124
125
  firstLoadRef.current = false;
125
126
  }
126
127
  }, [initValue, form]);
128
+ var processEnumData = React.useCallback(function (data) {
129
+ var _data$fields$, _data$fields$$value, _data$fields$$value$e;
130
+
131
+ var _options = [];
132
+
133
+ var _enum = deepClone(data.enum || []); // 扩展规则的value
134
+
135
+
136
+ if (data === null || data === void 0 ? void 0 : (_data$fields$ = data.fields[0]) === null || _data$fields$ === void 0 ? void 0 : (_data$fields$$value = _data$fields$.value) === null || _data$fields$$value === void 0 ? void 0 : (_data$fields$$value$e = _data$fields$$value.enum) === null || _data$fields$$value$e === void 0 ? void 0 : _data$fields$$value$e.value) {
137
+ var _data$fields$2, _data$fields$2$value, _data$fields$2$value$;
138
+
139
+ _enum = deepClone(data === null || data === void 0 ? void 0 : (_data$fields$2 = data.fields[0]) === null || _data$fields$2 === void 0 ? void 0 : (_data$fields$2$value = _data$fields$2.value) === null || _data$fields$2$value === void 0 ? void 0 : (_data$fields$2$value$ = _data$fields$2$value.enum) === null || _data$fields$2$value$ === void 0 ? void 0 : _data$fields$2$value$.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
+ }, []);
127
153
  var processSchemaToColumns = React.useCallback(function (_properties) {
128
154
  var _columns = [];
129
155
 
130
156
  for (var i = 0; i < _properties.length; i++) {
157
+ var _extraInfo$text;
158
+
131
159
  var it = _properties[i];
160
+ var extraInfo = refFieldsRef.current.get(it.id);
132
161
  var obj = {
133
162
  title: getLabelByProps(it),
134
163
  key: it.id,
135
164
  dataIndex: it.id,
136
165
  width: 100,
137
166
  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
167
+ type: it.type === 'text' && (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$text = extraInfo.text) === null || _extraInfo$text === void 0 ? void 0 : _extraInfo$text.type) === 'colorPicker' ? 'colorPicker' : it.type,
168
+ enum: it.type === 'enum' ? processEnumData(it) : undefined
145
169
  };
146
170
 
147
171
  _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.24",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",