@kep-platform/basic-component 0.0.28 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,4 +27,5 @@ export declare const Column: import("styled-components/dist/types").IStyledCompo
27
27
  left?: string | undefined;
28
28
  right?: string | undefined;
29
29
  }>> & string & Omit<React.FC<ListItemProps>, keyof React.Component<any, {}, any>>;
30
- export default function Columns({ columns, rowData, rowIndex, isFlex, leftBase, columnsKey, ...columnsRestProps }: ColumnsProps): React.JSX.Element;
30
+ declare const _default: React.FunctionComponent<ColumnsProps>;
31
+ export default _default;
@@ -3,6 +3,7 @@ var _excluded = ["columns", "rowData", "rowIndex", "isFlex", "leftBase", "column
3
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
5
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
+ import { observer } from 'mobx-react-lite';
6
7
  import React, { useMemo } from 'react';
7
8
  import styled, { css } from 'styled-components';
8
9
  import { List, ListItem } from "../List";
@@ -57,7 +58,7 @@ export var Column = styled(ListItem).withConfig({
57
58
  }
58
59
  });
59
60
  var displayColumnsCache = {};
60
- export default function Columns(_ref) {
61
+ export default observer(function Columns(_ref) {
61
62
  var columns = _ref.columns,
62
63
  rowData = _ref.rowData,
63
64
  _ref$rowIndex = _ref.rowIndex,
@@ -129,4 +130,4 @@ export default function Columns(_ref) {
129
130
  isFlex: isFlex
130
131
  }), (render === null || render === void 0 ? void 0 : render(rowData[dataIndex], rowData, rowIndex)) || rowData[dataIndex]);
131
132
  }));
132
- }
133
+ });
@@ -17,5 +17,7 @@ export type TreeProps = {
17
17
  bordered?: boolean;
18
18
  groupBy?: string | null;
19
19
  };
20
- declare const Tree: React.FC<TreeProps>;
20
+ declare const Tree: (({ treeData, columns, fieldNames, title: treeTitle, titleWidth, titleRender, selectedKeys, expandedKeys, isFlex, onSelect, onExpand, contextMenuRender, onContextMenuItemSelect, multiple, bordered, }: TreeProps) => React.JSX.Element) & {
21
+ displayName: string;
22
+ };
21
23
  export default Tree;
package/dist/Tree/Tree.js CHANGED
@@ -2,7 +2,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
4
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
- import React, { useMemo, useRef } from 'react';
5
+ import { observer } from 'mobx-react-lite';
6
+ import React, { useCallback, useMemo, useRef } from 'react';
6
7
  import styled, { css } from 'styled-components';
7
8
  import { BoxShadowBox } from "../BoxShadowBox";
8
9
  import { Column, Columns } from "../Columns";
@@ -40,7 +41,7 @@ var TreeHeader = styled('div').withConfig({
40
41
  }
41
42
  }, Column, MainArea);
42
43
  var rootLevel = -1;
