@kep-platform/basic-component 0.0.58 → 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 = (
@@ -414,18 +414,18 @@ export default function Table(_ref3) {
414
414
  columns: formatedColumns,
415
415
  isFlex: isFlex
416
416
  }));else return undefined;
417
- })) : empty), pagination !== false && dataSource.length !== 0 && /*#__PURE__*/React.createElement(Pagination, _extends({}, pagination, {
417
+ })) : empty), pagination !== false && ((pagination === null || pagination === void 0 ? void 0 : pagination.total) || dataSource.length) !== 0 && /*#__PURE__*/React.createElement(Pagination, _extends({}, pagination, {
418
418
  total: (pagination === null || pagination === void 0 ? void 0 : pagination.total) || dataSource.length,
419
419
  justifyContent: "right",
420
420
  onChange: function onChange(current, pageSize) {
421
- _onChange2 === null || _onChange2 === void 0 || _onChange2({
421
+ _onChange2 === null || _onChange2 === void 0 || _onChange2(_objectSpread(_objectSpread({}, pagination), {}, {
422
422
  current: current,
423
423
  pageSize: pageSize
424
- });
425
- setPagination({
424
+ }));
425
+ setPagination(_objectSpread(_objectSpread({}, pagination), {}, {
426
426
  current: current,
427
427
  pageSize: pageSize
428
- });
428
+ }));
429
429
  }
430
430
  })));
431
431
  }
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
- export declare const MainArea: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("../Flex").FlexItemProps | keyof React.HtmlHTMLAttributes<HTMLDivElement>> & import("../Flex").FlexItemProps & React.HtmlHTMLAttributes<HTMLDivElement>, "ref"> & {
2
+ export declare const MainArea: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HtmlHTMLAttributes<HTMLDivElement> | keyof import("../Flex").FlexItemProps> & import("../Flex").FlexItemProps & React.HtmlHTMLAttributes<HTMLDivElement>, "ref"> & {
3
3
  ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
4
4
  }, never>> & string;
5
5
  type MainPropertyProps = {
@@ -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.58",
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.58",
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": "a493e28e826430e666079e3d2568460c14912886"
90
+ "gitHead": "05d862e763f6127675b8c148c87e1671f18ac33e"
91
91
  }