@ccs-ui/rc-pro 1.1.25-beta-3 → 1.1.25-beta-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/auth/index.d.ts +4 -1
- package/es/auth/index.js +19 -7
- package/es/ccs.d.ts +16 -0
- package/es/dialog/HookModal.d.ts +1 -1
- package/es/pro-table/_utils.d.ts +12 -0
- package/es/pro-table/_utils.js +94 -0
- package/es/pro-table/index.less +41 -12
- package/es/pro-table/operation.d.ts +11 -0
- package/es/pro-table/operation.js +171 -0
- package/es/pro-table/search.d.ts +3 -8
- package/es/pro-table/search.js +108 -251
- package/es/pro-table/table.d.ts +18 -4
- package/es/pro-table/table.js +74 -91
- package/es/pro-table/tree.d.ts +4 -6
- package/es/pro-table/tree.js +3 -5
- package/es/table/index.d.ts +9 -1
- package/es/table/index.js +28 -27
- package/package.json +2 -2
package/es/auth/index.d.ts
CHANGED
|
@@ -36,5 +36,8 @@ declare namespace CcsAuth {
|
|
|
36
36
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
37
37
|
var Dropdown: ({ auth, menus, children, onClick, ...restProps }: import("./auth-dropdown").CcsAuthDropdownProps) => ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
38
38
|
}
|
|
39
|
-
declare function AuthGroup({ size, isLink, showCount, moreIcon, moreText, items, onClick, }: CcsAuthGroupProps): import("react/jsx-runtime").JSX.Element | null;
|
|
39
|
+
declare function AuthGroup({ size, isLink, showCount, moreIcon, moreText, items, onClick, ...otherProps }: CcsAuthGroupProps): import("react/jsx-runtime").JSX.Element | null;
|
|
40
|
+
declare namespace AuthGroup {
|
|
41
|
+
var displayName: string;
|
|
42
|
+
}
|
|
40
43
|
export default CcsAuth;
|
package/es/auth/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
var _excluded = ["
|
|
3
|
-
_excluded2 = ["key", "label"]
|
|
2
|
+
var _excluded = ["size", "isLink", "showCount", "moreIcon", "moreText", "items", "onClick"],
|
|
3
|
+
_excluded2 = ["key", "label"],
|
|
4
|
+
_excluded3 = ["key", "label", "disabled", "onDisabled"];
|
|
4
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -54,15 +55,16 @@ function AuthGroup(_ref4) {
|
|
|
54
55
|
moreText = _ref4.moreText,
|
|
55
56
|
_ref4$items = _ref4.items,
|
|
56
57
|
items = _ref4$items === void 0 ? [] : _ref4$items,
|
|
57
|
-
onClick = _ref4.onClick
|
|
58
|
+
onClick = _ref4.onClick,
|
|
59
|
+
otherProps = _objectWithoutProperties(_ref4, _excluded);
|
|
58
60
|
var _ref5 = useCcsPage() || {},
|
|
59
61
|
onAuth = _ref5.onAuth;
|
|
60
62
|
var modalRef = useRef(null);
|
|
61
63
|
var authButtons = [];
|
|
62
64
|
|
|
63
65
|
// 过滤隐藏按钮
|
|
64
|
-
authButtons = items.filter(function (
|
|
65
|
-
return !
|
|
66
|
+
authButtons = items.filter(function (item) {
|
|
67
|
+
return !item.hidden && !(item.onHidden && item.onHidden(otherProps === null || otherProps === void 0 ? void 0 : otherProps.selectedRows));
|
|
66
68
|
});
|
|
67
69
|
|
|
68
70
|
// 需要判断权限
|
|
@@ -98,13 +100,15 @@ function AuthGroup(_ref4) {
|
|
|
98
100
|
}
|
|
99
101
|
onClick(key);
|
|
100
102
|
};
|
|
103
|
+
|
|
104
|
+
// link类型按钮
|
|
101
105
|
if (isLink) {
|
|
102
106
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
103
107
|
children: [/*#__PURE__*/_jsx(Space, {
|
|
104
108
|
children: showBtns === null || showBtns === void 0 ? void 0 : showBtns.map(function (_ref6) {
|
|
105
109
|
var key = _ref6.key,
|
|
106
110
|
label = _ref6.label,
|
|
107
|
-
restProps = _objectWithoutProperties(_ref6,
|
|
111
|
+
restProps = _objectWithoutProperties(_ref6, _excluded2);
|
|
108
112
|
return /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({}, restProps), {}, {
|
|
109
113
|
size: size,
|
|
110
114
|
type: "link",
|
|
@@ -136,10 +140,13 @@ function AuthGroup(_ref4) {
|
|
|
136
140
|
}
|
|
137
141
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
138
142
|
children: [/*#__PURE__*/_jsx(Space, {
|
|
143
|
+
wrap: true,
|
|
139
144
|
children: showBtns === null || showBtns === void 0 ? void 0 : showBtns.map(function (_ref7, index) {
|
|
140
145
|
var key = _ref7.key,
|
|
141
146
|
label = _ref7.label,
|
|
142
|
-
|
|
147
|
+
disabled = _ref7.disabled,
|
|
148
|
+
onDisabled = _ref7.onDisabled,
|
|
149
|
+
restProps = _objectWithoutProperties(_ref7, _excluded3);
|
|
143
150
|
// 更多按钮
|
|
144
151
|
if (index === showBtns.length - 1 && authButtons.length > 0) {
|
|
145
152
|
return /*#__PURE__*/_jsxs(Space.Compact, {
|
|
@@ -163,8 +170,12 @@ function AuthGroup(_ref4) {
|
|
|
163
170
|
})]
|
|
164
171
|
}, key);
|
|
165
172
|
}
|
|
173
|
+
|
|
174
|
+
// 按钮禁用
|
|
175
|
+
var isDisabled = disabled || onDisabled && onDisabled(otherProps === null || otherProps === void 0 ? void 0 : otherProps.selectedRows);
|
|
166
176
|
return /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({}, restProps), {}, {
|
|
167
177
|
size: size,
|
|
178
|
+
disabled: isDisabled,
|
|
168
179
|
onClick: function onClick() {
|
|
169
180
|
return handleOnClick(key);
|
|
170
181
|
},
|
|
@@ -178,6 +189,7 @@ function AuthGroup(_ref4) {
|
|
|
178
189
|
}) : null]
|
|
179
190
|
});
|
|
180
191
|
}
|
|
192
|
+
AuthGroup.displayName = 'AuthGroup';
|
|
181
193
|
CcsAuth.Group = AuthGroup;
|
|
182
194
|
CcsAuth.Button = AuthButton;
|
|
183
195
|
CcsAuth.Dropdown = AuthDropdown;
|
package/es/ccs.d.ts
CHANGED
|
@@ -121,6 +121,8 @@ type TableInstance<T = any> = {
|
|
|
121
121
|
formValues: Record<string, any>;
|
|
122
122
|
/** 获取当前表单数据 */
|
|
123
123
|
data: TableDataType<T>;
|
|
124
|
+
/** 获取当前选中的数据 */
|
|
125
|
+
selectedRows: T[];
|
|
124
126
|
/** 查询数据,根据条件,从第一页开始显示 */
|
|
125
127
|
onSearch: () => void;
|
|
126
128
|
/** 刷新数据、根据条件,当前页 */
|
|
@@ -131,16 +133,30 @@ type TableInstance<T = any> = {
|
|
|
131
133
|
onReset: () => void;
|
|
132
134
|
/** 改变data 数据 */
|
|
133
135
|
onChangeData: React.Dispatch<React.SetStateAction<TableDataType<T>>>;
|
|
136
|
+
/** 清空选中的数据 */
|
|
137
|
+
onClearSelected: () => void;
|
|
134
138
|
};
|
|
135
139
|
type AuthButtonItem = {
|
|
136
140
|
key: string;
|
|
141
|
+
/** 按钮名称 */
|
|
137
142
|
label: string;
|
|
143
|
+
/** 按钮权限 */
|
|
138
144
|
auth?: string;
|
|
145
|
+
/** 按钮类型 */
|
|
139
146
|
type?: ButtonProps['type'];
|
|
147
|
+
/** 按钮禁用 */
|
|
140
148
|
disabled?: boolean;
|
|
149
|
+
/** 根据选中数据判断是否禁用 */
|
|
150
|
+
onDisabled?: (selectedRows: any[]) => boolean;
|
|
151
|
+
/** 根据选中数据判断是否隐藏 */
|
|
152
|
+
onHidden?: (selectedRows: any[]) => boolean;
|
|
153
|
+
/** 按钮隐藏 */
|
|
141
154
|
hidden?: boolean;
|
|
155
|
+
/** 警告按钮 */
|
|
142
156
|
danger?: boolean;
|
|
157
|
+
/** 按钮图标 */
|
|
143
158
|
icon?: ReactNode;
|
|
159
|
+
/** 按钮操作确认消息 */
|
|
144
160
|
confirm?: string;
|
|
145
161
|
};
|
|
146
162
|
type TriggerChildrenProps<T = any> = {
|
package/es/dialog/HookModal.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { FormProps } from 'antd';
|
|
3
3
|
import { DialogFormRef } from './form';
|
|
4
4
|
import { CcsDialogModal, CcsDialogModalProps } from './hook';
|
|
5
|
-
export declare const DialogSelfButton: ({ auth, formRef, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "
|
|
5
|
+
export declare const DialogSelfButton: ({ auth, formRef, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "auth" | "request" | "onRequestBefore" | "onCancel"> & {
|
|
6
6
|
formRef: React.RefObject<DialogFormRef>;
|
|
7
7
|
formInitialValues: FormProps['initialValues'];
|
|
8
8
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TableSticky } from 'rc-table/lib/interface';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
|
+
import CCS from '..';
|
|
4
|
+
import { ShowDependType, TableStickyProps } from './table';
|
|
5
|
+
declare const onTableInModalOrDrawer: (node: any) => TableStickyProps;
|
|
6
|
+
declare const onTableInTabItem: (node: any) => boolean | TableSticky;
|
|
7
|
+
declare const getDataById: (data: any[], rowKey: string, id: React.Key) => any;
|
|
8
|
+
declare const getAllChildrenId: (data: any[], rowKey: string) => string[];
|
|
9
|
+
declare const isComponent: (element: ReactNode, displayName: string) => boolean;
|
|
10
|
+
/** 查找所有父级依赖 */
|
|
11
|
+
declare const getShowDpends: (items: CCS.TableFormItems, item: CCS.TableFormItems[0], depends: ShowDependType[]) => ShowDependType[];
|
|
12
|
+
export { isComponent, getDataById, getShowDpends, onTableInTabItem, getAllChildrenId, onTableInModalOrDrawer, };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _isArray from 'lodash/isArray';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
// 判断组件所处dom
|
|
4
|
+
var onTableInModalOrDrawer = function onTableInModalOrDrawer(node) {
|
|
5
|
+
var _parent$classList, _parent$classList2, _parent$classList3, _parent$classList4, _parent$classList5;
|
|
6
|
+
var parent = node.parentNode;
|
|
7
|
+
if (!parent) return false;
|
|
8
|
+
if (
|
|
9
|
+
// 通过指定dom吸顶
|
|
10
|
+
(_parent$classList = parent.classList) !== null && _parent$classList !== void 0 && _parent$classList.contains('ccs-trigger-container') || (_parent$classList2 = parent.classList) !== null && _parent$classList2 !== void 0 && _parent$classList2.contains('ccs-drawer-content') || (_parent$classList3 = parent.classList) !== null && _parent$classList3 !== void 0 && _parent$classList3.contains('ant-drawer-body')) {
|
|
11
|
+
return {
|
|
12
|
+
getContainer: function getContainer() {
|
|
13
|
+
return parent;
|
|
14
|
+
},
|
|
15
|
+
isInDialog: true
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 在弹出框中吸顶top
|
|
20
|
+
if ((_parent$classList4 = parent.classList) !== null && _parent$classList4 !== void 0 && _parent$classList4.contains('ant-modal') || (_parent$classList5 = parent.classList) !== null && _parent$classList5 !== void 0 && _parent$classList5.contains('ant-drawer')) {
|
|
21
|
+
return {
|
|
22
|
+
offsetHeader: 0,
|
|
23
|
+
isInDialog: true
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return onTableInModalOrDrawer(parent);
|
|
27
|
+
};
|
|
28
|
+
var onTableInTabItem = function onTableInTabItem(node) {
|
|
29
|
+
var _parent$classList6;
|
|
30
|
+
var parent = node.parentNode;
|
|
31
|
+
if (!parent) return false;
|
|
32
|
+
if ( // 通过指定dom吸顶
|
|
33
|
+
(_parent$classList6 = parent.classList) !== null && _parent$classList6 !== void 0 && _parent$classList6.contains('ccs-table-item-scroll')) {
|
|
34
|
+
return {
|
|
35
|
+
getContainer: function getContainer() {
|
|
36
|
+
return node;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return onTableInTabItem(parent);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// 根据ID查找树形节点
|
|
44
|
+
var getDataById = function getDataById(data, rowKey, id) {
|
|
45
|
+
if (!_isArray(data)) return;
|
|
46
|
+
for (var i = 0; i < data.length; i += 1) {
|
|
47
|
+
if (data[i][rowKey] === id) {
|
|
48
|
+
return data[i];
|
|
49
|
+
}
|
|
50
|
+
if (data[i].children) {
|
|
51
|
+
var v = getDataById(data[i].children, rowKey, id);
|
|
52
|
+
if (v) return v;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var getAllChildrenId = function getAllChildrenId(data, rowKey) {
|
|
57
|
+
return data.reduce(function (keys, item) {
|
|
58
|
+
keys.push(item[rowKey]);
|
|
59
|
+
if (item.children && _isArray(item.children)) {
|
|
60
|
+
return keys.concat(getAllChildrenId(item.children, rowKey));
|
|
61
|
+
}
|
|
62
|
+
return keys;
|
|
63
|
+
}, []);
|
|
64
|
+
};
|
|
65
|
+
var isComponent = function isComponent(element, displayName) {
|
|
66
|
+
if (! /*#__PURE__*/React.isValidElement(element)) return false;
|
|
67
|
+
var type = element === null || element === void 0 ? void 0 : element.type;
|
|
68
|
+
if (typeof type === 'string') return false;
|
|
69
|
+
return (type === null || type === void 0 ? void 0 : type.displayName) === displayName;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** 查找所有父级依赖 */
|
|
73
|
+
var getShowDpends = function getShowDpends(items, item, depends) {
|
|
74
|
+
var showDepends = item.showDepends;
|
|
75
|
+
if (showDepends) {
|
|
76
|
+
var dependItems = items.filter(function (i) {
|
|
77
|
+
return showDepends.some(function (e) {
|
|
78
|
+
return e && e.name === i.name;
|
|
79
|
+
});
|
|
80
|
+
}) || [];
|
|
81
|
+
dependItems.forEach(function (dependItem) {
|
|
82
|
+
if (dependItem !== null && dependItem !== void 0 && dependItem.showDepends) {
|
|
83
|
+
dependItem.showDepends.forEach(function (e) {
|
|
84
|
+
return depends.push(e);
|
|
85
|
+
});
|
|
86
|
+
return getShowDpends(items, dependItem, depends);
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
});
|
|
90
|
+
return depends;
|
|
91
|
+
}
|
|
92
|
+
return depends;
|
|
93
|
+
};
|
|
94
|
+
export { isComponent, getDataById, getShowDpends, onTableInTabItem, getAllChildrenId, onTableInModalOrDrawer };
|
package/es/pro-table/index.less
CHANGED
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
margin: 0 !important;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
&-tradition-toolbar {
|
|
28
|
+
padding: 10px 16px;
|
|
29
|
+
}
|
|
30
|
+
|
|
27
31
|
&-icon {
|
|
28
32
|
// color: rgb(0 0 0 / 75%);
|
|
29
33
|
font-size: 16;
|
|
@@ -33,6 +37,12 @@
|
|
|
33
37
|
// margin: 10px;
|
|
34
38
|
// background: #fff;
|
|
35
39
|
position: relative;
|
|
40
|
+
|
|
41
|
+
&.tradition {
|
|
42
|
+
.ant-table-title {
|
|
43
|
+
border-radius: 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
&-form {
|
|
@@ -41,13 +51,18 @@
|
|
|
41
51
|
display: flex;
|
|
42
52
|
flex-direction: row;
|
|
43
53
|
align-items: flex-end;
|
|
44
|
-
justify-content: space-between;
|
|
54
|
+
// justify-content: space-between;
|
|
55
|
+
// flex-wrap: wrap;
|
|
56
|
+
gap: 8px;
|
|
45
57
|
|
|
46
58
|
.ant-form-item {
|
|
47
|
-
flex-wrap: nowrap;
|
|
48
59
|
flex: 0 1 auto;
|
|
49
60
|
}
|
|
50
61
|
|
|
62
|
+
.ant-row {
|
|
63
|
+
flex-wrap: nowrap;
|
|
64
|
+
}
|
|
65
|
+
|
|
51
66
|
.ant-form-item .ant-form-item-label {
|
|
52
67
|
padding: 0;
|
|
53
68
|
}
|
|
@@ -74,14 +89,26 @@
|
|
|
74
89
|
margin-inline-end: 0;
|
|
75
90
|
}
|
|
76
91
|
}
|
|
77
|
-
}
|
|
78
92
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// box-shadow: 0 2px 2px 0 rgb(0 0 0 / 3%);
|
|
93
|
+
&.tradition {
|
|
94
|
+
flex-wrap: wrap;
|
|
82
95
|
|
|
83
|
-
|
|
84
|
-
|
|
96
|
+
& > .ant-form-inline {
|
|
97
|
+
flex-wrap: wrap;
|
|
98
|
+
justify-content: flex-start;
|
|
99
|
+
gap: 10px;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&.vertical {
|
|
104
|
+
.ant-form-item-row {
|
|
105
|
+
flex-direction: row;
|
|
106
|
+
align-items: center;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.ant-form-item .ant-form-item-control {
|
|
110
|
+
width: auto;
|
|
111
|
+
}
|
|
85
112
|
}
|
|
86
113
|
}
|
|
87
114
|
|
|
@@ -89,9 +116,10 @@
|
|
|
89
116
|
line-height: 0;
|
|
90
117
|
}
|
|
91
118
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
119
|
+
.ant-form-item {
|
|
120
|
+
margin-bottom: 0;
|
|
121
|
+
margin-inline-end: 0;
|
|
122
|
+
}
|
|
95
123
|
|
|
96
124
|
.ant-input-number {
|
|
97
125
|
width: 100%;
|
|
@@ -126,6 +154,7 @@
|
|
|
126
154
|
justify-content: space-between;
|
|
127
155
|
align-items: center;
|
|
128
156
|
// background-color: #fff;
|
|
157
|
+
width: 100%;
|
|
129
158
|
|
|
130
159
|
.ant-form-item-explain {
|
|
131
160
|
position: absolute;
|
|
@@ -137,7 +166,7 @@
|
|
|
137
166
|
}
|
|
138
167
|
|
|
139
168
|
&-buttons {
|
|
140
|
-
margin-left: 6px;
|
|
169
|
+
// margin-left: 6px;
|
|
141
170
|
white-space: nowrap;
|
|
142
171
|
}
|
|
143
172
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TableRefType } from '../table';
|
|
3
|
+
type PropsType = {
|
|
4
|
+
/** 显示列 */ columns?: any;
|
|
5
|
+
/** 弹框中显示 */
|
|
6
|
+
isInModalOrDrawer: boolean;
|
|
7
|
+
onReset: () => void;
|
|
8
|
+
tableRef: React.MutableRefObject<TableRefType | undefined>;
|
|
9
|
+
};
|
|
10
|
+
export default function TableOperation({ columns, tableRef, isInModalOrDrawer, onReset, }: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { RedoOutlined, SettingOutlined } from '@ant-design/icons';
|
|
12
|
+
import { Button, Checkbox, Dropdown, Tooltip } from 'antd';
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import { CcsFullScreenButton } from '..';
|
|
15
|
+
import { classPrefix } from "./table";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
export default function TableOperation(_ref) {
|
|
20
|
+
var columns = _ref.columns,
|
|
21
|
+
tableRef = _ref.tableRef,
|
|
22
|
+
isInModalOrDrawer = _ref.isInModalOrDrawer,
|
|
23
|
+
onReset = _ref.onReset;
|
|
24
|
+
var _useState = useState(columns),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
filterColumns = _useState2[0],
|
|
27
|
+
setFilterColumns = _useState2[1];
|
|
28
|
+
var _useState3 = useState(false),
|
|
29
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
30
|
+
dropdownVisible = _useState4[0],
|
|
31
|
+
setDropdownVisible = _useState4[1];
|
|
32
|
+
var _useState5 = useState(true),
|
|
33
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
34
|
+
isCheckAll = _useState6[0],
|
|
35
|
+
setIsCheckAll = _useState6[1];
|
|
36
|
+
|
|
37
|
+
// 获取全选初始状态
|
|
38
|
+
var getHalfCheckState = function getHalfCheckState() {
|
|
39
|
+
var cols = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : columns;
|
|
40
|
+
var col = cols === null || cols === void 0 ? void 0 : cols.filter(function (t) {
|
|
41
|
+
return t.dataIndex;
|
|
42
|
+
});
|
|
43
|
+
return (col === null || col === void 0 ? void 0 : col.every(function (c) {
|
|
44
|
+
return !c.hidden;
|
|
45
|
+
})) || (col === null || col === void 0 ? void 0 : col.every(function (c) {
|
|
46
|
+
return c.hidden;
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
var _useState7 = useState(getHalfCheckState),
|
|
50
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
51
|
+
isHalfCheck = _useState8[0],
|
|
52
|
+
setIsHalfCheck = _useState8[1];
|
|
53
|
+
|
|
54
|
+
// 全选、取消全选
|
|
55
|
+
var onCheckAllChange = function onCheckAllChange(e) {
|
|
56
|
+
var _tableRef$current;
|
|
57
|
+
// 隐藏的列key
|
|
58
|
+
var columnHiddenKeys = [];
|
|
59
|
+
filterColumns.forEach(function (t) {
|
|
60
|
+
var s = t;
|
|
61
|
+
if (s.dataIndex) s.hidden = !e.target.checked;
|
|
62
|
+
if (s.hidden) columnHiddenKeys.push(t.dataIndex);
|
|
63
|
+
});
|
|
64
|
+
setFilterColumns(_toConsumableArray(filterColumns));
|
|
65
|
+
setIsCheckAll(e.target.checked);
|
|
66
|
+
setIsHalfCheck(true);
|
|
67
|
+
|
|
68
|
+
// 列改变
|
|
69
|
+
(_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.onColumnFilter({
|
|
70
|
+
columnHiddenKeys: columnHiddenKeys
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// 列选中事件
|
|
75
|
+
var onCheckChange = function onCheckChange(checked, index) {
|
|
76
|
+
var _tableRef$current2;
|
|
77
|
+
filterColumns[index].hidden = !checked;
|
|
78
|
+
setFilterColumns(_toConsumableArray(filterColumns));
|
|
79
|
+
var isHalf = getHalfCheckState(filterColumns);
|
|
80
|
+
if (isHalf !== isHalfCheck) {
|
|
81
|
+
setIsHalfCheck(isHalf);
|
|
82
|
+
}
|
|
83
|
+
if (isHalf) {
|
|
84
|
+
setIsCheckAll(checked);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 计算隐藏的列key
|
|
88
|
+
var columnHiddenKeys = [];
|
|
89
|
+
filterColumns.forEach(function (t) {
|
|
90
|
+
if (t.hidden) columnHiddenKeys.push(t.dataIndex);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// 发布列改变通知
|
|
94
|
+
(_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.onColumnFilter({
|
|
95
|
+
columnHiddenKeys: columnHiddenKeys
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// 列过滤
|
|
100
|
+
var renderCheck = function renderCheck() {
|
|
101
|
+
var fc = [{
|
|
102
|
+
key: '1',
|
|
103
|
+
label: /*#__PURE__*/_jsx(Checkbox, {
|
|
104
|
+
indeterminate: !isHalfCheck,
|
|
105
|
+
onChange: onCheckAllChange,
|
|
106
|
+
checked: isCheckAll,
|
|
107
|
+
children: "\u5168\u9009"
|
|
108
|
+
})
|
|
109
|
+
}, {
|
|
110
|
+
key: '2',
|
|
111
|
+
type: 'divider'
|
|
112
|
+
}];
|
|
113
|
+
filterColumns.forEach(function (c, index) {
|
|
114
|
+
if (c.dataIndex) {
|
|
115
|
+
fc.push({
|
|
116
|
+
key: c.dataIndex,
|
|
117
|
+
label: /*#__PURE__*/_jsx(Checkbox, {
|
|
118
|
+
checked: !c.hidden,
|
|
119
|
+
onChange: function onChange(e) {
|
|
120
|
+
return onCheckChange(e.target.checked, index);
|
|
121
|
+
},
|
|
122
|
+
children: c.title
|
|
123
|
+
})
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return fc;
|
|
128
|
+
};
|
|
129
|
+
var onFullScreen = function onFullScreen() {
|
|
130
|
+
var _tableRef$current3;
|
|
131
|
+
(_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 ? void 0 : _tableRef$current3.onFullScreen();
|
|
132
|
+
};
|
|
133
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
134
|
+
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
135
|
+
title: "\u91CD\u7F6E",
|
|
136
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
137
|
+
onClick: onReset,
|
|
138
|
+
icon: /*#__PURE__*/_jsx(RedoOutlined, {
|
|
139
|
+
className: "".concat(classPrefix, "-icon")
|
|
140
|
+
}),
|
|
141
|
+
type: "text",
|
|
142
|
+
style: {
|
|
143
|
+
width: 24
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
}), filterColumns && /*#__PURE__*/_jsx(Dropdown, {
|
|
147
|
+
menu: {
|
|
148
|
+
items: renderCheck()
|
|
149
|
+
},
|
|
150
|
+
trigger: ['click'],
|
|
151
|
+
open: dropdownVisible,
|
|
152
|
+
onOpenChange: function onOpenChange(flag) {
|
|
153
|
+
return setDropdownVisible(flag);
|
|
154
|
+
},
|
|
155
|
+
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
156
|
+
title: "\u5217\u8BBE\u7F6E",
|
|
157
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
158
|
+
icon: /*#__PURE__*/_jsx(SettingOutlined, {
|
|
159
|
+
className: "".concat(classPrefix, "-icon")
|
|
160
|
+
}),
|
|
161
|
+
type: "text",
|
|
162
|
+
style: {
|
|
163
|
+
width: 24
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
}), !isInModalOrDrawer && /*#__PURE__*/_jsx(CcsFullScreenButton, {
|
|
168
|
+
onFullScreen: onFullScreen
|
|
169
|
+
})]
|
|
170
|
+
});
|
|
171
|
+
}
|
package/es/pro-table/search.d.ts
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import { EventEmitter } from 'ahooks/lib/useEventEmitter';
|
|
2
1
|
import { FormInstance } from 'antd/lib/form';
|
|
3
2
|
import { ReactElement } from 'react';
|
|
4
3
|
import { CcsProTableProps } from './table';
|
|
5
4
|
type PropsType<T> = Pick<CcsProTableProps<T>, 'toolbar' | 'formItems' | 'formInitValues' | 'expandForm' | 'formItemLabelWidth' | 'formItemLayout' | 'formItemCol' | 'title'> & {
|
|
6
|
-
/** 显示列 */
|
|
7
|
-
columns?: any;
|
|
8
5
|
/** 更多查询条件 */
|
|
9
6
|
hasMore?: boolean;
|
|
10
7
|
/** 标题边框 */
|
|
11
8
|
titleBordered?: boolean;
|
|
12
|
-
/** 弹框中显示 */
|
|
13
|
-
isInModalOrDrawer: boolean;
|
|
14
9
|
form: FormInstance<any>;
|
|
15
10
|
children?: ReactElement;
|
|
16
|
-
|
|
11
|
+
/** table 操作栏 */
|
|
12
|
+
tableOperation: ReactElement;
|
|
17
13
|
onSearch: () => void;
|
|
18
|
-
event$: EventEmitter<any>;
|
|
19
14
|
};
|
|
20
15
|
/** 操作按钮、查询,重置、列筛选、 */
|
|
21
|
-
declare function SearchComponent<T>(
|
|
16
|
+
declare function SearchComponent<T>(props: PropsType<T>): import("react/jsx-runtime").JSX.Element;
|
|
22
17
|
export default SearchComponent;
|