43
- var Tree = function Tree(_ref) {
44
+ var Tree = observer(function (_ref) {
44
45
  var treeData = _ref.treeData,
45
46
  _ref$columns = _ref.columns,
46
47
  columns = _ref$columns === void 0 ? [] : _ref$columns,
@@ -70,6 +71,7 @@ var Tree = function Tree(_ref) {
70
71
  multiple = _ref$multiple === void 0 ? false : _ref$multiple,
71
72
  _ref$bordered = _ref.bordered,
72
73
  bordered = _ref$bordered === void 0 ? false : _ref$bordered;
74
+ console.log('tree render...');
73
75
  var rootNode = useMemo(function () {
74
76
  return _defineProperty(_defineProperty(_defineProperty({}, fieldNames.key, 'root'), "nodeType", nodeTypeMap.virtual), "children", treeData);
75
77
  }, [treeData]);
@@ -125,19 +127,20 @@ var Tree = function Tree(_ref) {
125
127
  return newColumns;
126
128
  }, [columns, fieldNames]);
127
129
  var boxShadowBox = useRef(null);
130
+ var onScrollHandler = useCallback(function (e) {
131
+ var treeContainer = e.target;
132
+ if (boxShadowBox.current) {
133
+ if (treeContainer.scrollLeft === 0) {
134
+ boxShadowBox.current.style.opacity = '0';
135
+ } else {
136
+ boxShadowBox.current.style.opacity = '1';
137
+ }
138
+ boxShadowBox.current.style.left = treeContainer.scrollLeft + titleWidth + 'px';
139
+ }
140
+ }, [titleWidth]);
128
141
  /* 树组件的结构其实比较简单,就是一个树标题(TableMode下),然后树节点形成的列表 */
129
142
  return /*#__PURE__*/React.createElement(TreeContainer, {
130
- onScroll: function onScroll(e) {
131
- var treeContainer = e.target;
132
- if (boxShadowBox.current) {
133
- if (treeContainer.scrollLeft === 0) {
134
- boxShadowBox.current.style.opacity = '0';
135
- } else {
136
- boxShadowBox.current.style.opacity = '1';
137
- }
138
- boxShadowBox.current.style.left = treeContainer.scrollLeft + titleWidth + 'px';
139
- }
140
- },
143
+ onScroll: onScrollHandler,
141
144
  bordered: bordered
142
145
  }, isTableMode && !isFlex && /*#__PURE__*/React.createElement(BoxShadowBox, {
143
146
  ref: boxShadowBox,
@@ -160,7 +163,6 @@ var Tree = function Tree(_ref) {
160
163
  })), /*#__PURE__*/React.createElement(TreeBody, {
161
164
  direction: "column"
162
165
  }, /*#__PURE__*/React.createElement(TreeNodeController, {
163
- key: rootNode[fieldNames.key],
164
166
  selectedKeys: selectedKeys,
165
167
  onSelect: onSelect,
166
168
  expandedKeys: expandedKeys,
@@ -178,5 +180,5 @@ var Tree = function Tree(_ref) {
178
180
  onContextMenuItemSelect: onContextMenuItemSelect,
179
181
  titleRender: titleRender
180
182
  })));
181
- };
183
+ });
182
184
  export default Tree;
@@ -20,4 +20,6 @@ export type TreeNodeControllerProps = {
20
20
  export declare const nodeTypeMap: {
21
21
  virtual: string;
22
22
  };
23
- export declare const TreeNodeController: React.FC<TreeNodeControllerProps>;
23
+ export declare const TreeNodeController: (({ node, selectedKeys, width, isTableMode, fieldNames, columns, isFlex, onSelect, multiple, level, mainWidth, expandedKeys, onExpand, contextMenuRender, onContextMenuItemSelect, titleRender, }: TreeNodeControllerProps) => React.JSX.Element) & {
24
+ displayName: string;
25
+ };
@@ -5,6 +5,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { CaretRightOutlined } from '@ant-design/icons';
8
+ import { observer } from 'mobx-react-lite';
8
9
  import React, { useCallback, useMemo, useState } from 'react';
9
10
  import styled, { css } from 'styled-components';
10
11
  import { Column, Columns } from "../Columns";
@@ -97,7 +98,7 @@ function groupTreeNodeByPropertyName(arr, propertyName, fieldNames) {
97
98
  export var nodeTypeMap = {
98
99
  virtual: 'virtual'
99
100
  };
100
- export var TreeNodeController = function TreeNodeController(_ref) {
101
+ export var TreeNodeController = observer(function (_ref) {
101
102
  var node = _ref.node,
102
103
  _ref$selectedKeys = _ref.selectedKeys,
103
104
  selectedKeys = _ref$selectedKeys === void 0 ? [] : _ref$selectedKeys,
@@ -116,6 +117,7 @@ export var TreeNodeController = function TreeNodeController(_ref) {
116
117
  onContextMenuItemSelect = _ref.onContextMenuItemSelect,
117
118
  titleRender = _ref.titleRender;
118
119
  /* 处理子节点缩进 */
120
+ console.log('treeNode render');
119
121
  var childLevel = useMemo(function () {
120
122
  return level + 1;
121
123
  }, [level]);
@@ -249,4 +251,4 @@ export var TreeNodeController = function TreeNodeController(_ref) {
249
251
  });
250
252
  }));
251
253
  }));
