@lemon-fe/components 0.0.32 → 0.1.0

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.
Files changed (57) hide show
  1. package/es/Actions/index.d.ts +3 -2
  2. package/es/Actions/index.js +29 -28
  3. package/es/Actions/index.less +26 -51
  4. package/es/BaseTable/Actions.d.ts +8 -0
  5. package/es/BaseTable/Actions.js +119 -0
  6. package/es/BaseTable/ResizeHeaderCell.js +16 -5
  7. package/es/BaseTable/index.js +63 -19
  8. package/es/BaseTable/index.less +99 -0
  9. package/es/BaseTable/typings.d.ts +11 -0
  10. package/es/DurationPicker/index.js +2 -10
  11. package/es/DurationPicker/index.less +4 -4
  12. package/es/Filter/index.js +100 -41
  13. package/es/Filter/index.less +11 -7
  14. package/es/Filter/typings.d.ts +3 -2
  15. package/es/FormLayout/index.less +1 -1
  16. package/es/Icons/Calendar.d.ts +5 -0
  17. package/es/Icons/Calendar.js +47 -0
  18. package/es/Icons/Down.js +10 -5
  19. package/es/Icons/More.d.ts +5 -0
  20. package/es/Icons/More.js +44 -0
  21. package/es/Icons/Search.js +8 -12
  22. package/es/Icons/index.d.ts +4 -0
  23. package/es/Icons/index.js +5 -1
  24. package/es/Layout/index.js +80 -3
  25. package/es/Layout/index.less +69 -25
  26. package/es/MainFramework/components/DropMenu/index.less +2 -32
  27. package/es/MainFramework/components/Menu/index.less +2 -2
  28. package/es/MainFramework/components/RefreshButton/index.less +2 -32
  29. package/es/Portal/index.d.ts +12 -0
  30. package/es/Portal/index.js +72 -0
  31. package/es/Section/TabBar.d.ts +12 -0
  32. package/es/Section/TabBar.js +48 -0
  33. package/es/Section/index.js +38 -53
  34. package/es/Section/index.less +44 -91
  35. package/es/SiderTree/TreeNodeTitle.d.ts +1 -1
  36. package/es/SiderTree/TreeNodeTitle.js +17 -35
  37. package/es/SiderTree/index.d.ts +3 -1
  38. package/es/SiderTree/index.js +40 -64
  39. package/es/SiderTree/index.less +76 -75
  40. package/es/SymbolIcon/index.d.ts +8 -0
  41. package/es/SymbolIcon/index.js +32 -0
  42. package/es/SymbolIcon/index.less +7 -0
  43. package/es/TabBar/index.d.ts +14 -0
  44. package/es/TabBar/index.js +52 -0
  45. package/es/TabBar/index.less +31 -0
  46. package/es/index.d.ts +3 -1
  47. package/es/index.js +3 -1
  48. package/es/index.less +4 -35
  49. package/es/init.js +15 -16
  50. package/es/overrides.less +136 -0
  51. package/es/theme.less +1 -8
  52. package/es/utils.d.ts +2 -0
  53. package/es/utils.js +14 -0
  54. package/es/utils.less +53 -0
  55. package/package.json +3 -3
  56. package/es/BaseTable/Sort.d.ts +0 -10
  57. package/es/BaseTable/Sort.js +0 -122
@@ -3,11 +3,12 @@ import type { CSSProperties } from 'react';
3
3
  import { ButtonProps } from 'antd';
