ronds-metadata 1.3.46 → 1.3.47

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,67 @@
1
+ import "antd/es/form/style";
2
+ import _Form from "antd/es/form";
3
+ import "antd/es/tree-select/style";
4
+ import _TreeSelect from "antd/es/tree-select";
5
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
6
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
7
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
8
+ var _excluded = ["dataIndex", "mode", "disabled"];
9
+ /*
10
+ * @Author: wangxian
11
+ * @Date: 2022-03-04 14:53:50
12
+ * @LastEditTime: 2024-05-30 08:56:19
13
+ */
14
+ import React from 'react';
15
+ import { EditableContext } from '../interface';
16
+ function Index(props) {
17
+ var dataIndex = props.dataIndex,
18
+ mode = props.mode,
19
+ disabled = props.disabled,
20
+ restProps = _objectWithoutProperties(props, _excluded);
21
+ var _ref = React.useContext(EditableContext) || undefined,
22
+ editConfig = _ref.editConfig;
23
+ var _React$useState = React.useState([]),
24
+ _React$useState2 = _slicedToArray(_React$useState, 2),
25
+ treeData = _React$useState2[0],
26
+ setTreeData = _React$useState2[1];
27
+ React.useEffect(function () {
28
+ if (restProps.treeSelect) {
29
+ Promise.resolve(restProps.treeSelect).then(function (value) {
30
+ setTreeData(_toConsumableArray(value));
31
+ });
32
+ }
33
+ }, [restProps === null || restProps === void 0 ? void 0 : restProps.treeSelect]);
34
+ return /*#__PURE__*/React.createElement(_Form.Item, {
35
+ name: dataIndex,
36
+ style: {
37
+ margin: 0
38
+ }
39
+ }, /*#__PURE__*/React.createElement(_TreeSelect, {
40
+ showSearch: true,
41
+ virtual: true,
42
+ filterTreeNode: function filterTreeNode(input, treeNode) {
43
+ var _treeNode$label;
44
+ return (treeNode === null || treeNode === void 0 ? void 0 : (_treeNode$label = treeNode.label) === null || _treeNode$label === void 0 ? void 0 : _treeNode$label.toString().indexOf(input)) >= 0;
45
+ },
46
+ fieldNames: {
47
+ label: 'label',
48
+ value: 'value',
49
+ children: 'children'
50
+ }
51
+ // getPopupContainer={(triggerNode) => triggerNode.parentNode}
52
+ ,
53
+ multiple: mode === 'multiple',
54
+ style: {
55
+ width: '100%'
56
+ },
57
+ dropdownStyle: {
58
+ maxHeight: 400,
59
+ overflow: 'auto'
60
+ },
61
+ treeData: treeData,
62
+ allowClear: true,
63
+ disabled: editConfig.type === 'edit' ? disabled : false,
64
+ size: "small"
65
+ }));
66
+ }
67
+ export default /*#__PURE__*/React.memo(Index);
@@ -11,7 +11,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
11
11
  /*
12
12
  * @Author: wangxain
13
13
  * @Date: 2022-03-04 08:53:04
14
- * @LastEditTime: 2024-05-14 11:27:04
14
+ * @LastEditTime: 2024-05-30 08:38:53
15
15
  */
16
16
  import React from 'react';
17
17
  import { pick, isArray } from 'lodash';
@@ -205,7 +205,7 @@ var Editable = function Editable(props) {
205
205
  record: record,
206
206
  editableType: type,
207
207
  isAddColumn: isAddColumn
208
- }, pick(column, ['editable', 'title', 'dataIndex', 'type', 'enum', 'mode', 'disabled', 'cellDisabled'])), {}, {
208
+ }, pick(column, ['editable', 'title', 'dataIndex', 'type', 'enum', 'treeSelect', 'mode', 'disabled', 'cellDisabled'])), {}, {
209
209
  rowIndex: rowIndex
210
210
  });
211
211
  };
@@ -17,6 +17,11 @@ export interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
17
17
  label: string;
18
18
  value: string;
19
19
  }[];
20
+ treeSelect?: {
21
+ label: string;
22
+ value: string;
23
+ children: any[];
24
+ }[];
20
25
  mode?: 'multiple' | 'tags';
21
26
  children: React.ReactNode;
22
27
  }
@@ -33,7 +38,7 @@ export interface EditableRowProps extends React.HTMLAttributes<HTMLElement> {
33
38
  index?: any;
34
39
  onMove?: (data: any) => void;
35
40
  }
36
- export type InputType = 'bool' | 'number' | 'text' | 'enum' | string;
41
+ export type InputType = 'bool' | 'number' | 'text' | 'enum' | 'treeSelect' | string;
37
42
  export interface EditColumnsType extends ColumnsType<any> {
38
43
  type?: InputType;
39
44
  enum?: {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author: wangxian
3
3
  * @Date: 2022-03-04 15:07:57
4
- * @LastEditTime: 2023-05-23 09:16:25
4
+ * @LastEditTime: 2024-05-30 08:42:06
5
5
  */
6
6
  import React from 'react';
7
7
  export var EditableContext = /*#__PURE__*/React.createContext(null);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author: wangxian
3
3
  * @Date: 2022-03-04 14:59:04
4
- * @LastEditTime: 2023-05-23 10:33:54
4
+ * @LastEditTime: 2024-05-30 08:55:25
5
5
  */
6
6
  import React from 'react';
7
7
  import Input from './DataCell/Input';
@@ -10,10 +10,12 @@ import Select from './DataCell/Select';
10
10
  import Switch from './DataCell/Switch';
11
11
  import ColorPicker from './DataCell/ColorPicker';
12
12
  import ButtonCell from './DataCell/ButtonCell';
13
+ import TreeSelect from './DataCell/TreeSelect';
13
14
  var DataCellMap = {
14
15
  text: Input,
15
16
  number: Number,
16
17
  enum: Select,
18
+ treeSelect: TreeSelect,
17
19
  bool: Switch,
18
20
  colorPicker: ColorPicker,
19
21
  buttonCell: ButtonCell
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.3.46",
4
+ "version": "1.3.47",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",