@pointcloud/pcloud-components 0.1.33 → 0.1.35
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/README.md +28 -22
- package/dist/esm/CRUD/config.d.ts +2 -0
- package/dist/esm/CRUD/config.js +21 -0
- package/dist/esm/CRUD/index.d.ts +98 -0
- package/dist/esm/CRUD/index.js +679 -0
- package/dist/esm/CRUD/index.less +154 -0
- package/dist/esm/CRUD/toolbar.d.ts +18 -0
- package/dist/esm/CRUD/toolbar.js +259 -0
- package/dist/esm/DModal/index.d.ts +4 -3
- package/dist/esm/DModal/index.js +11 -9
- package/dist/esm/DModal/interface.d.ts +2 -8
- package/dist/esm/DTable/index.d.ts +17 -1
- package/dist/esm/DTable/index.js +43 -13
- package/dist/esm/DUpload/helper.js +48 -48
- package/dist/esm/Loading/loading.d.ts +3 -1
- package/dist/esm/Loading/loading.js +48 -23
- package/dist/esm/Loading/styles/index.less +37 -25
- package/dist/esm/ModalForm/index.d.ts +4 -2
- package/dist/esm/ModalForm/index.js +76 -7
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -1
- package/dist/umd/pcloud-components.min.css +1 -1
- package/dist/umd/pcloud-components.min.js +1 -1
- package/package.json +16 -3
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
@import '../commonStyle/index.less';
|
|
2
|
+
|
|
3
|
+
.@{prefix}-crud {
|
|
4
|
+
height: 100%;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
|
|
8
|
+
&.fullscreen {
|
|
9
|
+
position: fixed;
|
|
10
|
+
inset: 0;
|
|
11
|
+
z-index: 10000;
|
|
12
|
+
padding: 10px;
|
|
13
|
+
background-color: #fff;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&-action-tool-bar {
|
|
17
|
+
display: flex;
|
|
18
|
+
justify-content: space-between;
|
|
19
|
+
align-items: center;
|
|
20
|
+
margin-bottom: 10px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-action-bar,
|
|
24
|
+
&-tool-bar {
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: 8px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.tool-icon {
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
padding: 5px;
|
|
34
|
+
border: 1px solid #e3e3e3;
|
|
35
|
+
border-radius: 50%;
|
|
36
|
+
font-size: 15px;
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
border-color: #2e4dd9;
|
|
40
|
+
color: #2e4dd9;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.rotating {
|
|
44
|
+
animation: rotating 0.5s linear;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// column setting popup
|
|
49
|
+
.column-setting-popup {
|
|
50
|
+
.ant-popover-title {
|
|
51
|
+
padding-right: 10px;
|
|
52
|
+
padding-left: 10px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.ant-popover-inner-content {
|
|
56
|
+
width: 100%;
|
|
57
|
+
padding: 8px 0 4px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.column-setting-title {
|
|
61
|
+
display: flex;
|
|
62
|
+
justify-content: space-between;
|
|
63
|
+
align-items: center;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.column-setting-list {
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
max-height: 300px;
|
|
70
|
+
overflow-y: auto;
|
|
71
|
+
margin-bottom: 0;
|
|
72
|
+
padding-inline-start: 0;
|
|
73
|
+
list-style: none;
|
|
74
|
+
padding: 5px 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.column-setting-list::-webkit-scrollbar {
|
|
78
|
+
width: 5px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.column-setting-list::-webkit-scrollbar-track {
|
|
82
|
+
border-radius: 3px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.column-setting-list::-webkit-scrollbar-thumb {
|
|
86
|
+
width: 5px;
|
|
87
|
+
border-radius: 3px;
|
|
88
|
+
background: #8b8b8b;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.column-setting-item {
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
padding: 8px 10px;
|
|
95
|
+
user-select: none;
|
|
96
|
+
border-radius: 4px;
|
|
97
|
+
margin-bottom: 2px;
|
|
98
|
+
min-height: 32px;
|
|
99
|
+
|
|
100
|
+
&:hover {
|
|
101
|
+
background-color: #f5f5f5;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.column-drag-handle {
|
|
106
|
+
cursor: move;
|
|
107
|
+
margin-right: 8px;
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
color: #666;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.column-setting-footer {
|
|
114
|
+
display: flex;
|
|
115
|
+
justify-content: flex-end;
|
|
116
|
+
padding-top: 4px;
|
|
117
|
+
border-top: 1px solid #f0f0f0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// form display
|
|
122
|
+
.@{prefix}-form {
|
|
123
|
+
transition: all 0.3s ease-in-out;
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
|
|
126
|
+
&.visible {
|
|
127
|
+
max-height: 300px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&.hidden {
|
|
131
|
+
max-height: 0;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
&-table {
|
|
136
|
+
flex: 1;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&-modalform-view {
|
|
140
|
+
.ant-form-item-label > label.ant-form-item-required:not(.ant-form-item-required-mark-optional)::before {
|
|
141
|
+
display: none;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@keyframes rotating {
|
|
146
|
+
from {
|
|
147
|
+
transform: rotate(0deg);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
to {
|
|
151
|
+
transform: rotate(360deg);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { CheckboxValueType } from 'antd/es/checkbox/Group';
|
|
3
|
+
import type { DColumnType } from '../DTable';
|
|
4
|
+
export interface ToolbarProps {
|
|
5
|
+
className?: string;
|
|
6
|
+
fullScreen?: boolean;
|
|
7
|
+
conditionVisible?: boolean;
|
|
8
|
+
columns?: DColumnType[];
|
|
9
|
+
onActions?: {
|
|
10
|
+
setFullScreen?: (fullScreen: boolean) => void;
|
|
11
|
+
handleRefresh?: () => void;
|
|
12
|
+
onColumnSettingChanged?: (checkedList: CheckboxValueType[], sortedColumns?: DColumnType[]) => void;
|
|
13
|
+
setConditionVisible?: (visible: boolean) => void;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
declare function Toolbar({ className, fullScreen, conditionVisible, columns, onActions }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare const _default: import("react").MemoExoticComponent<typeof Toolbar>;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import { memo, useState, useRef, useEffect, useMemo } from 'react';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import { Popover, Checkbox, Button } from 'antd';
|
|
7
|
+
import { ReloadOutlined, FullscreenOutlined, FullscreenExitOutlined, BarsOutlined, HolderOutlined, SearchOutlined } from '@ant-design/icons';
|
|
8
|
+
import Sortable from 'sortablejs';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
function Toolbar(_ref) {
|
|
13
|
+
var className = _ref.className,
|
|
14
|
+
fullScreen = _ref.fullScreen,
|
|
15
|
+
conditionVisible = _ref.conditionVisible,
|
|
16
|
+
_ref$columns = _ref.columns,
|
|
17
|
+
columns = _ref$columns === void 0 ? [] : _ref$columns,
|
|
18
|
+
onActions = _ref.onActions;
|
|
19
|
+
var timer = useRef(null);
|
|
20
|
+
var sortableInstance = useRef(null);
|
|
21
|
+
var sortableContainer = useRef(null);
|
|
22
|
+
var containerNode = useRef(null);
|
|
23
|
+
var _useState = useState(false),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
columnSettingVisible = _useState2[0],
|
|
26
|
+
setColumnSettingVisible = _useState2[1];
|
|
27
|
+
var _useState3 = useState(false),
|
|
28
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
29
|
+
rotating = _useState4[0],
|
|
30
|
+
setRotating = _useState4[1];
|
|
31
|
+
var reloadIconClass = useMemo(function () {
|
|
32
|
+
return classNames('tool-icon', {
|
|
33
|
+
rotating: rotating
|
|
34
|
+
});
|
|
35
|
+
}, [rotating]);
|
|
36
|
+
var checkedValues = useMemo(function () {
|
|
37
|
+
return columns === null || columns === void 0 ? void 0 : columns.map(function (item) {
|
|
38
|
+
return item.title;
|
|
39
|
+
}).filter(function (title) {
|
|
40
|
+
return title !== undefined;
|
|
41
|
+
});
|
|
42
|
+
}, [columns]);
|
|
43
|
+
var _useState5 = useState({
|
|
44
|
+
sortedColumns: columns,
|
|
45
|
+
checkedList: checkedValues
|
|
46
|
+
}),
|
|
47
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
48
|
+
columnSetting = _useState6[0],
|
|
49
|
+
setColumnSetting = _useState6[1];
|
|
50
|
+
var _ref2 = onActions || {},
|
|
51
|
+
setFullScreen = _ref2.setFullScreen,
|
|
52
|
+
handleRefresh = _ref2.handleRefresh;
|
|
53
|
+
var handleFullScreen = function handleFullScreen() {
|
|
54
|
+
var newFullscreen = !fullScreen;
|
|
55
|
+
setFullScreen === null || setFullScreen === void 0 || setFullScreen(newFullscreen);
|
|
56
|
+
};
|
|
57
|
+
var handleDisplaySearch = function handleDisplaySearch() {
|
|
58
|
+
var _onActions$setConditi;
|
|
59
|
+
var visible = !conditionVisible;
|
|
60
|
+
onActions === null || onActions === void 0 || (_onActions$setConditi = onActions.setConditionVisible) === null || _onActions$setConditi === void 0 || _onActions$setConditi.call(onActions, visible);
|
|
61
|
+
};
|
|
62
|
+
var handleReload = function handleReload() {
|
|
63
|
+
setRotating(true);
|
|
64
|
+
handleRefresh === null || handleRefresh === void 0 || handleRefresh();
|
|
65
|
+
if (timer.current) clearTimeout(timer.current);
|
|
66
|
+
timer.current = window.setTimeout(function () {
|
|
67
|
+
setRotating(false);
|
|
68
|
+
}, 500);
|
|
69
|
+
};
|
|
70
|
+
var handleConfirm = function handleConfirm() {
|
|
71
|
+
var _onActions$onColumnSe;
|
|
72
|
+
setColumnSettingVisible(false);
|
|
73
|
+
onActions === null || onActions === void 0 || (_onActions$onColumnSe = onActions.onColumnSettingChanged) === null || _onActions$onColumnSe === void 0 || _onActions$onColumnSe.call(onActions, columnSetting.checkedList, columnSetting.sortedColumns);
|
|
74
|
+
};
|
|
75
|
+
var handleReset = function handleReset() {
|
|
76
|
+
setColumnSetting({
|
|
77
|
+
sortedColumns: columns,
|
|
78
|
+
checkedList: checkedValues
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
var onCheckAllChange = function onCheckAllChange(e) {
|
|
82
|
+
var checked = e.target.checked;
|
|
83
|
+
if (checked) {
|
|
84
|
+
// 全选所有列标题
|
|
85
|
+
var allValues = columns.map(function (item) {
|
|
86
|
+
return item.title;
|
|
87
|
+
}).filter(function (title) {
|
|
88
|
+
return title !== undefined;
|
|
89
|
+
});
|
|
90
|
+
setColumnSetting(function (prev) {
|
|
91
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
92
|
+
checkedList: allValues
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
// 取消全选
|
|
97
|
+
setColumnSetting(function (prev) {
|
|
98
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
99
|
+
checkedList: []
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
useEffect(function () {
|
|
105
|
+
return function () {
|
|
106
|
+
if (timer.current) clearTimeout(timer.current);
|
|
107
|
+
};
|
|
108
|
+
}, []);
|
|
109
|
+
useEffect(function () {
|
|
110
|
+
if (columnSettingVisible && !sortableInstance.current && sortableContainer.current) {
|
|
111
|
+
sortableInstance.current = Sortable.create(sortableContainer.current, {
|
|
112
|
+
animation: 150,
|
|
113
|
+
handle: '.column-drag-handle',
|
|
114
|
+
draggable: '.column-setting-item',
|
|
115
|
+
direction: 'vertical',
|
|
116
|
+
onEnd: function onEnd(_ref3) {
|
|
117
|
+
var oldIndex = _ref3.oldIndex,
|
|
118
|
+
newIndex = _ref3.newIndex;
|
|
119
|
+
if (oldIndex !== undefined && newIndex !== undefined && oldIndex !== newIndex) {
|
|
120
|
+
// 更新临时列顺序
|
|
121
|
+
var newColumns = _toConsumableArray(columnSetting.sortedColumns);
|
|
122
|
+
newColumns.splice(newIndex, 0, newColumns.splice(oldIndex, 1)[0]);
|
|
123
|
+
setColumnSetting(function (prev) {
|
|
124
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
125
|
+
sortedColumns: newColumns
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
} else if (!columnSettingVisible && sortableInstance.current) {
|
|
132
|
+
sortableInstance.current.destroy();
|
|
133
|
+
sortableInstance.current = null;
|
|
134
|
+
}
|
|
135
|
+
return function () {
|
|
136
|
+
if (sortableInstance.current) {
|
|
137
|
+
sortableInstance.current.destroy();
|
|
138
|
+
sortableInstance.current = null;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}, [columns, columnSettingVisible, columnSetting.sortedColumns]);
|
|
142
|
+
var indeterminate = useMemo(function () {
|
|
143
|
+
return !!columnSetting.checkedList.length && columnSetting.checkedList.length < columns.length;
|
|
144
|
+
}, [columnSetting.checkedList, columns.length]);
|
|
145
|
+
var checkAll = useMemo(function () {
|
|
146
|
+
return columnSetting.checkedList.length === columns.length;
|
|
147
|
+
}, [columnSetting.checkedList, columns.length]);
|
|
148
|
+
var popoverContent = useMemo(function () {
|
|
149
|
+
var _columnSetting$sorted;
|
|
150
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
151
|
+
children: [/*#__PURE__*/_jsx("ul", {
|
|
152
|
+
ref: sortableContainer,
|
|
153
|
+
className: "column-setting-list",
|
|
154
|
+
children: (_columnSetting$sorted = columnSetting.sortedColumns) === null || _columnSetting$sorted === void 0 ? void 0 : _columnSetting$sorted.map(function (item) {
|
|
155
|
+
var isChecked = columnSetting.checkedList.includes(item === null || item === void 0 ? void 0 : item.title);
|
|
156
|
+
return /*#__PURE__*/_jsxs("li", {
|
|
157
|
+
className: "column-setting-item",
|
|
158
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
159
|
+
className: "column-drag-handle",
|
|
160
|
+
children: /*#__PURE__*/_jsx(HolderOutlined, {})
|
|
161
|
+
}), /*#__PURE__*/_jsx(Checkbox, {
|
|
162
|
+
checked: isChecked,
|
|
163
|
+
onChange: function onChange(e) {
|
|
164
|
+
var newCheckedList = e.target.checked ? [].concat(_toConsumableArray(columnSetting.checkedList), [item === null || item === void 0 ? void 0 : item.title]).filter(function (title) {
|
|
165
|
+
return title !== undefined;
|
|
166
|
+
}) : columnSetting.checkedList.filter(function (title) {
|
|
167
|
+
return title !== (item === null || item === void 0 ? void 0 : item.title);
|
|
168
|
+
});
|
|
169
|
+
setColumnSetting(function (prev) {
|
|
170
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
171
|
+
checkedList: newCheckedList
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
value: item === null || item === void 0 ? void 0 : item.title,
|
|
176
|
+
children: item === null || item === void 0 ? void 0 : item.title
|
|
177
|
+
})]
|
|
178
|
+
}, (item === null || item === void 0 ? void 0 : item.key) || (item === null || item === void 0 ? void 0 : item.dataIndex));
|
|
179
|
+
})
|
|
180
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
181
|
+
className: "column-setting-footer",
|
|
182
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
183
|
+
type: "link",
|
|
184
|
+
style: {
|
|
185
|
+
color: 'inherit'
|
|
186
|
+
},
|
|
187
|
+
onClick: function onClick() {
|
|
188
|
+
return setColumnSettingVisible(false);
|
|
189
|
+
},
|
|
190
|
+
children: "\u53D6\u6D88"
|
|
191
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
192
|
+
type: "link",
|
|
193
|
+
onClick: handleConfirm,
|
|
194
|
+
children: "\u786E\u5B9A"
|
|
195
|
+
})]
|
|
196
|
+
})]
|
|
197
|
+
});
|
|
198
|
+
}, [columnSetting.sortedColumns, columnSetting.checkedList, handleConfirm]);
|
|
199
|
+
|
|
200
|
+
// 使用useMemo优化Popover标题,避免不必要的重渲染
|
|
201
|
+
var popoverTitle = useMemo(function () {
|
|
202
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
203
|
+
className: "column-setting-title",
|
|
204
|
+
children: [/*#__PURE__*/_jsx(Checkbox, {
|
|
205
|
+
indeterminate: indeterminate,
|
|
206
|
+
onChange: onCheckAllChange,
|
|
207
|
+
checked: checkAll,
|
|
208
|
+
children: "\u5168\u9009"
|
|
209
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
210
|
+
type: "link",
|
|
211
|
+
size: "small",
|
|
212
|
+
onClick: handleReset,
|
|
213
|
+
children: "\u91CD\u7F6E"
|
|
214
|
+
})]
|
|
215
|
+
});
|
|
216
|
+
}, [indeterminate, onCheckAllChange, checkAll, handleReset]);
|
|
217
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
218
|
+
className: className,
|
|
219
|
+
ref: containerNode,
|
|
220
|
+
children: [/*#__PURE__*/_jsx(ReloadOutlined, {
|
|
221
|
+
className: reloadIconClass,
|
|
222
|
+
title: "\u5237\u65B0",
|
|
223
|
+
onClick: handleReload
|
|
224
|
+
}), /*#__PURE__*/_jsx(SearchOutlined, {
|
|
225
|
+
className: "tool-icon",
|
|
226
|
+
title: "".concat(conditionVisible ? '隐藏' : '显示', "\u641C\u7D22"),
|
|
227
|
+
onClick: handleDisplaySearch
|
|
228
|
+
}), fullScreen ? /*#__PURE__*/_jsx(FullscreenExitOutlined, {
|
|
229
|
+
className: "tool-icon",
|
|
230
|
+
title: "\u53D6\u6D88\u5168\u5C4F",
|
|
231
|
+
onClick: handleFullScreen
|
|
232
|
+
}) : /*#__PURE__*/_jsx(FullscreenOutlined, {
|
|
233
|
+
className: "tool-icon",
|
|
234
|
+
title: "\u5168\u5C4F",
|
|
235
|
+
onClick: handleFullScreen
|
|
236
|
+
}), /*#__PURE__*/_jsx(Popover, {
|
|
237
|
+
open: columnSettingVisible,
|
|
238
|
+
title: popoverTitle,
|
|
239
|
+
trigger: "click",
|
|
240
|
+
placement: "bottomRight",
|
|
241
|
+
onOpenChange: function onOpenChange(open) {
|
|
242
|
+
return setColumnSettingVisible(open);
|
|
243
|
+
},
|
|
244
|
+
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
245
|
+
return triggerNode.parentElement;
|
|
246
|
+
},
|
|
247
|
+
overlayClassName: "column-setting-popup",
|
|
248
|
+
content: popoverContent,
|
|
249
|
+
children: /*#__PURE__*/_jsx(BarsOutlined, {
|
|
250
|
+
className: "tool-icon",
|
|
251
|
+
title: "\u5217\u8BBE\u7F6E",
|
|
252
|
+
onClick: function onClick() {
|
|
253
|
+
return setColumnSettingVisible(true);
|
|
254
|
+
}
|
|
255
|
+
})
|
|
256
|
+
})]
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
export default /*#__PURE__*/memo(Toolbar);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModalFuncProps } from 'antd';
|
|
2
|
+
import { DModalProps } from './interface';
|
|
2
3
|
import './styles/index.less';
|
|
3
4
|
declare function DModal(props: DModalProps): import("react/jsx-runtime").JSX.Element;
|
|
4
5
|
declare namespace DModal {
|
|
@@ -9,9 +10,9 @@ declare namespace DModal {
|
|
|
9
10
|
export var warning: import("antd/lib/modal/confirm").ModalFunc;
|
|
10
11
|
export var confirm: import("antd/lib/modal/confirm").ModalFunc;
|
|
11
12
|
export var destroyAll: () => void;
|
|
12
|
-
var _a: (
|
|
13
|
+
var _a: (props: ModalFuncProps) => {
|
|
13
14
|
destroy: () => void;
|
|
14
|
-
update: (configUpdate:
|
|
15
|
+
update: (configUpdate: ModalFuncProps | ((prevConfig: ModalFuncProps) => ModalFuncProps)) => void;
|
|
15
16
|
};
|
|
16
17
|
export { _a as delete };
|
|
17
18
|
}
|
package/dist/esm/DModal/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["children", "mode"]
|
|
3
|
+
var _excluded = ["children", "mode"],
|
|
4
|
+
_excluded2 = ["content", "onOk", "onCancel", "zIndex"];
|
|
4
5
|
import { ConfigContext } from "../ConfigProvider";
|
|
5
6
|
import { Modal } from 'antd';
|
|
6
7
|
import { useContext, useEffect, useMemo, useRef } from 'react';
|
|
@@ -57,22 +58,23 @@ DModal.error = Modal.error;
|
|
|
57
58
|
DModal.warning = Modal.warning;
|
|
58
59
|
DModal.confirm = Modal.confirm;
|
|
59
60
|
DModal.destroyAll = Modal.destroyAll;
|
|
60
|
-
DModal.delete = function (
|
|
61
|
-
var content =
|
|
62
|
-
onOk =
|
|
63
|
-
onCancel =
|
|
64
|
-
zIndex =
|
|
65
|
-
|
|
61
|
+
DModal.delete = function (props) {
|
|
62
|
+
var content = props.content,
|
|
63
|
+
onOk = props.onOk,
|
|
64
|
+
onCancel = props.onCancel,
|
|
65
|
+
zIndex = props.zIndex,
|
|
66
|
+
otherProps = _objectWithoutProperties(props, _excluded2);
|
|
67
|
+
return DModal.confirm(_objectSpread({
|
|
66
68
|
title: '删除提示',
|
|
67
69
|
content: content,
|
|
68
70
|
centered: true,
|
|
69
71
|
closable: true,
|
|
70
72
|
okText: '确定',
|
|
71
73
|
cancelText: '取消',
|
|
72
|
-
className: 'pui-modal-container',
|
|
74
|
+
className: 'pui-modal-container pui-delete-modal',
|
|
73
75
|
onOk: onOk,
|
|
74
76
|
onCancel: onCancel,
|
|
75
77
|
zIndex: zIndex
|
|
76
|
-
});
|
|
78
|
+
}, otherProps));
|
|
77
79
|
};
|
|
78
80
|
export default DModal;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { ModalProps } from 'antd';
|
|
3
|
-
type IModalProps = Omit<ModalProps, '
|
|
2
|
+
import type { ModalProps } from 'antd';
|
|
3
|
+
type IModalProps = Omit<ModalProps, 'className'>;
|
|
4
4
|
export interface DModalProps extends IModalProps {
|
|
5
5
|
children?: ReactNode | undefined;
|
|
6
6
|
mode?: 'absolute' | 'relative' | 'panel';
|
|
7
7
|
}
|
|
8
|
-
export interface DeleteModalProps {
|
|
9
|
-
content?: React.ReactNode;
|
|
10
|
-
onOk?: <T>(..._args: T[]) => T;
|
|
11
|
-
onCancel?: <T>(..._args: T[]) => T;
|
|
12
|
-
zIndex?: number;
|
|
13
|
-
}
|
|
14
8
|
export {};
|
|
@@ -29,6 +29,22 @@ export type DTableProps = Omit<TableProps<any>, 'columns'> & {
|
|
|
29
29
|
/** 表格列配置 */
|
|
30
30
|
columns?: DColumnType[];
|
|
31
31
|
};
|
|
32
|
+
export type DTableRef = {
|
|
33
|
+
/** 手动刷新列表方法
|
|
34
|
+
* @param params 可选的新参数,如果不传则使用现有参数
|
|
35
|
+
*/
|
|
36
|
+
refresh: (params?: TableParamsProps) => void;
|
|
37
|
+
/** 手动刷新列表到指定页数方法
|
|
38
|
+
* @param page 指定页数
|
|
39
|
+
*/
|
|
40
|
+
refreshToPage: (page: number) => void;
|
|
41
|
+
/** 获取当前分页信息 */
|
|
42
|
+
getPaginationState: () => {
|
|
43
|
+
current: number;
|
|
44
|
+
size: number;
|
|
45
|
+
total: number;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
32
48
|
declare const DTable: React.ForwardRefExoticComponent<Omit<TableProps<any>, "columns"> & {
|
|
33
49
|
/** 表格列的基础默认配置,默认所有列居中,表头文字超出显示省略号,详见 antd columns */
|
|
34
50
|
defaultColumnProps?: DColumnType | undefined;
|
|
@@ -42,5 +58,5 @@ declare const DTable: React.ForwardRefExoticComponent<Omit<TableProps<any>, "col
|
|
|
42
58
|
extraParams?: TableParamsProps | undefined;
|
|
43
59
|
/** 表格列配置 */
|
|
44
60
|
columns?: DColumnType[] | undefined;
|
|
45
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
61
|
+
} & React.RefAttributes<HTMLDivElement & DTableRef>>;
|
|
46
62
|
export default DTable;
|
package/dist/esm/DTable/index.js
CHANGED
|
@@ -2,17 +2,19 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
4
|
var _excluded = ["loadMore", "defaultColumnProps", "actionColumn", "showErrorMsg", "extraParams", "dataSource", "rowKey", "scroll", "className", "pagination", "columns", "loading"];
|
|
5
|
-
/*
|
|
6
|
-
* @Author : wangfeihu
|
|
7
|
-
* @Date : 2023-05-09 15:04:48
|
|
8
|
-
* @LastEditors : wangfeihu
|
|
9
|
-
* @LastEditTime : 2023-08-16 16:45:15
|
|
10
|
-
* @Description : 基于antd的Table组件
|
|
5
|
+
/*
|
|
6
|
+
* @Author : wangfeihu
|
|
7
|
+
* @Date : 2023-05-09 15:04:48
|
|
8
|
+
* @LastEditors : wangfeihu
|
|
9
|
+
* @LastEditTime : 2023-08-16 16:45:15
|
|
10
|
+
* @Description : 基于antd的Table组件
|
|
11
11
|
*/
|
|
12
|
-
import React, { forwardRef, useEffect, useRef, useState, useContext, useMemo } from 'react';
|
|
12
|
+
import React, { forwardRef, useEffect, useRef, useState, useContext, useMemo, useImperativeHandle } from 'react';
|
|
13
13
|
import { message, Table } from 'antd';
|
|
14
14
|
import { ConfigContext } from "../ConfigProvider";
|
|
15
15
|
import "./index.less";
|
|
16
|
+
|
|
17
|
+
// DTable组件的Ref接口定义
|
|
16
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
20
|
// 分页器配置项
|
|
@@ -53,7 +55,8 @@ function getActionColumnProps(props, defaultColumnProps) {
|
|
|
53
55
|
var defaultProps = {
|
|
54
56
|
width: 140,
|
|
55
57
|
title: '操作',
|
|
56
|
-
dataIndex: 'action'
|
|
58
|
+
dataIndex: 'action',
|
|
59
|
+
align: 'center'
|
|
57
60
|
};
|
|
58
61
|
return typeof props === 'function' ? _objectSpread(_objectSpread(_objectSpread({}, defaultColumnProps), defaultProps), {}, {
|
|
59
62
|
render: props
|
|
@@ -106,17 +109,21 @@ function InternalTable(props, ref) {
|
|
|
106
109
|
tableParams = _useState4[0],
|
|
107
110
|
setTableParams = _useState4[1];
|
|
108
111
|
|
|
112
|
+
// 隐藏单个分页时, 高度充满
|
|
113
|
+
var extraHeight = useMemo(function () {
|
|
114
|
+
return _pagination['hideOnSinglePage'] ? 0 : 56;
|
|
115
|
+
}, [_pagination]);
|
|
116
|
+
|
|
109
117
|
// 默认垂直滚动高度为 calc(100% - 56px),其中56px为表格header高度,如需修改,需要自行覆盖styles中的相关样式
|
|
110
118
|
var _scroll = scroll ? _objectSpread({
|
|
111
|
-
y:
|
|
119
|
+
y: "calc(100% - ".concat(extraHeight, "px)")
|
|
112
120
|
}, scroll) : {
|
|
113
|
-
y:
|
|
121
|
+
y: "calc(100% - ".concat(extraHeight, "px)")
|
|
114
122
|
};
|
|
115
123
|
|
|
116
124
|
// 合并列属性
|
|
117
125
|
var _columns = getColumns(columns, defaultColumnProps);
|
|
118
126
|
|
|
119
|
-
// 加入操作列
|
|
120
127
|
// 加入操作列
|
|
121
128
|
var _actionColumn = actionColumn ? getActionColumnProps(actionColumn, defaultColumnProps) : undefined;
|
|
122
129
|
if (_actionColumn && _columns instanceof Array) _columns.push(_actionColumn);
|
|
@@ -180,6 +187,12 @@ function InternalTable(props, ref) {
|
|
|
180
187
|
}
|
|
181
188
|
};
|
|
182
189
|
|
|
190
|
+
// 手动刷新方法
|
|
191
|
+
var refresh = function refresh(params) {
|
|
192
|
+
var refreshParams = _objectSpread(_objectSpread({}, tableParams), params);
|
|
193
|
+
loadData(refreshParams);
|
|
194
|
+
};
|
|
195
|
+
|
|
183
196
|
// 监听分页大小变化,如果外部也监听了onChange,则不会触发loadMore,但如果外部onChange返回值为undefined则正常触loadMore
|
|
184
197
|
var onChange = function onChange(page, pageSize) {
|
|
185
198
|
if (_pagination && typeof (_pagination === null || _pagination === void 0 ? void 0 : _pagination.onChange) === 'function') {
|
|
@@ -201,13 +214,30 @@ function InternalTable(props, ref) {
|
|
|
201
214
|
pageSize: tableParams.size,
|
|
202
215
|
onChange: onChange
|
|
203
216
|
}) : _pagination;
|
|
204
|
-
|
|
217
|
+
useImperativeHandle(ref, function () {
|
|
218
|
+
return {
|
|
219
|
+
refresh: refresh,
|
|
220
|
+
// 提供获取当前分页状态的方法
|
|
221
|
+
getPaginationState: function getPaginationState() {
|
|
222
|
+
return {
|
|
223
|
+
current: tableParams.current,
|
|
224
|
+
size: tableParams.size,
|
|
225
|
+
total: tableSource.total
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
// 提供刷新到指定页面的方法
|
|
229
|
+
refreshToPage: function refreshToPage(page) {
|
|
230
|
+
refresh({
|
|
231
|
+
current: page
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
});
|
|
205
236
|
// 数据初始加载
|
|
206
237
|
useEffect(function () {
|
|
207
238
|
return loadData(extraParams);
|
|
208
239
|
}, [dataSource, extraParams]);
|
|
209
240
|
return /*#__PURE__*/_jsx(Table, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
210
|
-
ref: ref,
|
|
211
241
|
rowKey: rowKey,
|
|
212
242
|
className: _className,
|
|
213
243
|
columns: _columns,
|