252
- };
254
+ });
@@ -0,0 +1,190 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
+ import { Button, GlobalStyles, Tree } from "./..";
15
+ import { makeAutoObservable } from 'mobx';
16
+ import React, { useState } from 'react';
17
+ import styled from 'styled-components';
18
+ function findTreeNode(key, node) {
19
+ if (node.key === key) {
20
+ return node;
21
+ } else {
22
+ for (var i = 0; i < node.children.length; i++) {
23
+ var n = findTreeNode(key, node.children[i]);
24
+ if (n) {
25
+ return n;
26
+ }
27
+ }
28
+ }
29
+ }
30
+ var MyStore = /*#__PURE__*/function () {
31
+ function MyStore(treeData) {
32
+ _classCallCheck(this, MyStore);
33
+ _defineProperty(this, "root", {
34
+ key: Symbol('virtual root'),
35
+ children: []
36
+ });
37
+ makeAutoObservable(this);
38
+ if (treeData) {
39
+ this.root.children = treeData;
40
+ }
41
+ }
42
+ _createClass(MyStore, [{
43
+ key: "setTreeTitle",
44
+ value: function setTreeTitle(key, title) {
45
+ var node = findTreeNode(key, this.root);
46
+ if (node) {
47
+ node.title = title;
48
+ }
49
+ }
50
+ }, {
51
+ key: "setTreeName",
52
+ value: function setTreeName(key, name) {
53
+ var node = findTreeNode(key, this.root);
54
+ if (node) {
55
+ node.name = name;
56
+ }
57
+ }
58
+ }, {
59
+ key: "addNode",
60
+ value: function addNode(node) {
61
+ this.root.children.push(node);
62
+ }
63
+ }, {
64
+ key: "report",
65
+ get: function get() {
66
+ return JSON.stringify(this.root, null, 4);
67
+ }
68
+ }]);
69
+ return MyStore;
70
+ }();
71
+ var mystore = new MyStore([{
72
+ key: '1',
73
+ title: 'jss',
74
+ count: 1,
75
+ groupBy: 'count',
76
+ children: [{
77
+ key: '4',
78
+ title: 'skjdfkljasklfjkljdsklajfkl就是要长一的点点滴滴的点点滴滴哒哒哒哒哒哒哒哒哒哒哒哒哒哒',
79
+ children: []
80
+ }, {
81
+ key: '5',
82
+ title: 567,
83
+ children: []
84
+ }, {
85
+ key: '6',
86
+ title: 789,
87
+ children: []
88
+ }]
89
+ }, {
90
+ key: '2121212121212',
91
+ title: '2',
92
+ count: 1,
93
+ groupBy: 'count',
94
+ children: [{
95
+ key: '3',
96
+ title: 'jss',
97
+ name: 'jss',
98
+ children: [],
99
+ count: 2
100
+ }, {
101
+ key: '10',
102
+ title: 'jss',
103
+ name: 'jss',
104
+ children: [],
105
+ count: 2
106
+ }, {
107
+ key: '20',
108
+ title: '3',
109
+ children: [],
110
+ count: 2
111
+ }]
112
+ }]);
113
+ var Title = styled.div.withConfig({
114
+ displayName: "Title",
115
+ componentId: "basic-component-347b__sc-bc9b32-0"
116
+ })(["width:100%;text-align:center;"]);
117
+ export default (function () {
118
+ var _useState = useState([]),
119
+ _useState2 = _slicedToArray(_useState, 2),
120
+ selectedKeys = _useState2[0],
121
+ setSelectedKeys = _useState2[1];
122
+ var _useState3 = useState([]),
123
+ _useState4 = _slicedToArray(_useState3, 2),
124
+ expandedKeys = _useState4[0],
125
+ setExpandedKeys = _useState4[1];
126
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStyles, {
127
+ $css: []
128
+ }), /*#__PURE__*/React.createElement(Button, {
129
+ onClick: function onClick() {
130
+ mystore.setTreeName('2121212121212', 'name' + Math.random());
131
+ }
132
+ }, "\u70B9\u51FB"), /*#__PURE__*/React.createElement(Tree, {
133
+ title: /*#__PURE__*/React.createElement(Title, null, "\u6807\u8BC6"),
134
+ titleWidth: 400,
135
+ fieldNames: {
136
+ key: 'key',
137
+ title: 'treeTitle',
138
+ children: 'children'
139
+ },
140
+ contextMenuRender: function contextMenuRender(node) {
141
+ return [{
142
+ key: 'delete',
143
+ label: "\u5220\u9664 node".concat(node.key)
144
+ }, {
145
+ key: 'add',
146
+ label: '新增'
147
+ }, {
148
+ key: 'edit',
149
+ label: '编辑'
150
+ }];
151
+ },
152
+ treeData: mystore.root.children,
153
+ isFlex: false,
154
+ columns: [{
155
+ key: 'key',
156
+ title: '键值',
157
+ dataIndex: 'key',
158
+ align: 'center',
159
+ width: 400,
160
+ fixed: 'left'
161
+ }, {
162
+ key: 'title',
163
+ title: '标题',
164
+ dataIndex: 'title',
165
+ align: 'center',
166
+ width: 400
167
+ }, {
168
+ key: 'name',
169
+ title: '姓名',
170
+ dataIndex: 'name',
171
+ align: 'center'
172
+ }, {
173
+ key: 'count',
174
+ title: '数量',
175
+ dataIndex: 'count',
176
+ align: 'center'
177
+ }],
178
+ selectedKeys: selectedKeys,
179
+ expandedKeys: expandedKeys,
180
+ onSelect: function onSelect(selectedKeys) {
181
+ return setSelectedKeys(selectedKeys);
182
+ },
183
+ onExpand: function onExpand(expandedKeys) {
184
+ return setExpandedKeys(expandedKeys);
185
+ },
186
+ titleRender: function titleRender(node) {
187
+ return node.title;
188
+ }
189
+ }));
190
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kep-platform/basic-component",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "A react library developed with dumi",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -51,6 +51,8 @@
51
51
  "access": "public"
