@lemon-fe/components 0.1.22 → 0.1.27

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.
@@ -11,7 +11,7 @@ export interface RowAction<T> {
11
11
  /**
12
12
  * @description 当text不为字符串时,建议加上key属性
13
13
  */
14
- text: ReactElement;
14
+ text: string | ReactElement;
15
15
  key?: string;
16
16
  onClick?: (row: T, index: number) => void;
17
17
  disabled?: boolean;
@@ -10,9 +10,9 @@ interface Props {
10
10
  */
11
11
  loading?: boolean;
12
12
  /**
13
+ * @deprecated
13
14
  * @description 高度是否为100%
14
15
  * @default false
15
- * @deprecated
16
16
  */
17
17
  full?: boolean;
18
18
  left?: ReactNode;
@@ -26,11 +26,12 @@ declare namespace Layout {
26
26
  var Content: (props: {
27
27
  children?: React.ReactNode;
28
28
  left?: React.ReactNode;
29
+ tab?: string | undefined;
29
30
  }) => JSX.Element;
30
31
  }
31
32
  export default Layout;
32
33
  declare function LayoutTabs(props: {
33
- tabs: {
34
+ tabs?: {
34
35
  title: string;
35
36
  key?: string;
36
37
  }[];
@@ -25,6 +25,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
25
  import React, { useState } from 'react';
26
26
  import classNames from 'classnames';
27
27
  import { Spin, Tabs } from 'antd';
28
+ import { get } from 'lodash';
28
29
  import { PREFIX_CLS } from '../constants';
29
30
  import { mapChildren } from '../utils';
30
31
  var prefixCls = "".concat(PREFIX_CLS, "-layout");
@@ -131,7 +132,8 @@ export default function Layout(props) {
131
132
  }
132
133
 
133
134
  function LayoutTabs(props) {
134
- var tabs = props.tabs,
135
+ var _props$tabs = props.tabs,
136
+ tabs = _props$tabs === void 0 ? [] : _props$tabs,
135
137
  children = props.children,
136
138
  className = props.className,
137
139
  activeKey = props.activeKey,
@@ -143,10 +145,12 @@ function LayoutTabs(props) {
143
145
  };
144
146
 
145
147
  var nodes = mapChildren(children, function (node, index) {
148
+ var _get, _get2;
149
+
146
150
  var tab = tabs[index];
147
151
  return /*#__PURE__*/React.createElement(Tabs.TabPane, {
148
- tab: tab.title,
149
- key: getKey(tabs[index])
152
+ tab: (_get = get(node, ['props', 'tab'])) !== null && _get !== void 0 ? _get : tab.title,
153
+ key: (_get2 = get(node, 'key')) !== null && _get2 !== void 0 ? _get2 : getKey(tab)
150
154
  }, node);
151
155
  });
152
156
  return /*#__PURE__*/React.createElement(Layout, _objectSpread({
@@ -193,6 +193,8 @@ var favoriteIcon = /*#__PURE__*/React.createElement("svg", {
193
193
  strokeDasharray: "0,0",
194
194
  mask: "url(#mask-2)"
195
195
  })))));
196
+ var WIDTH = 1280;
197
+ var FAVORITES_POPOVER = 'FAVORITES_POPOVER';
196
198
  export default function Menu(props) {
197
199
  var menus = props.data,
198
200
  onClick = props.onClick,
@@ -208,8 +210,9 @@ export default function Menu(props) {
208
210
 
209
211
  var popup = useRef(null);
210
212
  var drawer = useRef(null);
213
+ var clientWidth = useRef(document.body.clientWidth);
211
214
 
212
- var _useState3 = useState(false),
215
+ var _useState3 = useState(clientWidth.current <= WIDTH),
213
216
  _useState4 = _slicedToArray(_useState3, 2),
214
217
  collapsed = _useState4[0],
215
218
  setCollapsed = _useState4[1];
@@ -224,7 +227,6 @@ export default function Menu(props) {
224
227
  top = _useState8[0],
225
228
  setTop = _useState8[1];
226
229
 
227
- var FAVORITES_POPOVER = 'FAVORITES_POPOVER';
228
230
  var activeMenu = useMemo(function () {
229
231
  var check = function check(path) {
230
232
  if (path) {
@@ -335,6 +337,22 @@ export default function Menu(props) {
335
337
  };
336
338
  }
337
339
  }, [visible]);
340
+ useEffect(function () {
341
+ var handleResize = function handleResize() {
342
+ var width = document.body.clientWidth;
343
+
344
+ if (clientWidth.current > WIDTH && width <= WIDTH) {
345
+ setCollapsed(true);
346
+ }
347
+
348
+ clientWidth.current = width;
349
+ };
350
+
351
+ window.addEventListener('resize', handleResize);
352
+ return function () {
353
+ window.removeEventListener('resize', handleResize);
354
+ };
355
+ }, []);
338
356
 
339
357
  var openDrawer = function openDrawer() {
340
358
  setVisible(true);
@@ -578,7 +596,7 @@ export default function Menu(props) {
578
596
  var target = e.currentTarget;
579
597
  toggle(function () {
580
598
  return openMenu({
581
- name: 'FAVORITES_POPOVER',
599
+ name: FAVORITES_POPOVER,
582
600
  children: _toConsumableArray(favoritesMap.values())
583
601
  }, target);
584
602
  });
@@ -8,6 +8,7 @@ interface Props<KeyType> extends Omit<TreeProps, 'onSelect' | 'selectedKeys' | '
8
8
  showSearch?: boolean;
9
9
  placeholder?: string;
10
10
  header?: ReactNode;
11
+ footer?: ReactNode;
11
12
  operation?: OperationType<KeyType>;
12
13
  onSelect?: (node: TreeData<KeyType>, info: {
13
14
  event: 'select';
@@ -1,5 +1,5 @@
1
1
  var _excluded = ["tabs", "children"],
2
- _excluded2 = ["data", "showSearch", "placeholder", "onSelect", "operation", "header"];
2
+ _excluded2 = ["data", "showSearch", "placeholder", "onSelect", "operation", "header", "footer"];
3
3
 
4
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
5
 
@@ -70,6 +70,7 @@ export default function SiderTree(props) {
70
70
  _onSelect = props.onSelect,
71
71
  operation = props.operation,
72
72
  header = props.header,
73
+ footer = props.footer,
73
74
  restProps = _objectWithoutProperties(props, _excluded2);
74
75
 
75
76
  var prefixCls = "".concat(PREFIX_CLS, "-tree");
@@ -213,6 +214,8 @@ export default function SiderTree(props) {
213
214
  d: "M7 3v7H6V3z"
214
215
  })));
215
216
  }
216
- }, restProps))));
217
+ }, restProps))), !!footer && /*#__PURE__*/React.createElement("div", {
218
+ className: "".concat(prefixCls, "-footer")
219
+ }, footer));
217
220
  }
