@lemon-fe/components 0.0.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.
- package/README.md +11 -0
- package/es/Actions/index.d.ts +25 -0
- package/es/Actions/index.js +164 -0
- package/es/Actions/index.less +82 -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 +115 -0
- package/es/BaseTable/Sort.d.ts +10 -0
- package/es/BaseTable/Sort.js +122 -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 +371 -0
- package/es/BaseTable/index.less +103 -0
- package/es/BaseTable/typings.d.ts +32 -0
- package/es/BaseTable/utils.d.ts +4 -0
- package/es/BaseTable/utils.js +26 -0
- package/es/DurationPicker/index.d.ts +26 -0
- package/es/DurationPicker/index.js +234 -0
- package/es/DurationPicker/index.less +63 -0
- package/es/EditableTable/EditableCell.d.ts +11 -0
- package/es/EditableTable/EditableCell.js +37 -0
- package/es/EditableTable/EditableTableFormItem.d.ts +6 -0
- package/es/EditableTable/EditableTableFormItem.js +49 -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/index.less +19 -0
- package/es/EditableTable/typings.d.ts +86 -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 +469 -0
- package/es/Filter/index.less +77 -0
- package/es/Filter/typings.d.ts +27 -0
- package/es/FormLayout/index.d.ts +32 -0
- package/es/FormLayout/index.js +41 -0
- package/es/FormLayout/index.less +89 -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 +30 -0
- package/es/Icons/Empty.d.ts +2 -0
- package/es/Icons/Empty.js +267 -0
- package/es/Icons/Search.d.ts +5 -0
- package/es/Icons/Search.js +39 -0
- package/es/Icons/Tip.d.ts +6 -0
- package/es/Icons/Tip.js +169 -0
- package/es/Icons/index.d.ts +12 -0
- package/es/Icons/index.js +13 -0
- package/es/InputMaxLength/index.d.ts +14 -0
- package/es/InputMaxLength/index.js +92 -0
- package/es/InputMaxLength/index.less +8 -0
- package/es/Layout/index.d.ts +21 -0
- package/es/Layout/index.js +35 -0
- package/es/Layout/index.less +92 -0
- package/es/PageLoading/index.d.ts +5 -0
- package/es/PageLoading/index.js +15 -0
- package/es/PageLoading/index.less +10 -0
- package/es/Popup/index.d.ts +27 -0
- package/es/Popup/index.js +191 -0
- package/es/Popup/index.less +14 -0
- package/es/Section/index.d.ts +54 -0
- package/es/Section/index.js +111 -0
- package/es/Section/index.less +177 -0
- package/es/SiderTree/TreeNodeTitle.d.ts +9 -0
- package/es/SiderTree/TreeNodeTitle.js +124 -0
- package/es/SiderTree/index.d.ts +35 -0
- package/es/SiderTree/index.js +237 -0
- package/es/SiderTree/index.less +170 -0
- package/es/SiderTree/typings.d.ts +19 -0
- package/es/Table/index.d.ts +3 -0
- package/es/Table/index.js +224 -0
- package/es/Table/index.less +1 -0
- package/es/Table/typings.d.ts +26 -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/TipMark/index.less +8 -0
- package/es/constants.d.ts +1 -0
- package/es/constants.js +1 -0
- package/es/index.d.ts +21 -0
- package/es/index.js +17 -0
- package/es/index.less +50 -0
- package/es/init.d.ts +3 -0
- package/es/init.js +100 -0
- package/es/theme.less +13 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* deprecated please use onClick
|
|
8
|
+
*/
|
|
9
|
+
action?: () => void;
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
dropDown?: ({
|
|
12
|
+
text: string;
|
|
13
|
+
onClick: () => void;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
} | null)[];
|
|
16
|
+
}
|
|
17
|
+
interface Props {
|
|
18
|
+
actions: (ActionBtn | ReactElement | null)[];
|
|
19
|
+
style?: CSSProperties;
|
|
20
|
+
className?: string;
|
|
21
|
+
prefixCls?: string;
|
|
22
|
+
maxShowCount?: number;
|
|
23
|
+
}
|
|
24
|
+
declare function Actions(props: Props): JSX.Element;
|
|
25
|
+
export default Actions;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
var _excluded = ["disabled", "dropDown", "text", "action", "onClick", "icon"];
|
|
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 { EllipsisOutlined } from '@ant-design/icons';
|
|
28
|
+
import classNames from 'classnames';
|
|
29
|
+
import Down from '../Icons/Down';
|
|
30
|
+
import { PREFIX_CLS } from '../constants';
|
|
31
|
+
|
|
32
|
+
function Actions(props) {
|
|
33
|
+
var actions = props.actions,
|
|
34
|
+
className = props.className,
|
|
35
|
+
style = props.style,
|
|
36
|
+
_props$prefixCls = props.prefixCls,
|
|
37
|
+
prefixCls = _props$prefixCls === void 0 ? PREFIX_CLS : _props$prefixCls,
|
|
38
|
+
_props$maxShowCount = props.maxShowCount,
|
|
39
|
+
maxShowCount = _props$maxShowCount === void 0 ? 3 : _props$maxShowCount;
|
|
40
|
+
|
|
41
|
+
var _useState = useState(false),
|
|
42
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
+
visible = _useState2[0],
|
|
44
|
+
setVisible = _useState2[1];
|
|
45
|
+
|
|
46
|
+
var visibleBtns = actions.slice(0, maxShowCount);
|
|
47
|
+
var collapsedBtns = actions.slice(maxShowCount);
|
|
48
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
className: classNames("".concat(prefixCls, "-actions"), className),
|
|
50
|
+
style: style
|
|
51
|
+
}, /*#__PURE__*/React.createElement(Space, {
|
|
52
|
+
direction: "horizontal",
|
|
53
|
+
size: 16
|
|
54
|
+
}, visibleBtns.map(function (item, index) {
|
|
55
|
+
if (item === null) {
|
|
56
|
+
return item;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if ( /*#__PURE__*/React.isValidElement(item)) {
|
|
60
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
61
|
+
key: index
|
|
62
|
+
}, item);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var disabled = item.disabled,
|
|
66
|
+
dropDown = item.dropDown,
|
|
67
|
+
text = item.text,
|
|
68
|
+
action = item.action,
|
|
69
|
+
onClick = item.onClick,
|
|
70
|
+
icon = item.icon,
|
|
71
|
+
rest = _objectWithoutProperties(item, _excluded);
|
|
72
|
+
|
|
73
|
+
if ( /*#__PURE__*/React.isValidElement(text)) {
|
|
74
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
75
|
+
key: index
|
|
76
|
+
}, text);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var handleClick = onClick || action;
|
|
80
|
+
|
|
81
|
+
if (Array.isArray(dropDown)) {
|
|
82
|
+
var overlay = /*#__PURE__*/React.createElement(Menu, null, dropDown.map(function (subItem) {
|
|
83
|
+
if (subItem) {
|
|
84
|
+
return /*#__PURE__*/React.createElement(Menu.Item, {
|
|
85
|
+
onClick: function onClick() {
|
|
86
|
+
return subItem.onClick();
|
|
87
|
+
},
|
|
88
|
+
key: subItem.text,
|
|
89
|
+
disabled: subItem.disabled
|
|
90
|
+
}, subItem.text);
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
93
|
+
|
|
94
|
+
if (handleClick !== undefined) {
|
|
95
|
+
return /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
96
|
+
key: text,
|
|
97
|
+
type: 'text',
|
|
98
|
+
disabled: disabled,
|
|
99
|
+
overlay: overlay,
|
|
100
|
+
onClick: handleClick
|
|
101
|
+
}, icon ? /*#__PURE__*/React.createElement("span", {
|
|
102
|
+
className: "".concat(prefixCls, "-actions-icon")
|
|
103
|
+
}, icon) : null, text);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
107
|
+
key: text,
|
|
108
|
+
disabled: disabled,
|
|
109
|
+
overlay: overlay
|
|
110
|
+
}, /*#__PURE__*/React.createElement(Button, _objectSpread({
|
|
111
|
+
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)));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
119
|
+
key: text,
|
|
120
|
+
disabled: disabled,
|
|
121
|
+
onClick: handleClick,
|
|
122
|
+
type: "text"
|
|
123
|
+
}, icon ? /*#__PURE__*/React.createElement("span", {
|
|
124
|
+
className: "".concat(prefixCls, "-actions-icon")
|
|
125
|
+
}, icon) : null, text);
|
|
126
|
+
}), collapsedBtns.length > 0 ? /*#__PURE__*/React.createElement(Popover, {
|
|
127
|
+
placement: "bottomRight",
|
|
128
|
+
overlayClassName: "".concat(prefixCls, "-actions-popover"),
|
|
129
|
+
onVisibleChange: setVisible,
|
|
130
|
+
visible: visible,
|
|
131
|
+
trigger: "click",
|
|
132
|
+
content: /*#__PURE__*/React.createElement("ul", {
|
|
133
|
+
className: "".concat(prefixCls, "-actions-popover-list")
|
|
134
|
+
}, collapsedBtns.map(function (item, index) {
|
|
135
|
+
if (item === null) {
|
|
136
|
+
return item;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if ( /*#__PURE__*/React.isValidElement(item)) {
|
|
140
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
141
|
+
key: index
|
|
142
|
+
}, item);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
146
|
+
className: "".concat(prefixCls, "-actions-popover-item"),
|
|
147
|
+
key: index,
|
|
148
|
+
onClick: function onClick() {
|
|
149
|
+
var handleClick = item.onClick || item.action;
|
|
150
|
+
setVisible(false);
|
|
151
|
+
|
|
152
|
+
if (handleClick) {
|
|
153
|
+
handleClick();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}, item.text);
|
|
157
|
+
}))
|
|
158
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
159
|
+
type: "text",
|
|
160
|
+
icon: /*#__PURE__*/React.createElement(EllipsisOutlined, null)
|
|
161
|
+
})) : null));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export default Actions;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
@import '../theme.less';
|
|
2
|
+
|
|
3
|
+
.@{prefixCls}-actions {
|
|
4
|
+
&-popover {
|
|
5
|
+
&.ant-popover {
|
|
6
|
+
padding-top: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
& .ant-popover-inner-content {
|
|
10
|
+
padding: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
& .ant-popover-arrow {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&-list {
|
|
18
|
+
margin: 0;
|
|
19
|
+
padding: 8px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&-item {
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
width: 124px;
|
|
25
|
+
height: 38px;
|
|
26
|
+
padding: 8px;
|
|
27
|
+
color: #646464;
|
|
28
|
+
line-height: 22px;
|
|
29
|
+
text-align: left;
|
|
30
|
+
list-style: none;
|
|
31
|
+
border-radius: 2px;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
|
|
34
|
+
&:hover {
|
|
35
|
+
color: .primary(1) [];
|
|
36
|
+
background: .primary(0.08) [];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ant-btn {
|
|
42
|
+
padding: 0 8px;
|
|
43
|
+
font-size: 14px;
|
|
44
|
+
border-radius: 2px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ant-dropdown-button.ant-btn-group > .ant-btn:last-child:not(:first-child) {
|
|
48
|
+
padding-right: 4px;
|
|
49
|
+
padding-left: 4px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.ant-btn-text {
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
|
|
56
|
+
&:not(:disabled) {
|
|
57
|
+
color: rgba(51, 51, 51, 0.65);
|
|
58
|
+
|
|
59
|
+
&:hover {
|
|
60
|
+
background: rgba(0, 0, 0, 0.08);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&-icon {
|
|
66
|
+
margin-right: 8px;
|
|
67
|
+
font-size: 20px;
|
|
68
|
+
line-height: 1;
|
|
69
|
+
|
|
70
|
+
svg > use {
|
|
71
|
+
color: .primary() [rgb];
|
|
72
|
+
fill: #595959;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
button:disabled &-icon {
|
|
77
|
+
svg > use {
|
|
78
|
+
color: inherit;
|
|
79
|
+
fill: currentColor;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -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,115 @@
|
|
|
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 handleResizeStart = function handleResizeStart() {
|
|
40
|
+
var _fullTableRef$current;
|
|
41
|
+
|
|
42
|
+
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");
|
|
44
|
+
elm.classList.add("".concat(prefixCls, "-resizable-indicator"));
|
|
45
|
+
var table = fullTableRef.current;
|
|
46
|
+
|
|
47
|
+
if (table) {
|
|
48
|
+
table.appendChild(elm);
|
|
49
|
+
table.classList.add("".concat(prefixCls, "-resizing-col"));
|
|
50
|
+
indicator.current = elm;
|
|
51
|
+
|
|
52
|
+
if (handle.current !== null) {
|
|
53
|
+
var _handle$current = handle.current,
|
|
54
|
+
parent = _handle$current.offsetParent,
|
|
55
|
+
left = _handle$current.offsetLeft;
|
|
56
|
+
var node = handle.current.parentNode;
|
|
57
|
+
|
|
58
|
+
while (node !== null && node !== table) {
|
|
59
|
+
left -= node.scrollLeft;
|
|
60
|
+
|
|
61
|
+
if (node === parent) {
|
|
62
|
+
left += node.offsetLeft;
|
|
63
|
+
parent = node.offsetParent;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
node = node.parentNode;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setOffset(left - size);
|
|
70
|
+
indicator.current.style.left = "".concat(left, "px");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
var handleResizeStop = function handleResizeStop() {
|
|
76
|
+
var table = fullTableRef.current;
|
|
77
|
+
|
|
78
|
+
if (table && indicator.current) {
|
|
79
|
+
table.removeChild(indicator.current);
|
|
80
|
+
table.classList.remove("".concat(prefixCls, "-resizing-col"));
|
|
81
|
+
|
|
82
|
+
if (onChange) {
|
|
83
|
+
onChange(size);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
var handleResize = function handleResize(e, data) {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
|
|
91
|
+
if (indicator.current) {
|
|
92
|
+
setSize(data.size.width);
|
|
93
|
+
indicator.current.style.left = "".concat(offset + data.size.width, "px");
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return /*#__PURE__*/React.createElement(Resizable, {
|
|
98
|
+
width: size,
|
|
99
|
+
height: 0,
|
|
100
|
+
handle: /*#__PURE__*/React.createElement("div", {
|
|
101
|
+
className: "".concat(prefixCls, "-resizable-handle"),
|
|
102
|
+
onClick: function onClick(e) {
|
|
103
|
+
e.stopPropagation();
|
|
104
|
+
}
|
|
105
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
106
|
+
ref: handle
|
|
107
|
+
})),
|
|
108
|
+
onResizeStart: handleResizeStart,
|
|
109
|
+
onResizeStop: handleResizeStop,
|
|
110
|
+
onResize: handleResize,
|
|
111
|
+
draggableOpts: {
|
|
112
|
+
enableUserSelectHack: false
|
|
113
|
+
}
|
|
114
|
+
}, children);
|
|
115
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
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, useEffect, useCallback } from 'react';
|
|
14
|
+
import { debounce } from 'lodash';
|
|
15
|
+
var SortValue;
|
|
16
|
+
|
|
17
|
+
(function (SortValue) {
|
|
18
|
+
SortValue["ASC"] = "asc";
|
|
19
|
+
SortValue["DESC"] = "desc";
|
|
20
|
+
})(SortValue || (SortValue = {}));
|
|
21
|
+
|
|
22
|
+
export default function Sort(props) {
|
|
23
|
+
var value = props.value,
|
|
24
|
+
title = props.title,
|
|
25
|
+
onChange = props.onChange,
|
|
26
|
+
align = props.align,
|
|
27
|
+
index = props.index;
|
|
28
|
+
|
|
29
|
+
var _useState = useState(value),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
val = _useState2[0],
|
|
32
|
+
setVal = _useState2[1];
|
|
33
|
+
|
|
34
|
+
useEffect(function () {
|
|
35
|
+
setVal(value);
|
|
36
|
+
}, [value]);
|
|
37
|
+
var handleChange = useCallback(debounce(function (result) {
|
|
38
|
+
onChange(result);
|
|
39
|
+
}, 500), [onChange]);
|
|
40
|
+
var node;
|
|
41
|
+
|
|
42
|
+
if (val === SortValue.DESC) {
|
|
43
|
+
node = /*#__PURE__*/React.createElement("svg", {
|
|
44
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
45
|
+
width: "8px",
|
|
46
|
+
height: "10px"
|
|
47
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
48
|
+
fillRule: "evenodd",
|
|
49
|
+
fill: "rgb(6, 57, 133)",
|
|
50
|
+
d: "M3.971,9.785 L-0.000,6.000 L8.000,6.000 L3.971,9.785 Z"
|
|
51
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
52
|
+
fillRule: "evenodd",
|
|
53
|
+
fill: "rgb(153, 153, 153)",
|
|
54
|
+
d: "M4.000,-0.000 L8.000,4.000 L-0.000,4.000 L4.000,-0.000 Z"
|
|
55
|
+
}));
|
|
56
|
+
} else if (val === SortValue.ASC) {
|
|
57
|
+
node = /*#__PURE__*/React.createElement("svg", {
|
|
58
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
59
|
+
width: "8px",
|
|
60
|
+
height: "10px"
|
|
61
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
62
|
+
fillRule: "evenodd",
|
|
63
|
+
fill: "rgb(6, 57, 133)",
|
|
64
|
+
d: "M4.029,0.215 L8.000,4.000 L-0.000,4.000 L4.029,0.215 Z"
|
|
65
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
66
|
+
fillRule: "evenodd",
|
|
67
|
+
fill: "rgb(153, 153, 153)",
|
|
68
|
+
d: "M4.000,10.000 L-0.000,6.000 L8.000,6.000 L4.000,10.000 Z"
|
|
69
|
+
}));
|
|
70
|
+
} else {
|
|
71
|
+
node = /*#__PURE__*/React.createElement("svg", {
|
|
72
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
73
|
+
width: "8px",
|
|
74
|
+
height: "10px"
|
|
75
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
76
|
+
fillRule: "evenodd",
|
|
77
|
+
fill: "rgb(153, 153, 153)",
|
|
78
|
+
d: "M4.029,0.215 L8.000,4.000 L-0.000,4.000 L4.029,0.215 ZM4.000,10.000 L0.004,6.008 L8.000,6.000 L4.000,10.000 Z"
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var handleClick = function handleClick() {
|
|
83
|
+
var nextVal;
|
|
84
|
+
|
|
85
|
+
if (val === SortValue.DESC) {
|
|
86
|
+
nextVal = undefined;
|
|
87
|
+
} else if (val === SortValue.ASC) {
|
|
88
|
+
nextVal = SortValue.DESC;
|
|
89
|
+
} else {
|
|
90
|
+
nextVal = SortValue.ASC;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
setVal(nextVal);
|
|
94
|
+
handleChange(nextVal);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var justify;
|
|
98
|
+
|
|
99
|
+
switch (align) {
|
|
100
|
+
case 'right':
|
|
101
|
+
justify = 'flex-end';
|
|
102
|
+
break;
|
|
103
|
+
|
|
104
|
+
case 'center':
|
|
105
|
+
justify = 'center';
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
default:
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: "lemon-table-sort",
|
|
113
|
+
onClick: handleClick,
|
|
114
|
+
style: justify ? {
|
|
115
|
+
justifyContent: justify
|
|
116
|
+
} : undefined
|
|
117
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
className: "lemon-table-sort-title"
|
|
119
|
+
}, title), /*#__PURE__*/React.createElement("div", null, node, index !== undefined && /*#__PURE__*/React.createElement("span", {
|
|
120
|
+
className: "lemon-table-sort-number"
|
|
121
|
+
}, index)));
|
|
122
|
+
}
|