@qn-pandora/pandora-component 4.0.12 → 4.0.13
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 +20 -0
- package/CHANGELOG.md +9 -1
- package/es/components/Drawer/index.d.ts +13 -2
- package/es/components/Drawer/index.js +38 -4
- package/es/components/Table/index.d.ts +2 -0
- package/es/components/Table/index.js +27 -5
- package/es/components/Tabs/index.d.ts +4 -0
- package/es/components/Tabs/index.js +2 -2
- package/es/constants/style.d.ts +1 -0
- package/es/constants/style.js +1 -0
- package/es/hoc/modalPopupContainer.d.ts +6 -0
- package/es/hoc/{popContainer.js → modalPopupContainer.js} +8 -3
- package/es/index.css +3725 -3725
- package/es/index.less +17 -17
- package/es/style/theme.less +2 -2
- package/es/utils/dom.d.ts +1 -0
- package/es/utils/dom.js +42 -0
- package/lib/components/Drawer/index.d.ts +13 -2
- package/lib/components/Drawer/index.js +37 -3
- package/lib/components/Table/index.d.ts +2 -0
- package/lib/components/Table/index.js +27 -5
- package/lib/components/Tabs/index.d.ts +4 -0
- package/lib/components/Tabs/index.js +2 -2
- package/lib/constants/style.d.ts +1 -0
- package/lib/constants/style.js +1 -0
- package/lib/hoc/modalPopupContainer.d.ts +6 -0
- package/lib/hoc/{popContainer.js → modalPopupContainer.js} +9 -4
- package/lib/index.css +4331 -4331
- package/lib/index.less +13 -13
- package/lib/style/theme.less +2 -2
- package/lib/utils/dom.d.ts +1 -0
- package/lib/utils/dom.js +45 -0
- package/package.json +3 -3
- package/es/hoc/popContainer.d.ts +0 -5
- package/lib/hoc/popContainer.d.ts +0 -5
package/CHANGELOG.json
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
{
|
2
2
|
"name": "@qn-pandora/pandora-component",
|
3
3
|
"entries": [
|
4
|
+
{
|
5
|
+
"version": "4.0.13",
|
6
|
+
"tag": "@qn-pandora/pandora-component_v4.0.13",
|
7
|
+
"date": "Tue, 06 Jun 2023 07:33:10 GMT",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"comment": "2023.06.06发布"
|
12
|
+
}
|
13
|
+
],
|
14
|
+
"dependency": [
|
15
|
+
{
|
16
|
+
"comment": "Updating dependency \"@qn-pandora/pandora-component-icons\" from `^3.0.15` to `^3.0.16`"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"comment": "Updating dependency \"@qn-pandora/app-sdk\" from `^3.0.16` to `^3.0.17`"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
23
|
+
},
|
4
24
|
{
|
5
25
|
"version": "4.0.12",
|
6
26
|
"tag": "@qn-pandora/pandora-component_v4.0.12",
|
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Change Log - @qn-pandora/pandora-component
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Tue, 06 Jun 2023 07:33:10 GMT and should not be manually modified.
|
4
|
+
|
5
|
+
## 4.0.13
|
6
|
+
|
7
|
+
Tue, 06 Jun 2023 07:33:10 GMT
|
8
|
+
|
9
|
+
### Patches
|
10
|
+
|
11
|
+
- 2023.06.06 发布
|
4
12
|
|
5
13
|
## 4.0.12
|
6
14
|
|
@@ -51,15 +51,20 @@ export declare type IDrawerProps = Overwrite<DrawerProps, {
|
|
51
51
|
*/
|
52
52
|
zIndex?: number;
|
53
53
|
getContainer?: string | HTMLElement | getContainerFunc | false;
|
54
|
-
onClose?: (e: EventType) => void;
|
54
|
+
onClose?: (e: EventType | null) => void;
|
55
55
|
afterVisibleChange?: (visible: boolean) => void;
|
56
56
|
/**
|
57
57
|
* 是否允许拖拽
|
58
58
|
*/
|
59
59
|
canDrag?: boolean;
|
60
60
|
closeIconPlacement?: 'left' | 'right';
|
61
|
+
/**
|
62
|
+
* 无遮罩时点击空白处中的哪些元素不关闭
|
63
|
+
*/
|
64
|
+
nonCloseSelector?: string;
|
61
65
|
}>;
|
62
66
|
export declare class Drawer extends React.Component<React.PropsWithChildren<IDrawerProps>, any> {
|
67
|
+
drawerId: string;
|
63
68
|
isResizing: boolean;
|
64
69
|
realWidth: string | number | undefined;
|
65
70
|
throttleMouseMove: import("lodash").DebouncedFunc<(e: any) => void>;
|
@@ -70,6 +75,7 @@ export declare class Drawer extends React.Component<React.PropsWithChildren<IDra
|
|
70
75
|
onMouseDown(): void;
|
71
76
|
onMouseUp(): void;
|
72
77
|
onMouseMove(e: any): void;
|
78
|
+
onMouseClick(e: MouseEvent): void;
|
73
79
|
componentDidMount(): void;
|
74
80
|
UNSAFE_componentWillUpdate(nextProps: Readonly<React.PropsWithChildren<IDrawerProps>>): void;
|
75
81
|
componentWillUnmount(): void;
|
@@ -122,17 +128,22 @@ declare const _default: (props: {
|
|
122
128
|
*/
|
123
129
|
zIndex?: number | undefined;
|
124
130
|
getContainer?: string | false | HTMLElement | getContainerFunc | undefined;
|
125
|
-
onClose?: ((e:
|
131
|
+
onClose?: ((e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement | HTMLButtonElement, MouseEvent> | null) => void) | undefined;
|
126
132
|
afterVisibleChange?: ((visible: boolean) => void) | undefined;
|
127
133
|
/**
|
128
134
|
* 是否允许拖拽
|
129
135
|
*/
|
130
136
|
canDrag?: boolean | undefined;
|
131
137
|
closeIconPlacement?: import("antd/es/collapse/Collapse").ExpandIconPosition;
|
138
|
+
/**
|
139
|
+
* 无遮罩时点击空白处中的哪些元素不关闭
|
140
|
+
*/
|
141
|
+
nonCloseSelector?: string | undefined;
|
132
142
|
} & Pick<DrawerProps, "style" | "autoFocus" | "size" | "prefixCls" | "footer" | "extra" | "bodyStyle" | "forceRender" | "keyboard" | "destroyOnClose" | "closeIcon" | "drawerStyle" | "headerStyle" | "contentWrapperStyle" | "push" | "handler" | "footerStyle" | "level" | "levelMove"> & {
|
133
143
|
children?: React.ReactNode;
|
134
144
|
} & {
|
135
145
|
bodyStyle?: React.CSSProperties | undefined;
|
136
146
|
children: React.ReactNode;
|
147
|
+
title?: React.ReactNode;
|
137
148
|
}) => JSX.Element;
|
138
149
|
export default _default;
|
@@ -49,8 +49,9 @@ import { observer } from 'mobx-react';
|
|
49
49
|
import { observable, action, computed } from 'mobx';
|
50
50
|
import { Drawer as BaseDrawer } from 'antd';
|
51
51
|
import { CloseOutlined } from '@ant-design/icons';
|
52
|
-
import {
|
53
|
-
import
|
52
|
+
import { doesDOMMatchSelector } from '../../utils/dom';
|
53
|
+
import { SDK_PREFIX, ANT_PREFIX } from '../../constants/style';
|
54
|
+
import modalPopupContainerWrapper from '../../hoc/modalPopupContainer';
|
54
55
|
import bind from '../../utils/bind';
|
55
56
|
var MAX_WIDTH = 6000;
|
56
57
|
var MIN_WIDTH = 300;
|
@@ -58,6 +59,7 @@ var Drawer = /** @class */ (function (_super) {
|
|
58
59
|
__extends(Drawer, _super);
|
59
60
|
function Drawer() {
|
60
61
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
62
|
+
_this.drawerId = "drawer-id-" + Math.floor(Math.random() * 10000);
|
61
63
|
_this.isResizing = false;
|
62
64
|
_this.realWidth = _this.props.width;
|
63
65
|
_this.throttleMouseMove = throttle(function (e) { return _this.onMouseMove(e); }, 100);
|
@@ -108,11 +110,36 @@ var Drawer = /** @class */ (function (_super) {
|
|
108
110
|
}
|
109
111
|
}
|
110
112
|
};
|
113
|
+
Drawer.prototype.onMouseClick = function (e) {
|
114
|
+
var _a = this.props, mask = _a.mask, maskClosable = _a.maskClosable, nonCloseSelector = _a.nonCloseSelector, onClose = _a.onClose, visible = _a.visible;
|
115
|
+
if (mask === false && maskClosable && visible) {
|
116
|
+
var currentEl = e.target;
|
117
|
+
var shouldClose = true;
|
118
|
+
while (currentEl) {
|
119
|
+
if (nonCloseSelector) {
|
120
|
+
if (doesDOMMatchSelector(nonCloseSelector, currentEl)) {
|
121
|
+
shouldClose = false;
|
122
|
+
break;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
if (doesDOMMatchSelector("." + this.drawerId, currentEl) ||
|
126
|
+
doesDOMMatchSelector("." + ANT_PREFIX + "-modal-root, .ant-modal-root", currentEl)) {
|
127
|
+
shouldClose = false;
|
128
|
+
break;
|
129
|
+
}
|
130
|
+
currentEl = currentEl.parentElement;
|
131
|
+
}
|
132
|
+
if (shouldClose) {
|
133
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(null);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
};
|
111
137
|
Drawer.prototype.componentDidMount = function () {
|
112
138
|
if (this.props.canDrag) {
|
113
139
|
document.addEventListener('mousemove', this.throttleMouseMove);
|
114
140
|
document.addEventListener('mouseup', this.onMouseUp);
|
115
141
|
}
|
142
|
+
document.body.addEventListener('click', this.onMouseClick);
|
116
143
|
};
|
117
144
|
Drawer.prototype.UNSAFE_componentWillUpdate = function (nextProps) {
|
118
145
|
if (nextProps.canDrag && !this.props.canDrag) {
|
@@ -123,11 +150,12 @@ var Drawer = /** @class */ (function (_super) {
|
|
123
150
|
Drawer.prototype.componentWillUnmount = function () {
|
124
151
|
document.removeEventListener('mousemove', this.throttleMouseMove);
|
125
152
|
document.removeEventListener('mouseup', this.onMouseUp);
|
153
|
+
document.body.removeEventListener('click', this.onMouseClick);
|
126
154
|
};
|
127
155
|
Drawer.prototype.render = function () {
|
128
156
|
var _a;
|
129
157
|
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, other = __rest(_b, ["width", "className", "children", "canDrag", "visible", "closable", "extra"]);
|
130
|
-
return (React.createElement(BaseDrawer, __assign({ className: classnames(SDK_PREFIX + "-drawer", className, (_a = {},
|
158
|
+
return (React.createElement(BaseDrawer, __assign({ className: classnames(this.drawerId, SDK_PREFIX + "-drawer", className, (_a = {},
|
131
159
|
_a[SDK_PREFIX + "-drawer-no-mask"] = this.props.mask === false,
|
132
160
|
_a)), width: this.realWidth || 'auto', zIndex: 1200, visible: visible, closable: this.closable, extra: this.extra }, other),
|
133
161
|
canDrag && (React.createElement("div", { className: SDK_PREFIX + "-scroll-handler", onMouseDown: this.onMouseDown })),
|
@@ -183,10 +211,16 @@ var Drawer = /** @class */ (function (_super) {
|
|
183
211
|
__metadata("design:paramtypes", [Object]),
|
184
212
|
__metadata("design:returntype", void 0)
|
185
213
|
], Drawer.prototype, "onMouseMove", null);
|
214
|
+
__decorate([
|
215
|
+
bind,
|
216
|
+
__metadata("design:type", Function),
|
217
|
+
__metadata("design:paramtypes", [MouseEvent]),
|
218
|
+
__metadata("design:returntype", void 0)
|
219
|
+
], Drawer.prototype, "onMouseClick", null);
|
186
220
|
Drawer = __decorate([
|
187
221
|
observer
|
188
222
|
], Drawer);
|
189
223
|
return Drawer;
|
190
224
|
}(React.Component));
|
191
225
|
export { Drawer };
|
192
|
-
export default
|
226
|
+
export default modalPopupContainerWrapper(Drawer);
|
@@ -29,6 +29,7 @@ export interface ITableProps<T> extends TableProps<T> {
|
|
29
29
|
selectedRows?: T[];
|
30
30
|
/** 如果支持多选,则batchOptions为多选时的一些批量操作,如删除、添加等 */
|
31
31
|
batchOptions?: IOptionItem[];
|
32
|
+
emptyText?: React.ReactNode;
|
32
33
|
}
|
33
34
|
/**
|
34
35
|
* pandora2.0风格的表格
|
@@ -48,6 +49,7 @@ declare class Table<T = any> extends React.Component<ITableProps<T>, any> {
|
|
48
49
|
get rowSelection(): TableRowSelection<T> | undefined;
|
49
50
|
get undisabledData(): readonly T[];
|
50
51
|
get keysOfCurrentPage(): any[];
|
52
|
+
get emptyTextComp(): {};
|
51
53
|
getRowKey(row: any, index: number): any;
|
52
54
|
setIndeterminate(indeterminate: boolean): void;
|
53
55
|
setCheckAll(checkAll: boolean): void;
|
@@ -154,6 +154,26 @@ var Table = /** @class */ (function (_super) {
|
|
154
154
|
enumerable: true,
|
155
155
|
configurable: true
|
156
156
|
});
|
157
|
+
Object.defineProperty(Table.prototype, "emptyTextComp", {
|
158
|
+
get: function () {
|
159
|
+
var emptyText = this.props.emptyText;
|
160
|
+
if (!emptyText) {
|
161
|
+
return (React.createElement("div", { className: SDK_PREFIX + "-table-empty" },
|
162
|
+
React.createElement("div", { className: SDK_PREFIX + "-table-empty-icon" },
|
163
|
+
React.createElement(EmptyIcon, null)),
|
164
|
+
React.createElement("div", { className: SDK_PREFIX + "-table-empty-text" }, formatString(TableLocale.empty, this.context.locale))));
|
165
|
+
}
|
166
|
+
if (typeof emptyText === 'string' || typeof emptyText === 'number') {
|
167
|
+
return (React.createElement("div", { className: SDK_PREFIX + "-table-empty" },
|
168
|
+
React.createElement("div", { className: SDK_PREFIX + "-table-empty-icon" },
|
169
|
+
React.createElement(EmptyIcon, null)),
|
170
|
+
React.createElement("div", { className: SDK_PREFIX + "-table-empty-text" }, emptyText)));
|
171
|
+
}
|
172
|
+
return emptyText;
|
173
|
+
},
|
174
|
+
enumerable: true,
|
175
|
+
configurable: true
|
176
|
+
});
|
157
177
|
Table.prototype.getRowKey = function (row, index) {
|
158
178
|
var rowKey = this.props.rowKey;
|
159
179
|
if (typeof rowKey === 'function') {
|
@@ -238,12 +258,9 @@ var Table = /** @class */ (function (_super) {
|
|
238
258
|
Table.prototype.render = function () {
|
239
259
|
var _a, _b;
|
240
260
|
var _this = this;
|
241
|
-
var _c = this.props, className = _c.className, batchOptions = _c.batchOptions, scroll = _c.scroll, locale = _c.locale, restProps = __rest(_c, ["className", "batchOptions", "scroll", "locale"]);
|
261
|
+
var _c = this.props, className = _c.className, batchOptions = _c.batchOptions, scroll = _c.scroll, locale = _c.locale, emptyText = _c.emptyText, restProps = __rest(_c, ["className", "batchOptions", "scroll", "locale", "emptyText"]);
|
242
262
|
return (React.createElement("div", null,
|
243
|
-
React.createElement(AntTable, __assign({ scroll: scroll, locale: __assign({ emptyText:
|
244
|
-
React.createElement("div", { className: SDK_PREFIX + "-table-empty-icon" },
|
245
|
-
React.createElement(EmptyIcon, null)),
|
246
|
-
React.createElement("div", { className: SDK_PREFIX + "-table-empty-text" }, formatString(TableLocale.empty, this.context.locale)))) }, locale) }, 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),
|
263
|
+
React.createElement(AntTable, __assign({ scroll: scroll, locale: __assign({ emptyText: this.emptyTextComp }, locale) }, 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),
|
247
264
|
// 涉及到权限
|
248
265
|
// getCheckboxProps只能放到tableBatchWrapper里,因为selectedRowKeys在那个组件计算
|
249
266
|
rowSelection: batchOptions && this.props.rowSelection
|
@@ -297,6 +314,11 @@ var Table = /** @class */ (function (_super) {
|
|
297
314
|
__metadata("design:type", Object),
|
298
315
|
__metadata("design:paramtypes", [])
|
299
316
|
], Table.prototype, "keysOfCurrentPage", null);
|
317
|
+
__decorate([
|
318
|
+
computed,
|
319
|
+
__metadata("design:type", Object),
|
320
|
+
__metadata("design:paramtypes", [])
|
321
|
+
], Table.prototype, "emptyTextComp", null);
|
300
322
|
__decorate([
|
301
323
|
bind,
|
302
324
|
__metadata("design:type", Function),
|
@@ -32,7 +32,7 @@ export function Tabs(props) {
|
|
32
32
|
var className = props.className, active = props.active, options = props.options, onChange = props.onChange, refreshText = props.refreshText, onRefresh = props.onRefresh, restProps = __rest(props, ["className", "active", "options", "onChange", "refreshText", "onRefresh"]);
|
33
33
|
var panes = options.map(function (_a) {
|
34
34
|
var _b;
|
35
|
-
var key = _a.key, text = _a.text, hidden = _a.hidden, refreshTextCur = _a.refreshText, onRefreshCur = _a.onRefresh;
|
35
|
+
var key = _a.key, text = _a.text, children = _a.children, hidden = _a.hidden, refreshTextCur = _a.refreshText, onRefreshCur = _a.onRefresh;
|
36
36
|
if (hidden) {
|
37
37
|
return null;
|
38
38
|
}
|
@@ -44,7 +44,7 @@ export function Tabs(props) {
|
|
44
44
|
_b)) },
|
45
45
|
text,
|
46
46
|
refresh));
|
47
|
-
return React.createElement(BaseTabs.TabPane, { key: key, tab: tab });
|
47
|
+
return (React.createElement(BaseTabs.TabPane, { key: key, tab: tab }, children));
|
48
48
|
});
|
49
49
|
return (React.createElement(BaseTabs, __assign({ className: classnames(SDK_PREFIX + "-tabs", className), tabBarGutter: 16, activeKey: active, onChange: onChange }, restProps), panes));
|
50
50
|
}
|
package/es/constants/style.d.ts
CHANGED
package/es/constants/style.js
CHANGED
@@ -23,14 +23,19 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
23
23
|
import React, { useRef, useCallback } from 'react';
|
24
24
|
import ConfigProvider, { ConfigConsumer } from 'antd/es/config-provider';
|
25
25
|
import { SDK_PREFIX } from '../constants/style';
|
26
|
-
export default function
|
26
|
+
export default function modalPopupContainerWrapper(Comp) {
|
27
27
|
return function (props) {
|
28
28
|
var containerRef = useRef(null);
|
29
|
-
var
|
29
|
+
var titleRef = useRef(null);
|
30
|
+
var _a = props.bodyStyle, bodyStyle = _a === void 0 ? {} : _a, children = props.children, title = props.title, rest = __rest(props, ["bodyStyle", "children", "title"]);
|
30
31
|
var childrenGetPopupContainer = useCallback(function () {
|
31
32
|
return (containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) || document.body;
|
32
33
|
}, []);
|
33
|
-
|
34
|
+
var titleGetPopupContainer = useCallback(function () {
|
35
|
+
return (containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) || document.body;
|
36
|
+
}, []);
|
37
|
+
return (React.createElement(Comp, __assign({}, rest, { title: React.createElement("div", { ref: titleRef },
|
38
|
+
React.createElement(ConfigConsumer, null, function (config) { return (React.createElement(ConfigProvider, __assign({}, config, { getPopupContainer: titleGetPopupContainer }), title)); })) }),
|
34
39
|
React.createElement("div", { className: SDK_PREFIX + "-drawer-container", ref: containerRef, style: bodyStyle },
|
35
40
|
React.createElement(ConfigConsumer, null, function (config) { return (React.createElement(ConfigProvider, __assign({}, config, { getPopupContainer: childrenGetPopupContainer }), children)); }))));
|
36
41
|
};
|