52
52
  },
53
53
  "peerDependencies": {
54
+ "mobx": "^6.12.3",
55
+ "mobx-react-lite": "^4.0.7",
54
56
  "react": ">=16.9.0",
55
57
  "react-dom": ">=16.9.0"
56
58
  },
@@ -74,10 +76,10 @@
74
76
  "react-dom": "^18.0.0",
75
77
  "stylelint": "^14.9.1"
76
78
  },
77
- "gitHead": "199e06d46f67de10c87f790fc5c704666a0eb288",
79
+ "gitHead": "b6a8afddc8aeca25f7a15bd7a64b6467ba730a54",
78
80
  "dependencies": {
79
81
  "@ant-design/icons": "^5.3.7",
80
- "@kep-platform/hooks": "^0.0.28",
82
+ "@kep-platform/hooks": "^0.0.29",
81
83
  "color": "^4.2.3",
82
84
  "rc-pagination": "^4.1.0",
83
85
  "styled-components": "^6.1.11"
@@ -1,117 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import { GlobalStyles } from "./..";
8
- import React, { useState } from 'react';
9
- import styled from 'styled-components';
10
- import Tree from "./Tree";
11
- var Title = styled.div.withConfig({
12
- displayName: "Title",
13
- componentId: "basic-component-347b__sc-klaw2r-0"
14
- })(["width:100%;text-align:center;"]);
15
- export default (function () {
16
- var _useState = useState([]),
17
- _useState2 = _slicedToArray(_useState, 2),
18
- selectedKeys = _useState2[0],
19
- setSelectedKeys = _useState2[1];
20
- var _useState3 = useState([]),
21
- _useState4 = _slicedToArray(_useState3, 2),
22
- expandedKeys = _useState4[0],
23
- setExpandedKeys = _useState4[1];
24
- var treeData = [{
25
- key: '1',
26
- title: 'jss',
27
- count: 1,
28
- groupBy: 'count',
29
- children: [{
30
- key: '4',
31
- title: 'skjdfkljasklfjkljdsklajfkl就是要长一的点点滴滴的点点滴滴哒哒哒哒哒哒哒哒哒哒哒哒哒哒',
32
- children: []
33
- }, {
34
- key: '5',
35
- title: 567,
36
- children: []
37
- }, {
38
- key: '6',
39
- title: 789,
40
- children: []
41
- }]
42
- }, {
43
- key: '2121212121212',
44
- title: '2',
45
- count: 1,
46
- groupBy: 'count',
47
- children: [{
48
- key: '3',
49
- title: 'jss',
50
- name: 'jss',
51
- children: [],
52
- count: 2
53
- }, {
54
- key: '10',
55
- title: 'jss',
56
- name: 'jss',
57
- children: [],
58
- count: 2
59
- }, {
60
- key: '20',
61
- title: '3',
62
- children: [],
63
- count: 2
64
- }]
65
- }];
66
- var columns = [{
67
- key: 'key',
68
- title: '键值',
69
- dataIndex: 'key',
70
- align: 'center',
71
- width: 400,
72
- fixed: 'left'
73
- }, {
74
- key: 'name',
75
- title: '姓名',
76
- dataIndex: 'name',
77
- align: 'center'
78
- }, {
79
- key: 'count',
80
- title: '数量',
81
- dataIndex: 'count',
82
- align: 'center'
83
- }];
84
- var contextMenuRender = function contextMenuRender(node) {
85
- return [{
86
- key: 'delete',
87
- label: "\u5220\u9664 node".concat(node.key)
88
- }, {
89
- key: 'add',
90
- label: '新增'
91
- }, {
92
- key: 'edit',
93
- label: '编辑'
94
- }];
95
- };
96
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStyles, {
97
- $css: []
98
- }), /*#__PURE__*/React.createElement(Tree, {
99
- title: /*#__PURE__*/React.createElement(Title, null, "\u6807\u8BC6"),
100
- multiple: true,
101
- titleWidth: 400,
102
- contextMenuRender: contextMenuRender,
103
- onContextMenuItemSelect: function onContextMenuItemSelect(node) {
104
- console.log(node.key);
105
- },
106
- treeData: treeData,
107
- columns: columns,
108
- selectedKeys: selectedKeys,
109
- expandedKeys: expandedKeys,
110
- onSelect: function onSelect(selectedKeys) {
111
- return setSelectedKeys(selectedKeys);
112
- },
113
- onExpand: function onExpand(expandedKeys) {
114
- return setExpandedKeys(expandedKeys);
115
- }
116
- }));
117
- });
File without changes