@lemon-fe/kits 1.0.0-107 → 1.0.0-109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,3 +31,8 @@ Build library via `father-build`,
31
31
  ```bash
32
32
  $ npm run build
33
33
  ```
34
+
35
+ ## Break Changes
36
+
37
+ - Layout Tab 属性 key 必须,title 可选
38
+ - Section Tab 属性 Key 必须,title 可选
@@ -879,7 +879,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
879
879
  value: function isPreserveSelected() {
880
880
  var rowSelection = this.props.rowSelection;
881
881
 
882
- if (rowSelection === undefined) {
882
+ if (rowSelection === undefined || rowSelection.type === 'radio') {
883
883
  return false;
884
884
  }
885
885
 
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { ReactNode, CSSProperties } from 'react';
3
3
  interface Tab {
4
- title: string;
5
- key?: string;
4
+ title?: ReactNode;
5
+ key: string;
6
6
  }
7
7
  interface Props {
8
8
  children?: ReactNode;
@@ -28,10 +28,6 @@ import { Resizable } from 'react-resizable';
28
28
  import { mapChildren, prefixClassName } from "../utils";
29
29
  var prefix = prefixClassName('layout');
30
30
 
31
- var getKey = function getKey(tab) {
32
- return tab.key || tab.title;
33
- };
34
-
35
31
  function Sider(props) {
36
32
  var _classNames;
37
33
 
@@ -174,7 +170,7 @@ export default function Layout(props) {
174
170
  items: tabs.map(function (item) {
175
171
  return {
176
172
  label: item.title,
177
- key: getKey(item)
173
+ key: item.key
178
174
  };
179
175
  })
180
176
  }) : null, body || /*#__PURE__*/React.createElement(Content, {
@@ -208,7 +204,7 @@ function LayoutTabs(props) {
208
204
  var tab = tabs[index];
209
205
  return {
210
206
  label: (_get = get(node, ['props', 'tab'])) !== null && _get !== void 0 ? _get : tab.title,
211
- key: (_get2 = get(node, 'key')) !== null && _get2 !== void 0 ? _get2 : getKey(tab),
207
+ key: (_get2 = get(node, 'key')) !== null && _get2 !== void 0 ? _get2 : tab.key,
212
208
  forceRender: get(node, ['props', 'forceRender']),
213
209
  children: node
214
210
  };
@@ -1,8 +1,9 @@
1
+ import { type ReactNode } from 'react';
1
2
  import type { MouseEvent } from 'react';
2
3
  interface Props {
3
4
  prefixCls: string;
4
5
  tabs: {
5
- title?: string;
6
+ title?: ReactNode;
6
7
  key: string;
7
8
  }[];
8
9
  activeKey?: string;
@@ -30,10 +30,14 @@ interface Props extends Pick<TabsProps, 'activeKey' | 'onTabClick'> {
30
30
  * @description tabs
31
31
  */
32
32
  tabs?: {
33
- title?: string;
33
+ title?: ReactNode;
34
34
  key: string;
35
35
  forceRender?: boolean;
36
36
  }[];
37
+ /**
38
+ * 是否隐藏TabBar
39
+ */
40
+ hideTabBar?: boolean;
37
41
  /**
38
42
  * @description body元素的样式
39
43
  */
@@ -8,8 +8,9 @@ import React from 'react';
8
8
  import classNames from 'classnames';
9
9
  import { Tabs } from 'antd';
10
10
  import { mapChildren } from "../utils";
11
- import { PREFIX_CLS } from "../../constants";
12
11
  import TabBar from "./TabBar";
12
+ import { prefixClassName } from "../utils";
13
+ var prefix = prefixClassName('section');
13
14
  export default function Section(props) {
14
15
  var _classNames;
15
16
 
@@ -24,8 +25,8 @@ export default function Section(props) {
24
25
  actions = props.actions,
25
26
  flex = props.flex,
26
27
  activeKey = props.activeKey,
27
- _onTabClick = props.onTabClick;
28
- var prefixCls = PREFIX_CLS + '-section';
28
+ _onTabClick = props.onTabClick,
29
+ hideTabBar = props.hideTabBar;
29
30
  var containerStyle = style;
30
31
 
31
32
  if (flex) {
@@ -36,22 +37,40 @@ export default function Section(props) {
36
37
 
37
38
  var hasActions = !!actions;
38
39
  return /*#__PURE__*/React.createElement("div", {
39
- className: classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-").concat(type), !!type), _defineProperty(_classNames, "".concat(prefixCls, "-flex"), !!flex), _classNames), className),
40
+ className: classNames(prefix(), (_classNames = {}, _defineProperty(_classNames, prefix(type), !!type), _defineProperty(_classNames, prefix('flex'), !!flex), _classNames), className),
40
41
  style: containerStyle
41
42
  }, title || hasActions ? /*#__PURE__*/React.createElement("div", {
42
- className: "".concat(prefixCls, "-header")
43
+ className: prefix('header')
43
44
  }, /*#__PURE__*/React.createElement("div", {
44
- className: "".concat(prefixCls, "-title")
45
+ className: prefix('title')
45
46
  }, title), actions) : null, tabs !== undefined && tabs.length > 0 ? Array.isArray(children) && children.length > 1 ? /*#__PURE__*/React.createElement(Tabs, {
46
47
  activeKey: activeKey,
47
48
  onTabClick: _onTabClick,
49
+ items: mapChildren(children, function (child, index) {
50
+ var _tabs$index = tabs[index],
51
+ tab = _tabs$index.title,
52
+ key = _tabs$index.key,
53
+ forceRender = _tabs$index.forceRender;
54
+ return {
55
+ key: key,
56
+ label: tab,
57
+ className: prefix('body'),
58
+ style: bodyStyle,
59
+ forceRender: forceRender,
60
+ children: child
61
+ };
62
+ }),
48
63
  renderTabBar: function renderTabBar(tabProps) {
64
+ if (hideTabBar) {
65
+ return null;
66
+ }
67
+
49
68
  var mKey = tabProps.activeKey,
50
69
  mClick = tabProps.onTabClick;
51
70
  return /*#__PURE__*/React.createElement(TabBar, {
52
71
  activeKey: mKey,
53
72
  tabs: tabs,
54
- prefixCls: prefixCls,
73
+ prefixCls: prefix(),
55
74
  onTabClick: function onTabClick(key, index, e) {
56
75
  mClick(key, e);
57
76
 
@@ -63,22 +82,10 @@ export default function Section(props) {
63
82
  }
64
83
  });
65
84
  }
66
- }, mapChildren(children, function (child, index) {
67
- var _tabs$index = tabs[index],
68
- tab = _tabs$index.title,
69
- key = _tabs$index.key,
70
- forceRender = _tabs$index.forceRender;
71
- return /*#__PURE__*/React.createElement(Tabs.TabPane, {
72
- tab: tab,
73
- key: key,
74
- className: "".concat(prefixCls, "-body"),
75
- style: bodyStyle,
76
- forceRender: forceRender
77
- }, child);
78
- })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TabBar, {
85
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TabBar, {
79
86
  activeKey: activeKey,
80
87
  tabs: tabs,
81
- prefixCls: prefixCls,
88
+ prefixCls: prefix(),
82
89
  onTabClick: function onTabClick(key, index, e) {
83
90
  if (_onTabClick) {
84
91
  _onTabClick(key, e);
@@ -89,10 +96,10 @@ export default function Section(props) {
89
96
  }
90
97
  }
91
98
  }), /*#__PURE__*/React.createElement("div", {
92
- className: "".concat(prefixCls, "-body"),
99
+ className: prefix('body'),
93
100
  style: bodyStyle
94
101
  }, children)) : /*#__PURE__*/React.createElement("div", {
95
- className: "".concat(prefixCls, "-body"),
102
+ className: prefix('body'),
96
103
  style: bodyStyle
97
104
  }, children));
98
105
  }
@@ -132,3 +132,7 @@
132
132
  min-height: 0;
133
133
  }
134
134
  }
135
+
136
+ .@{prefixCls}-section-body > .@{prefixCls}-tab-bar:first-child {
137
+ margin-top: -@space-v;
138
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/kits",
3
- "version": "1.0.0-107",
3
+ "version": "1.0.0-109",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -31,12 +31,12 @@
31
31
  ]
32
32
  },
33
33
  "dependencies": {
34
- "@ag-grid-community/client-side-row-model": "^29.2.0",
35
- "@ag-grid-community/core": "^29.2.0",
36
- "@ag-grid-community/csv-export": "^29.2.0",
37
- "@ag-grid-community/infinite-row-model": "^29.2.0",
38
- "@ag-grid-community/react": "^29.2.0",
39
- "@ag-grid-community/styles": "^29.2.0",
34
+ "@ag-grid-community/client-side-row-model": "29.2.0",
35
+ "@ag-grid-community/core": "29.2.0",
36
+ "@ag-grid-community/csv-export": "29.2.0",
37
+ "@ag-grid-community/infinite-row-model": "29.2.0",
38
+ "@ag-grid-community/react": "29.2.0",
39
+ "@ag-grid-community/styles": "29.2.0",
40
40
  "@ant-design/icons": "^4.7.0",
41
41
  "@lemon-fe/hooks": "^0.1.142",
42
42
  "@lemon-fe/utils": "^0.1.117",
@@ -59,12 +59,12 @@
59
59
  "react": ">=16.8"
60
60
  },
61
61
  "devDependencies": {
62
- "@ag-grid-enterprise/clipboard": "^29.2.0",
63
- "@ag-grid-enterprise/column-tool-panel": "^29.2.0",
64
- "@ag-grid-enterprise/master-detail": "^29.2.0",
65
- "@ag-grid-enterprise/menu": "^29.2.0",
66
- "@ag-grid-enterprise/row-grouping": "^29.2.0",
67
- "@ag-grid-enterprise/side-bar": "^29.2.0",
62
+ "@ag-grid-enterprise/clipboard": "29.2.0",
63
+ "@ag-grid-enterprise/column-tool-panel": "29.2.0",
64
+ "@ag-grid-enterprise/master-detail": "29.2.0",
65
+ "@ag-grid-enterprise/menu": "29.2.0",
66
+ "@ag-grid-enterprise/row-grouping": "29.2.0",
67
+ "@ag-grid-enterprise/side-bar": "29.2.0",
68
68
  "@testing-library/jest-dom": "^5.15.1",
69
69
  "@testing-library/react": "^13.0.0",
70
70
  "@types/color-string": "^1.5.2",