4
4
  interface ActionBtn extends ButtonProps {
5
5
  text: string | ReactElement;
6
+ onClick?: () => void;
6
7
  /**
7
- * deprecated please use onClick
8
+ * @deprecated
9
+ * 请不要使用
8
10
  */
9
11
  action?: () => void;
10
- onClick?: () => void;
11
12
  dropDown?: ({
12
13
  text: string;
13
14
  onClick: () => void;
@@ -1,4 +1,4 @@
1
- var _excluded = ["disabled", "dropDown", "text", "action", "onClick", "icon"];
1
+ var _excluded = ["disabled", "dropDown", "text", "onClick", "icon", "action"];
2
2
 
3
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
4
 
@@ -24,9 +24,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
24
 
25
25
  import React, { Fragment, useState } from 'react';
26
26
  import { Space, Dropdown, Menu, Button, Popover } from 'antd';
27
- import { EllipsisOutlined } from '@ant-design/icons';
28
27
  import classNames from 'classnames';
29
- import Down from '../Icons/Down';
28
+ import Icons from '../Icons';
30
29
  import { PREFIX_CLS } from '../constants';
31
30
 
32
31
  function Actions(props) {
@@ -65,9 +64,9 @@ function Actions(props) {
65
64
  var disabled = item.disabled,
66
65
  dropDown = item.dropDown,
67
66
  text = item.text,
68
- action = item.action,
69
67
  onClick = item.onClick,
70
68
  icon = item.icon,
69
+ action = item.action,
71
70
  rest = _objectWithoutProperties(item, _excluded);
72
71
 
73
72
  if ( /*#__PURE__*/React.isValidElement(text)) {
@@ -94,13 +93,19 @@ function Actions(props) {
94
93
  if (handleClick !== undefined) {
95
94
  return /*#__PURE__*/React.createElement(Dropdown.Button, {
96
95
  key: text,
97
- type: 'text',
98
96
  disabled: disabled,
99
97
  overlay: overlay,
100
- onClick: handleClick
101
- }, icon ? /*#__PURE__*/React.createElement("span", {
102
- className: "".concat(prefixCls, "-actions-icon")
103
- }, icon) : null, text);
98
+ onClick: handleClick,
99
+ buttonsRender: function buttonsRender(_ref) {
100
+ var _ref2 = _slicedToArray(_ref, 2),
101
+ leftBtn = _ref2[0],
102
+ _ = _ref2[1];
103
+
104
+ return [leftBtn, /*#__PURE__*/React.createElement(Button, {
105
+ icon: /*#__PURE__*/React.createElement(Icons.More, null)
106
+ })];
107
+ }
108
+ }, text);
104
109
  }
105
110
 
106
111
  return /*#__PURE__*/React.createElement(Dropdown, {
@@ -109,31 +114,28 @@ function Actions(props) {
109
114
  overlay: overlay
110
115
  }, /*#__PURE__*/React.createElement(Button, _objectSpread({
111
116
  disabled: disabled,
112
- type: "text"
113
- }, rest), icon ? /*#__PURE__*/React.createElement("span", {
114
- className: "".concat(prefixCls, "-actions-icon")
115
- }, icon) : null, text, /*#__PURE__*/React.createElement(Down, null)));
117
+ icon: icon
118
+ }, rest), text, /*#__PURE__*/React.createElement(Icons.Down, {
119
+ style: {
120
+ opacity: 0.7,
121
+ fontSize: 16
122
+ }
123
+ })));
116
124
  }
117
125
 
118
- return /*#__PURE__*/React.createElement(Button, {
126
+ return /*#__PURE__*/React.createElement(Button, _objectSpread({
119
127
  key: text,
120
128
  disabled: disabled,
121
129
  onClick: handleClick,
122
- type: "text"
123
- }, icon ? /*#__PURE__*/React.createElement("span", {
124
- className: "".concat(prefixCls, "-actions-icon")
125
- }, icon) : null, text);
130
+ icon: icon
131
+ }, rest), text);
126
132
  }), collapsedBtns.length > 0 ? /*#__PURE__*/React.createElement(Popover, {
127
133
  placement: "bottomRight",
128
134
  overlayClassName: "".concat(prefixCls, "-actions-popover"),
129
135
  onVisibleChange: setVisible,
130
136
  visible: visible,
131
137
  trigger: "click",
132
- content: /*#__PURE__*/React.createElement("ul", {
133
- className: "".concat(prefixCls, "-actions-popover-list")
134
- }, collapsedBtns.map(function (item, index) {
135
- var _classNames;
136
-
138
+ content: collapsedBtns.map(function (item, index) {
137
139
  if (item === null) {
138
140
  return item;
139
141
  }
@@ -145,8 +147,8 @@ function Actions(props) {
145
147
  }
146
148
 
147
149
  var disabled = item.disabled;
148
- return /*#__PURE__*/React.createElement("li", {
149
- className: classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-actions-popover-item-disabled"), disabled), _defineProperty(_classNames, "".concat(prefixCls, "-actions-popover-item"), !disabled), _classNames)),
150
+ return /*#__PURE__*/React.createElement("div", {
151
+ className: classNames("".concat(prefixCls, "-actions-popover-item"), _defineProperty({}, "".concat(prefixCls, "-actions-popover-item-disabled"), disabled)),
150
152
  key: index,
151
153
  onClick: function onClick() {
152
154
  if (!disabled) {
@@ -159,10 +161,9 @@ function Actions(props) {
159
161
  }
160
162
  }
161
163
  }, item.text);
162
- }))
164
+ })
163
165
  }, /*#__PURE__*/React.createElement(Button, {
164
- type: "text",
165
- icon: /*#__PURE__*/React.createElement(EllipsisOutlined, null)
166
+ icon: /*#__PURE__*/React.createElement(Icons.More, null)
166
167
  })) : null));
167
168
  }
