@lemon-fe/components 0.1.82 → 0.1.85
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 +467 -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 +33 -0
- package/es/index.js +28 -0
- package/es/init.d.ts +3 -0
- package/es/init.js +149 -0
- package/es/utils.d.ts +2 -0
- package/es/utils.js +14 -0
- package/package.json +2 -2
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
var _excluded = ["onWidthChange", "width", "fullTableRef", "children", "className"],
|
|
2
|
+
_excluded2 = ["id", "columns", "defaultColumnProps", "rowKey", "children", "summaryTitle", "summaryRecord", "dataSource", "onSortChange", "sort", "scroll", "virtual", "components", "pagination", "rowHeight", "tableLayout", "rowActions", "style", "className", "locale"];
|
|
3
|
+
|
|
4
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
+
|
|
6
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
|
|
8
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
+
|
|
10
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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
|
+
|
|
14
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
|
+
|
|
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."); }
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
/// <reference path="../../typings.d.ts" />
|
|
37
|
+
import React, { useMemo, useState, useEffect, useRef } from 'react';
|
|
38
|
+
import { Table as AntdTable } from 'antd';
|
|
39
|
+
import classNames from 'classnames';
|
|
40
|
+
import { get } from 'lodash';
|
|
41
|
+
import ResizeObserver from 'rc-resize-observer';
|
|
42
|
+
import { isColumnType, getColumnKey } from './utils';
|
|
43
|
+
import ResizeHeaderCell from './ResizeHeaderCell';
|
|
44
|
+
import { PREFIX_CLS } from '../constants';
|
|
45
|
+
import VirtualList from './VirtualBody';
|
|
46
|
+
import BaseTableContext from './BaseTableContext';
|
|
47
|
+
import Actions from './Actions';
|
|
48
|
+
import empty from './empty.png';
|
|
49
|
+
|
|
50
|
+
function formatSummary(summary) {
|
|
51
|
+
if (!summary) {
|
|
52
|
+
return summary;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var obj = _objectSpread({}, summary);
|
|
56
|
+
|
|
57
|
+
var pretty = new Intl.NumberFormat('en-US', {
|
|
58
|
+
minimumFractionDigits: 2,
|
|
59
|
+
maximumFractionDigits: 2
|
|
60
|
+
});
|
|
61
|
+
Object.keys(obj).forEach(function (key) {
|
|
62
|
+
if (obj.hasOwnProperty(key) && typeof obj[key] === 'number') {
|
|
63
|
+
obj[key] = pretty.format(obj[key]);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function Th(props) {
|
|
70
|
+
var onWidthChange = props.onWidthChange,
|
|
71
|
+
width = props.width,
|
|
72
|
+
fullTableRef = props.fullTableRef,
|
|
73
|
+
children = props.children,
|
|
74
|
+
className = props.className,
|
|
75
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
76
|
+
|
|
77
|
+
var reg = /\bant-table-cell-ellipsis\b/;
|
|
78
|
+
var content = children;
|
|
79
|
+
var mClassName = className;
|
|
80
|
+
|
|
81
|
+
if (mClassName && reg.test(mClassName)) {
|
|
82
|
+
mClassName = mClassName.replace(reg, '');
|
|
83
|
+
content = /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
className: "ant-table-cell-ellipsis"
|
|
85
|
+
}, content);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!width || !onWidthChange) {
|
|
89
|
+
return /*#__PURE__*/React.createElement("th", _objectSpread(_objectSpread({}, restProps), {}, {
|
|
90
|
+
className: mClassName
|
|
91
|
+
}), content);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return /*#__PURE__*/React.createElement(ResizeHeaderCell, {
|
|
95
|
+
width: width,
|
|
96
|
+
onChange: onWidthChange,
|
|
97
|
+
fullTableRef: fullTableRef,
|
|
98
|
+
prefixCls: "".concat(PREFIX_CLS, "-table")
|
|
99
|
+
}, /*#__PURE__*/React.createElement("th", _objectSpread(_objectSpread({}, restProps), {}, {
|
|
100
|
+
className: mClassName
|
|
101
|
+
}), content));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function BaseTable(props) {
|
|
105
|
+
var id = props.id,
|
|
106
|
+
columns = props.columns,
|
|
107
|
+
defaultColumnProps = props.defaultColumnProps,
|
|
108
|
+
rowKey = props.rowKey,
|
|
109
|
+
children = props.children,
|
|
110
|
+
summaryTitle = props.summaryTitle,
|
|
111
|
+
summaryRecord = props.summaryRecord,
|
|
112
|
+
_props$dataSource = props.dataSource,
|
|
113
|
+
dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
|
|
114
|
+
onSortChange = props.onSortChange,
|
|
115
|
+
defaultSort = props.sort,
|
|
116
|
+
scroll = props.scroll,
|
|
117
|
+
virtual = props.virtual,
|
|
118
|
+
componentsProp = props.components,
|
|
119
|
+
paginationProp = props.pagination,
|
|
120
|
+
rowHeight = props.rowHeight,
|
|
121
|
+
_props$tableLayout = props.tableLayout,
|
|
122
|
+
tableLayout = _props$tableLayout === void 0 ? 'fixed' : _props$tableLayout,
|
|
123
|
+
rowActions = props.rowActions,
|
|
124
|
+
style = props.style,
|
|
125
|
+
className = props.className,
|
|
126
|
+
localeProp = props.locale,
|
|
127
|
+
restProps = _objectWithoutProperties(props, _excluded2);
|
|
128
|
+
|
|
129
|
+
var fullTableRef = useRef(null);
|
|
130
|
+
|
|
131
|
+
var _useState = useState(new Map()),
|
|
132
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
133
|
+
colsState = _useState2[0],
|
|
134
|
+
setColsState = _useState2[1];
|
|
135
|
+
|
|
136
|
+
var scrollYProp = scroll === null || scroll === void 0 ? void 0 : scroll.y;
|
|
137
|
+
|
|
138
|
+
var _useState3 = useState(scrollYProp === true ? 0 : scrollYProp),
|
|
139
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
140
|
+
scrollY = _useState4[0],
|
|
141
|
+
setScrollY = _useState4[1];
|
|
142
|
+
|
|
143
|
+
var memoHeight = useRef(0);
|
|
144
|
+
/** auto scroll y */
|
|
145
|
+
|
|
146
|
+
var calcScrollY = function calcScrollY() {
|
|
147
|
+
var wrapper = fullTableRef.current;
|
|
148
|
+
|
|
149
|
+
if (wrapper === null) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
var table = wrapper.querySelector('.ant-table');
|
|
154
|
+
var tableBody = wrapper.querySelector('.ant-table-body');
|
|
155
|
+
|
|
156
|
+
if (tableBody === null || table === null) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
var parent = wrapper.parentElement;
|
|
161
|
+
|
|
162
|
+
if (parent === null) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
var style = getComputedStyle(parent);
|
|
167
|
+
var contentHeight = parent.offsetHeight - (parseFloat(style.getPropertyValue('padding-top')) || 0) - (parseFloat(style.getPropertyValue('padding-bottom')) || 0);
|
|
168
|
+
var nodes = [];
|
|
169
|
+
|
|
170
|
+
if (tableBody.previousElementSibling !== null) {
|
|
171
|
+
nodes.push(tableBody.previousElementSibling);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (tableBody.nextElementSibling !== null) {
|
|
175
|
+
nodes.push(tableBody.nextElementSibling);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (table.nextElementSibling !== null) {
|
|
179
|
+
nodes.push(table.nextElementSibling);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
contentHeight -= nodes.reduce(function (prev, dom) {
|
|
183
|
+
var cpStyle = window.getComputedStyle(dom);
|
|
184
|
+
var height = dom.offsetHeight + (parseFloat(cpStyle.getPropertyValue('margin-top')) || 0) + (parseFloat(cpStyle.getPropertyValue('margin-bottom')) || 0);
|
|
185
|
+
return prev + height;
|
|
186
|
+
}, 0);
|
|
187
|
+
return contentHeight;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
var changeScrollY = function changeScrollY(height) {
|
|
191
|
+
if (height === memoHeight.current) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
memoHeight.current = height;
|
|
196
|
+
|
|
197
|
+
if (memoHeight.current === 0) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
setScrollY(calcScrollY() || undefined);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
var hasPagination = false;
|
|
205
|
+
|
|
206
|
+
if (paginationProp !== false) {
|
|
207
|
+
hasPagination = paginationProp !== undefined && !!paginationProp.total || dataSource.length > 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
useEffect(function () {
|
|
211
|
+
if (scrollYProp === true) {
|
|
212
|
+
setScrollY(calcScrollY() || 0);
|
|
213
|
+
}
|
|
214
|
+
}, [hasPagination]);
|
|
215
|
+
useEffect(function () {
|
|
216
|
+
if (scrollYProp !== true) {
|
|
217
|
+
setScrollY(scrollYProp);
|
|
218
|
+
}
|
|
219
|
+
}, [scrollYProp]);
|
|
220
|
+
useEffect(function () {
|
|
221
|
+
if (scrollY !== undefined && fullTableRef.current !== null) {
|
|
222
|
+
var body = fullTableRef.current.querySelector('.ant-table-body');
|
|
223
|
+
|
|
224
|
+
if (body !== null) {
|
|
225
|
+
var dataType = _typeof(scrollY);
|
|
226
|
+
|
|
227
|
+
switch (dataType) {
|
|
228
|
+
case 'string':
|
|
229
|
+
body.style.height = scrollY;
|
|
230
|
+
break;
|
|
231
|
+
|
|
232
|
+
case 'number':
|
|
233
|
+
body.style.height = scrollY + 'px';
|
|
234
|
+
break;
|
|
235
|
+
|
|
236
|
+
default:
|
|
237
|
+
body.style.height = 'auto';
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}, [scrollY]);
|
|
242
|
+
/** resizable column */
|
|
243
|
+
|
|
244
|
+
var _useMemo = useMemo(function () {
|
|
245
|
+
var flattenCols = [];
|
|
246
|
+
var isFixedLayout = tableLayout === 'fixed';
|
|
247
|
+
var hasAutoWidthCol = false;
|
|
248
|
+
|
|
249
|
+
var traverse = function traverse(cols) {
|
|
250
|
+
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
251
|
+
return cols.map(function (col, index) {
|
|
252
|
+
var currPath = [].concat(_toConsumableArray(path), [index]);
|
|
253
|
+
|
|
254
|
+
if (isColumnType(col)) {
|
|
255
|
+
var colKey = getColumnKey(col);
|
|
256
|
+
|
|
257
|
+
var nextCol = _objectSpread(_objectSpread({}, defaultColumnProps), col);
|
|
258
|
+
|
|
259
|
+
var colState = colsState.get(colKey);
|
|
260
|
+
|
|
261
|
+
if (colState && colState.width !== undefined) {
|
|
262
|
+
nextCol.width = colState.width;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (isFixedLayout && !!nextCol.title) {
|
|
266
|
+
if (nextCol.width === undefined) {
|
|
267
|
+
nextCol.width = 160;
|
|
268
|
+
} else if (nextCol.width === 'auto') {
|
|
269
|
+
nextCol.width = undefined;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (!nextCol.width) {
|
|
274
|
+
hasAutoWidthCol = true;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (nextCol.width && !nextCol.fixed) {
|
|
278
|
+
if (nextCol.ellipsis === undefined) {
|
|
279
|
+
nextCol.ellipsis = true;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
nextCol.onHeaderCell = function () {
|
|
283
|
+
return {
|
|
284
|
+
width: nextCol.width,
|
|
285
|
+
fullTableRef: fullTableRef,
|
|
286
|
+
onWidthChange: function onWidthChange(size) {
|
|
287
|
+
setColsState(function (prev) {
|
|
288
|
+
var prevItem = prev.get(colKey);
|
|
289
|
+
|
|
290
|
+
if (prevItem !== undefined && prevItem.width === size) {
|
|
291
|
+
return prev;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
prevItem = _objectSpread(_objectSpread({}, prevItem), {}, {
|
|
295
|
+
width: size
|
|
296
|
+
});
|
|
297
|
+
var next = new Map(prev);
|
|
298
|
+
next.set(colKey, prevItem);
|
|
299
|
+
return next;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
flattenCols.push(nextCol);
|
|
307
|
+
return nextCol;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return _objectSpread(_objectSpread(_objectSpread({}, defaultColumnProps), col), {}, {
|
|
311
|
+
children: traverse(col.children, currPath)
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
var newColumns = traverse(columns);
|
|
317
|
+
|
|
318
|
+
if (isFixedLayout && !hasAutoWidthCol) {
|
|
319
|
+
var emptyCol = {
|
|
320
|
+
title: ''
|
|
321
|
+
};
|
|
322
|
+
newColumns.push(emptyCol);
|
|
323
|
+
flattenCols.push(emptyCol);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return [newColumns, flattenCols];
|
|
327
|
+
}, [columns, colsState, tableLayout]),
|
|
328
|
+
_useMemo2 = _slicedToArray(_useMemo, 2),
|
|
329
|
+
formatedColumns = _useMemo2[0],
|
|
330
|
+
flattenColumns = _useMemo2[1];
|
|
331
|
+
/** row actions */
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
var _useMemo3 = useMemo(function () {
|
|
335
|
+
if (rowActions !== undefined) {
|
|
336
|
+
var actionCol = {
|
|
337
|
+
title: '',
|
|
338
|
+
className: "".concat(PREFIX_CLS, "-table-operator-column"),
|
|
339
|
+
width: 1,
|
|
340
|
+
fixed: 'right',
|
|
341
|
+
render: function render(_, row, index) {
|
|
342
|
+
return /*#__PURE__*/React.createElement(Actions, {
|
|
343
|
+
actions: rowActions,
|
|
344
|
+
row: row,
|
|
345
|
+
index: index
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
return [[].concat(_toConsumableArray(formatedColumns), [actionCol]), [].concat(_toConsumableArray(flattenColumns), [actionCol])];
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return [formatedColumns, flattenColumns];
|
|
353
|
+
}, [rowActions, flattenColumns, formatedColumns]);
|
|
354
|
+
|
|
355
|
+
var _useMemo4 = _slicedToArray(_useMemo3, 2);
|
|
356
|
+
|
|
357
|
+
formatedColumns = _useMemo4[0];
|
|
358
|
+
flattenColumns = _useMemo4[1];
|
|
359
|
+
|
|
360
|
+
/** virtualize scroll */
|
|
361
|
+
var _useMemo5 = useMemo(function () {
|
|
362
|
+
return {
|
|
363
|
+
components: _objectSpread({
|
|
364
|
+
header: {
|
|
365
|
+
cell: Th
|
|
366
|
+
},
|
|
367
|
+
body: virtual ? {
|
|
368
|
+
wrapper: VirtualList
|
|
369
|
+
} : undefined
|
|
370
|
+
}, componentsProp)
|
|
371
|
+
};
|
|
372
|
+
}, [virtual]),
|
|
373
|
+
components = _useMemo5.components;
|
|
374
|
+
/** summary row */
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
var summary = useMemo(function () {
|
|
378
|
+
var Summary = AntdTable.Summary;
|
|
379
|
+
|
|
380
|
+
if (!summaryRecord) {
|
|
381
|
+
return undefined;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return function () {
|
|
385
|
+
var _props$rowSelection;
|
|
386
|
+
|
|
387
|
+
var data = formatSummary(summaryRecord);
|
|
388
|
+
var offset = 0;
|
|
389
|
+
return /*#__PURE__*/React.createElement(Summary, {
|
|
390
|
+
fixed: true
|
|
391
|
+
}, /*#__PURE__*/React.createElement(Summary.Row, null, ((_props$rowSelection = props.rowSelection) === null || _props$rowSelection === void 0 ? void 0 : _props$rowSelection.type) !== undefined && /*#__PURE__*/React.createElement(Summary.Cell, {
|
|
392
|
+
index: offset++
|
|
393
|
+
}), flattenColumns.map(function (item, index) {
|
|
394
|
+
var value;
|
|
395
|
+
|
|
396
|
+
if (index === 0) {
|
|
397
|
+
value = summaryTitle;
|
|
398
|
+
} else if (item.dataIndex) {
|
|
399
|
+
value = get(data, item.dataIndex);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return /*#__PURE__*/React.createElement(Summary.Cell, {
|
|
403
|
+
index: index + offset,
|
|
404
|
+
key: getColumnKey(item) || index,
|
|
405
|
+
align: item.align
|
|
406
|
+
}, value);
|
|
407
|
+
})));
|
|
408
|
+
};
|
|
409
|
+
}, [flattenColumns, summaryRecord, summaryTitle]);
|
|
410
|
+
var ctx = useMemo(function () {
|
|
411
|
+
return {
|
|
412
|
+
scrollY: scrollY,
|
|
413
|
+
rowHeight: rowHeight
|
|
414
|
+
};
|
|
415
|
+
}, [scrollY, rowHeight]);
|
|
416
|
+
var tableNode = /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread({
|
|
417
|
+
size: "small",
|
|
418
|
+
ref: fullTableRef,
|
|
419
|
+
className: classNames("".concat(PREFIX_CLS, "-table"), className),
|
|
420
|
+
columns: formatedColumns,
|
|
421
|
+
dataSource: dataSource,
|
|
422
|
+
rowKey: rowKey,
|
|
423
|
+
summary: summary,
|
|
424
|
+
components: components,
|
|
425
|
+
tableLayout: tableLayout,
|
|
426
|
+
scroll: {
|
|
427
|
+
x: (scroll === null || scroll === void 0 ? void 0 : scroll.x) || '100%',
|
|
428
|
+
y: scrollY
|
|
429
|
+
},
|
|
430
|
+
style: scrollYProp === true ? _objectSpread(_objectSpread({}, style), {}, {
|
|
431
|
+
height: '100%'
|
|
432
|
+
}) : style,
|
|
433
|
+
locale: _objectSpread({
|
|
434
|
+
emptyText: /*#__PURE__*/React.createElement("div", {
|
|
435
|
+
className: "".concat(PREFIX_CLS, "-table-empty")
|
|
436
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
437
|
+
src: empty
|
|
438
|
+
}), /*#__PURE__*/React.createElement("div", null, "\u6682\u65E0\u6570\u636E"))
|
|
439
|
+
}, localeProp)
|
|
440
|
+
}, restProps), {}, {
|
|
441
|
+
pagination: paginationProp !== false ? _objectSpread({
|
|
442
|
+
size: 'small',
|
|
443
|
+
pageSizeOptions: ['10', '20', '50', '100'],
|
|
444
|
+
showSizeChanger: true,
|
|
445
|
+
showQuickJumper: true,
|
|
446
|
+
showTotal: function showTotal(val) {
|
|
447
|
+
return "\u5171".concat(val, "\u6761");
|
|
448
|
+
},
|
|
449
|
+
defaultPageSize: 20
|
|
450
|
+
}, paginationProp) : false
|
|
451
|
+
}));
|
|
452
|
+
|
|
453
|
+
if (scrollYProp === true) {
|
|
454
|
+
tableNode = /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
455
|
+
onResize: function onResize(size) {
|
|
456
|
+
changeScrollY(size.height);
|
|
457
|
+
}
|
|
458
|
+
}, tableNode);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return /*#__PURE__*/React.createElement(BaseTableContext.Provider, {
|
|
462
|
+
value: ctx
|
|
463
|
+
}, tableNode);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
BaseTable.Summary = AntdTable.Summary;
|
|
467
|
+
export default BaseTable;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ColumnType, ColumnGroupType } from './typings';
|
|
2
|
+
export declare function isColumnType<T>(col: ColumnGroupType<T> | ColumnType<T>): col is ColumnType<T>;
|
|
3
|
+
export declare function getColumnKey(col: ColumnType<any>): string | number;
|
|
4
|
+
export declare function randomStr(): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function isColumnType(col) {
|
|
2
|
+
return col.children === undefined;
|
|
3
|
+
}
|
|
4
|
+
export function getColumnKey(col) {
|
|
5
|
+
if (typeof col.dataIndex === 'string' || typeof col.dataIndex === 'number') {
|
|
6
|
+
return col.dataIndex;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (Array.isArray(col.dataIndex)) {
|
|
10
|
+
return col.dataIndex.join('-');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return col.key;
|
|
14
|
+
}
|
|
15
|
+
export function randomStr() {
|
|
16
|
+
var len = 8;
|
|
17
|
+
var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz';
|
|
18
|
+
var maxPos = chars.length;
|
|
19
|
+
var pwd = '';
|
|
20
|
+
|
|
21
|
+
for (var i = 0; i < len; i += 1) {
|
|
22
|
+
pwd += chars.charAt(Math.floor(Math.random() * maxPos));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return pwd;
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IColorPickerProps {
|
|
3
|
+
/** 选中的颜色,例:rgba(255, 255, 255, 0) */
|
|
4
|
+
value?: string;
|
|
5
|
+
/** 是否禁用透明度 */
|
|
6
|
+
disableAlpha?: boolean;
|
|
7
|
+
/** 颜色变化回调 */
|
|
8
|
+
onChange?: (val: string) => void;
|
|
9
|
+
/** 是否使用渐变选择器 */
|
|
10
|
+
gradientEnable?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const ColorPicker: React.FC<IColorPickerProps>;
|
|
13
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,114 @@
|
|
|
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 { Tooltip } from 'antd';
|
|
14
|
+
import React, { useEffect, useState } from 'react';
|
|
15
|
+
import colorString from 'color-string';
|
|
16
|
+
import ReactGPicker from 'react-gcolor-picker';
|
|
17
|
+
import { SketchPicker } from 'react-color';
|
|
18
|
+
var DEFAULT_COLORS = ['#FFD5B6', '#F5A623', '#F8E71C', '#8B572A', '#7ED321', '#417505', '#BD10E0', '#9013FE', '#456ad4', '#4A90E2', '#50E3C2', '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF'];
|
|
19
|
+
var DEFAULT_COLOR = 'rgba(255, 255, 255, 0)';
|
|
20
|
+
|
|
21
|
+
var ColorPicker = function ColorPicker(_ref) {
|
|
22
|
+
var _ref$value = _ref.value,
|
|
23
|
+
value = _ref$value === void 0 ? DEFAULT_COLOR : _ref$value,
|
|
24
|
+
disableAlpha = _ref.disableAlpha,
|
|
25
|
+
gradientEnable = _ref.gradientEnable,
|
|
26
|
+
_onChange = _ref.onChange;
|
|
27
|
+
|
|
28
|
+
var _useState = useState(false),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
pickerShow = _useState2[0],
|
|
31
|
+
setPickerShow = _useState2[1];
|
|
32
|
+
|
|
33
|
+
var _useState3 = useState(),
|
|
34
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
35
|
+
hexColor = _useState4[0],
|
|
36
|
+
setHexColor = _useState4[1];
|
|
37
|
+
|
|
38
|
+
var _useState5 = useState(),
|
|
39
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
40
|
+
alpha = _useState6[0],
|
|
41
|
+
setAlpha = _useState6[1];
|
|
42
|
+
|
|
43
|
+
useEffect(function () {
|
|
44
|
+
if (!gradientEnable) {
|
|
45
|
+
var rgbaColorArr = colorString.get.rgb(value);
|
|
46
|
+
|
|
47
|
+
if (!rgbaColorArr) {
|
|
48
|
+
rgbaColorArr = colorString.get.rgb(DEFAULT_COLOR);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setHexColor(colorString.to.hex(rgbaColorArr));
|
|
52
|
+
setAlpha(rgbaColorArr[3]);
|
|
53
|
+
}
|
|
54
|
+
}, [value]);
|
|
55
|
+
|
|
56
|
+
var handlePickerShow = function handlePickerShow() {
|
|
57
|
+
setPickerShow(function (val) {
|
|
58
|
+
return !val;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var handleColorChange = function handleColorChange(val, event) {
|
|
63
|
+
var _val$rgb$a;
|
|
64
|
+
|
|
65
|
+
event.stopPropagation();
|
|
66
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange("rgba(".concat(val.rgb.r, ", ").concat(val.rgb.g, ", ").concat(val.rgb.b, ", ").concat((_val$rgb$a = val.rgb.a) !== null && _val$rgb$a !== void 0 ? _val$rgb$a : 1, ")"));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
style: {
|
|
71
|
+
border: pickerShow ? '2px solid rgb(69, 143, 255)' : undefined
|
|
72
|
+
},
|
|
73
|
+
className: "lemon-color-picker",
|
|
74
|
+
onClick: handlePickerShow
|
|
75
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
className: "lemon-color-picker-color",
|
|
77
|
+
style: {
|
|
78
|
+
background: value,
|
|
79
|
+
width: gradientEnable ? '100%' : 120
|
|
80
|
+
}
|
|
81
|
+
}), !gradientEnable && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
className: "lemon-color-picker-hex"
|
|
83
|
+
}, hexColor === null || hexColor === void 0 ? void 0 : hexColor.toLocaleUpperCase()), /*#__PURE__*/React.createElement(Tooltip, {
|
|
84
|
+
placement: "topRight",
|
|
85
|
+
title: "\u989C\u8272\u7684\u900F\u660E\u5EA6\uFF0C0\u8868\u793A\u900F\u660E\uFF0C100\u8868\u793A\u4E0D\u900F\u660E"
|
|
86
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: "lemon-color-picker-alpha"
|
|
88
|
+
}, Math.floor(Number(alpha) * 100), "%"))), pickerShow && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
89
|
+
className: "lemon-color-picker-pop",
|
|
90
|
+
onClick: function onClick(e) {
|
|
91
|
+
return e.stopPropagation();
|
|
92
|
+
}
|
|
93
|
+
}, gradientEnable ? /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: "lemon-color-picker-react-picker"
|
|
95
|
+
}, /*#__PURE__*/React.createElement(ReactGPicker, {
|
|
96
|
+
showAlpha: !disableAlpha,
|
|
97
|
+
value: value,
|
|
98
|
+
onChange: function onChange(v) {
|
|
99
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(v);
|
|
100
|
+
},
|
|
101
|
+
format: "hex",
|
|
102
|
+
gradient: true,
|
|
103
|
+
solid: false
|
|
104
|
+
})) : /*#__PURE__*/React.createElement(SketchPicker, {
|
|
105
|
+
disableAlpha: disableAlpha,
|
|
106
|
+
onChange: handleColorChange,
|
|
107
|
+
color: value,
|
|
108
|
+
presetColors: DEFAULT_COLORS
|
|
109
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
className: "lemon-color-picker-mask"
|
|
111
|
+
}))));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PopoverProps } from 'antd';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
interface Props {
|
|
4
|
+
actions: ({
|
|
5
|
+
text: string | ReactElement;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
} | null)[];
|
|
9
|
+
overlayClassName?: string;
|
|
10
|
+
placement?: PopoverProps['placement'];
|
|
11
|
+
children?: ReactElement | null;
|
|
12
|
+
}
|
|
13
|
+
export default function Dropdown(props: Props): JSX.Element;
|
|
14
|
+
export {};
|