@lemon-fe/components 0.1.13 → 0.1.17

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.
@@ -62,21 +62,27 @@ export default function Actions(props) {
62
62
  };
63
63
 
64
64
  var actions = typeof actionsProp === 'function' ? actionsProp(row, index) : actionsProp;
65
+
66
+ var getKey = function getKey(item, idx) {
67
+ var key = item.key || (typeof item.text === 'string' ? item.text : idx);
68
+ return key;
69
+ };
70
+
65
71
  return /*#__PURE__*/React.createElement("div", {
66
72
  className: prefixCls,
67
73
  onMouseLeave: closePop
68
- }, actions.map(function (item) {
74
+ }, actions.map(function (item, idx) {
69
75
  if (item === null) {
70
76
  return null;
71
77
  }
72
78
 
73
- var key = item.text;
79
+ var key = getKey(item, idx);
74
80
  var dropDown = item.dropDown ? item.dropDown.filter(function (item) {
75
81
  return item !== null;
76
82
  }) : [];
77
83
  return /*#__PURE__*/React.createElement("div", {
78
84
  className: classNames("".concat(prefixCls, "-item"), _defineProperty({}, "".concat(prefixCls, "-item-disabled"), item.disabled)),
79
- key: item.text,
85
+ key: key,
80
86
  onMouseEnter: function onMouseEnter() {
81
87
  if (pop !== null && pop.key !== key) {
82
88
  closePop();
@@ -113,10 +119,10 @@ export default function Actions(props) {
113
119
  className: classNames("".concat(prefixCls, "-popover-items"), {
114
120
  animated: visible
115
121
  })
116
- }, pop.items.map(function (item) {
122
+ }, pop.items.map(function (item, idx) {
117
123
  return /*#__PURE__*/React.createElement("div", {
118
124
  className: classNames("".concat(prefixCls, "-popover-item"), _defineProperty({}, "".concat(prefixCls, "-popover-item-disabled"), item.disabled)),
119
- key: item.text,
125
+ key: getKey(item, idx),
120
126
  onClick: function onClick() {
121
127
  if (!item.disabled) {
122
128
  var _item$onClick2;
@@ -1,4 +1,4 @@
1
- import type { ReactText } from 'react';
1
+ import type { ReactElement, ReactText } from 'react';
2
2
  import { TableProps, TableColumnType, TableColumnGroupType, TableColumnsType } from 'antd';
3
3
 
4
4
  export type ColumnType<T> = TableColumnType<T>;
@@ -8,7 +8,11 @@ export type ColumnGroupType<T> = TableColumnGroupType<T>;
8
8
  export type ColumnsType<T> = TableColumnsType<T>;
9
9
 
10
10
  export interface RowAction<T> {
11
- text: string;
11
+ /**
12
+ * @description 当text不为字符串时,建议加上key属性
13
+ */
14
+ text: ReactElement;
15
+ key?: string;
12
16
  onClick?: (row: T, index: number) => void;
13
17
  disabled?: boolean;
14
18
  dropDown?: (RowAction<T> | null)[];
@@ -396,17 +396,23 @@ function Filter(props) {
396
396
  };
397
397
 
398
398
  var _useMemo = useMemo(function () {
399
+ var result = data.filter(function (item) {
400
+ if (activeKeys.has(item.key) && compMap.has(item.type)) {
401
+ return true;
402
+ }
403
+
404
+ return false;
405
+ });
406
+
399
407
  if (!width) {
400
- return [data, false];
408
+ return [result, false];
401
409
  }
402
410
 
403
411
  var rows = [];
404
412
  var currRow = [];
405
413
  var value = 0;
406
- data.forEach(function (item) {
407
- var _compMap$get;
408
-
409
- var itemWidth = getColStyle(item.colSpan || ((_compMap$get = compMap.get(item.type)) === null || _compMap$get === void 0 ? void 0 : _compMap$get.colSpan)).width;
414
+ result.forEach(function (item) {
415
+ var itemWidth = getColStyle(item.colSpan || compMap.get(item.type).colSpan).width;
410
416
 
411
417
  if (value + itemWidth > width) {
412
418
  if (currRow.length > 0) {
@@ -430,11 +436,11 @@ function Filter(props) {
430
436
  var visible = rows.length > 2;
431
437
 
432
438
  if (!collapsed || !visible) {
433
- return [data, visible];
439
+ return [result, visible];
434
440
  }
435
441
 
436
442
  return [[rows[0], rows[rows.length - 1]].flat(), visible];
437
- }, [data, width, collapsed, simple]),
443
+ }, [data, width, collapsed, simple, activeKeys]),
438
444
  _useMemo2 = _slicedToArray(_useMemo, 2),
439
445
  cols = _useMemo2[0],
440
446
  showCollapse = _useMemo2[1];
@@ -485,13 +491,7 @@ function Filter(props) {
485
491
  }), /*#__PURE__*/React.createElement(FormLayout, {
486
492
  direction: "row"
487
493
  }, cols.map(function (item) {
488
- var visible = activeKeys.has(item.key);
489
494
  var target = compMap.get(item.type);
490
-
491
- if (!visible || !target) {
492
- return null;
493
- }
494
-
495
495
  return /*#__PURE__*/React.createElement("div", {
496
496
  style: getColStyle(item.colSpan || target.colSpan),
497
497
  key: item.key
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import type { ReactNode, CSSProperties } from 'react';
2
3
  interface Props {
3
4
  children?: ReactNode;
@@ -11,11 +12,28 @@ interface Props {
11
12
  /**
12
13
  * @description 高度是否为100%
13
14
  * @default false
15
+ * @deprecated
14
16
  */
15
17
  full?: boolean;
16
18
  left?: ReactNode;
17
19
  header?: ReactNode;
18
20
  footer?: ReactNode;
21
+ body?: ReactNode;
19
22
  }
20
- export default function Layout(props: Props): JSX.Element;
21
- export {};
23
+ declare function Layout(props: Props): JSX.Element;
24
+ declare namespace Layout {
25
+ var Tabs: typeof LayoutTabs;
26
+ var Content: (props: {
27
+ children?: React.ReactNode;
28
+ left?: React.ReactNode;
29
+ }) => JSX.Element;
30
+ }
31
+ export default Layout;
32
+ declare function LayoutTabs(props: {
33
+ tabs: {
34
+ title: string;
35
+ key?: string;
36
+ }[];
37
+ activeKey?: string;
38
+ onTabClick?: (activeKey: string, e: React.KeyboardEvent | React.MouseEvent) => void;
39
+ } & Omit<Props, 'body'>): JSX.Element;
@@ -1,3 +1,13 @@
1
+ var _excluded = ["tabs", "children", "className", "activeKey", "onTabClick"];
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
8
+
9
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
+
1
11
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
12
 
3
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -14,12 +24,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
24
 
15
25
  import React, { useState } from 'react';
16
26
  import classNames from 'classnames';
17
- import { Spin } from 'antd';
27
+ import { Spin, Tabs } from 'antd';
18
28
  import { PREFIX_CLS } from '../constants';
29
+ import { mapChildren } from '../utils';
30
+ var prefixCls = "".concat(PREFIX_CLS, "-layout");
19
31
 
20
32
  function Sider(props) {
21
- var prefixCls = props.prefixCls,
22
- children = props.children;
33
+ var children = props.children;
23
34
 
24
35
  var _useState = useState(false),
25
36
  _useState2 = _slicedToArray(_useState, 2),
@@ -81,6 +92,16 @@ function Sider(props) {
81
92
  }))))))));
82
93
  }
83
94
 
95
+ function Content(props) {
96
+ var left = props.left,
97
+ children = props.children;
98
+ return /*#__PURE__*/React.createElement("div", {
99
+ className: "".concat(prefixCls, "-content")
100
+ }, left ? /*#__PURE__*/React.createElement(Sider, null, left) : null, /*#__PURE__*/React.createElement("div", {
101
+ className: "".concat(prefixCls, "-main")
102
+ }, children));
103
+ }
104
+
84
105
  export default function Layout(props) {
85
106
  var className = props.className,
86
107
  style = props.style,
@@ -91,22 +112,52 @@ export default function Layout(props) {
91
112
  full = _props$full === void 0 ? false : _props$full,
92
113
  header = props.header,
93
114
  left = props.left,
94
- footer = props.footer;
95
- var prefixCls = "".concat(PREFIX_CLS, "-layout");
115
+ footer = props.footer,
116
+ body = props.body;
96
117
  return /*#__PURE__*/React.createElement("div", {
97
118
  className: classNames(prefixCls, className, _defineProperty({}, "".concat(prefixCls, "-full"), full)),
98
119
  style: style
99
120
  }, header ? /*#__PURE__*/React.createElement("div", {
100
121
  className: "".concat(prefixCls, "-header")
101
122
  }, header) : null, /*#__PURE__*/React.createElement("div", {
102
- className: "".concat(prefixCls, "-content")
103
- }, left ? /*#__PURE__*/React.createElement(Sider, {
104
- prefixCls: prefixCls
105
- }, left) : null, /*#__PURE__*/React.createElement("div", {
106
- className: "".concat(prefixCls, "-main")
123
+ className: "".concat(prefixCls, "-body")
124
+ }, body || /*#__PURE__*/React.createElement(Content, {
125
+ left: left
107
126
  }, children)), footer ? /*#__PURE__*/React.createElement("div", {
108
127
  className: "".concat(prefixCls, "-footer")
109
128
  }, footer) : null, loading && /*#__PURE__*/React.createElement("div", {
110
129
  className: "".concat(prefixCls, "-spin")
111
130
  }, /*#__PURE__*/React.createElement(Spin, null)));
112
- }
131
+ }
132
+
133
+ function LayoutTabs(props) {
134
+ var tabs = props.tabs,
135
+ children = props.children,
136
+ className = props.className,
137
+ activeKey = props.activeKey,
138
+ onTabClick = props.onTabClick,
139
+ restProps = _objectWithoutProperties(props, _excluded);
140
+
141
+ var getKey = function getKey(tab) {
142
+ return tab.key || tab.title;
143
+ };
144
+
145
+ var nodes = mapChildren(children, function (node, index) {
146
+ var tab = tabs[index];
147
+ return /*#__PURE__*/React.createElement(Tabs.TabPane, {
148
+ tab: tab.title,
149
+ key: getKey(tabs[index])
150
+ }, node);
151
+ });
152
+ return /*#__PURE__*/React.createElement(Layout, _objectSpread({
153
+ className: classNames(className, "".concat(prefixCls, "-tabs-wrapper")),
154
+ body: /*#__PURE__*/React.createElement(Tabs, {
155
+ accessKey: activeKey,
156
+ onTabClick: onTabClick,
157
+ className: "".concat(prefixCls, "-tabs")
158
+ }, nodes)
159
+ }, restProps));
160
+ }
161
+
162
+ Layout.Tabs = LayoutTabs;
163
+ Layout.Content = Content;
@@ -11,20 +11,32 @@
11
11
  background-color: #f2f2f2;
12
12
  }
13
13
 
14
- &-content {
15
- display: flex;
14
+ &-body {
16
15
  flex: 1;
17
16
  min-height: 0;
18
- overflow: hidden;
19
- background-color: #fff;
20
- border-top-left-radius: 8px;
21
- border-top-right-radius: 8px;
22
17
 
23
18
  &:first-child {
24
19
  margin-top: @space;
25
20
  }
26
21
  }
27
22
 
23
+ &-tabs {
24
+ .fullTabs();
25
+ }
26
+
27
+ &-tabs-wrapper &-header {
28
+ padding-bottom: 0;
29
+ }
30
+
31
+ &-content {
32
+ display: flex;
33
+ height: 100%;
34
+ overflow: hidden;
35
+ background-color: #fff;
36
+ border-top-left-radius: 8px;
37
+ border-top-right-radius: 8px;
38
+ }
39
+
28
40
  &-left {
29
41
  position: relative;
30
42
 
@@ -66,12 +66,17 @@
66
66
  & > .ant-tabs-content-holder {
67
67
  flex: 1;
68
68
 
69
- .ant-tabs-content {
69
+ & > .ant-tabs-content {
70
70
  height: 100%;
71
71
  }
72
72
  }
73
73
  }
74
74
 
75
+ &-flex > .ant-tabs,
76
+ &-table > .ant-tabs {
77
+ min-height: 0;
78
+ }
79
+
75
80
  &-tab {
76
81
  display: inline-flex;
77
82
  align-self: flex-start;
@@ -38,7 +38,6 @@ import { Input, Tabs } from 'antd';
38
38
  import { PREFIX_CLS } from '../constants';
39
39
  import TreeNodeTitle from './TreeNodeTitle';
40
40
  import Icons from '../Icons';
41
- import TabBar from '../TabBar';
42
41
  import { mapChildren } from '../utils';
43
42
  import empty from './empty.png';
44
43
 
@@ -52,22 +51,9 @@ function SiderTreeTabs(props) {
52
51
  };
53
52
 
54
53
  var prefixCls = "".concat(PREFIX_CLS, "-tree");
55
- return /*#__PURE__*/React.createElement(Tabs, _objectSpread(_objectSpread({
54
+ return /*#__PURE__*/React.createElement(Tabs, _objectSpread({
56
55
  className: "".concat(prefixCls, "-tabs")
57
- }, restProps), {}, {
58
- renderTabBar: function renderTabBar(tabProps) {
59
- var activeKey = tabProps.activeKey,
60
- _onTabClick = tabProps.onTabClick;
61
- return /*#__PURE__*/React.createElement(TabBar, {
62
- className: "".concat(PREFIX_CLS, "-tree-tab-bar"),
63
- activeKey: activeKey,
64
- tabs: tabs,
65
- onTabClick: function onTabClick(key, _, e) {
66
- return _onTabClick(key, e);
67
- }
68
- });
69
- }
70
- }), mapChildren(children, function (child, index) {
56
+ }, restProps), mapChildren(children, function (child, index) {
71
57
  var tab = tabs[index];
72
58
  return /*#__PURE__*/React.createElement(Tabs.TabPane, {
73
59
  tab: tab.title,
@@ -44,25 +44,13 @@
44
44
  }
45
45
 
46
46
  &-tabs {
47
- height: 100%;
48
-
49
- & > .ant-tabs-content-holder {
50
- flex: 1;
51
-
52
- & > .ant-tabs-content {
53
- height: 100%;
47
+ .fullTabs();
54
48
 
55
- & > .ant-tabs-tabpane {
56
- height: 100%;
57
- }
58
- }
49
+ & > .ant-tabs-nav {
50
+ margin: 0 @space;
59
51
  }
60
52
  }
61
53
 
62
- &-tab-bar {
63
- margin: 0 @space;
64
- }
65
-
66
54
  &-header {
67
55
  padding: 0 @space;
68
56
  }
@@ -217,7 +205,3 @@
217
205
  .@{prefixCls}-layout-left .@{prefixCls}-tree-wrapper:first-child .@{prefixCls}-tree-header {
218
206
  padding-right: 12px + @space;
219
207
  }
220
-
221
- .ant-tabs-tabpane .@{prefixCls}-tree-wrapper:first-child .@{prefixCls}-tree-header {
222
- padding-right: @space;
223
- }
package/es/overrides.less CHANGED
@@ -4,6 +4,11 @@ a[title='站长统计'] {
4
4
 
5
5
  @blue-base: #2357df;
6
6
 
7
+ ::selection {
8
+ color: inherit;
9
+ background: #d3ddf9;
10
+ }
11
+
7
12
  /** basic */
8
13
 
9
14
  @height-base: 32px;
@@ -71,6 +76,10 @@ a[title='站长统计'] {
71
76
  border-radius: 8px;
72
77
  }
73
78
 
79
+ .ant-modal-header {
80
+ border-radius: 8px 8px 0 0;
81
+ }
82
+
74
83
  .ant-modal-confirm {
75
84
  .ant-modal-body {
76
85
  padding: 0;
package/es/utils.less CHANGED
@@ -1,10 +1,14 @@
1
1
  /* stylelint-disable property-no-unknown */
2
2
 
3
+ // primary color
4
+
3
5
  .primary(@alpha: 1) {
4
6
  rgb: rgb(var(--lemon-primary-color));
5
7
  rgba: rgba(var(--lemon-primary-color), @alpha);
6
8
  }
7
9
 
10
+ // popover
11
+
8
12
  .popoverInner(@width: 120px) {
9
13
  position: relative;
10
14
  width: @width;
@@ -51,3 +55,35 @@
51
55
  background-color: #eee;
52
56
  }
53
57
  }
58
+
59
+ // tabs
60
+
61
+ .fullTabs() {
62
+ height: 100%;
63
+
64
+ & > .ant-tabs-nav {
65
+ .ant-tabs-tab {
66
+ padding: 12px 12px 14px;
67
+
68
+ &.ant-tabs-tab-active .ant-tabs-tab-btn {
69
+ text-shadow: unset;
70
+ }
71
+ }
72
+
73
+ .ant-tabs-tab + .ant-tabs-tab {
74
+ margin-left: 24px;
75
+ }
76
+ }
77
+
78
+ & > .ant-tabs-content-holder {
79
+ flex: 1;
80
+
81
+ & > .ant-tabs-content {
82
+ height: 100%;
83
+
84
+ & > .ant-tabs-tabpane {
85
+ height: 100%;
86
+ }
87
+ }
88
+ }
89
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "0.1.13",
3
+ "version": "0.1.17",
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": "11880998a3dbc05d5385b43a9a3497db75815e4d"
44
+ "gitHead": "a8bf149d318e0f6a021bce9a23fa8ca64dd926f9"
45
45
  }