@qn-pandora/pandora-component 4.4.1 → 4.4.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +34 -0
- package/CHANGELOG.md +15 -1
- package/es/components/Drawer/index.d.ts +1 -1
- package/es/components/InputNumberWithUnit/index.d.ts +2 -0
- package/es/components/InputNumberWithUnit/index.js +2 -2
- 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 +8597 -8576
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/index.less +21 -20
- package/lib/components/Drawer/index.d.ts +1 -1
- package/lib/components/InputNumberWithUnit/index.d.ts +2 -0
- package/lib/components/InputNumberWithUnit/index.js +2 -2
- 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 +2594 -2573
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/index.less +18 -17
- package/package.json +7 -5
package/CHANGELOG.json
CHANGED
@@ -1,6 +1,40 @@
|
|
1
1
|
{
|
2
2
|
"name": "@qn-pandora/pandora-component",
|
3
3
|
"entries": [
|
4
|
+
{
|
5
|
+
"version": "4.4.3",
|
6
|
+
"tag": "@qn-pandora/pandora-component_v4.4.3",
|
7
|
+
"date": "Fri, 23 Feb 2024 06:02:50 GMT",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"comment": "2024-02-23发包"
|
12
|
+
}
|
13
|
+
],
|
14
|
+
"dependency": [
|
15
|
+
{
|
16
|
+
"comment": "Updating dependency \"@qn-pandora/app-sdk\" from `^3.4.2` to `^3.4.3`"
|
17
|
+
}
|
18
|
+
]
|
19
|
+
}
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"version": "4.4.2",
|
23
|
+
"tag": "@qn-pandora/pandora-component_v4.4.2",
|
24
|
+
"date": "Fri, 19 Jan 2024 03:09:26 GMT",
|
25
|
+
"comments": {
|
26
|
+
"patch": [
|
27
|
+
{
|
28
|
+
"comment": "2024-01-19发包"
|
29
|
+
}
|
30
|
+
],
|
31
|
+
"dependency": [
|
32
|
+
{
|
33
|
+
"comment": "Updating dependency \"@qn-pandora/pandora-component-icons\" from `^3.4.0` to `^3.4.1`"
|
34
|
+
}
|
35
|
+
]
|
36
|
+
}
|
37
|
+
},
|
4
38
|
{
|
5
39
|
"version": "4.4.1",
|
6
40
|
"tag": "@qn-pandora/pandora-component_v4.4.1",
|
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
# Change Log - @qn-pandora/pandora-component
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Fri, 23 Feb 2024 06:02:50 GMT and should not be manually modified.
|
4
|
+
|
5
|
+
## 4.4.3
|
6
|
+
Fri, 23 Feb 2024 06:02:50 GMT
|
7
|
+
|
8
|
+
### Patches
|
9
|
+
|
10
|
+
- 2024-02-23发包
|
11
|
+
|
12
|
+
## 4.4.2
|
13
|
+
Fri, 19 Jan 2024 03:09:26 GMT
|
14
|
+
|
15
|
+
### Patches
|
16
|
+
|
17
|
+
- 2024-01-19发包
|
4
18
|
|
5
19
|
## 4.4.1
|
6
20
|
Mon, 15 Jan 2024 01:53:53 GMT
|
@@ -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;
|
@@ -14,6 +14,8 @@ interface IInputNumberWithUnitProps {
|
|
14
14
|
[value: string]: string;
|
15
15
|
};
|
16
16
|
unitWidth?: number;
|
17
|
+
min?: number;
|
18
|
+
max?: number;
|
17
19
|
}
|
18
20
|
declare function InputNumberWithUnit(props: IInputNumberWithUnitProps): JSX.Element;
|
19
21
|
export default InputNumberWithUnit;
|
@@ -26,7 +26,7 @@ var getUnit = function (value) {
|
|
26
26
|
return (value === null || value === void 0 ? void 0 : value.replace(/\d+/, '')) || '';
|
27
27
|
};
|
28
28
|
function InputNumberWithUnit(props) {
|
29
|
-
var value = props.value, onChange = props.onChange, onNumberChange = props.onNumberChange, onUnitChange = props.onUnitChange, className = props.className, unitClassName = props.unitClassName, placeholder = props.placeholder, unitOptions = props.unitOptions, _a = props.unitWidth, unitWidth = _a === void 0 ? 86 : _a;
|
29
|
+
var value = props.value, onChange = props.onChange, onNumberChange = props.onNumberChange, onUnitChange = props.onUnitChange, className = props.className, unitClassName = props.unitClassName, placeholder = props.placeholder, unitOptions = props.unitOptions, _a = props.unitWidth, unitWidth = _a === void 0 ? 86 : _a, min = props.min, max = props.max;
|
30
30
|
var _b = __read(useState(), 2), num = _b[0], setNum = _b[1];
|
31
31
|
var _c = __read(useState(), 2), unit = _c[0], setUnit = _c[1];
|
32
32
|
var controlled = Object.hasOwnProperty.call(props, 'value');
|
@@ -51,6 +51,6 @@ function InputNumberWithUnit(props) {
|
|
51
51
|
onUnitChange === null || onUnitChange === void 0 ? void 0 : onUnitChange(unit);
|
52
52
|
}, [num, onChange, onUnitChange, controlled, value]);
|
53
53
|
var addonAfterNode = (React.createElement(Selector, { options: unitOptions, className: unitClassName, value: controlled ? getUnit(value) : unit, style: { width: unitWidth }, onChange: onSelectorChange }));
|
54
|
-
return (React.createElement(InputNumber, { className: SDK_PREFIX + "-input-number-unit " + className, value: controlled ? getNum(value) : num, onChange: onInputChange, placeholder: placeholder, addonAfter: addonAfterNode }));
|
54
|
+
return (React.createElement(InputNumber, { className: SDK_PREFIX + "-input-number-unit " + className, value: controlled ? getNum(value) : num, onChange: onInputChange, placeholder: placeholder, addonAfter: addonAfterNode, min: min, max: max }));
|
55
55
|
}
|
56
56
|
export default InputNumberWithUnit;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
13
|
+
var t = {};
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
15
|
+
t[p] = s[p];
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
19
|
+
t[p[i]] = s[p[i]];
|
20
|
+
}
|
21
|
+
return t;
|
22
|
+
};
|
23
|
+
import React from 'react';
|
24
|
+
import { Resizable } from 'react-resizable';
|
25
|
+
import classnames from 'classnames';
|
26
|
+
import { Resizable as ResizableIcon } from '@qn-pandora/pandora-component-icons';
|
27
|
+
import { SDK_PREFIX } from '../../../constants/style';
|
28
|
+
var ResizableTitle = function (props) {
|
29
|
+
var onResize = props.onResize, width = props.width, className = props.className, restProps = __rest(props, ["onResize", "width", "className"]);
|
30
|
+
if (!width) {
|
31
|
+
return (React.createElement("th", __assign({}, restProps, { className: classnames(className, SDK_PREFIX + "-table-resizable-th") })));
|
32
|
+
}
|
33
|
+
return (React.createElement(Resizable, { width: width, height: 0, onResize: onResize, minConstraints: [40, 0], draggableOpts: { enableUserSelectHack: false }, handle: React.createElement("span", { className: SDK_PREFIX + "-table-resizable-handle", onClick: function (e) {
|
34
|
+
e.preventDefault();
|
35
|
+
e.stopPropagation();
|
36
|
+
} },
|
37
|
+
React.createElement(ResizableIcon, null)) },
|
38
|
+
React.createElement("th", __assign({}, restProps, { className: classnames(className, SDK_PREFIX + "-table-resizable-th") }))));
|
39
|
+
};
|
40
|
+
export 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
|
+
}
|
@@ -5,3 +5,18 @@ export var ESearchType;
|
|
5
5
|
/** fetch表示搜索为后端搜索 */
|
6
6
|
ESearchType["Fetch"] = "fetch";
|
7
7
|
})(ESearchType || (ESearchType = {}));
|
8
|
+
export var ETableDragSaveKey;
|
9
|
+
(function (ETableDragSaveKey) {
|
10
|
+
/** Apm */
|
11
|
+
ETableDragSaveKey["ApmMq"] = "Keta_drag_table_apm_mq";
|
12
|
+
ETableDragSaveKey["ApmTrace"] = "Keta_drag_table_apm_trace";
|
13
|
+
ETableDragSaveKey["ApmTraceCall"] = "Keta_drag_table_apm_trace_call";
|
14
|
+
ETableDragSaveKey["ApmServiceOption"] = "Keta_drag_table_apm_service_option";
|
15
|
+
/** 告警 */
|
16
|
+
ETableDragSaveKey["AlertRule"] = "Keta_drag_table_alert_rule";
|
17
|
+
ETableDragSaveKey["AlertEvent"] = "Keta_drag_table_alert_event";
|
18
|
+
/** 仪表盘 */
|
19
|
+
ETableDragSaveKey["Dashboard"] = "Keta_drag_table_dashboard";
|
20
|
+
/** 采集任务 */
|
21
|
+
ETableDragSaveKey["CollectionTask"] = "Keta_drag_collection_task";
|
22
|
+
})(ETableDragSaveKey || (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;
|
@@ -66,7 +66,7 @@ import * as React from 'react';
|
|
66
66
|
import classnames from 'classnames';
|
67
67
|
import { observer } from 'mobx-react';
|
68
68
|
import { observable, action, computed } from 'mobx';
|
69
|
-
import { size, xor, union, unionBy, differenceBy, get, isEqual, includes } from 'lodash';
|
69
|
+
import { size, xor, union, unionBy, differenceBy, get, isEqual, includes, isNumber } from 'lodash';
|
70
70
|
import { Table as AntTable, Checkbox } from 'antd';
|
71
71
|
import { ConfigContext } from 'antd/es/config-provider';
|
72
72
|
import { toaster as toasterStore } from '@qn-pandora/app-sdk';
|
@@ -77,6 +77,7 @@ import { SDK_PREFIX } from '../../constants/style';
|
|
77
77
|
import { TableLocale } from '../../constants/language/table/type';
|
78
78
|
import { ColumnTag } from './ColumnTag/ColumnTag';
|
79
79
|
import ColumnSetting from './ColumnSetting';
|
80
|
+
import ResizableTitle from './ResizableTitle';
|
80
81
|
/**
|
81
82
|
* pandora2.0风格的表格
|
82
83
|
*/
|
@@ -87,6 +88,7 @@ var Table = /** @class */ (function (_super) {
|
|
87
88
|
_this.indeterminate = false;
|
88
89
|
_this.checkAll = false;
|
89
90
|
_this.hiddenColumn = _this.props.hiddenColumns;
|
91
|
+
_this.columns = [];
|
90
92
|
return _this;
|
91
93
|
}
|
92
94
|
Table.prototype.UNSAFE_componentWillReceiveProps = function (nextProps) {
|
@@ -120,6 +122,11 @@ var Table = /** @class */ (function (_super) {
|
|
120
122
|
if (isEqual(nextProps.hiddenColumns, this.props.hiddenColumns)) {
|
121
123
|
this.setHiddenColumn(nextProps.hiddenColumns);
|
122
124
|
}
|
125
|
+
if (nextProps.columns !== this.props.columns) {
|
126
|
+
this.setColumns(nextProps.scroll && nextProps.draggable
|
127
|
+
? this.getResizeColumns(nextProps.columns)
|
128
|
+
: nextProps.columns);
|
129
|
+
}
|
123
130
|
};
|
124
131
|
Object.defineProperty(Table.prototype, "selectedRowKeys", {
|
125
132
|
get: function () {
|
@@ -238,14 +245,14 @@ var Table = /** @class */ (function (_super) {
|
|
238
245
|
(_b = (_a = this.props).onHiddenColumnsChange) === null || _b === void 0 ? void 0 : _b.call(_a, keys);
|
239
246
|
};
|
240
247
|
Table.prototype.getColumns = function () {
|
241
|
-
var _a = this.props, showColumnSetting = _a.showColumnSetting,
|
248
|
+
var _a = this.props, showColumnSetting = _a.showColumnSetting, columnSettingOverlayClass = _a.columnSettingOverlayClass;
|
242
249
|
var hiddenColumn = this.hiddenColumn || [];
|
243
250
|
if (!showColumnSetting) {
|
244
|
-
return columns;
|
251
|
+
return this.columns;
|
245
252
|
}
|
246
253
|
// 获取到列设置的options
|
247
254
|
var columnsSettingOptions = this.columnsSettingOptions;
|
248
|
-
var selectedCols = __spread((columns || []).filter(function (item) {
|
255
|
+
var selectedCols = __spread((this.columns || []).filter(function (item) {
|
249
256
|
if (item.configurable === false || !includes(hiddenColumn, item.key)) {
|
250
257
|
return true;
|
251
258
|
}
|
@@ -278,6 +285,9 @@ var Table = /** @class */ (function (_super) {
|
|
278
285
|
Table.prototype.setHiddenColumn = function (hiddenColumn) {
|
279
286
|
this.hiddenColumn = hiddenColumn;
|
280
287
|
};
|
288
|
+
Table.prototype.setColumns = function (columns) {
|
289
|
+
this.columns = columns;
|
290
|
+
};
|
281
291
|
// 设置全选checkout的状态
|
282
292
|
Table.prototype.setCheckboxStatus = function (selectedRowsOfCurrentPage, dataSource) {
|
283
293
|
if (selectedRowsOfCurrentPage === void 0) { selectedRowsOfCurrentPage = []; }
|
@@ -346,17 +356,80 @@ var Table = /** @class */ (function (_super) {
|
|
346
356
|
: option.disabled;
|
347
357
|
return noneSelected || disabled;
|
348
358
|
};
|
359
|
+
Table.prototype.handleResize = function (col, size, oldColumn) {
|
360
|
+
var newColumns = __spread(oldColumn);
|
361
|
+
newColumns.forEach(function (item) {
|
362
|
+
if (get(item, 'dataIndex') === col.dataIndex) {
|
363
|
+
item.width = size.width;
|
364
|
+
}
|
365
|
+
});
|
366
|
+
var sizeMap = {};
|
367
|
+
newColumns.forEach(function (element) {
|
368
|
+
if (element.dataIndex && isNumber(element.width)) {
|
369
|
+
sizeMap[element.dataIndex] = element.width;
|
370
|
+
}
|
371
|
+
});
|
372
|
+
if (this.props.onDraggableChange) {
|
373
|
+
this.props.onDraggableChange(sizeMap);
|
374
|
+
}
|
375
|
+
else if (this.props.dragSaveKey) {
|
376
|
+
localStorage.setItem(this.props.dragSaveKey, JSON.stringify(sizeMap));
|
377
|
+
}
|
378
|
+
this.setColumns(newColumns);
|
379
|
+
};
|
380
|
+
Table.prototype.getResizeColumns = function (columns) {
|
381
|
+
var _this = this;
|
382
|
+
var sizeMap;
|
383
|
+
if (this.props.dragSaveKey) {
|
384
|
+
var sizeStr = localStorage.getItem(this.props.dragSaveKey);
|
385
|
+
sizeMap = !!sizeStr && JSON.parse(sizeStr);
|
386
|
+
if (sizeMap) {
|
387
|
+
columns = columns === null || columns === void 0 ? void 0 : columns.map(function (col) {
|
388
|
+
var dataIndex = get(col, 'dataIndex');
|
389
|
+
var width = sizeMap[dataIndex];
|
390
|
+
return isNumber(width) ? __assign(__assign({}, col), { width: width }) : col;
|
391
|
+
});
|
392
|
+
}
|
393
|
+
}
|
394
|
+
var transformColumns = columns === null || columns === void 0 ? void 0 : columns.map(function (it) {
|
395
|
+
if (get(it, 'resizable') && _this.props.draggable) {
|
396
|
+
return __assign(__assign({}, it), { ellipsis: {
|
397
|
+
showTitle: true
|
398
|
+
}, onHeaderCell: function (col) { return ({
|
399
|
+
width: col.width,
|
400
|
+
// !传入newColumn,而不传入column是因为需要拿到有onHeaderCell的值,外面collumn的变化内部监听不到
|
401
|
+
onResize: function (_, _a) {
|
402
|
+
var size = _a.size;
|
403
|
+
_this.handleResize(col, size, transformColumns);
|
404
|
+
}
|
405
|
+
}); } });
|
406
|
+
}
|
407
|
+
return it;
|
408
|
+
});
|
409
|
+
return transformColumns;
|
410
|
+
};
|
411
|
+
Table.prototype.componentDidMount = function () {
|
412
|
+
this.setColumns(this.props.draggable && this.props.scroll
|
413
|
+
? this.getResizeColumns(this.props.columns)
|
414
|
+
: this.props.columns);
|
415
|
+
};
|
349
416
|
Table.prototype.render = function () {
|
350
417
|
var _a, _b;
|
351
418
|
var _this = this;
|
352
|
-
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"]);
|
419
|
+
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"]);
|
353
420
|
return (React.createElement("div", null,
|
354
421
|
React.createElement(AntTable, __assign({ scroll: scroll, locale: __assign({ emptyText: this.emptyTextComp }, locale), columns: this.getColumns() }, restProps, { className: classnames(SDK_PREFIX + "-table-wrapper", (_a = {}, _a[SDK_PREFIX + "-table-scrollX"] = get(scroll, 'x'), _a), (_b = {}, _b[SDK_PREFIX + "-table-scrollY"] = get(scroll, 'y'), _b), className),
|
355
422
|
// 涉及到权限
|
356
423
|
// getCheckboxProps只能放到tableBatchWrapper里,因为selectedRowKeys在那个组件计算
|
357
424
|
rowSelection: batchOptions && this.props.rowSelection
|
358
425
|
? this.rowSelection
|
359
|
-
: this.props.rowSelection, rowClassName: this.getRowClassName })),
|
426
|
+
: this.props.rowSelection, rowClassName: this.getRowClassName, components: __assign(__assign({}, (components || {})), (draggable && scroll
|
427
|
+
? {
|
428
|
+
header: {
|
429
|
+
cell: ResizableTitle
|
430
|
+
}
|
431
|
+
}
|
432
|
+
: {})) })),
|
360
433
|
this.props.batchOptions &&
|
361
434
|
this.props.rowSelection &&
|
362
435
|
this.props.dataSource &&
|
@@ -389,6 +462,10 @@ var Table = /** @class */ (function (_super) {
|
|
389
462
|
observable.ref,
|
390
463
|
__metadata("design:type", Object)
|
391
464
|
], Table.prototype, "hiddenColumn", void 0);
|
465
|
+
__decorate([
|
466
|
+
observable.ref,
|
467
|
+
__metadata("design:type", Array)
|
468
|
+
], Table.prototype, "columns", void 0);
|
392
469
|
__decorate([
|
393
470
|
computed,
|
394
471
|
__metadata("design:type", Object),
|
@@ -463,6 +540,13 @@ var Table = /** @class */ (function (_super) {
|
|
463
540
|
__metadata("design:paramtypes", [Array]),
|
464
541
|
__metadata("design:returntype", void 0)
|
465
542
|
], Table.prototype, "setHiddenColumn", null);
|
543
|
+
__decorate([
|
544
|
+
bind,
|
545
|
+
action,
|
546
|
+
__metadata("design:type", Function),
|
547
|
+
__metadata("design:paramtypes", [Array]),
|
548
|
+
__metadata("design:returntype", void 0)
|
549
|
+
], Table.prototype, "setColumns", null);
|
466
550
|
__decorate([
|
467
551
|
bind,
|
468
552
|
__metadata("design:type", Function),
|
@@ -505,6 +589,18 @@ var Table = /** @class */ (function (_super) {
|
|
505
589
|
__metadata("design:paramtypes", [Object]),
|
506
590
|
__metadata("design:returntype", void 0)
|
507
591
|
], Table.prototype, "getDisabledStatus", null);
|
592
|
+
__decorate([
|
593
|
+
bind,
|
594
|
+
__metadata("design:type", Function),
|
595
|
+
__metadata("design:paramtypes", [Object, Object, Array]),
|
596
|
+
__metadata("design:returntype", void 0)
|
597
|
+
], Table.prototype, "handleResize", null);
|
598
|
+
__decorate([
|
599
|
+
bind,
|
600
|
+
__metadata("design:type", Function),
|
601
|
+
__metadata("design:paramtypes", [Array]),
|
602
|
+
__metadata("design:returntype", void 0)
|
603
|
+
], Table.prototype, "getResizeColumns", null);
|
508
604
|
Table = __decorate([
|
509
605
|
observer
|
510
606
|
], Table);
|