218
221
  SiderTree.Tabs = SiderTreeTabs;
@@ -56,7 +56,6 @@
56
56
  }
57
57
 
58
58
  &-body {
59
- flex: 1;
60
59
  min-height: 0;
61
60
  padding: 0 @space;
62
61
  overflow: auto;
@@ -70,6 +69,11 @@
70
69
  margin-top: 8px;
71
70
  }
72
71
 
72
+ &-footer {
73
+ margin-top: 12px;
74
+ padding: 0 12px;
75
+ }
76
+
73
77
  &-treenode {
74
78
  display: flex;
75
79
  align-items: center;
package/es/init.js CHANGED
@@ -7,7 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
7
7
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
8
8
 
9
9
  import React from 'react';
10
- import { message, Modal, Select, ConfigProvider, Result, Button, version, DatePicker } from 'antd';
10
+ import { message, Modal, Select, ConfigProvider, Result, Button, version, DatePicker, Cascader } from 'antd';
11
11
  import { config } from '@lemon-fe/hooks';
12
12
  import PageLoading from './PageLoading';
13
13
  import Icons from './Icons';
@@ -86,6 +86,10 @@ export default function init() {
86
86
  suffixIcon: version >= '4.18.9' ? node : function () {
87
87
  return node;
88
88
  }
89
+ }; //@ts-ignore
90
+
91
+ Cascader.defaultProps = {
92
+ suffixIcon: node
89
93
  };
90
94
  DatePicker.RangePicker.defaultProps = {
91
95
  suffixIcon: /*#__PURE__*/React.createElement(Icons.Calendar, null)
package/es/utils.js CHANGED
@@ -9,6 +9,6 @@ export var mapChildren = function mapChildren(children, cb) {
9
9
  }
10
10
 
11
11
  return nodes.filter(function (item) {
12
- return item !== null;
12
+ return item !== null && item !== undefined;
13
13
  }).map(cb);
14
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "0.1.22",
3
+ "version": "0.1.27",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -41,5 +41,5 @@
41
41
  "react": "^17.0.2",
42
42
  "react-dom": "^17.0.2"
43
43
  },
44
- "gitHead": "ee59debc65be8960fe3250c71c75ec907d616f90"
44
+ "gitHead": "227a3713f84228eef6b06d4553cf47d23af1be06"
45
45
  }