@kep-platform/basic-component 0.0.59 → 0.0.60

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,6 +46,8 @@ declare global {
46
46
  type TreeNodeType = {
47
47
  [key: string]: any;
48
48
  groupBy?: Condition[];
49
+ selectable?: boolean;
50
+ isLeaf?: boolean;
49
51
  };
50
52
 
51
53
  type onExpandHandler = (
@@ -14,7 +14,7 @@ export declare const Column: import("styled-components/dist/types").IStyledCompo
14
14
  title?: React.ReactNode;
15
15
  index?: number | undefined;
16
16
  itemRender?: ListItemRender | undefined;
17
- } & Omit<React.HtmlHTMLAttributes<HTMLLIElement>, "title">, Omit<ColumnType, "dataIndex" | "render"> & {
17
+ } & Omit<React.HtmlHTMLAttributes<HTMLLIElement>, "title">, Omit<ColumnType, "render" | "dataIndex"> & {
18
18
  key: React.Key;
19
19
  title?: React.ReactNode;
20
20
  index?: number | undefined;
@@ -99,6 +99,9 @@ var groupTreeNodeByPropertyName = function groupTreeNodeByPropertyName(condition
99
99
  export var nodeTypeMap = {
100
100
  virtual: 'virtual'
101
101
  };
102
+ function isFalse(value) {
103
+ return typeof value === 'boolean' && value === false;
104
+ }
102
105
  export var TreeNodeController = observer(function (_ref) {
103
106
  var node = _ref.node,
104
107
  _ref$selectedKeys = _ref.selectedKeys,
@@ -122,15 +125,16 @@ export var TreeNodeController = observer(function (_ref) {
122
125
  return level + 1;
123
126
  }, [level]);
124
127
  var selected = useMemo(function () {
125
- return selectedKeys.includes(node[fieldNames.key]);
128
+ return selectedKeys.includes(node[fieldNames.key]) && !isFalse(node.selectable);
126
129
  }, [selectedKeys, fieldNames, node]);
127
130
  var expanded = useMemo(function () {
128
- return expandedKeys.includes(node[fieldNames.key]) || node.nodeType === nodeTypeMap.virtual;
131
+ return (expandedKeys.includes(node[fieldNames.key]) || node.nodeType === nodeTypeMap.virtual) && !node.isLeaf;
129
132
  }, [expandedKeys, fieldNames, node]);
130
133
  var treeNodeGroup = useMemo(function () {
131
134
  return groupTreeNodeByPropertyName(node.groupBy, node.children || []);
132
135
  }, [node.children, node.groupBy]);
133
136
  var onClickNodeHandler = useCallback(function (e) {
137
+ if (typeof node.selectable === 'boolean' && node.selectable === false) return;
134
138
  if (multiple) {
135
139
  if (selected) {
136
140
  onSelect(selectedKeys.filter(function (key) {
@@ -154,7 +158,7 @@ export var TreeNodeController = observer(function (_ref) {
154
158
  selected: !selected
155
159
  });
156
160
  }
157
- }, [onSelect, selectedKeys, multiple, selected]);
161
+ }, [onSelect, selectedKeys, multiple, selected, node]);
158
162
  var onContextMenuHandler = useCallback(function (e) {
159
163
  onSelect([node[fieldNames.key]], {
160
164
  nativeEvent: e,
@@ -192,7 +196,8 @@ export var TreeNodeController = observer(function (_ref) {
192
196
  cursor: "pointer",
193
197
  onClick: onClickExpandIconhandler
194
198
  }, /*#__PURE__*/React.createElement(ExpandedIcon, {
195
- expanded: expanded
199
+ expanded: expanded,
200
+ hidden: node.isLeaf
196
201
  })), /*#__PURE__*/React.createElement(TitleArea, {
197
202
  flex: 1
198
203
  }, titleRender ? titleRender(node) : node[fieldNames.title])),
@@ -205,7 +210,7 @@ export var TreeNodeController = observer(function (_ref) {
205
210
  });
206
211
  return /*#__PURE__*/React.createElement(React.Fragment, null, node.nodeType !== nodeTypeMap.virtual && /*#__PURE__*/React.createElement(TreeNode, {
207
212
  key: node[fieldNames.key],
208
- selected: selectedKeys.includes(node[fieldNames.key]),
213
+ selected: selected,
209
214
  width: width,
210
215
  onClick: onClickNodeHandler,
211
216
  onContextMenu: onContextMenuHandler
package/dist/Tree/test.js CHANGED
@@ -74,6 +74,8 @@ var mystore = new MyStore([{
74
74
  key: '1',
75
75
  title: 'jss',
76
76
  count: 1,
77
+ selectable: false,
78
+ isLeaf: true,
77
79
  children: [{
78
80
  key: '4',
79
81
  title: 'skjdfkljasklfjkljdsklajfkl就是要长一的点点滴滴的点点滴滴哒哒哒哒哒哒哒哒哒哒哒哒哒哒',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kep-platform/basic-component",
3
- "version": "0.0.59",
3
+ "version": "0.0.60",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@ant-design/icons": "^5.3.7",
50
- "@kep-platform/hooks": "^0.0.59",
50
+ "@kep-platform/hooks": "^0.0.60",
51
51
  "color": "^4.2.3",
52
52
  "rc-pagination": "^4.1.0"
53
53
  },
@@ -87,5 +87,5 @@
87
87
  "authors": [
88
88
  "less-step-jss 1599925910@qq.com"
89
89
  ],
90
- "gitHead": "155b608b6a424086947c5f65735a39644d8225d9"
90
+ "gitHead": "05d862e763f6127675b8c148c87e1671f18ac33e"
91
91
  }