@qn-pandora/pandora-component 4.1.7 → 4.2.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/CHANGELOG.json +7 -10
- package/CHANGELOG.md +5 -5
- package/es/components/Drawer/index.d.ts +20 -1
- package/es/components/Drawer/index.js +53 -9
- package/es/components/Drawer/style.css +8 -0
- package/es/components/Drawer/style.less +9 -0
- package/es/components/RadioGroup/style.css +7 -0
- package/es/components/RadioGroup/style.less +9 -0
- package/es/components/Table/ColumnSetting/index.d.ts +16 -0
- package/es/components/Table/ColumnSetting/index.js +91 -0
- package/es/components/Table/ColumnSetting/style.css +47 -0
- package/es/components/Table/ColumnSetting/style.less +46 -0
- package/es/components/Table/index.d.ts +27 -2
- package/es/components/Table/index.js +127 -3
- package/es/components/Table/style.css +4 -0
- package/es/components/Table/style.less +7 -0
- package/es/constants/language/table/en.js +4 -1
- package/es/constants/language/table/type.d.ts +3 -0
- package/es/constants/language/table/zh.js +4 -1
- package/es/index.css +2891 -2825
- package/es/index.less +8 -7
- package/es/style/theme.less +5 -0
- package/lib/components/Drawer/index.d.ts +20 -1
- package/lib/components/Drawer/index.js +53 -9
- package/lib/components/Drawer/style.css +8 -0
- package/lib/components/Drawer/style.less +9 -0
- package/lib/components/RadioGroup/style.css +7 -0
- package/lib/components/RadioGroup/style.less +9 -0
- package/lib/components/Table/ColumnSetting/index.d.ts +16 -0
- package/lib/components/Table/ColumnSetting/index.js +104 -0
- package/lib/components/Table/ColumnSetting/style.css +47 -0
- package/lib/components/Table/ColumnSetting/style.less +46 -0
- package/lib/components/Table/index.d.ts +27 -2
- package/lib/components/Table/index.js +126 -2
- package/lib/components/Table/style.css +4 -0
- package/lib/components/Table/style.less +7 -0
- package/lib/constants/language/table/en.js +4 -1
- package/lib/constants/language/table/type.d.ts +3 -0
- package/lib/constants/language/table/zh.js +4 -1
- package/lib/index.css +2293 -2227
- package/lib/index.less +3 -2
- package/lib/style/theme.less +5 -0
- package/package.json +6 -5
package/CHANGELOG.json
CHANGED
@@ -2,24 +2,21 @@
|
|
2
2
|
"name": "@qn-pandora/pandora-component",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"version": "4.
|
6
|
-
"tag": "@qn-pandora/pandora-component_v4.
|
7
|
-
"date": "
|
5
|
+
"version": "4.2.0",
|
6
|
+
"tag": "@qn-pandora/pandora-component_v4.2.0",
|
7
|
+
"date": "Mon, 25 Sep 2023 06:36:41 GMT",
|
8
8
|
"comments": {
|
9
|
-
"
|
9
|
+
"minor": [
|
10
10
|
{
|
11
|
-
"comment": "2023-
|
11
|
+
"comment": "2023-09-25发包"
|
12
12
|
}
|
13
13
|
],
|
14
14
|
"dependency": [
|
15
15
|
{
|
16
|
-
"comment": "Updating dependency \"@qn-pandora/pandora-component-icons\" from `^3.1.6` to `^3.
|
17
|
-
},
|
18
|
-
{
|
19
|
-
"comment": "Updating dependency \"@qn-pandora/app-sdk\" from `^3.1.6` to `^3.1.7`"
|
16
|
+
"comment": "Updating dependency \"@qn-pandora/pandora-component-icons\" from `^3.1.6` to `^3.2.0`"
|
20
17
|
},
|
21
18
|
{
|
22
|
-
"comment": "Updating dependency \"@qn-pandora/
|
19
|
+
"comment": "Updating dependency \"@qn-pandora/app-sdk\" from `^3.1.6` to `^3.2.0`"
|
23
20
|
}
|
24
21
|
]
|
25
22
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Change Log - @qn-pandora/pandora-component
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Mon, 25 Sep 2023 06:36:41 GMT and should not be manually modified.
|
4
4
|
|
5
|
-
## 4.
|
6
|
-
|
5
|
+
## 4.2.0
|
6
|
+
Mon, 25 Sep 2023 06:36:41 GMT
|
7
7
|
|
8
|
-
###
|
8
|
+
### Minor changes
|
9
9
|
|
10
|
-
- 2023-
|
10
|
+
- 2023-09-25发包
|
11
11
|
|
12
12
|
## 4.1.6
|
13
13
|
Fri, 25 Aug 2023 10:29:46 GMT
|
@@ -57,22 +57,33 @@ export declare type IDrawerProps = Overwrite<DrawerProps, {
|
|
57
57
|
* 是否允许拖拽
|
58
58
|
*/
|
59
59
|
canDrag?: boolean;
|
60
|
+
/**
|
61
|
+
* 关闭按钮显示的位置,默认left
|
62
|
+
*/
|
60
63
|
closeIconPlacement?: 'left' | 'right';
|
61
64
|
/**
|
62
65
|
* 无遮罩时点击空白处中的哪些元素不关闭
|
63
66
|
*/
|
64
67
|
nonCloseSelector?: string;
|
65
68
|
size?: 'small' | 'default' | 'large';
|
69
|
+
/**
|
70
|
+
* 是否显示全屏按钮
|
71
|
+
*/
|
72
|
+
showFullScreen?: boolean;
|
73
|
+
onScreenFullChange?: (showFullScreen: boolean) => void;
|
66
74
|
}>;
|
67
75
|
export declare class Drawer extends React.Component<React.PropsWithChildren<IDrawerProps>, any> {
|
68
76
|
drawerId: string;
|
69
77
|
isResizing: boolean;
|
70
78
|
realWidth: React.ReactText;
|
79
|
+
isFullscreen: boolean;
|
71
80
|
throttleMouseMove: import("lodash").DebouncedFunc<(e: any) => void>;
|
72
81
|
get closable(): boolean | undefined;
|
73
|
-
get extra():
|
82
|
+
get extra(): JSX.Element;
|
74
83
|
setIsResizing(isResizing?: boolean): void;
|
75
84
|
setRealWidth(realWidth: string | number): void;
|
85
|
+
setIsFullscreen(isFullscreen: boolean): void;
|
86
|
+
handleFull(): void;
|
76
87
|
onMouseDown(): void;
|
77
88
|
onMouseUp(): void;
|
78
89
|
onMouseMove(e: any): void;
|
@@ -136,12 +147,20 @@ declare const _default: (props: {
|
|
136
147
|
* 是否允许拖拽
|
137
148
|
*/
|
138
149
|
canDrag?: boolean | undefined;
|
150
|
+
/**
|
151
|
+
* 关闭按钮显示的位置,默认left
|
152
|
+
*/
|
139
153
|
closeIconPlacement?: import("antd/es/collapse/Collapse").ExpandIconPosition;
|
140
154
|
/**
|
141
155
|
* 无遮罩时点击空白处中的哪些元素不关闭
|
142
156
|
*/
|
143
157
|
nonCloseSelector?: string | undefined;
|
144
158
|
size?: "small" | "default" | "large" | undefined;
|
159
|
+
/**
|
160
|
+
* 是否显示全屏按钮
|
161
|
+
*/
|
162
|
+
showFullScreen?: boolean | undefined;
|
163
|
+
onScreenFullChange?: ((showFullScreen: boolean) => void) | undefined;
|
145
164
|
} & Pick<DrawerProps, "style" | "autoFocus" | "prefixCls" | "footer" | "extra" | "bodyStyle" | "forceRender" | "keyboard" | "destroyOnClose" | "closeIcon" | "drawerStyle" | "headerStyle" | "contentWrapperStyle" | "push" | "handler" | "footerStyle" | "level" | "levelMove"> & {
|
146
165
|
children?: React.ReactNode;
|
147
166
|
} & {
|
@@ -48,14 +48,16 @@ import { throttle } from 'lodash';
|
|
48
48
|
import { observer } from 'mobx-react';
|
49
49
|
import { observable, action, computed } from 'mobx';
|
50
50
|
import { Drawer as BaseDrawer } from 'antd';
|
51
|
+
import screenfull from 'screenfull';
|
52
|
+
import { FullscreenExitOutlined, FullscreenOutlined } from '@qn-pandora/pandora-component-icons';
|
51
53
|
import { doesDOMMatchSelector } from '../../utils/dom';
|
52
54
|
import { SDK_PREFIX, ANT_PREFIX } from '../../constants/style';
|
53
55
|
import modalPopupContainerWrapper from '../../hoc/modalPopupContainer';
|
54
56
|
import bind from '../../utils/bind';
|
55
57
|
import CloseIcon from './CloseIcon';
|
56
|
-
var DEFAULT_WIDTH =
|
57
|
-
var SMALL_WIDTH =
|
58
|
-
var LARGE_WIDTH =
|
58
|
+
var DEFAULT_WIDTH = '50%';
|
59
|
+
var SMALL_WIDTH = '38%';
|
60
|
+
var LARGE_WIDTH = '75%';
|
59
61
|
var MAX_WIDTH = 6000;
|
60
62
|
var MIN_WIDTH = 300;
|
61
63
|
var Drawer = /** @class */ (function (_super) {
|
@@ -65,6 +67,7 @@ var Drawer = /** @class */ (function (_super) {
|
|
65
67
|
_this.drawerId = "drawer-id-" + Math.floor(Math.random() * 10000);
|
66
68
|
_this.isResizing = false;
|
67
69
|
_this.realWidth = _this.initWidth(_this.props.width, _this.props.size);
|
70
|
+
_this.isFullscreen = false;
|
68
71
|
_this.throttleMouseMove = throttle(function (e) { return _this.onMouseMove(e); }, 100);
|
69
72
|
return _this;
|
70
73
|
}
|
@@ -82,13 +85,17 @@ var Drawer = /** @class */ (function (_super) {
|
|
82
85
|
});
|
83
86
|
Object.defineProperty(Drawer.prototype, "extra", {
|
84
87
|
get: function () {
|
85
|
-
var _a = this.props, closable = _a.closable, closeIconPlacement = _a.closeIconPlacement, onClose = _a.onClose;
|
88
|
+
var _a = this.props, closable = _a.closable, closeIconPlacement = _a.closeIconPlacement, onClose = _a.onClose, showFullScreen = _a.showFullScreen;
|
89
|
+
var fullIcon = showFullScreen === true ? (this.isFullscreen ? (React.createElement(FullscreenExitOutlined, { onClick: this.handleFull, className: SDK_PREFIX + "-drawer-header-full-icon" })) : (React.createElement(FullscreenOutlined, { onClick: this.handleFull, className: SDK_PREFIX + "-drawer-header-full-icon" }))) : null;
|
86
90
|
if (closable !== false && closeIconPlacement === 'right') {
|
87
91
|
return (React.createElement(React.Fragment, null,
|
88
92
|
this.props.extra,
|
93
|
+
fullIcon,
|
89
94
|
React.createElement(CloseIcon, { className: SDK_PREFIX + "-drawer-close-icon", onClick: onClose })));
|
90
95
|
}
|
91
|
-
return
|
96
|
+
return (React.createElement(React.Fragment, null,
|
97
|
+
fullIcon,
|
98
|
+
this.props.extra));
|
92
99
|
},
|
93
100
|
enumerable: true,
|
94
101
|
configurable: true
|
@@ -100,6 +107,17 @@ var Drawer = /** @class */ (function (_super) {
|
|
100
107
|
Drawer.prototype.setRealWidth = function (realWidth) {
|
101
108
|
this.realWidth = realWidth;
|
102
109
|
};
|
110
|
+
Drawer.prototype.setIsFullscreen = function (isFullscreen) {
|
111
|
+
this.isFullscreen = isFullscreen;
|
112
|
+
};
|
113
|
+
Drawer.prototype.handleFull = function () {
|
114
|
+
var draw = document.querySelector("." + this.drawerId);
|
115
|
+
if (!screenfull || !draw) {
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
this.setIsFullscreen(!this.isFullscreen);
|
119
|
+
screenfull.toggle(draw);
|
120
|
+
};
|
103
121
|
Drawer.prototype.onMouseDown = function () {
|
104
122
|
this.setIsResizing(true);
|
105
123
|
};
|
@@ -119,6 +137,8 @@ var Drawer = /** @class */ (function (_super) {
|
|
119
137
|
};
|
120
138
|
Drawer.prototype.onMouseClick = function (e) {
|
121
139
|
var _a = this.props, mask = _a.mask, maskClosable = _a.maskClosable, nonCloseSelector = _a.nonCloseSelector, onClose = _a.onClose, visible = _a.visible;
|
140
|
+
if (this.isResizing)
|
141
|
+
return;
|
122
142
|
if (mask === false && maskClosable && visible) {
|
123
143
|
var currentEl = e.target;
|
124
144
|
var shouldClose = true;
|
@@ -152,11 +172,21 @@ var Drawer = /** @class */ (function (_super) {
|
|
152
172
|
return DEFAULT_WIDTH;
|
153
173
|
};
|
154
174
|
Drawer.prototype.componentDidMount = function () {
|
175
|
+
document.body.addEventListener('mousedown', this.onMouseClick);
|
176
|
+
var onScreenFullChange = this.props.onScreenFullChange;
|
177
|
+
if (this.props.showFullScreen) {
|
178
|
+
if (screenfull && onScreenFullChange) {
|
179
|
+
screenfull.on('change', function () {
|
180
|
+
if (screenfull) {
|
181
|
+
onScreenFullChange(screenfull.isFullscreen);
|
182
|
+
}
|
183
|
+
});
|
184
|
+
}
|
185
|
+
}
|
155
186
|
if (this.props.canDrag) {
|
156
187
|
document.addEventListener('mousemove', this.throttleMouseMove);
|
157
188
|
document.addEventListener('mouseup', this.onMouseUp);
|
158
189
|
}
|
159
|
-
document.body.addEventListener('click', this.onMouseClick);
|
160
190
|
};
|
161
191
|
Drawer.prototype.UNSAFE_componentWillUpdate = function (nextProps) {
|
162
192
|
if (nextProps.canDrag && !this.props.canDrag) {
|
@@ -174,9 +204,6 @@ var Drawer = /** @class */ (function (_super) {
|
|
174
204
|
var _b = this.props, width = _b.width, className = _b.className, children = _b.children, canDrag = _b.canDrag, visible = _b.visible, closable = _b.closable, extra = _b.extra, size = _b.size, onClose = _b.onClose, other = __rest(_b, ["width", "className", "children", "canDrag", "visible", "closable", "extra", "size", "onClose"]);
|
175
205
|
return (React.createElement(BaseDrawer, __assign({ className: classnames(this.drawerId, SDK_PREFIX + "-drawer", className, (_a = {},
|
176
206
|
_a[SDK_PREFIX + "-drawer-no-mask"] = this.props.mask === false,
|
177
|
-
_a[SDK_PREFIX + "-drawer-size-small"] = size === 'small',
|
178
|
-
_a[SDK_PREFIX + "-drawer-size-default"] = size === 'default',
|
179
|
-
_a[SDK_PREFIX + "-drawer-size-large"] = size === 'large',
|
180
207
|
_a)), width: this.realWidth || 800, zIndex: 1200, visible: visible, closable: this.closable, extra: this.extra, closeIcon: React.createElement(CloseIcon, { className: SDK_PREFIX + "-drawer-close-icon", onClick: onClose }), onClose: onClose }, other),
|
181
208
|
canDrag && (React.createElement("div", { className: SDK_PREFIX + "-scroll-handler", onMouseDown: this.onMouseDown })),
|
182
209
|
children));
|
@@ -189,6 +216,10 @@ var Drawer = /** @class */ (function (_super) {
|
|
189
216
|
observable,
|
190
217
|
__metadata("design:type", Object)
|
191
218
|
], Drawer.prototype, "realWidth", void 0);
|
219
|
+
__decorate([
|
220
|
+
observable,
|
221
|
+
__metadata("design:type", Boolean)
|
222
|
+
], Drawer.prototype, "isFullscreen", void 0);
|
192
223
|
__decorate([
|
193
224
|
computed,
|
194
225
|
__metadata("design:type", Object),
|
@@ -213,6 +244,19 @@ var Drawer = /** @class */ (function (_super) {
|
|
213
244
|
__metadata("design:paramtypes", [Object]),
|
214
245
|
__metadata("design:returntype", void 0)
|
215
246
|
], Drawer.prototype, "setRealWidth", null);
|
247
|
+
__decorate([
|
248
|
+
bind,
|
249
|
+
action,
|
250
|
+
__metadata("design:type", Function),
|
251
|
+
__metadata("design:paramtypes", [Boolean]),
|
252
|
+
__metadata("design:returntype", void 0)
|
253
|
+
], Drawer.prototype, "setIsFullscreen", null);
|
254
|
+
__decorate([
|
255
|
+
bind,
|
256
|
+
__metadata("design:type", Function),
|
257
|
+
__metadata("design:paramtypes", []),
|
258
|
+
__metadata("design:returntype", void 0)
|
259
|
+
], Drawer.prototype, "handleFull", null);
|
216
260
|
__decorate([
|
217
261
|
bind,
|
218
262
|
__metadata("design:type", Function),
|
@@ -263,6 +263,9 @@
|
|
263
263
|
height: 60px;
|
264
264
|
line-height: 60px;
|
265
265
|
}
|
266
|
+
.pandora-sdk-drawer .ant-drawer-header-title {
|
267
|
+
overflow: hidden;
|
268
|
+
}
|
266
269
|
.pandora-sdk-drawer-size-small {
|
267
270
|
max-width: 38%;
|
268
271
|
}
|
@@ -288,3 +291,8 @@
|
|
288
291
|
.pandora-sdk-drawer-close-icon {
|
289
292
|
margin-left: 24px;
|
290
293
|
}
|
294
|
+
.pandora-sdk-drawer-header-full-icon {
|
295
|
+
margin-left: 24px;
|
296
|
+
color: #333;
|
297
|
+
font-size: 14px;
|
298
|
+
}
|
@@ -14,6 +14,9 @@
|
|
14
14
|
height: 60px;
|
15
15
|
line-height: 60px;
|
16
16
|
}
|
17
|
+
.@{ant-prefix}-drawer-header-title {
|
18
|
+
overflow: hidden;
|
19
|
+
}
|
17
20
|
}
|
18
21
|
|
19
22
|
.@{sdk-prefix}-drawer-size-small {
|
@@ -46,3 +49,9 @@
|
|
46
49
|
.@{sdk-prefix}-drawer-close-icon {
|
47
50
|
margin-left: 24px;
|
48
51
|
}
|
52
|
+
|
53
|
+
.@{sdk-prefix}-drawer-header-full-icon {
|
54
|
+
margin-left: 24px;
|
55
|
+
color: @font-color-7;
|
56
|
+
font-size: 14px;
|
57
|
+
}
|
@@ -377,12 +377,19 @@ span.ant-radio + * {
|
|
377
377
|
.ant-radio-button-wrapper.ant-radio-button-wrapper-rtl.ant-radio-button-wrapper-disabled:first-child {
|
378
378
|
border-right-color: #e5e5e5;
|
379
379
|
}
|
380
|
+
.pandora-sdk-solid-radio-group .ant-radio-button-wrapper:not(.pandora-sdk-solid-radio-group .ant-radio-button-wrapper-checked)::before {
|
381
|
+
background-color: #bfbfbf;
|
382
|
+
}
|
380
383
|
.pandora-sdk-solid-radio-group .ant-radio-button-wrapper {
|
381
384
|
padding: 0 12px;
|
382
385
|
}
|
383
386
|
.pandora-sdk-solid-radio-group .ant-radio-button-wrapper:not(.pandora-sdk-solid-radio-group .ant-radio-button-wrapper-checked) {
|
384
387
|
border-color: #bfbfbf;
|
385
388
|
}
|
389
|
+
.pandora-sdk-solid-radio-group .ant-radio-button-wrapper:focus-within {
|
390
|
+
-webkit-box-shadow: unset;
|
391
|
+
box-shadow: unset;
|
392
|
+
}
|
386
393
|
.pandora-sdk-solid-radio-group .ant-radio:not(.pandora-sdk-solid-radio-group .ant-radio-checked) .ant-radio-inner {
|
387
394
|
border-color: #bfbfbf;
|
388
395
|
}
|
@@ -2,11 +2,20 @@
|
|
2
2
|
@import '../../style/theme.less';
|
3
3
|
|
4
4
|
.@{sdk-prefix}-solid-radio-group {
|
5
|
+
.@{ant-prefix}-radio-button-wrapper:not(.@{sdk-prefix}-solid-radio-group
|
6
|
+
.@{ant-prefix}-radio-button-wrapper-checked) {
|
7
|
+
&::before {
|
8
|
+
background-color: @border-color-2;
|
9
|
+
}
|
10
|
+
}
|
5
11
|
.@{ant-prefix}-radio-button-wrapper {
|
6
12
|
padding: 0 12px;
|
7
13
|
&:not(&-checked) {
|
8
14
|
border-color: @input-border-color;
|
9
15
|
}
|
16
|
+
&:focus-within {
|
17
|
+
box-shadow: unset;
|
18
|
+
}
|
10
19
|
}
|
11
20
|
|
12
21
|
.@{ant-prefix}-radio {
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
export declare const All = "_all";
|
3
|
+
export interface IOption {
|
4
|
+
label: string | React.ReactNode;
|
5
|
+
value: string;
|
6
|
+
}
|
7
|
+
export interface ISettingBtnProps {
|
8
|
+
overlayClass?: string;
|
9
|
+
onHiddenKeysChange?: (value: string[]) => void;
|
10
|
+
hiddenKeys?: string[];
|
11
|
+
options?: IOption[];
|
12
|
+
loading?: boolean;
|
13
|
+
}
|
14
|
+
export declare function ColumnSetting(props: ISettingBtnProps): JSX.Element;
|
15
|
+
declare const _default: React.MemoExoticComponent<typeof ColumnSetting>;
|
16
|
+
export default _default;
|
@@ -0,0 +1,91 @@
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
3
|
+
if (!m) return o;
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
5
|
+
try {
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
7
|
+
}
|
8
|
+
catch (error) { e = { error: error }; }
|
9
|
+
finally {
|
10
|
+
try {
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
12
|
+
}
|
13
|
+
finally { if (e) throw e.error; }
|
14
|
+
}
|
15
|
+
return ar;
|
16
|
+
};
|
17
|
+
var __spread = (this && this.__spread) || function () {
|
18
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
19
|
+
return ar;
|
20
|
+
};
|
21
|
+
import React, { useMemo, useCallback, useState, useContext } from 'react';
|
22
|
+
import classnames from 'classnames';
|
23
|
+
import { includes } from 'lodash';
|
24
|
+
import { Popover, Checkbox, Spin } from 'antd';
|
25
|
+
import { SettingOutlined } from '@ant-design/icons';
|
26
|
+
import { ConfigContext } from 'antd/es/config-provider';
|
27
|
+
import { formatString } from '../../../utils/language';
|
28
|
+
import { TableLocale } from '../../../constants/language/table/type';
|
29
|
+
import { SDK_PREFIX } from '../../../constants/style';
|
30
|
+
import NameLimiter from '../../NameLimiter';
|
31
|
+
import Input from '../../Input';
|
32
|
+
export var All = '_all';
|
33
|
+
export function ColumnSetting(props) {
|
34
|
+
var overlayClass = props.overlayClass, _a = props.hiddenKeys, hiddenKeys = _a === void 0 ? [] : _a, onHiddenKeysChange = props.onHiddenKeysChange, _b = props.options, options = _b === void 0 ? [] : _b, loading = props.loading;
|
35
|
+
var locale = useContext(ConfigContext).locale;
|
36
|
+
var _c = __read(useState(''), 2), prefix = _c[0], setPrefix = _c[1];
|
37
|
+
var allKeys = useMemo(function () {
|
38
|
+
return options.map(function (item) { return item.value; });
|
39
|
+
}, [options]);
|
40
|
+
var realOptions = useMemo(function () {
|
41
|
+
if (!prefix || prefix.length === 0)
|
42
|
+
return options;
|
43
|
+
return options.filter(function (item) {
|
44
|
+
if (typeof item.label === 'string' &&
|
45
|
+
item.label.toLowerCase().indexOf(prefix.toLowerCase()) !== -1) {
|
46
|
+
return true;
|
47
|
+
}
|
48
|
+
return false;
|
49
|
+
});
|
50
|
+
}, [prefix, options]);
|
51
|
+
var realValues = useMemo(function () {
|
52
|
+
return allKeys.filter(function (item) { return !includes(hiddenKeys, item); });
|
53
|
+
}, [hiddenKeys, allKeys]);
|
54
|
+
var allCheckChange = useCallback(function (e) {
|
55
|
+
if (e.target.checked) {
|
56
|
+
onHiddenKeysChange === null || onHiddenKeysChange === void 0 ? void 0 : onHiddenKeysChange([]);
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
onHiddenKeysChange === null || onHiddenKeysChange === void 0 ? void 0 : onHiddenKeysChange(allKeys);
|
60
|
+
}, [onHiddenKeysChange, allKeys]);
|
61
|
+
var handlePrefixChange = useCallback(function (value) {
|
62
|
+
setPrefix(value || '');
|
63
|
+
}, [setPrefix]);
|
64
|
+
var handleChange = useCallback(function (e) {
|
65
|
+
var v = e.target.value;
|
66
|
+
var checked = e.target.checked;
|
67
|
+
// 添加
|
68
|
+
if (checked) {
|
69
|
+
var checkedValues_1 = Array.from(new Set(__spread(realValues, [v])));
|
70
|
+
onHiddenKeysChange === null || onHiddenKeysChange === void 0 ? void 0 : onHiddenKeysChange(allKeys.filter(function (item) { return !includes(checkedValues_1, item); }));
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
// 删除
|
74
|
+
var restValues = realValues.filter(function (item) { return item !== v; });
|
75
|
+
onHiddenKeysChange === null || onHiddenKeysChange === void 0 ? void 0 : onHiddenKeysChange(allKeys.filter(function (item) { return !includes(restValues, item); }));
|
76
|
+
}, [onHiddenKeysChange, realValues, allKeys]);
|
77
|
+
return (React.createElement(Popover, { trigger: "click", placement: "bottomRight", content: React.createElement(Spin, { spinning: !!loading },
|
78
|
+
React.createElement("div", { className: classnames(SDK_PREFIX + "-table-column-setting-popover", overlayClass) },
|
79
|
+
React.createElement("div", { className: SDK_PREFIX + "-table-column-setting-header" },
|
80
|
+
React.createElement(Checkbox, { value: All, checked: hiddenKeys.length === 0, onChange: allCheckChange, className: SDK_PREFIX + "-table-column-setting-all-check" }, formatString(TableLocale.check_all, locale)),
|
81
|
+
React.createElement(Input, { value: prefix, allowClear: true, onChange: handlePrefixChange, placeholder: formatString(TableLocale.search, locale), className: SDK_PREFIX + "-table-column-setting-search-input" })),
|
82
|
+
React.createElement("div", null,
|
83
|
+
React.createElement("div", { className: SDK_PREFIX + "-table-column-setting-content" }, realOptions.map(function (item) {
|
84
|
+
return (React.createElement("div", { key: item.value },
|
85
|
+
React.createElement("div", { className: SDK_PREFIX + "-table-column-setting-checkbox-container" },
|
86
|
+
React.createElement(Checkbox, { checked: !!realValues.find(function (v) { return v === item.value; }), value: item.value, className: SDK_PREFIX + "-table-column-setting-checkbox", onChange: handleChange },
|
87
|
+
React.createElement("span", { className: SDK_PREFIX + "-table-column-setting-value" }, typeof item.label === 'string' ? (React.createElement(NameLimiter, { name: item.label })) : (item.label))))));
|
88
|
+
}))))) },
|
89
|
+
React.createElement(SettingOutlined, { className: SDK_PREFIX + "-table-column-setting-icon" })));
|
90
|
+
}
|
91
|
+
export default React.memo(ColumnSetting);
|
@@ -0,0 +1,47 @@
|
|
1
|
+
.pandora-sdk-table-column-setting-popover {
|
2
|
+
padding: 10px;
|
3
|
+
width: 100%;
|
4
|
+
width: 600px;
|
5
|
+
max-height: 300px;
|
6
|
+
overflow-y: auto;
|
7
|
+
}
|
8
|
+
.pandora-sdk-table-column-setting-popover .pandora-sdk-table-column-setting-header {
|
9
|
+
border-bottom: 1px solid #e5e5e5;
|
10
|
+
display: -webkit-box;
|
11
|
+
display: -ms-flexbox;
|
12
|
+
display: flex;
|
13
|
+
padding-bottom: 10px;
|
14
|
+
}
|
15
|
+
.pandora-sdk-table-column-setting-popover .pandora-sdk-table-column-setting-header .pandora-sdk-table-column-setting-all-check {
|
16
|
+
line-height: 32px;
|
17
|
+
}
|
18
|
+
.pandora-sdk-table-column-setting-popover .pandora-sdk-table-column-setting-header .pandora-sdk-table-column-setting-search-input {
|
19
|
+
width: 200px;
|
20
|
+
}
|
21
|
+
.pandora-sdk-table-column-setting-icon {
|
22
|
+
color: #333;
|
23
|
+
}
|
24
|
+
.pandora-sdk-table-column-setting-content {
|
25
|
+
display: -webkit-box;
|
26
|
+
display: -ms-flexbox;
|
27
|
+
display: flex;
|
28
|
+
-ms-flex-wrap: wrap;
|
29
|
+
flex-wrap: wrap;
|
30
|
+
}
|
31
|
+
.pandora-sdk-table-column-setting-content > div {
|
32
|
+
-webkit-box-flex: 0;
|
33
|
+
-ms-flex: 0 0 33.33%;
|
34
|
+
flex: 0 0 33.33%;
|
35
|
+
-webkit-box-sizing: border-box;
|
36
|
+
box-sizing: border-box;
|
37
|
+
position: relative;
|
38
|
+
overflow: hidden;
|
39
|
+
text-overflow: ellipsis;
|
40
|
+
}
|
41
|
+
.pandora-sdk-table-column-setting-content > div .pandora-sdk-table-column-setting-checkbox-container .pandora-sdk-table-column-setting-checkbox {
|
42
|
+
width: 100%;
|
43
|
+
overflow: hidden;
|
44
|
+
}
|
45
|
+
.pandora-sdk-table-column-setting-content > div .pandora-sdk-table-column-setting-checkbox-container .pandora-sdk-table-column-setting-checkbox > span:nth-child(2) {
|
46
|
+
overflow: hidden;
|
47
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
@import '../../../style/theme.less';
|
2
|
+
|
3
|
+
.@{sdk-prefix}-table-column-setting-popover {
|
4
|
+
padding: 10px;
|
5
|
+
width: 100%;
|
6
|
+
width: 600px;
|
7
|
+
.@{sdk-prefix}-table-column-setting-header {
|
8
|
+
border-bottom: 1px solid @border-color-base;
|
9
|
+
display: flex;
|
10
|
+
padding-bottom: 10px;
|
11
|
+
.@{sdk-prefix}-table-column-setting-all-check {
|
12
|
+
line-height: 32px;
|
13
|
+
}
|
14
|
+
.@{sdk-prefix}-table-column-setting-search-input {
|
15
|
+
width: 200px;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
max-height: 300px;
|
19
|
+
overflow-y: auto;
|
20
|
+
}
|
21
|
+
|
22
|
+
.@{sdk-prefix}-table-column-setting-icon {
|
23
|
+
color: @font-color-7;
|
24
|
+
}
|
25
|
+
|
26
|
+
.@{sdk-prefix}-table-column-setting-content {
|
27
|
+
display: flex;
|
28
|
+
flex-wrap: wrap;
|
29
|
+
}
|
30
|
+
|
31
|
+
.@{sdk-prefix}-table-column-setting-content > div {
|
32
|
+
flex: 0 0 33.33%;
|
33
|
+
box-sizing: border-box;
|
34
|
+
position: relative;
|
35
|
+
overflow: hidden;
|
36
|
+
text-overflow: ellipsis;
|
37
|
+
.@{sdk-prefix}-table-column-setting-checkbox-container {
|
38
|
+
.@{sdk-prefix}-table-column-setting-checkbox {
|
39
|
+
width: 100%;
|
40
|
+
overflow: hidden;
|
41
|
+
}
|
42
|
+
.@{sdk-prefix}-table-column-setting-checkbox > span:nth-child(2) {
|
43
|
+
overflow: hidden;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { TableProps } from 'antd/es/table';
|
2
|
+
import { TableProps, ColumnType, ColumnGroupType } from 'antd/es/table';
|
3
3
|
import { TableRowSelection } from 'antd/es/table/interface';
|
4
|
+
import { IOption } from './ColumnSetting';
|
4
5
|
/**
|
5
6
|
* 表格提供自定义多选, 通过 rowSelection对象的selectedRowKeys和onChange来控制多选的状态
|
6
7
|
* 需要注意的是, 当在外部进行增删改或者外部需要控制选择状态时, 例如删除之后清空全选状态, 需要受控
|
@@ -20,7 +21,17 @@ export interface IOptionItem {
|
|
20
21
|
*/
|
21
22
|
disabled?: boolean | ((selectItems: any[]) => boolean);
|
22
23
|
}
|
23
|
-
export interface
|
24
|
+
export interface IColumnType<T> extends ColumnType<T> {
|
25
|
+
colTitle?: string | React.ReactNode;
|
26
|
+
configurable?: boolean;
|
27
|
+
}
|
28
|
+
export interface IColumnGroupType<T> extends ColumnGroupType<T> {
|
29
|
+
colTitle?: string | React.ReactNode;
|
30
|
+
configurable?: boolean;
|
31
|
+
}
|
32
|
+
export declare type IColumnsType<T> = Array<IColumnGroupType<T> | IColumnType<T>>;
|
33
|
+
export interface ITableProps<T> extends Omit<TableProps<T>, 'columns'> {
|
34
|
+
columns?: IColumnsType<T>;
|
24
35
|
/**
|
25
36
|
* 设置selectedRow选项, 可以获取当前选中的所有
|
26
37
|
* 数据.
|
@@ -30,6 +41,10 @@ export interface ITableProps<T> extends TableProps<T> {
|
|
30
41
|
/** 如果支持多选,则batchOptions为多选时的一些批量操作,如删除、添加等 */
|
31
42
|
batchOptions?: IOptionItem[];
|
32
43
|
emptyText?: React.ReactNode;
|
44
|
+
showColumnSetting?: boolean;
|
45
|
+
hiddenColumns?: string[];
|
46
|
+
onHiddenColumnsChange?: (keys: string[]) => void;
|
47
|
+
columnSettingOverlayClass?: string;
|
33
48
|
}
|
34
49
|
/**
|
35
50
|
* pandora2.0风格的表格
|
@@ -44,15 +59,25 @@ declare class Table<T = any> extends React.Component<ITableProps<T>, any> {
|
|
44
59
|
static contextType: React.Context<import("antd/es/config-provider").ConfigConsumerProps>;
|
45
60
|
indeterminate: boolean;
|
46
61
|
checkAll: boolean;
|
62
|
+
hiddenColumn: string[] | undefined;
|
47
63
|
UNSAFE_componentWillReceiveProps(nextProps: ITableProps<T>): void;
|
48
64
|
get selectedRowKeys(): React.ReactText[];
|
49
65
|
get rowSelection(): TableRowSelection<T> | undefined;
|
50
66
|
get undisabledData(): readonly T[];
|
51
67
|
get keysOfCurrentPage(): any[];
|
52
68
|
get emptyTextComp(): {};
|
69
|
+
get columnsSettingOptions(): IOption[];
|
70
|
+
get columnKeys(): {
|
71
|
+
allKeys: string[];
|
72
|
+
unconfigableKeys: string[];
|
73
|
+
resetKeys: string[];
|
74
|
+
};
|
75
|
+
handleHideColumnsChange(keys: string[]): Promise<void> | undefined;
|
76
|
+
getColumns(): IColumnsType<T> | undefined;
|
53
77
|
getRowKey(row: any, index: number): any;
|
54
78
|
setIndeterminate(indeterminate: boolean): void;
|
55
79
|
setCheckAll(checkAll: boolean): void;
|
80
|
+
setHiddenColumn(hiddenColumn?: string[]): void;
|
56
81
|
setCheckboxStatus(selectedRowsOfCurrentPage?: T[], dataSource?: T[]): void;
|
57
82
|
handleSelectionChange(selectedRowKeys: React.Key[], selectedRowsOfCurrentPage: any[]): void;
|
58
83
|
onRowSelectionChange(selectedRowKeys: React.Key[], selectedRowsOfCurrentPage: any[]): void;
|