@qn-pandora/pandora-component 4.4.0 → 4.4.2
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/CHANGELOG.json +29 -0
- package/CHANGELOG.md +15 -1
- package/es/components/Drawer/index.d.ts +1 -1
- package/es/components/FileResumable/constants.d.ts +1 -0
- package/es/components/FileResumable/index.js +10 -3
- package/es/components/Table/ResizableTitle/index.d.ts +3 -0
- package/es/components/Table/ResizableTitle/index.js +40 -0
- package/es/components/Table/ResizableTitle/style.css +21 -0
- package/es/components/Table/ResizableTitle/style.less +26 -0
- package/es/components/Table/constant.d.ts +14 -0
- package/es/components/Table/constant.js +15 -0
- package/es/components/Table/index.d.ts +14 -1
- package/es/components/Table/index.js +102 -6
- package/es/index.css +7232 -7211
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/index.less +20 -19
- package/lib/components/Drawer/index.d.ts +1 -1
- package/lib/components/FileResumable/constants.d.ts +1 -0
- package/lib/components/FileResumable/index.js +10 -3
- package/lib/components/Table/ResizableTitle/index.d.ts +3 -0
- package/lib/components/Table/ResizableTitle/index.js +45 -0
- package/lib/components/Table/ResizableTitle/style.css +21 -0
- package/lib/components/Table/ResizableTitle/style.less +26 -0
- package/lib/components/Table/constant.d.ts +14 -0
- package/lib/components/Table/constant.js +15 -0
- package/lib/components/Table/index.d.ts +14 -1
- package/lib/components/Table/index.js +101 -5
- package/lib/index.css +5211 -5190
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/index.less +12 -11
- package/package.json +7 -5
package/es/index.d.ts
CHANGED
@@ -9,6 +9,7 @@ export { default as Input, TInputProps } from './components/Input';
|
|
9
9
|
export { default as Selector, ISelectorProps, IGroupOption as ISelectorGroupOption, IOptions as ISelectorOptions, SelectValue as ISelectValue } from './components/Selector';
|
10
10
|
export { default as SelectorWidthChildren } from './components/Selector/SelectorWidthChildren';
|
11
11
|
export { default as Table, ITableProps, IOptionItem as ITableOptionItem } from './components/Table';
|
12
|
+
export { ETableDragSaveKey } from './components/Table/constant';
|
12
13
|
export { default as Steps } from './components/Steps';
|
13
14
|
export { default as DateTimePicker, Time, EButtonType, IDateTimePickerProps } from './components/DateTimePicker';
|
14
15
|
export * from './components/DateTimePicker/constants';
|
package/es/index.js
CHANGED
@@ -9,6 +9,7 @@ export { default as Input } from './components/Input';
|
|
9
9
|
export { default as Selector } from './components/Selector';
|
10
10
|
export { default as SelectorWidthChildren } from './components/Selector/SelectorWidthChildren';
|
11
11
|
export { default as Table } from './components/Table';
|
12
|
+
export { ETableDragSaveKey } from './components/Table/constant';
|
12
13
|
export { default as Steps } from './components/Steps';
|
13
14
|
export { default as DateTimePicker, Time, EButtonType } from './components/DateTimePicker';
|
14
15
|
export * from './components/DateTimePicker/constants';
|
package/es/index.less
CHANGED
@@ -1,53 +1,54 @@
|
|
1
1
|
@import './style/mixin.less';
|
2
2
|
@import './style/theme.less';
|
3
|
+
@import './components/AutoComplete/style.less';
|
3
4
|
@import './components/Button/style.less';
|
5
|
+
@import './components/Breadcrumb/style.less';
|
6
|
+
@import './components/Card/style.less';
|
4
7
|
@import './components/CheckTransformList/style.less';
|
5
8
|
@import './components/Checkbox/style.less';
|
6
9
|
@import './components/CheckboxList/style.less';
|
7
10
|
@import './components/Collapse/style.less';
|
8
|
-
@import './components/Breadcrumb/style.less';
|
9
11
|
@import './components/CollapsiblePanel/style.less';
|
10
12
|
@import './components/DateTimePicker/style.less';
|
11
|
-
@import './components/AutoComplete/style.less';
|
12
|
-
@import './components/Card/style.less';
|
13
13
|
@import './components/Drawer/style.less';
|
14
|
+
@import './components/FileResumable/style.less';
|
14
15
|
@import './components/Descriptions/style.less';
|
15
16
|
@import './components/Input/style.less';
|
16
|
-
@import './components/FileResumable/style.less';
|
17
17
|
@import './components/KeyValuePair/style.less';
|
18
|
+
@import './components/Menu/style.less';
|
18
19
|
@import './components/Modal/style.less';
|
19
20
|
@import './components/NameExplainTooltip/style.less';
|
20
|
-
@import './components/Menu/style.less';
|
21
21
|
@import './components/NameLimiter/style.less';
|
22
22
|
@import './components/OptionList/style.less';
|
23
23
|
@import './components/RadioGroup/style.less';
|
24
|
-
@import './components/RemarkName/style.less';
|
25
|
-
@import './components/Selector/style.less';
|
26
24
|
@import './components/RangeInput/style.less';
|
27
|
-
@import './components/
|
25
|
+
@import './components/Selector/style.less';
|
26
|
+
@import './components/RemarkName/style.less';
|
28
27
|
@import './components/Spin/style.less';
|
29
|
-
@import './components/
|
28
|
+
@import './components/Steps/style.less';
|
30
29
|
@import './components/Tabs/style.less';
|
31
|
-
@import './components/
|
30
|
+
@import './components/Table/style.less';
|
32
31
|
@import './components/TagList/style.less';
|
32
|
+
@import './components/Timeline/style.less';
|
33
33
|
@import './components/TreeSelector/style.less';
|
34
34
|
@import './components/Transfer/style.less';
|
35
|
+
@import './components/Card/RowExtra/style.less';
|
36
|
+
@import './components/Card/SearchInput/style.less';
|
37
|
+
@import './components/DateTimePicker/BaseMobile/style.less';
|
35
38
|
@import './components/DateTimePicker/Base/style.less';
|
36
39
|
@import './components/DateTimePicker/DisplayInput/style.less';
|
37
|
-
@import './components/DateTimePicker/BaseMobile/style.less';
|
38
|
-
@import './components/Card/SearchInput/style.less';
|
39
|
-
@import './components/Card/RowExtra/style.less';
|
40
40
|
@import './components/Drawer/CloseIcon/style.less';
|
41
|
-
@import './components/OptionList/OptionItem/style.less';
|
42
41
|
@import './components/OptionList/InlineOptionList/style.less';
|
42
|
+
@import './components/OptionList/OptionItem/style.less';
|
43
43
|
@import './components/OptionList/PopoverOptionList/style.less';
|
44
44
|
@import './components/Steps/ControlButton/style.less';
|
45
45
|
@import './components/Table/ColumnSetting/style.less';
|
46
46
|
@import './components/Table/ColumnTag/style.less';
|
47
|
-
@import './components/
|
48
|
-
@import './components/TagList/TagSwitch/style.less';
|
47
|
+
@import './components/Table/ResizableTitle/style.less';
|
49
48
|
@import './components/TagList/Tag/style.less';
|
50
|
-
@import './components/
|
49
|
+
@import './components/TagList/TagSwitch/style.less';
|
50
|
+
@import './components/Timeline/TimelineItem/style.less';
|
51
51
|
@import './components/Transfer/List/style.less';
|
52
|
-
@import './components/
|
53
|
-
@import './components/DateTimePicker/BaseMobile/Absolute/style.less';
|
52
|
+
@import './components/Transfer/ListBody/style.less';
|
53
|
+
@import './components/DateTimePicker/BaseMobile/Absolute/style.less';
|
54
|
+
@import './components/DateTimePicker/Collapse/Panel/style.less';
|
@@ -164,7 +164,7 @@ declare const _default: (props: {
|
|
164
164
|
*/
|
165
165
|
showFullScreen?: boolean | undefined;
|
166
166
|
onScreenFullChange?: ((showFullScreen: boolean) => void) | undefined;
|
167
|
-
} & Pick<DrawerProps, "style" | "autoFocus" | "prefixCls" | "footer" | "extra" | "bodyStyle" | "forceRender" | "keyboard" | "destroyOnClose" | "closeIcon" | "drawerStyle" | "headerStyle" | "contentWrapperStyle" | "
|
167
|
+
} & Pick<DrawerProps, "style" | "autoFocus" | "prefixCls" | "footer" | "extra" | "bodyStyle" | "forceRender" | "push" | "keyboard" | "destroyOnClose" | "closeIcon" | "drawerStyle" | "headerStyle" | "contentWrapperStyle" | "handler" | "footerStyle" | "level" | "levelMove"> & {
|
168
168
|
children?: React.ReactNode;
|
169
169
|
} & {
|
170
170
|
bodyStyle?: React.CSSProperties | undefined;
|
@@ -110,7 +110,7 @@ function FileResumable(props) {
|
|
110
110
|
var _g = __read(react_1.useState(false), 2), showTool = _g[0], setShowTool = _g[1];
|
111
111
|
var _h = __read(react_1.useState(''), 2), imageUrl = _h[0], setImageUrl = _h[1];
|
112
112
|
var locale = react_1.useContext(config_provider_1.ConfigContext).locale;
|
113
|
-
var maxFileSize = props.maxFileSize, minFileSize = props.minFileSize, minFileSizeErrorCallback = props.minFileSizeErrorCallback, maxFileSizeErrorCallback = props.maxFileSizeErrorCallback, onError = props.onError, onChange = props.onChange, query = props.query, onStop = props.onStop, onSuccess = props.onSuccess, accept = props.accept, fileList = props.fileList, uploading = props.uploading, children = props.children, className = props.className, showUploadList = props.showUploadList, mode = props.mode, uploadIcon = props.uploadIcon, uploadDesc = props.uploadDesc, disabled = props.disabled, defaultImageUrl = props.defaultImageUrl, others = __rest(props, ["maxFileSize", "minFileSize", "minFileSizeErrorCallback", "maxFileSizeErrorCallback", "onError", "onChange", "query", "onStop", "onSuccess", "accept", "fileList", "uploading", "children", "className", "showUploadList", "mode", "uploadIcon", "uploadDesc", "disabled", "defaultImageUrl"]);
|
113
|
+
var maxFileSize = props.maxFileSize, minFileSize = props.minFileSize, minFileSizeErrorCallback = props.minFileSizeErrorCallback, maxFileSizeErrorCallback = props.maxFileSizeErrorCallback, onError = props.onError, onChange = props.onChange, query = props.query, onStop = props.onStop, onSuccess = props.onSuccess, accept = props.accept, fileList = props.fileList, uploading = props.uploading, children = props.children, className = props.className, showUploadList = props.showUploadList, mode = props.mode, uploadIcon = props.uploadIcon, uploadDesc = props.uploadDesc, disabled = props.disabled, defaultImageUrl = props.defaultImageUrl, _j = props.persistence, persistence = _j === void 0 ? 0 : _j, others = __rest(props, ["maxFileSize", "minFileSize", "minFileSizeErrorCallback", "maxFileSizeErrorCallback", "onError", "onChange", "query", "onStop", "onSuccess", "accept", "fileList", "uploading", "children", "className", "showUploadList", "mode", "uploadIcon", "uploadDesc", "disabled", "defaultImageUrl", "persistence"]);
|
114
114
|
var handleRemove = react_1.useCallback(function () {
|
115
115
|
onChange === null || onChange === void 0 ? void 0 : onChange(null);
|
116
116
|
}, [onChange]);
|
@@ -276,7 +276,7 @@ function FileResumable(props) {
|
|
276
276
|
var params, realFile_1, reader, extension_1;
|
277
277
|
var _this = this;
|
278
278
|
return __generator(this, function (_a) {
|
279
|
-
params = __assign({}, query);
|
279
|
+
params = __assign(__assign({}, query), { persistence: persistence });
|
280
280
|
if (fileList.length === 1) {
|
281
281
|
realFile_1 = fileList[0];
|
282
282
|
reader = new FileReader();
|
@@ -335,7 +335,14 @@ function FileResumable(props) {
|
|
335
335
|
setShowTool(true);
|
336
336
|
return [2 /*return*/];
|
337
337
|
});
|
338
|
-
}); }, [
|
338
|
+
}); }, [
|
339
|
+
query,
|
340
|
+
setShowTool,
|
341
|
+
fileList,
|
342
|
+
handleError,
|
343
|
+
handleFileSuccess,
|
344
|
+
persistence
|
345
|
+
]);
|
339
346
|
var handleUploadStart = react_1.useCallback(function () {
|
340
347
|
setIsPlayDisabled(true);
|
341
348
|
setIsPauseDisabled(false);
|
@@ -0,0 +1,45 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
14
|
+
var t = {};
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
16
|
+
t[p] = s[p];
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
20
|
+
t[p[i]] = s[p[i]];
|
21
|
+
}
|
22
|
+
return t;
|
23
|
+
};
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
26
|
+
};
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
28
|
+
var react_1 = __importDefault(require("react"));
|
29
|
+
var react_resizable_1 = require("react-resizable");
|
30
|
+
var classnames_1 = __importDefault(require("classnames"));
|
31
|
+
var pandora_component_icons_1 = require("@qn-pandora/pandora-component-icons");
|
32
|
+
var style_1 = require("../../../constants/style");
|
33
|
+
var ResizableTitle = function (props) {
|
34
|
+
var onResize = props.onResize, width = props.width, className = props.className, restProps = __rest(props, ["onResize", "width", "className"]);
|
35
|
+
if (!width) {
|
36
|
+
return (react_1.default.createElement("th", __assign({}, restProps, { className: classnames_1.default(className, style_1.SDK_PREFIX + "-table-resizable-th") })));
|
37
|
+
}
|
38
|
+
return (react_1.default.createElement(react_resizable_1.Resizable, { width: width, height: 0, onResize: onResize, minConstraints: [40, 0], draggableOpts: { enableUserSelectHack: false }, handle: react_1.default.createElement("span", { className: style_1.SDK_PREFIX + "-table-resizable-handle", onClick: function (e) {
|
39
|
+
e.preventDefault();
|
40
|
+
e.stopPropagation();
|
41
|
+
} },
|
42
|
+
react_1.default.createElement(pandora_component_icons_1.Resizable, null)) },
|
43
|
+
react_1.default.createElement("th", __assign({}, restProps, { className: classnames_1.default(className, style_1.SDK_PREFIX + "-table-resizable-th") }))));
|
44
|
+
};
|
45
|
+
exports.default = ResizableTitle;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
.pandora-sdk-table-resizable-th .pandora-sdk-table-resizable-handle {
|
2
|
+
position: absolute;
|
3
|
+
cursor: col-resize;
|
4
|
+
right: 6px;
|
5
|
+
margin-left: 6px;
|
6
|
+
height: 40%;
|
7
|
+
top: 50%;
|
8
|
+
-webkit-transform: translateY(-50%);
|
9
|
+
transform: translateY(-50%);
|
10
|
+
padding: 2px;
|
11
|
+
width: 8px;
|
12
|
+
opacity: 0;
|
13
|
+
-webkit-transition: opacity 0.2s ease-in-out;
|
14
|
+
transition: opacity 0.2s ease-in-out;
|
15
|
+
}
|
16
|
+
.pandora-sdk-table-resizable-th:hover .pandora-sdk-table-resizable-handle {
|
17
|
+
opacity: 0.3;
|
18
|
+
}
|
19
|
+
.pandora-sdk-table-resizable-th::before {
|
20
|
+
display: none;
|
21
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
@import '../../../style/theme.less';
|
2
|
+
|
3
|
+
.@{sdk-prefix}-table-resizable-th {
|
4
|
+
.@{sdk-prefix}-table-resizable-handle {
|
5
|
+
position: absolute;
|
6
|
+
cursor: col-resize;
|
7
|
+
right: 6px;
|
8
|
+
margin-left: 6px;
|
9
|
+
height: 40%;
|
10
|
+
top: 50%;
|
11
|
+
transform: translateY(-50%);
|
12
|
+
padding: 2px;
|
13
|
+
width: 8px;
|
14
|
+
opacity: 0;
|
15
|
+
transition: opacity 0.2s ease-in-out;
|
16
|
+
}
|
17
|
+
&:hover {
|
18
|
+
.@{sdk-prefix}-table-resizable-handle {
|
19
|
+
opacity: 0.3;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
&::before {
|
24
|
+
display: none;
|
25
|
+
}
|
26
|
+
}
|
@@ -4,3 +4,17 @@ export declare enum ESearchType {
|
|
4
4
|
/** fetch表示搜索为后端搜索 */
|
5
5
|
Fetch = "fetch"
|
6
6
|
}
|
7
|
+
export declare enum ETableDragSaveKey {
|
8
|
+
/** Apm */
|
9
|
+
ApmMq = "Keta_drag_table_apm_mq",
|
10
|
+
ApmTrace = "Keta_drag_table_apm_trace",
|
11
|
+
ApmTraceCall = "Keta_drag_table_apm_trace_call",
|
12
|
+
ApmServiceOption = "Keta_drag_table_apm_service_option",
|
13
|
+
/** 告警 */
|
14
|
+
AlertRule = "Keta_drag_table_alert_rule",
|
15
|
+
AlertEvent = "Keta_drag_table_alert_event",
|
16
|
+
/** 仪表盘 */
|
17
|
+
Dashboard = "Keta_drag_table_dashboard",
|
18
|
+
/** 采集任务 */
|
19
|
+
CollectionTask = "Keta_drag_collection_task"
|
20
|
+
}
|
@@ -7,3 +7,18 @@ var ESearchType;
|
|
7
7
|
/** fetch表示搜索为后端搜索 */
|
8
8
|
ESearchType["Fetch"] = "fetch";
|
9
9
|
})(ESearchType = exports.ESearchType || (exports.ESearchType = {}));
|
10
|
+
var ETableDragSaveKey;
|
11
|
+
(function (ETableDragSaveKey) {
|
12
|
+
/** Apm */
|
13
|
+
ETableDragSaveKey["ApmMq"] = "Keta_drag_table_apm_mq";
|
14
|
+
ETableDragSaveKey["ApmTrace"] = "Keta_drag_table_apm_trace";
|
15
|
+
ETableDragSaveKey["ApmTraceCall"] = "Keta_drag_table_apm_trace_call";
|
16
|
+
ETableDragSaveKey["ApmServiceOption"] = "Keta_drag_table_apm_service_option";
|
17
|
+
/** 告警 */
|
18
|
+
ETableDragSaveKey["AlertRule"] = "Keta_drag_table_alert_rule";
|
19
|
+
ETableDragSaveKey["AlertEvent"] = "Keta_drag_table_alert_event";
|
20
|
+
/** 仪表盘 */
|
21
|
+
ETableDragSaveKey["Dashboard"] = "Keta_drag_table_dashboard";
|
22
|
+
/** 采集任务 */
|
23
|
+
ETableDragSaveKey["CollectionTask"] = "Keta_drag_collection_task";
|
24
|
+
})(ETableDragSaveKey = exports.ETableDragSaveKey || (exports.ETableDragSaveKey = {}));
|
@@ -24,10 +24,12 @@ export interface IOptionItem {
|
|
24
24
|
export interface IColumnType<T> extends ColumnType<T> {
|
25
25
|
colTitle?: string | React.ReactNode;
|
26
26
|
configurable?: boolean;
|
27
|
+
resizable?: boolean;
|
27
28
|
}
|
28
29
|
export interface IColumnGroupType<T> extends ColumnGroupType<T> {
|
29
30
|
colTitle?: string | React.ReactNode;
|
30
31
|
configurable?: boolean;
|
32
|
+
resizable?: boolean;
|
31
33
|
}
|
32
34
|
export declare type IColumnsType<T> = Array<IColumnGroupType<T> | IColumnType<T>>;
|
33
35
|
export interface ITableProps<T> extends Omit<TableProps<T>, 'columns'> {
|
@@ -45,6 +47,9 @@ export interface ITableProps<T> extends Omit<TableProps<T>, 'columns'> {
|
|
45
47
|
hiddenColumns?: string[];
|
46
48
|
onHiddenColumnsChange?: (keys: string[]) => void;
|
47
49
|
columnSettingOverlayClass?: string;
|
50
|
+
draggable?: boolean;
|
51
|
+
dragSaveKey?: string;
|
52
|
+
onDraggableChange?: (fieldsWidth: IKeyValues<number>) => void;
|
48
53
|
}
|
49
54
|
/**
|
50
55
|
* pandora2.0风格的表格
|
@@ -60,6 +65,7 @@ declare class Table<T = any> extends React.Component<ITableProps<T>, any> {
|
|
60
65
|
indeterminate: boolean;
|
61
66
|
checkAll: boolean;
|
62
67
|
hiddenColumn: string[] | undefined;
|
68
|
+
columns: IKeyValues[];
|
63
69
|
UNSAFE_componentWillReceiveProps(nextProps: ITableProps<T>): void;
|
64
70
|
get selectedRowKeys(): React.ReactText[];
|
65
71
|
get rowSelection(): TableRowSelection<T> | undefined;
|
@@ -73,11 +79,12 @@ declare class Table<T = any> extends React.Component<ITableProps<T>, any> {
|
|
73
79
|
resetKeys: string[];
|
74
80
|
};
|
75
81
|
handleHideColumnsChange(keys: string[]): Promise<void> | undefined;
|
76
|
-
getColumns():
|
82
|
+
getColumns(): IKeyValues<any>[];
|
77
83
|
getRowKey(row: any, index: number): any;
|
78
84
|
setIndeterminate(indeterminate: boolean): void;
|
79
85
|
setCheckAll(checkAll: boolean): void;
|
80
86
|
setHiddenColumn(hiddenColumn?: string[]): void;
|
87
|
+
setColumns(columns: IKeyValues[]): void;
|
81
88
|
setCheckboxStatus(selectedRowsOfCurrentPage?: T[], dataSource?: T[]): void;
|
82
89
|
handleSelectionChange(selectedRowKeys: React.Key[], selectedRowsOfCurrentPage: any[]): void;
|
83
90
|
onRowSelectionChange(selectedRowKeys: React.Key[], selectedRowsOfCurrentPage: any[]): void;
|
@@ -85,6 +92,12 @@ declare class Table<T = any> extends React.Component<ITableProps<T>, any> {
|
|
85
92
|
handleBatchOptionClick(option: IOptionItem): void;
|
86
93
|
getRowClassName(record: any, index: number, indent: number): string;
|
87
94
|
getDisabledStatus(option: IOptionItem): boolean | undefined;
|
95
|
+
handleResize(col: ColumnType<T>, size: {
|
96
|
+
width: number;
|
97
|
+
height: number;
|
98
|
+
}, oldColumn: IColumnsType<T>): void;
|
99
|
+
getResizeColumns(columns?: IColumnsType<T>): any;
|
100
|
+
componentDidMount(): void;
|
88
101
|
render(): JSX.Element;
|
89
102
|
}
|
90
103
|
export default Table;
|
@@ -89,6 +89,7 @@ var style_1 = require("../../constants/style");
|
|
89
89
|
var type_1 = require("../../constants/language/table/type");
|
90
90
|
var ColumnTag_1 = require("./ColumnTag/ColumnTag");
|
91
91
|
var ColumnSetting_1 = __importDefault(require("./ColumnSetting"));
|
92
|
+
var ResizableTitle_1 = __importDefault(require("./ResizableTitle"));
|
92
93
|
/**
|
93
94
|
* pandora2.0风格的表格
|
94
95
|
*/
|
@@ -99,6 +100,7 @@ var Table = /** @class */ (function (_super) {
|
|
99
100
|
_this.indeterminate = false;
|
100
101
|
_this.checkAll = false;
|
101
102
|
_this.hiddenColumn = _this.props.hiddenColumns;
|
103
|
+
_this.columns = [];
|
102
104
|
return _this;
|
103
105
|
}
|
104
106
|
Table.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
|
@@ -132,6 +134,11 @@ var Table = /** @class */ (function (_super) {
|
|
132
134
|
if (lodash_1.isEqual(nextProps.hiddenColumns, this.props.hiddenColumns)) {
|
133
135
|
this.setHiddenColumn(nextProps.hiddenColumns);
|
134
136
|
}
|
137
|
+
if (nextProps.columns !== this.props.columns) {
|
138
|
+
this.setColumns(nextProps.scroll && nextProps.draggable
|
139
|
+
? this.getResizeColumns(nextProps.columns)
|
140
|
+
: nextProps.columns);
|
141
|
+
}
|
135
142
|
};
|
136
143
|
Object.defineProperty(Table.prototype, "selectedRowKeys", {
|
137
144
|
get: function () {
|
@@ -250,14 +257,14 @@ var Table = /** @class */ (function (_super) {
|
|
250
257
|
(_b = (_a = this.props).onHiddenColumnsChange) === null || _b === void 0 ? void 0 : _b.call(_a, keys);
|
251
258
|
};
|
252
259
|
Table.prototype.getColumns = function () {
|
253
|
-
var _a = this.props, showColumnSetting = _a.showColumnSetting,
|
260
|
+
var _a = this.props, showColumnSetting = _a.showColumnSetting, columnSettingOverlayClass = _a.columnSettingOverlayClass;
|
254
261
|
var hiddenColumn = this.hiddenColumn || [];
|
255
262
|
if (!showColumnSetting) {
|
256
|
-
return columns;
|
263
|
+
return this.columns;
|
257
264
|
}
|
258
265
|
// 获取到列设置的options
|
259
266
|
var columnsSettingOptions = this.columnsSettingOptions;
|
260
|
-
var selectedCols = __spread((columns || []).filter(function (item) {
|
267
|
+
var selectedCols = __spread((this.columns || []).filter(function (item) {
|
261
268
|
if (item.configurable === false || !lodash_1.includes(hiddenColumn, item.key)) {
|
262
269
|
return true;
|
263
270
|
}
|
@@ -290,6 +297,9 @@ var Table = /** @class */ (function (_super) {
|
|
290
297
|
Table.prototype.setHiddenColumn = function (hiddenColumn) {
|
291
298
|
this.hiddenColumn = hiddenColumn;
|
292
299
|
};
|
300
|
+
Table.prototype.setColumns = function (columns) {
|
301
|
+
this.columns = columns;
|
302
|
+
};
|
293
303
|
// 设置全选checkout的状态
|
294
304
|
Table.prototype.setCheckboxStatus = function (selectedRowsOfCurrentPage, dataSource) {
|
295
305
|
if (selectedRowsOfCurrentPage === void 0) { selectedRowsOfCurrentPage = []; }
|
@@ -358,17 +368,80 @@ var Table = /** @class */ (function (_super) {
|
|
358
368
|
: option.disabled;
|
359
369
|
return noneSelected || disabled;
|
360
370
|
};
|
371
|
+
Table.prototype.handleResize = function (col, size, oldColumn) {
|
372
|
+
var newColumns = __spread(oldColumn);
|
373
|
+
newColumns.forEach(function (item) {
|
374
|
+
if (lodash_1.get(item, 'dataIndex') === col.dataIndex) {
|
375
|
+
item.width = size.width;
|
376
|
+
}
|
377
|
+
});
|
378
|
+
var sizeMap = {};
|
379
|
+
newColumns.forEach(function (element) {
|
380
|
+
if (element.dataIndex && lodash_1.isNumber(element.width)) {
|
381
|
+
sizeMap[element.dataIndex] = element.width;
|
382
|
+
}
|
383
|
+
});
|
384
|
+
if (this.props.onDraggableChange) {
|
385
|
+
this.props.onDraggableChange(sizeMap);
|
386
|
+
}
|
387
|
+
else if (this.props.dragSaveKey) {
|
388
|
+
localStorage.setItem(this.props.dragSaveKey, JSON.stringify(sizeMap));
|
389
|
+
}
|
390
|
+
this.setColumns(newColumns);
|
391
|
+
};
|
392
|
+
Table.prototype.getResizeColumns = function (columns) {
|
393
|
+
var _this = this;
|
394
|
+
var sizeMap;
|
395
|
+
if (this.props.dragSaveKey) {
|
396
|
+
var sizeStr = localStorage.getItem(this.props.dragSaveKey);
|
397
|
+
sizeMap = !!sizeStr && JSON.parse(sizeStr);
|
398
|
+
if (sizeMap) {
|
399
|
+
columns = columns === null || columns === void 0 ? void 0 : columns.map(function (col) {
|
400
|
+
var dataIndex = lodash_1.get(col, 'dataIndex');
|
401
|
+
var width = sizeMap[dataIndex];
|
402
|
+
return lodash_1.isNumber(width) ? __assign(__assign({}, col), { width: width }) : col;
|
403
|
+
});
|
404
|
+
}
|
405
|
+
}
|
406
|
+
var transformColumns = columns === null || columns === void 0 ? void 0 : columns.map(function (it) {
|
407
|
+
if (lodash_1.get(it, 'resizable') && _this.props.draggable) {
|
408
|
+
return __assign(__assign({}, it), { ellipsis: {
|
409
|
+
showTitle: true
|
410
|
+
}, onHeaderCell: function (col) { return ({
|
411
|
+
width: col.width,
|
412
|
+
// !传入newColumn,而不传入column是因为需要拿到有onHeaderCell的值,外面collumn的变化内部监听不到
|
413
|
+
onResize: function (_, _a) {
|
414
|
+
var size = _a.size;
|
415
|
+
_this.handleResize(col, size, transformColumns);
|
416
|
+
}
|
417
|
+
}); } });
|
418
|
+
}
|
419
|
+
return it;
|
420
|
+
});
|
421
|
+
return transformColumns;
|
422
|
+
};
|
423
|
+
Table.prototype.componentDidMount = function () {
|
424
|
+
this.setColumns(this.props.draggable && this.props.scroll
|
425
|
+
? this.getResizeColumns(this.props.columns)
|
426
|
+
: this.props.columns);
|
427
|
+
};
|
361
428
|
Table.prototype.render = function () {
|
362
429
|
var _a, _b;
|
363
430
|
var _this = this;
|
364
|
-
var _c = this.props, className = _c.className, batchOptions = _c.batchOptions, scroll = _c.scroll, locale = _c.locale, emptyText = _c.emptyText, columns = _c.columns, restProps = __rest(_c, ["className", "batchOptions", "scroll", "locale", "emptyText", "columns"]);
|
431
|
+
var _c = this.props, className = _c.className, batchOptions = _c.batchOptions, scroll = _c.scroll, locale = _c.locale, emptyText = _c.emptyText, columns = _c.columns, components = _c.components, draggable = _c.draggable, restProps = __rest(_c, ["className", "batchOptions", "scroll", "locale", "emptyText", "columns", "components", "draggable"]);
|
365
432
|
return (React.createElement("div", null,
|
366
433
|
React.createElement(antd_1.Table, __assign({ scroll: scroll, locale: __assign({ emptyText: this.emptyTextComp }, locale), columns: this.getColumns() }, restProps, { className: classnames_1.default(style_1.SDK_PREFIX + "-table-wrapper", (_a = {}, _a[style_1.SDK_PREFIX + "-table-scrollX"] = lodash_1.get(scroll, 'x'), _a), (_b = {}, _b[style_1.SDK_PREFIX + "-table-scrollY"] = lodash_1.get(scroll, 'y'), _b), className),
|
367
434
|
// 涉及到权限
|
368
435
|
// getCheckboxProps只能放到tableBatchWrapper里,因为selectedRowKeys在那个组件计算
|
369
436
|
rowSelection: batchOptions && this.props.rowSelection
|
370
437
|
? this.rowSelection
|
371
|
-
: this.props.rowSelection, rowClassName: this.getRowClassName })),
|
438
|
+
: this.props.rowSelection, rowClassName: this.getRowClassName, components: __assign(__assign({}, (components || {})), (draggable && scroll
|
439
|
+
? {
|
440
|
+
header: {
|
441
|
+
cell: ResizableTitle_1.default
|
442
|
+
}
|
443
|
+
}
|
444
|
+
: {})) })),
|
372
445
|
this.props.batchOptions &&
|
373
446
|
this.props.rowSelection &&
|
374
447
|
this.props.dataSource &&
|
@@ -401,6 +474,10 @@ var Table = /** @class */ (function (_super) {
|
|
401
474
|
mobx_1.observable.ref,
|
402
475
|
__metadata("design:type", Object)
|
403
476
|
], Table.prototype, "hiddenColumn", void 0);
|
477
|
+
__decorate([
|
478
|
+
mobx_1.observable.ref,
|
479
|
+
__metadata("design:type", Array)
|
480
|
+
], Table.prototype, "columns", void 0);
|
404
481
|
__decorate([
|
405
482
|
mobx_1.computed,
|
406
483
|
__metadata("design:type", Object),
|
@@ -475,6 +552,13 @@ var Table = /** @class */ (function (_super) {
|
|
475
552
|
__metadata("design:paramtypes", [Array]),
|
476
553
|
__metadata("design:returntype", void 0)
|
477
554
|
], Table.prototype, "setHiddenColumn", null);
|
555
|
+
__decorate([
|
556
|
+
bind_1.default,
|
557
|
+
mobx_1.action,
|
558
|
+
__metadata("design:type", Function),
|
559
|
+
__metadata("design:paramtypes", [Array]),
|
560
|
+
__metadata("design:returntype", void 0)
|
561
|
+
], Table.prototype, "setColumns", null);
|
478
562
|
__decorate([
|
479
563
|
bind_1.default,
|
480
564
|
__metadata("design:type", Function),
|
@@ -517,6 +601,18 @@ var Table = /** @class */ (function (_super) {
|
|
517
601
|
__metadata("design:paramtypes", [Object]),
|
518
602
|
__metadata("design:returntype", void 0)
|
519
603
|
], Table.prototype, "getDisabledStatus", null);
|
604
|
+
__decorate([
|
605
|
+
bind_1.default,
|
606
|
+
__metadata("design:type", Function),
|
607
|
+
__metadata("design:paramtypes", [Object, Object, Array]),
|
608
|
+
__metadata("design:returntype", void 0)
|
609
|
+
], Table.prototype, "handleResize", null);
|
610
|
+
__decorate([
|
611
|
+
bind_1.default,
|
612
|
+
__metadata("design:type", Function),
|
613
|
+
__metadata("design:paramtypes", [Array]),
|
614
|
+
__metadata("design:returntype", void 0)
|
615
|
+
], Table.prototype, "getResizeColumns", null);
|
520
616
|
Table = __decorate([
|
521
617
|
mobx_react_1.observer
|
522
618
|
], Table);
|