@lemon-fe/components 0.1.82 → 0.1.83
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/es/Actions/index.d.ts +26 -0
- package/es/Actions/index.js +171 -0
- package/es/BaseTable/Actions.d.ts +8 -0
- package/es/BaseTable/Actions.js +136 -0
- package/es/BaseTable/BaseTableContext.d.ts +6 -0
- package/es/BaseTable/BaseTableContext.js +6 -0
- package/es/BaseTable/ResizeHeaderCell.d.ts +8 -0
- package/es/BaseTable/ResizeHeaderCell.js +126 -0
- package/es/BaseTable/VirtualBody.d.ts +8 -0
- package/es/BaseTable/VirtualBody.js +165 -0
- package/es/BaseTable/index.d.ts +7 -0
- package/es/BaseTable/index.js +465 -0
- package/es/BaseTable/utils.d.ts +4 -0
- package/es/BaseTable/utils.js +26 -0
- package/es/ColorPicker/index.d.ts +13 -0
- package/es/ColorPicker/index.js +114 -0
- package/es/Dropdown/index.d.ts +14 -0
- package/es/Dropdown/index.js +53 -0
- package/es/DurationPicker/index.d.ts +25 -0
- package/es/DurationPicker/index.js +237 -0
- package/es/EditableTable/EditableCell.d.ts +11 -0
- package/es/EditableTable/EditableCell.js +37 -0
- package/es/EditableTable/EditableTableFormItem.d.ts +5 -0
- package/es/EditableTable/EditableTableFormItem.js +51 -0
- package/es/EditableTable/Table.d.ts +7 -0
- package/es/EditableTable/Table.js +363 -0
- package/es/EditableTable/index.d.ts +9 -0
- package/es/EditableTable/index.js +8 -0
- package/es/EditableTable/util.d.ts +25 -0
- package/es/EditableTable/util.js +387 -0
- package/es/Filter/index.d.ts +7 -0
- package/es/Filter/index.js +612 -0
- package/es/FormHorizontal/index.d.ts +6 -0
- package/es/FormHorizontal/index.js +35 -0
- package/es/FormInline/index.d.ts +15 -0
- package/es/FormInline/index.js +90 -0
- package/es/FormLayout/index.d.ts +32 -0
- package/es/FormLayout/index.js +41 -0
- package/es/FormTable/index.d.ts +6 -0
- package/es/FormTable/index.js +159 -0
- package/es/Icons/BigTip/index.d.ts +6 -0
- package/es/Icons/BigTip/index.js +50 -0
- package/es/Icons/Calendar.d.ts +5 -0
- package/es/Icons/Calendar.js +47 -0
- package/es/Icons/Close.d.ts +5 -0
- package/es/Icons/Close.js +29 -0
- package/es/Icons/CollapseUp.d.ts +5 -0
- package/es/Icons/CollapseUp.js +31 -0
- package/es/Icons/DarkSearch.d.ts +5 -0
- package/es/Icons/DarkSearch.js +38 -0
- package/es/Icons/Down.d.ts +5 -0
- package/es/Icons/Down.js +35 -0
- package/es/Icons/Empty.d.ts +2 -0
- package/es/Icons/Empty.js +267 -0
- package/es/Icons/LookUp.d.ts +5 -0
- package/es/Icons/LookUp.js +74 -0
- package/es/Icons/More.d.ts +5 -0
- package/es/Icons/More.js +44 -0
- package/es/Icons/Search.d.ts +5 -0
- package/es/Icons/Search.js +35 -0
- package/es/Icons/Tip.d.ts +6 -0
- package/es/Icons/Tip.js +169 -0
- package/es/Icons/index.d.ts +24 -0
- package/es/Icons/index.js +25 -0
- package/es/InputMaxLength/index.d.ts +14 -0
- package/es/InputMaxLength/index.js +92 -0
- package/es/Layout/index.d.ts +41 -0
- package/es/Layout/index.js +175 -0
- package/es/MainFramework/components/DropMenu/index.d.ts +10 -0
- package/es/MainFramework/components/DropMenu/index.js +104 -0
- package/es/MainFramework/components/Menu/index.d.ts +9 -0
- package/es/MainFramework/components/Menu/index.js +656 -0
- package/es/MainFramework/components/Menu/index.less +407 -0
- package/es/MainFramework/components/RefreshButton/index.d.ts +5 -0
- package/es/MainFramework/components/RefreshButton/index.js +72 -0
- package/es/MainFramework/components/RefreshButton/index.less +30 -0
- package/es/MainFramework/components/TabBar/index.d.ts +9 -0
- package/es/MainFramework/components/TabBar/index.js +116 -0
- package/es/MainFramework/index.d.ts +24 -0
- package/es/MainFramework/index.js +66 -0
- package/es/PageLoading/index.d.ts +5 -0
- package/es/PageLoading/index.js +15 -0
- package/es/Popup/index.d.ts +37 -0
- package/es/Popup/index.js +198 -0
- package/es/Portal/index.d.ts +12 -0
- package/es/Portal/index.js +72 -0
- package/es/Section/TabBar.d.ts +12 -0
- package/es/Section/TabBar.js +48 -0
- package/es/Section/index.d.ts +54 -0
- package/es/Section/index.js +96 -0
- package/es/SelectView/index.d.ts +53 -0
- package/es/SelectView/index.js +257 -0
- package/es/SiderTree/TreeNodeTitle.d.ts +8 -0
- package/es/SiderTree/TreeNodeTitle.js +107 -0
- package/es/SiderTree/index.d.ts +37 -0
- package/es/SiderTree/index.js +221 -0
- package/es/SymbolIcon/index.d.ts +8 -0
- package/es/SymbolIcon/index.js +32 -0
- package/es/TabBar/index.d.ts +14 -0
- package/es/TabBar/index.js +52 -0
- package/es/Table/index.d.ts +2 -0
- package/es/Table/index.js +236 -0
- package/es/Table/utils.d.ts +2 -0
- package/es/Table/utils.js +3 -0
- package/es/TipMark/index.d.ts +10 -0
- package/es/TipMark/index.js +45 -0
- package/es/constants.d.ts +1 -0
- package/es/constants.js +1 -0
- package/es/index.d.ts +32 -0
- package/es/index.js +27 -0
- package/es/init.d.ts +3 -0
- package/es/init.js +145 -0
- package/es/utils.d.ts +2 -0
- package/es/utils.js +14 -0
- package/package.json +2 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import type { CSSProperties } from 'react';
|
|
3
|
+
import { ButtonProps } from 'antd';
|
|
4
|
+
interface ActionBtn extends ButtonProps {
|
|
5
|
+
text: string | ReactElement;
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
* 请不要使用
|
|
10
|
+
*/
|
|
11
|
+
action?: () => void;
|
|
12
|
+
dropDown?: ({
|
|
13
|
+
text: string;
|
|
14
|
+
onClick: () => void;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
} | null)[];
|
|
17
|
+
}
|
|
18
|
+
interface Props {
|
|
19
|
+
actions: (ActionBtn | ReactElement | null)[];
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
className?: string;
|
|
22
|
+
prefixCls?: string;
|
|
23
|
+
maxShowCount?: number;
|
|
24
|
+
}
|
|
25
|
+
declare function Actions(props: Props): JSX.Element;
|
|
26
|
+
export default Actions;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var _excluded = ["disabled", "dropDown", "text", "onClick", "icon", "action"];
|
|
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 _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; }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
|
+
|
|
15
|
+
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."); }
|
|
16
|
+
|
|
17
|
+
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); }
|
|
18
|
+
|
|
19
|
+
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; }
|
|
20
|
+
|
|
21
|
+
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; }
|
|
22
|
+
|
|
23
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
24
|
+
|
|
25
|
+
import React, { Fragment, useState } from 'react';
|
|
26
|
+
import { Space, Dropdown, Menu, Button, Popover } from 'antd';
|
|
27
|
+
import classNames from 'classnames';
|
|
28
|
+
import Icons from '../Icons';
|
|
29
|
+
import { PREFIX_CLS } from '../constants';
|
|
30
|
+
|
|
31
|
+
function Actions(props) {
|
|
32
|
+
var actions = props.actions,
|
|
33
|
+
className = props.className,
|
|
34
|
+
style = props.style,
|
|
35
|
+
_props$prefixCls = props.prefixCls,
|
|
36
|
+
prefixCls = _props$prefixCls === void 0 ? PREFIX_CLS : _props$prefixCls,
|
|
37
|
+
_props$maxShowCount = props.maxShowCount,
|
|
38
|
+
maxShowCount = _props$maxShowCount === void 0 ? 3 : _props$maxShowCount;
|
|
39
|
+
|
|
40
|
+
var _useState = useState(false),
|
|
41
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
42
|
+
visible = _useState2[0],
|
|
43
|
+
setVisible = _useState2[1];
|
|
44
|
+
|
|
45
|
+
var visibleBtns = actions.slice(0, maxShowCount);
|
|
46
|
+
var collapsedBtns = actions.slice(maxShowCount);
|
|
47
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: classNames("".concat(prefixCls, "-actions"), className),
|
|
49
|
+
style: style
|
|
50
|
+
}, /*#__PURE__*/React.createElement(Space, {
|
|
51
|
+
direction: "horizontal",
|
|
52
|
+
size: 12
|
|
53
|
+
}, visibleBtns.map(function (item, index) {
|
|
54
|
+
if (item === null) {
|
|
55
|
+
return item;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if ( /*#__PURE__*/React.isValidElement(item)) {
|
|
59
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
60
|
+
key: index
|
|
61
|
+
}, item);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var disabled = item.disabled,
|
|
65
|
+
dropDown = item.dropDown,
|
|
66
|
+
text = item.text,
|
|
67
|
+
onClick = item.onClick,
|
|
68
|
+
icon = item.icon,
|
|
69
|
+
action = item.action,
|
|
70
|
+
rest = _objectWithoutProperties(item, _excluded);
|
|
71
|
+
|
|
72
|
+
if ( /*#__PURE__*/React.isValidElement(text)) {
|
|
73
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
74
|
+
key: index
|
|
75
|
+
}, text);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var handleClick = onClick || action;
|
|
79
|
+
|
|
80
|
+
if (Array.isArray(dropDown)) {
|
|
81
|
+
var overlay = /*#__PURE__*/React.createElement(Menu, null, dropDown.map(function (subItem) {
|
|
82
|
+
if (subItem) {
|
|
83
|
+
return /*#__PURE__*/React.createElement(Menu.Item, {
|
|
84
|
+
onClick: function onClick() {
|
|
85
|
+
return subItem.onClick();
|
|
86
|
+
},
|
|
87
|
+
key: subItem.text,
|
|
88
|
+
disabled: subItem.disabled
|
|
89
|
+
}, subItem.text);
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
|
|
93
|
+
if (handleClick !== undefined) {
|
|
94
|
+
return /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
95
|
+
key: text,
|
|
96
|
+
disabled: disabled,
|
|
97
|
+
overlay: overlay,
|
|
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);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
112
|
+
key: text,
|
|
113
|
+
disabled: disabled,
|
|
114
|
+
overlay: overlay
|
|
115
|
+
}, /*#__PURE__*/React.createElement(Button, _objectSpread({
|
|
116
|
+
disabled: disabled,
|
|
117
|
+
icon: icon
|
|
118
|
+
}, rest), text, /*#__PURE__*/React.createElement(Icons.Down, {
|
|
119
|
+
style: {
|
|
120
|
+
opacity: 0.7,
|
|
121
|
+
fontSize: 16,
|
|
122
|
+
verticalAlign: -3
|
|
123
|
+
}
|
|
124
|
+
})));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return /*#__PURE__*/React.createElement(Button, _objectSpread({
|
|
128
|
+
key: text,
|
|
129
|
+
disabled: disabled,
|
|
130
|
+
onClick: handleClick,
|
|
131
|
+
icon: icon
|
|
132
|
+
}, rest), text);
|
|
133
|
+
}), collapsedBtns.length > 0 ? /*#__PURE__*/React.createElement(Popover, {
|
|
134
|
+
placement: "bottomRight",
|
|
135
|
+
overlayClassName: "".concat(prefixCls, "-actions-popover"),
|
|
136
|
+
onVisibleChange: setVisible,
|
|
137
|
+
visible: visible,
|
|
138
|
+
trigger: "click",
|
|
139
|
+
content: collapsedBtns.map(function (item, index) {
|
|
140
|
+
if (item === null) {
|
|
141
|
+
return item;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if ( /*#__PURE__*/React.isValidElement(item)) {
|
|
145
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
146
|
+
key: index
|
|
147
|
+
}, item);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
var disabled = item.disabled;
|
|
151
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
152
|
+
className: classNames("".concat(prefixCls, "-actions-popover-item"), _defineProperty({}, "".concat(prefixCls, "-actions-popover-item-disabled"), disabled)),
|
|
153
|
+
key: index,
|
|
154
|
+
onClick: function onClick() {
|
|
155
|
+
if (!disabled) {
|
|
156
|
+
var handleClick = item.onClick || item.action;
|
|
157
|
+
setVisible(false);
|
|
158
|
+
|
|
159
|
+
if (handleClick) {
|
|
160
|
+
handleClick();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}, item.text);
|
|
165
|
+
})
|
|
166
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
167
|
+
icon: /*#__PURE__*/React.createElement(Icons.More, null)
|
|
168
|
+
})) : null));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export default Actions;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RowAction } from './typings';
|
|
2
|
+
interface Props<T> {
|
|
3
|
+
actions: (RowAction<T> | null)[] | ((record: T, index: number) => (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,136 @@
|
|
|
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 actionsProp = 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
|
+
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
|
+
|
|
71
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
className: prefixCls,
|
|
73
|
+
onMouseLeave: closePop
|
|
74
|
+
}, actions.map(function (item, idx) {
|
|
75
|
+
if (item === null) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var key = getKey(item, idx);
|
|
80
|
+
var dropDown = item.dropDown ? item.dropDown.filter(function (item) {
|
|
81
|
+
return item !== null;
|
|
82
|
+
}) : [];
|
|
83
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
className: classNames("".concat(prefixCls, "-item"), _defineProperty({}, "".concat(prefixCls, "-item-disabled"), item.disabled)),
|
|
85
|
+
key: key,
|
|
86
|
+
onMouseEnter: function onMouseEnter() {
|
|
87
|
+
if (pop !== null && pop.key !== key) {
|
|
88
|
+
closePop();
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
onClick: function onClick(e) {
|
|
92
|
+
if (item.disabled) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (dropDown.length > 0) {
|
|
97
|
+
var rect = e.target.getBoundingClientRect();
|
|
98
|
+
openPop({
|
|
99
|
+
key: key,
|
|
100
|
+
top: rect.top + rect.height,
|
|
101
|
+
right: document.body.clientWidth - rect.right,
|
|
102
|
+
items: dropDown
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
var _item$onClick;
|
|
106
|
+
|
|
107
|
+
(_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, row, index);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, item.text, dropDown.length > 0 && /*#__PURE__*/React.createElement(Icons.Down, null));
|
|
111
|
+
}), pop !== null && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: "".concat(prefixCls, "-popover"),
|
|
113
|
+
style: {
|
|
114
|
+
top: pop.top,
|
|
115
|
+
right: pop.right
|
|
116
|
+
}
|
|
117
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
ref: ref,
|
|
119
|
+
className: classNames("".concat(prefixCls, "-popover-items"), {
|
|
120
|
+
animated: visible
|
|
121
|
+
})
|
|
122
|
+
}, pop.items.map(function (item, idx) {
|
|
123
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
124
|
+
className: classNames("".concat(prefixCls, "-popover-item"), _defineProperty({}, "".concat(prefixCls, "-popover-item-disabled"), item.disabled)),
|
|
125
|
+
key: getKey(item, idx),
|
|
126
|
+
onClick: function onClick() {
|
|
127
|
+
if (!item.disabled) {
|
|
128
|
+
var _item$onClick2;
|
|
129
|
+
|
|
130
|
+
closePop();
|
|
131
|
+
(_item$onClick2 = item.onClick) === null || _item$onClick2 === void 0 ? void 0 : _item$onClick2.call(item, row, index);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, item.text);
|
|
135
|
+
}))), document.body));
|
|
136
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactElement, RefObject } from 'react';
|
|
2
|
+
export default function ResizeHeaderCell(props: {
|
|
3
|
+
children?: ReactElement;
|
|
4
|
+
fullTableRef: RefObject<HTMLDivElement>;
|
|
5
|
+
width: number;
|
|
6
|
+
prefixCls?: string;
|
|
7
|
+
onChange?: (width: number) => void;
|
|
8
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
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."); }
|
|
4
|
+
|
|
5
|
+
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); }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
13
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
14
|
+
import { Resizable } from 'react-resizable';
|
|
15
|
+
export default function ResizeHeaderCell(props) {
|
|
16
|
+
var children = props.children,
|
|
17
|
+
prefixCls = props.prefixCls,
|
|
18
|
+
fullTableRef = props.fullTableRef,
|
|
19
|
+
width = props.width,
|
|
20
|
+
onChange = props.onChange;
|
|
21
|
+
|
|
22
|
+
var _useState = useState(width),
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
size = _useState2[0],
|
|
25
|
+
setSize = _useState2[1];
|
|
26
|
+
|
|
27
|
+
var indicator = useRef();
|
|
28
|
+
var handle = useRef(null);
|
|
29
|
+
|
|
30
|
+
var _useState3 = useState(0),
|
|
31
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
32
|
+
offset = _useState4[0],
|
|
33
|
+
setOffset = _useState4[1];
|
|
34
|
+
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
setSize(width);
|
|
37
|
+
}, [width]);
|
|
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
|
+
|
|
47
|
+
var handleResizeStart = function handleResizeStart() {
|
|
48
|
+
var table = getTable();
|
|
49
|
+
|
|
50
|
+
if (table === null) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var elm = document.createElement('div');
|
|
55
|
+
elm.style.height = "".concat(table.offsetHeight || 0, "px");
|
|
56
|
+
elm.classList.add("".concat(prefixCls, "-resizable-indicator"));
|
|
57
|
+
|
|
58
|
+
if (table) {
|
|
59
|
+
table.appendChild(elm);
|
|
60
|
+
table.classList.add("".concat(prefixCls, "-resizing-col"));
|
|
61
|
+
indicator.current = elm;
|
|
62
|
+
|
|
63
|
+
if (handle.current !== null) {
|
|
64
|
+
var _handle$current = handle.current,
|
|
65
|
+
parent = _handle$current.offsetParent,
|
|
66
|
+
left = _handle$current.offsetLeft;
|
|
67
|
+
var node = handle.current.parentNode;
|
|
68
|
+
|
|
69
|
+
while (node !== null && node !== table) {
|
|
70
|
+
left -= node.scrollLeft;
|
|
71
|
+
|
|
72
|
+
if (node === parent) {
|
|
73
|
+
left += node.offsetLeft;
|
|
74
|
+
parent = node.offsetParent;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
node = node.parentNode;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setOffset(left - size);
|
|
81
|
+
indicator.current.style.left = "".concat(left, "px");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
var handleResizeStop = function handleResizeStop() {
|
|
87
|
+
var table = getTable();
|
|
88
|
+
|
|
89
|
+
if (table !== null && indicator.current !== undefined) {
|
|
90
|
+
table.removeChild(indicator.current);
|
|
91
|
+
table.classList.remove("".concat(prefixCls, "-resizing-col"));
|
|
92
|
+
|
|
93
|
+
if (onChange) {
|
|
94
|
+
onChange(size);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var handleResize = function handleResize(e, data) {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
|
|
102
|
+
if (indicator.current) {
|
|
103
|
+
setSize(data.size.width);
|
|
104
|
+
indicator.current.style.left = "".concat(offset + data.size.width, "px");
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return /*#__PURE__*/React.createElement(Resizable, {
|
|
109
|
+
width: size,
|
|
110
|
+
height: 0,
|
|
111
|
+
handle: /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: "".concat(prefixCls, "-resizable-handle"),
|
|
113
|
+
onClick: function onClick(e) {
|
|
114
|
+
e.stopPropagation();
|
|
115
|
+
}
|
|
116
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
117
|
+
ref: handle
|
|
118
|
+
})),
|
|
119
|
+
onResizeStart: handleResizeStart,
|
|
120
|
+
onResizeStop: handleResizeStop,
|
|
121
|
+
onResize: handleResize,
|
|
122
|
+
draggableOpts: {
|
|
123
|
+
enableUserSelectHack: false
|
|
124
|
+
}
|
|
125
|
+
}, children);
|
|
126
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var _excluded = ["children"];
|
|
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 _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; }
|
|
8
|
+
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
|
|
11
|
+
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."); }
|
|
12
|
+
|
|
13
|
+
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); }
|
|
14
|
+
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
|
|
21
|
+
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; }
|
|
22
|
+
|
|
23
|
+
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; }
|
|
24
|
+
|
|
25
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
26
|
+
import { useThrottle } from '@lemon-fe/hooks';
|
|
27
|
+
import { get } from 'lodash';
|
|
28
|
+
import BaseTableContext from './BaseTableContext';
|
|
29
|
+
import { PREFIX_CLS } from '../constants';
|
|
30
|
+
export default function VirtualList(props) {
|
|
31
|
+
var children = props.children,
|
|
32
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
33
|
+
|
|
34
|
+
var ref = useRef(null);
|
|
35
|
+
|
|
36
|
+
var _useContext = useContext(BaseTableContext),
|
|
37
|
+
scrollY = _useContext.scrollY,
|
|
38
|
+
_useContext$rowHeight = _useContext.rowHeight,
|
|
39
|
+
rowHeight = _useContext$rowHeight === void 0 ? 37 : _useContext$rowHeight;
|
|
40
|
+
|
|
41
|
+
var _useState = useState(null),
|
|
42
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
+
range = _useState2[0],
|
|
44
|
+
setRange = _useState2[1];
|
|
45
|
+
|
|
46
|
+
var getRange = function getRange() {
|
|
47
|
+
var height = Number(scrollY);
|
|
48
|
+
|
|
49
|
+
if (isNaN(height)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var body = ref.current;
|
|
54
|
+
|
|
55
|
+
if (body === null) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var scroller = body.closest('.ant-table-body');
|
|
60
|
+
|
|
61
|
+
if (scroller === null) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var pageSize = Math.ceil(height / rowHeight);
|
|
66
|
+
var offset = Math.round(scroller.scrollTop / rowHeight);
|
|
67
|
+
var start = offset - Math.floor(pageSize / 2);
|
|
68
|
+
|
|
69
|
+
if (start < 0) {
|
|
70
|
+
start = 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var end = offset + pageSize + Math.ceil(pageSize / 2) - 1;
|
|
74
|
+
var bufferSpace = height * 0.3;
|
|
75
|
+
return {
|
|
76
|
+
start: start,
|
|
77
|
+
end: end,
|
|
78
|
+
isTop: scroller.scrollTop - body.offsetTop <= bufferSpace,
|
|
79
|
+
isBottom: body.offsetHeight + body.offsetTop - (scroller.scrollTop + height) <= bufferSpace
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
var handleScroll = useThrottle(function () {
|
|
84
|
+
var mRange = getRange();
|
|
85
|
+
|
|
86
|
+
if (mRange === null) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var isTop = mRange.isTop,
|
|
91
|
+
isBottom = mRange.isBottom;
|
|
92
|
+
|
|
93
|
+
if (!isTop && !isBottom) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
setRange(mRange);
|
|
98
|
+
}, 300, {
|
|
99
|
+
trailing: true
|
|
100
|
+
});
|
|
101
|
+
useEffect(function () {
|
|
102
|
+
setRange(getRange());
|
|
103
|
+
}, [get(children, ['1', 'length']), rowHeight, scrollY]);
|
|
104
|
+
var render = useMemo(function () {
|
|
105
|
+
var _children = _slicedToArray(children, 2),
|
|
106
|
+
measureRow = _children[0],
|
|
107
|
+
rows = _children[1];
|
|
108
|
+
|
|
109
|
+
if (!Array.isArray(rows)) {
|
|
110
|
+
return [children, 0, 0];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (range === null) {
|
|
114
|
+
return [measureRow, 0, 0];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
var list = [];
|
|
118
|
+
var max = rows.length - 1;
|
|
119
|
+
var start = range.start,
|
|
120
|
+
end = range.end;
|
|
121
|
+
|
|
122
|
+
if (end > max) {
|
|
123
|
+
end = max;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
for (var i = start; i <= end; i += 1) {
|
|
127
|
+
list.push(rows[i]);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return [[measureRow, list], start * rowHeight, (max - end) * rowHeight];
|
|
131
|
+
}, [children, range]);
|
|
132
|
+
useEffect(function () {
|
|
133
|
+
var _ref$current;
|
|
134
|
+
|
|
135
|
+
if (ref.current === null) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
var tableBody = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.closest('.ant-table-body');
|
|
140
|
+
|
|
141
|
+
if (tableBody === null) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
tableBody.addEventListener('scroll', handleScroll);
|
|
146
|
+
return function () {
|
|
147
|
+
tableBody.removeEventListener('scroll', handleScroll);
|
|
148
|
+
};
|
|
149
|
+
}, []);
|
|
150
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("tbody", {
|
|
151
|
+
className: "".concat(PREFIX_CLS, "-table-append-before"),
|
|
152
|
+
style: {
|
|
153
|
+
display: 'block',
|
|
154
|
+
height: render[1]
|
|
155
|
+
}
|
|
156
|
+
}), /*#__PURE__*/React.createElement("tbody", _objectSpread(_objectSpread({}, restProps), {}, {
|
|
157
|
+
ref: ref
|
|
158
|
+
}), render[0]), /*#__PURE__*/React.createElement("tbody", {
|
|
159
|
+
className: "".concat(PREFIX_CLS, "-table-append-after"),
|
|
160
|
+
style: {
|
|
161
|
+
display: 'block',
|
|
162
|
+
height: render[2]
|
|
163
|
+
}
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference path="../../typings.d.ts" />
|
|
2
|
+
import type { BaseTableProps as Props } from './typings';
|
|
3
|
+
declare function BaseTable<T extends Record<string, any>>(props: Props<T>): JSX.Element;
|
|
4
|
+
declare namespace BaseTable {
|
|
5
|
+
var Summary: typeof import("rc-table/lib/Footer/Summary").default;
|
|
6
|
+
}
|
|
7
|
+
export default BaseTable;
|