168
169
 
@@ -6,11 +6,16 @@
6
6
  padding-top: 0;
7
7
  }
8
8
 
9
- & .ant-popover-inner-content {
9
+ .ant-popover-inner {
10
+ padding: 8px 0;
11
+ border-radius: 8px;
12
+ }
13
+
14
+ .ant-popover-inner-content {
10
15
  padding: 0;
11
16
  }
12
17
 
13
- & .ant-popover-arrow {
18
+ .ant-popover-arrow {
14
19
  display: none;
15
20
  }
16
21
 
@@ -21,75 +26,45 @@
21
26
 
22
27
  &-item {
23
28
  box-sizing: border-box;
24
- width: 124px;
29
+ width: 120px;
25
30
  height: 38px;
26
- padding: 8px;
27
- color: #646464;
28
- line-height: 22px;
29
- text-align: left;
31
+ padding: 0 16px;
32
+ color: #333;
33
+ line-height: 38px;
30
34
  list-style: none;
31
- border-radius: 2px;
32
35
  cursor: pointer;
36
+ transition: background-color 0.2s;
33
37
 
34
38
  &:hover {
35
- color: .primary(1) [];
36
- background: .primary(0.08) [];
39
+ background-color: #eee;
37
40
  }
38
41
 
39
42
  &-disabled {
40
- box-sizing: border-box;
41
- width: 124px;
42
- height: 38px;
43
- padding: 8px;
44
43
  color: rgba(0, 0, 0, 0.25);
45
- line-height: 22px;
46
- text-align: left;
47
- list-style: none;
48
- border-radius: 2px;
44
+ background-color: #fff !important;
49
45
  cursor: not-allowed;
50
46
  }
51
47
  }
52
48
  }
53
49
 
54
- .ant-btn {
55
- padding: 0 8px;
56
- font-size: 14px;
57
- border-radius: 2px;
58
- }
59
-
60
- .ant-dropdown-button.ant-btn-group > .ant-btn:last-child:not(:first-child) {
61
- padding-right: 4px;
62
- padding-left: 4px;
63
- }
64
-
65
- .ant-btn-text {
66
- display: inline-flex;
67
- align-items: center;
50
+ .ant-btn:not(.ant-btn-icon-only) {
51
+ min-width: 80px;
52
+ padding: 4px 12px;
68
53
 
69
- &:not(:disabled) {
70
- color: rgba(51, 51, 51, 0.65);
71
-
72
- &:hover {
73
- background: rgba(0, 0, 0, 0.08);
74
- }
54
+ .@{prefixCls}-symbol-icon {
55
+ margin-right: 8px;
56
+ font-size: 20px;
57
+ vertical-align: -5px;
75
58
  }
76
59
  }
77
60
 
78
- &-icon {
79
- margin-right: 8px;
80
- font-size: 20px;
81
- line-height: 1;
82
-
83
- svg > use {
84
- color: .primary() [rgb];
85
- fill: #595959;
61
+ .ant-btn-default {
62
+ .@{prefixCls}-symbol-icon {
63
+ opacity: 0.7;
86
64
  }
87
- }
88
65
 
89
- button:disabled &-icon {
90
- svg > use {
91
- color: inherit;
92
- fill: currentColor;
66
+ &:not(:disabled) {
67
+ background-color: #fff;
93
68
  }
94
69
  }
95
70
  }
@@ -0,0 +1,8 @@
1
+ import type { RowAction } from './typings';
2
+ interface Props<T> {
3
+ actions: (RowAction<T> | null)[];
4
+ row: T;
5
+ index: number;
6
+ }
7
+ export default function Actions<T>(props: Props<T>): JSX.Element;
8
+ export {};
@@ -0,0 +1,119 @@
1
+ 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
+
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+
5
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
10
+
11
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
12
+
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+
15
+ import React, { useRef, useState } from 'react';
16
+ import classNames from 'classnames';
17
+ import { createPortal } from 'react-dom';
18
+ import { PREFIX_CLS } from '../constants';
19
+ import Icons from '../Icons';
20
+ export default function Actions(props) {
21
+ var actions = props.actions,
22
+ row = props.row,
23
+ index = props.index;
24
+
25
+ var _useState = useState(null),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ pop = _useState2[0],
28
+ setPop = _useState2[1];
29
+
30
+ var _useState3 = useState(false),
31
+ _useState4 = _slicedToArray(_useState3, 2),
32
+ visible = _useState4[0],
33
+ setVisible = _useState4[1];
34
+
35
+ var prefixCls = "".concat(PREFIX_CLS, "-table-operator");
36
+ var ref = useRef(null);
37
+
38
+ var openPop = function openPop(data) {
39
+ setPop(data);
40
+ setTimeout(function () {
41
+ setVisible(true);
42
+ }, 16);
43
+ };
44
+
45
+ var closePop = function closePop() {
46
+ if (visible === false) {
47
+ setPop(null);
48
+ return;
49
+ }
50
+
51
+ if (ref.current !== null) {
52
+ var node = ref.current;
53
+ setVisible(false);
54
+
55
+ var handler = function handler() {
56
+ node.removeEventListener('transitionend', handler);
57
+ setPop(null);
58
+ };
59
+
60
+ node.addEventListener('transitionend', handler);
61
+ }
62
+ };
63
+
64
+ return /*#__PURE__*/React.createElement("div", {
65
+ className: prefixCls,
66
+ onMouseLeave: closePop
67
+ }, actions.map(function (item) {
68
+ if (item === null) {
69
+ return null;
70
+ }
71
+
72
+ var dropDown = item.dropDown ? item.dropDown.filter(function (item) {
73
+ return item !== null;
74
+ }) : [];
75
+ return /*#__PURE__*/React.createElement("button", {
76
+ className: "".concat(prefixCls, "-item"),
77
+ key: item.text,
78
+ disabled: item.disabled,
79
+ onClick: function onClick(e) {
80
+ if (dropDown.length > 0) {
81
+ var rect = e.target.getBoundingClientRect();
82
+ openPop({
83
+ top: rect.top + rect.height,
84
+ right: document.body.clientWidth - rect.right,
85
+ items: dropDown
86
+ });
87
+ } else {
88
+ var _item$onClick;
89
+
90
+ (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, row, index);
91
+ }
92
+ }
93
+ }, item.text, dropDown.length > 0 && /*#__PURE__*/React.createElement(Icons.Down, null));
94
+ }), pop !== null && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", {
95
+ className: "".concat(prefixCls, "-popover"),
96
+ style: {
97
+ top: pop.top,
98
+ right: pop.right
99
+ }
100
+ }, /*#__PURE__*/React.createElement("div", {
101
+ ref: ref,
102
+ className: classNames("".concat(prefixCls, "-popover-items"), {
103
+ animated: visible
104
+ })
105
+ }, pop.items.map(function (item) {
106
+ return /*#__PURE__*/React.createElement("div", {
107
+ className: classNames("".concat(prefixCls, "-popover-item"), _defineProperty({}, "".concat(prefixCls, "-popover-item-disabled"), item.disabled)),
108
+ key: item.text,
109
+ onClick: function onClick() {
110
+ if (!item.disabled) {
111
+ var _item$onClick2;
112
+
113
+ closePop();
114
+ (_item$onClick2 = item.onClick) === null || _item$onClick2 === void 0 ? void 0 : _item$onClick2.call(item, row, index);
115
+ }
116
+ }
117
+ }, item.text);
118
+ }))), document.body));
119
+ }
@@ -36,13 +36,24 @@ export default function ResizeHeaderCell(props) {
36
36
  setSize(width);
37
37
  }, [width]);
38
38
 
39
+ var getTable = function getTable() {
40
+ if (fullTableRef.current === null) {
41
+ return null;
42
+ }
43
+
44
+ return fullTableRef.current.querySelector('.ant-table');
45
+ };
46
+
39
47
  var handleResizeStart = function handleResizeStart() {
40
- var _fullTableRef$current;
48
+ var table = getTable();
49
+
50
+ if (table === null) {
51
+ return;
52
+ }
41
53
 
42
54
  var elm = document.createElement('div');
43
- elm.style.height = "".concat(((_fullTableRef$current = fullTableRef.current) === null || _fullTableRef$current === void 0 ? void 0 : _fullTableRef$current.offsetHeight) || 0, "px");
55
+ elm.style.height = "".concat(table.offsetHeight || 0, "px");
44
56
  elm.classList.add("".concat(prefixCls, "-resizable-indicator"));
45
- var table = fullTableRef.current;
46
57
 
47
58
  if (table) {
48
59
  table.appendChild(elm);
@@ -73,9 +84,9 @@ export default function ResizeHeaderCell(props) {
73
84
  };
74
85
 
75
86
  var handleResizeStop = function handleResizeStop() {
76
- var table = fullTableRef.current;
87
+ var table = getTable();
77
88
 
78
- if (table && indicator.current) {
89
+ if (table !== null && indicator.current !== undefined) {
79
90
  table.removeChild(indicator.current);
80
91
  table.classList.remove("".concat(prefixCls, "-resizing-col"));
81
92
 
@@ -1,5 +1,5 @@
1
1
  var _excluded = ["onWidthChange", "width", "fullTableRef"],
2
- _excluded2 = ["id", "columns", "defaultColumnProps", "rowKey", "children", "summaryTitle", "summaryRecord", "dataSource", "onSortChange", "sort", "scroll", "virtual", "components", "pagination", "onChange", "rowHeight", "tableLayout"];
2
+ _excluded2 = ["id", "columns", "defaultColumnProps", "rowKey", "children", "summaryTitle", "summaryRecord", "dataSource", "onSortChange", "sort", "scroll", "virtual", "components", "pagination", "onChange", "rowHeight", "tableLayout", "rowActions"];
3
3
 
4
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
5
 
@@ -9,6 +9,8 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
9
9
 
10
10
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
11
 
12
+ 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); }
13
+
12
14
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
15
 
14
16
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -35,11 +37,12 @@ import React, { useMemo, useState, useEffect, useRef } from 'react';
35
37
  import { Table as AntdTable } from 'antd';
36
38
  import { get } from 'lodash';
37
39
  import { useThrottle } from '@lemon-fe/hooks';
38
- import { isColumnType, getColumnKey, randomStr } from './utils';
40
+ import { isColumnType, getColumnKey } from './utils';
39
41
  import ResizeHeaderCell from './ResizeHeaderCell';
40
42
  import { PREFIX_CLS } from '../constants';
41
43
  import VirtualList from './VirtualBody';
42
44
  import BaseTableContext from './BaseTableContext';
45
+ import Actions from './Actions';
43
46
 
44
47
  function formatSummary(summary) {
45
48
  if (!summary) {
@@ -98,12 +101,10 @@ function BaseTable(props) {
98
101
  rowHeight = props.rowHeight,
99
102
  _props$tableLayout = props.tableLayout,
100
103
  tableLayout = _props$tableLayout === void 0 ? 'fixed' : _props$tableLayout,
104
+ rowActions = props.rowActions,
101
105
  restProps = _objectWithoutProperties(props, _excluded2);
102
106
 
103
107
  var fullTableRef = useRef(null);
104
- var tableID = useMemo(function () {
105
- return id || randomStr();
106
- }, [id]);
107
108
 
108
109
  var _useState = useState(0),
109
110
  _useState2 = _slicedToArray(_useState, 2),
@@ -114,23 +115,20 @@ function BaseTable(props) {
114
115
  _useState4 = _slicedToArray(_useState3, 2),
115
116
  colsState = _useState4[0],
116
117
  setColsState = _useState4[1];
117
-
118
- useEffect(function () {
119
- fullTableRef.current = document.getElementById(tableID);
120
- }, [tableID]);
121
118
  /** auto scroll y */
122
119
 
120
+
123
121
  var calcScrollY = function calcScrollY() {
124
- var table = fullTableRef.current;
122
+ var wrapper = fullTableRef.current;
125
123
 
126
- if (table === null) {
124
+ if (wrapper === null) {
127
125
  return null;
128
126
  }
129
127
 
130
- var wrapper = table.closest('.ant-table-wrapper');
131
- var tableBody = table.querySelector('.ant-table-body');
128
+ var table = wrapper.querySelector('.ant-table');
129
+ var tableBody = wrapper.querySelector('.ant-table-body');
132
130
 
133
- if (tableBody === null || wrapper === null) {
131
+ if (tableBody === null || table === null) {
134
132
  return null;
135
133
  }
136
134
 
@@ -165,13 +163,38 @@ function BaseTable(props) {
165
163
  };
166
164
 
167
165
  var changeScrollY = useThrottle(function () {
166
+ var nextScrollY = scrollY;
167
+
168
168
  if ((scroll === null || scroll === void 0 ? void 0 : scroll.y) === true) {
169
169
  var y = calcScrollY();
170
- setScrollY(y || undefined);
170
+ nextScrollY = y || undefined;
171
171
  } else {
172
- setScrollY(scroll === null || scroll === void 0 ? void 0 : scroll.y);
172
+ nextScrollY = scroll === null || scroll === void 0 ? void 0 : scroll.y;
173
+ }
174
+
175
+ setScrollY(nextScrollY);
176
+
177
+ if (fullTableRef.current !== null) {
178
+ var body = fullTableRef.current.querySelector('.ant-table-body');
179
+
180
+ if (body !== null) {
181
+ var dataType = _typeof(nextScrollY);
182
+
183
+ switch (dataType) {
184
+ case 'string':
185
+ body.style.height = nextScrollY;
186
+ break;
187
+
188
+ case 'number':
189
+ body.style.height = nextScrollY + 'px';
190
+ break;
191
+
192
+ default:
193
+ body.style.height = 'auto';
194
+ }
195
+ }
173
196
  }
174
- }, 80, {
197
+ }, 100, {
175
198
  trailing: true
176
199
  });
177
200
  useEffect(function () {
@@ -279,9 +302,30 @@ function BaseTable(props) {
279
302
  _useMemo2 = _slicedToArray(_useMemo, 2),
280
303
  formatedColumns = _useMemo2[0],
281
304
  flattenColumns = _useMemo2[1];
305
+ /** row actions */
306
+
307
+
308
+ useMemo(function () {
309
+ if (rowActions !== undefined && rowActions.length > 0) {
310
+ var actionCol = {
311
+ title: '',
312
+ className: "".concat(PREFIX_CLS, "-table-operator-column"),
313
+ width: 1,
314
+ fixed: 'right',
315
+ render: function render(_, row, index) {
316
+ return /*#__PURE__*/React.createElement(Actions, {
317
+ actions: rowActions,
318
+ row: row,
319
+ index: index
320
+ });
321
+ }
322
+ };
323
+ formatedColumns.push(actionCol);
324
+ flattenColumns.push(actionCol);
325
+ }
326
+ }, [rowActions, flattenColumns, formatedColumns]);
282
327
  /** virtualize scroll */
283
328
 
284
-
285
329
  var _useMemo3 = useMemo(function () {
286
330
  return {
287
331
  components: _objectSpread({
@@ -341,7 +385,7 @@ function BaseTable(props) {
341
385
  value: ctx
342
386
  }, /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread({
343
387
  size: "small",
344
- id: tableID,
388
+ ref: fullTableRef,
345
389
  columns: formatedColumns,
346
390
  dataSource: dataSource,
347
391
  rowKey: rowKey,
@@ -49,6 +49,105 @@
49
49
  color: @text-color;
50
50
  font-size: @font-size-base;
51
51
 
52
+ .ant-table-cell-row-hover &-operator {
53
+ display: flex;
54
+ }
55
+
56
+ &-operator {
57
+ position: absolute;
58
+ top: 0;
59
+ right: 0;
60
+ z-index: 10;
61
+ display: none;
62
+ align-items: center;
63
+ justify-content: flex-end;
64
+ height: 100%;
65
+ padding-left: 16px;
66
+ white-space: nowrap;
67
+ background-color: @table-row-hover-bg;
68
+ background-clip: content-box;
69
+
70
+ &::before {
71
+ position: absolute;
72
+ top: 0;
73
+ left: 0;
74
+ width: 16px;
75
+ height: 100%;
76
+ background: linear-gradient(90deg, rgba(248, 248, 248, 0) 0%, @table-row-hover-bg 100%);
77
+ content: '';
78
+ }
79
+
80
+ &-column::after {
81
+ display: none !important;
82
+ }
83
+
84
+ &-item {
85
+ margin-right: 8px;
86
+ padding: 0 8px;
87
+ color: @primary-color;
88
+ line-height: 28px;
89
+ background-color: transparent;
90
+ border: none;
91
+ border-radius: 4px;
92
+ outline: none;
93
+ cursor: pointer;
94
+ transition: background-color 0.2s;
95
+ user-select: none;
96
+
97
+ &:disabled {
98
+ color: rgba(51, 51, 51, 0.5);
99
+ cursor: not-allowed;
100
+
101
+ &:hover {
102
+ background-color: rgba(51, 51, 51, 0.06);
103
+ }
104
+ }
105
+
106
+ &:hover {
107
+ background-color: .primary(0.12) [];
108
+ }
109
+
110
+ &:active {
111
+ color: .primary(0.8) [];
112
+ }
113
+ }
114
+
115
+ &-popover {
116
+ position: absolute;
117
+ z-index: 1000;
118
+ width: 120px;
119
+
120
+ &-items {
121
+ transform: scale(0.6);
122
+ transform-origin: 100% 0;
123
+ opacity: 0;
124
+ transition: transform 0.2s, opacity 0.2s;
125
+ pointer-events: none;
126
+
127
+ .popoverInner();
128
+
129
+ &.animated {
130
+ transform: scale(1);
131
+ opacity: 1;
132
+ pointer-events: visible;
133
+ }
134
+ }
135
+
136
+ &-item {
137
+ text-align: left;
138
+ background-color: #fff;
139
+ border: none;
140
+ outline: none;
141
+ .popoverItem();
142
+
143
+ &-disabled {
144
+ color: rgba(51, 51, 51, 0.5);
145
+ cursor: not-allowed;
146
+ }
147
+ }
148
+ }
149
+ }
150
+
52
151
  &-resizable-handle {
53
152
  position: absolute;
54
153
  top: 50%;