@kep-platform/basic-component 0.0.59 → 0.0.63

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 = (
@@ -21,7 +21,7 @@ var StyledButton = styled('button').withConfig({
21
21
  shouldForwardProp: function shouldForwardProp(prop) {
22
22
  return !['isActive'].includes(prop);
23
23
  }
24
- })(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-weight: ", ";\n outline: none;\n border-width: ", ";\n border-style: solid;\n padding: var(--kep-platform-padding-block) var(--kep-platform-padding-inline);\n font-size: var(--kep-platform-font-size);\n ", ";\n /* type \u63A7\u5236 */\n ", "\n /* \u662F\u5426\u70B9\u51FBactive */\n ", "\n /* size\u63A7\u5236 */\n ", "\n &:hover {\n opacity: 0.7;\n }\n"])), function (props) {
24
+ })(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-weight: ", ";\n outline: none;\n border-width: ", ";\n border-style: solid;\n padding: var(--kep-platform-padding-block) var(--kep-platform-padding-inline);\n font-size: var(--kep-platform-font-size);\n word-break: normal;\n white-space: nowrap;\n ", ";\n /* type \u63A7\u5236 */\n ", "\n /* \u662F\u5426\u70B9\u51FBactive */\n ", "\n /* size\u63A7\u5236 */\n ", "\n &:hover {\n opacity: 0.7;\n }\n"])), function (props) {
25
25
  return props.theme.buttonFontWeight || theme.fontWeight;
26
26
  }, function (props) {
27
27
  return props.theme.background || theme.borderWidth;
@@ -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;
@@ -26,11 +26,11 @@ export var Column = styled(ListItem).withConfig({
26
26
  shouldForwardProp: function shouldForwardProp(prop) {
27
27
  return !['width', 'isFlex', 'bordered', 'hideInTable', 'filter', 'sorter', 'rowIndex', 'focused'].includes(prop);
28
28
  }
29
- })(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: var(--kep-platform-padding-xs);\n text-align: ", ";\n white-space: break-spaces;\n word-break: break-all;\n border-bottom: var(--kep-platform-line-width) var(--kep-platform-line-type)\n var(--kep-platform-color-border-secondary);\n ", "\n background-color: var(--kep-platform-color-bg-base);\n ", ":hover & {\n background-color: var(--kep-platform-color-bg-hover);\n }\n ", "\n ", "\n ", "\n"])), function (props) {
29
+ })(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: var(--kep-platform-padding-xs);\n text-align: ", ";\n white-space: break-spaces;\n word-break: break-all;\n min-width: 0;\n max-width: 100%;\n border-bottom: var(--kep-platform-line-width) var(--kep-platform-line-type) var(--kep-platform-color-border-secondary);\n ", "\n background-color: var(--kep-platform-color-bg-base);\n ", ":hover & {\n background-color: var(--kep-platform-color-bg-hover);\n }\n ", "\n ", "\n ", "\n"])), function (props) {
30
30
  return props.align;
31
31
  }, function (props) {
32
32
  if (props.bordered) {
33
- return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n border: var(--kep-platform-line-width) var(--kep-platform-line-type)\n var(--kep-platform-color-border-secondary);\n border-top-width: 0;\n border-left-width: 0;\n "])));
33
+ return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n border: var(--kep-platform-line-width) var(--kep-platform-line-type) var(--kep-platform-color-border-secondary);\n border-top-width: 0;\n border-left-width: 0;\n "])));
34
34
  }
35
35
  }, ColumnList, function (props) {
36
36
  if (props.isFlex) {
@@ -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.63",
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.63",
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": "34462a30b1ba2008cf45b40ca6e7cafe3109bb6f"
91
91
  }