@ccs-ui/rc-pro 2.3.6-beta-35 → 2.3.6-beta-37
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/aj-captcha/index.d.ts +5 -2
- package/es/aj-captcha/index.js +6 -2
- package/es/auth/index.d.ts +3 -0
- package/es/auth/index.js +3 -0
- package/es/button/dropdown.js +5 -17
- package/es/button/group.js +31 -48
- package/es/button/index.d.ts +2 -8
- package/es/button/index.js +10 -13
- package/es/cascader/index.d.ts +6 -3
- package/es/cascader/index.js +11 -7
- package/es/ccs.d.ts +1 -7
- package/es/color-picker/index.d.ts +5 -1
- package/es/color-picker/index.js +6 -2
- package/es/date-picker/index.d.ts +1 -0
- package/es/date-picker/index.js +3 -0
- package/es/dialog/button.d.ts +1 -1
- package/es/dialog/index.d.ts +3 -1
- package/es/dialog/index.js +3 -0
- package/es/editor/index.d.ts +1 -0
- package/es/editor/index.js +3 -0
- package/es/ellipsis/index.d.ts +2 -2
- package/es/ellipsis/index.js +7 -6
- package/es/hooks/use-selection.d.ts +28 -0
- package/es/hooks/use-selection.js +146 -0
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/interval-button/index.js +3 -0
- package/es/layout-keep-alive/index.d.ts +5 -2
- package/es/layout-keep-alive/index.js +6 -2
- package/es/layout-single-page/index.d.ts +5 -2
- package/es/layout-single-page/index.js +8 -7
- package/es/loading/index.d.ts +4 -1
- package/es/loading/index.js +4 -1
- package/es/pro-table/index.d.ts +5 -0
- package/es/pro-table/index.js +7 -0
- package/es/pro-table/selection-alert.d.ts +18 -0
- package/es/pro-table/selection-alert.js +52 -0
- package/es/pro-table/summary.d.ts +8 -0
- package/es/pro-table/summary.js +32 -0
- package/es/pro-table/table.d.ts +28 -18
- package/es/pro-table/table.js +266 -132
- package/es/pro-tabs/index.d.ts +5 -2
- package/es/pro-tabs/index.js +6 -2
- package/es/result/index.d.ts +11 -15
- package/es/result/index.js +57 -54
- package/es/select/ modal.d.ts +16 -0
- package/es/select/ modal.js +100 -0
- package/es/select/api.d.ts +25 -0
- package/es/select/api.js +67 -0
- package/es/select/customize.d.ts +33 -0
- package/es/{select-customize/index.js → select/customize.js} +82 -98
- package/es/select/index.d.ts +20 -20
- package/es/select/index.js +69 -80
- package/es/status-tag/index.d.ts +5 -1
- package/es/status-tag/index.js +6 -2
- package/es/table/index.d.ts +5 -2
- package/es/table/index.js +53 -43
- package/es/trigger/index.d.ts +1 -0
- package/es/trigger/index.js +1 -0
- package/es/upload/index.d.ts +4 -3
- package/es/upload/index.js +6 -3
- package/es/water-mark/index.d.ts +4 -1
- package/es/water-mark/index.js +3 -0
- package/package.json +3 -2
- package/es/select-customize/index.d.ts +0 -26
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { useMemoizedFn, useUpdateEffect } from 'ahooks';
|
|
14
|
+
import { useEffect, useRef, useState } from 'react';
|
|
15
|
+
// 判断相对
|
|
16
|
+
function isEq(obj1, obj2) {
|
|
17
|
+
var o1 = obj1 !== null && obj1 !== void 0 ? obj1 : [];
|
|
18
|
+
var o2 = obj2 !== null && obj2 !== void 0 ? obj2 : [];
|
|
19
|
+
if (!Array.isArray(o1)) {
|
|
20
|
+
o1 = [o1];
|
|
21
|
+
}
|
|
22
|
+
return JSON.stringify(o1) !== JSON.stringify(o2);
|
|
23
|
+
}
|
|
24
|
+
export default function useTableSelection(props) {
|
|
25
|
+
var _ref = props || {},
|
|
26
|
+
value = _ref.value,
|
|
27
|
+
defaultRows = _ref.defaultRows,
|
|
28
|
+
_ref$keyField = _ref.keyField,
|
|
29
|
+
keyField = _ref$keyField === void 0 ? 'key' : _ref$keyField,
|
|
30
|
+
multiple = _ref.multiple,
|
|
31
|
+
onChangeValue = _ref.onChange,
|
|
32
|
+
onChangeOptions = _ref.onChangeOptions;
|
|
33
|
+
var _useState = useState({}),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
setUpdate = _useState2[1];
|
|
36
|
+
var selectionRef = useRef({
|
|
37
|
+
selectedRowKeys: ['number', 'string'].includes(_typeof(value)) ? [value] : value,
|
|
38
|
+
selectedRows: defaultRows,
|
|
39
|
+
info: {
|
|
40
|
+
type: 'none'
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
var handleOnChange = useMemoizedFn(function () {
|
|
44
|
+
var _selectionRef$current = selectionRef.current.selectedRowKeys,
|
|
45
|
+
selectedRowKeys = _selectionRef$current === void 0 ? [] : _selectionRef$current;
|
|
46
|
+
if (multiple) {
|
|
47
|
+
// 受控调用onChange
|
|
48
|
+
onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys);
|
|
49
|
+
} else {
|
|
50
|
+
onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys[0]);
|
|
51
|
+
}
|
|
52
|
+
if (!onChangeValue) setUpdate({});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// 生成默认选中数据
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
if (defaultRows && !selectionRef.current.selectedRows) {
|
|
58
|
+
selectionRef.current.selectedRows = defaultRows;
|
|
59
|
+
|
|
60
|
+
// 生成选项
|
|
61
|
+
if (onChangeOptions) onChangeOptions(defaultRows);
|
|
62
|
+
setUpdate({});
|
|
63
|
+
}
|
|
64
|
+
}, [defaultRows]);
|
|
65
|
+
|
|
66
|
+
// value 变更,与当前选中数据不匹配
|
|
67
|
+
useUpdateEffect(function () {
|
|
68
|
+
if (isEq(value, selectionRef.current.selectedRowKeys)) {
|
|
69
|
+
var _selectionRef$current2;
|
|
70
|
+
var rows = (_selectionRef$current2 = selectionRef.current.selectedRows) === null || _selectionRef$current2 === void 0 ? void 0 : _selectionRef$current2.filter(function () {
|
|
71
|
+
var _ref2;
|
|
72
|
+
var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
73
|
+
return (_ref2 = value || []) === null || _ref2 === void 0 ? void 0 : _ref2.includes(row[keyField]);
|
|
74
|
+
});
|
|
75
|
+
selectionRef.current = {
|
|
76
|
+
selectedRowKeys: value,
|
|
77
|
+
selectedRows: rows,
|
|
78
|
+
info: {
|
|
79
|
+
type: 'none'
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
setUpdate({});
|
|
83
|
+
}
|
|
84
|
+
}, [value]);
|
|
85
|
+
|
|
86
|
+
// 选中改变
|
|
87
|
+
var onChange = useMemoizedFn(function (keys, rows, info) {
|
|
88
|
+
selectionRef.current = {
|
|
89
|
+
selectedRowKeys: keys,
|
|
90
|
+
selectedRows: rows,
|
|
91
|
+
info: info
|
|
92
|
+
};
|
|
93
|
+
// 未知选中数据,在初始化传入数据中匹配
|
|
94
|
+
if (defaultRows && defaultRows.length > 0) {
|
|
95
|
+
rows.forEach(function (row, index) {
|
|
96
|
+
if (!row) {
|
|
97
|
+
var defaultRow = defaultRows.find(function (r) {
|
|
98
|
+
return r[keyField] === keys[index];
|
|
99
|
+
});
|
|
100
|
+
if (defaultRow) rows[index] = defaultRow;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
onChangeOptions === null || onChangeOptions === void 0 || onChangeOptions(rows);
|
|
105
|
+
handleOnChange();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// 删除
|
|
109
|
+
var onClear = useMemoizedFn(function (key) {
|
|
110
|
+
// 未传入key,删除全部
|
|
111
|
+
if (!key) {
|
|
112
|
+
selectionRef.current = {
|
|
113
|
+
selectedRowKeys: undefined,
|
|
114
|
+
selectedRows: undefined,
|
|
115
|
+
info: {
|
|
116
|
+
type: 'none'
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
} else {
|
|
120
|
+
var _selectionRef$current3 = selectionRef.current,
|
|
121
|
+
_selectionRef$current4 = _selectionRef$current3.selectedRowKeys,
|
|
122
|
+
selectedRowKeys = _selectionRef$current4 === void 0 ? [] : _selectionRef$current4,
|
|
123
|
+
_selectionRef$current5 = _selectionRef$current3.selectedRows,
|
|
124
|
+
selectedRows = _selectionRef$current5 === void 0 ? [] : _selectionRef$current5;
|
|
125
|
+
var newRows = selectedRows.filter(function () {
|
|
126
|
+
var r = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
127
|
+
return r[keyField] !== key;
|
|
128
|
+
});
|
|
129
|
+
var newKey = selectedRowKeys.filter(function (k) {
|
|
130
|
+
return k !== key;
|
|
131
|
+
});
|
|
132
|
+
selectionRef.current = {
|
|
133
|
+
selectedRowKeys: newKey,
|
|
134
|
+
selectedRows: newRows,
|
|
135
|
+
info: {
|
|
136
|
+
type: 'none'
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
handleOnChange();
|
|
141
|
+
});
|
|
142
|
+
return _objectSpread(_objectSpread({}, selectionRef.current), {}, {
|
|
143
|
+
onChange: onChange,
|
|
144
|
+
onClear: onClear
|
|
145
|
+
});
|
|
146
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { default as CcsFullScreenButton } from './full-screen';
|
|
|
12
12
|
export { default as useAppConfig } from './hooks/use-app';
|
|
13
13
|
export { default as useCcsOnceEvent } from './hooks/use-once-event';
|
|
14
14
|
export { default as useCcsPage } from './hooks/use-page';
|
|
15
|
+
export { default as useTableSelection } from './hooks/use-selection';
|
|
15
16
|
export { default as useCcsTabs } from './hooks/use-tabs';
|
|
16
17
|
export { default as useCcsWindow } from './hooks/use-window';
|
|
17
18
|
export { default as CcsIntervalButton } from './interval-button';
|
|
@@ -23,8 +24,7 @@ export { default as CcsProTable } from './pro-table';
|
|
|
23
24
|
export { default as CcsProTabs } from './pro-tabs';
|
|
24
25
|
export { default as CcsResizeObserver } from './resize-observer';
|
|
25
26
|
export { default as CcsResult } from './result';
|
|
26
|
-
export { default as
|
|
27
|
-
export { default as CcsSelectCustomize } from './select-customize';
|
|
27
|
+
export { default as CcsSelect } from './select';
|
|
28
28
|
export { default as CcsStatusTag } from './status-tag';
|
|
29
29
|
export { default as CcsTable } from './table';
|
|
30
30
|
export { default as CcsTimePicker } from './time-picker';
|
package/es/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { default as CcsFullScreenButton } from "./full-screen";
|
|
|
12
12
|
export { default as useAppConfig } from "./hooks/use-app";
|
|
13
13
|
export { default as useCcsOnceEvent } from "./hooks/use-once-event";
|
|
14
14
|
export { default as useCcsPage } from "./hooks/use-page";
|
|
15
|
+
export { default as useTableSelection } from "./hooks/use-selection";
|
|
15
16
|
export { default as useCcsTabs } from "./hooks/use-tabs";
|
|
16
17
|
export { default as useCcsWindow } from "./hooks/use-window";
|
|
17
18
|
export { default as CcsIntervalButton } from "./interval-button";
|
|
@@ -23,8 +24,7 @@ export { default as CcsProTable } from "./pro-table";
|
|
|
23
24
|
export { default as CcsProTabs } from "./pro-tabs";
|
|
24
25
|
export { default as CcsResizeObserver } from "./resize-observer";
|
|
25
26
|
export { default as CcsResult } from "./result";
|
|
26
|
-
export { default as
|
|
27
|
-
export { default as CcsSelectCustomize } from "./select-customize";
|
|
27
|
+
export { default as CcsSelect } from "./select";
|
|
28
28
|
export { default as CcsStatusTag } from "./status-tag";
|
|
29
29
|
export { default as CcsTable } from "./table";
|
|
30
30
|
export { default as CcsTimePicker } from "./time-picker";
|
|
@@ -122,4 +122,7 @@ function IntervalButton(_ref, ref) {
|
|
|
122
122
|
children: disabled ? "".concat(count, "\u79D2").concat(disabledText) : "".concat(children)
|
|
123
123
|
}));
|
|
124
124
|
}
|
|
125
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
126
|
+
IntervalButton.displayName = 'CcsIntervalButton';
|
|
127
|
+
}
|
|
125
128
|
export default /*#__PURE__*/forwardRef(IntervalButton);
|
|
@@ -22,5 +22,8 @@ type PropsType = {
|
|
|
22
22
|
history: any;
|
|
23
23
|
};
|
|
24
24
|
export declare function findMenusByUrl(tree: MenuType | MenuType[], targetUrl: string, parents?: MenuType[]): MenuType[] | null;
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
declare function KeepAliveTabs({ maxLen, appName, history, menuItems, className, }: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
declare namespace KeepAliveTabs {
|
|
27
|
+
var displayName: string;
|
|
28
|
+
}
|
|
29
|
+
export default KeepAliveTabs;
|
|
@@ -124,7 +124,7 @@ export function findMenusByUrl(tree, targetUrl) {
|
|
|
124
124
|
}
|
|
125
125
|
return null;
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
function KeepAliveTabs(_ref) {
|
|
128
128
|
var _ref$maxLen = _ref.maxLen,
|
|
129
129
|
maxLen = _ref$maxLen === void 0 ? 10 : _ref$maxLen,
|
|
130
130
|
appName = _ref.appName,
|
|
@@ -387,4 +387,8 @@ export default function KeepAliveTabs(_ref) {
|
|
|
387
387
|
}, key);
|
|
388
388
|
})]
|
|
389
389
|
});
|
|
390
|
-
}
|
|
390
|
+
}
|
|
391
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
392
|
+
KeepAliveTabs.displayName = 'CcsKeepAliveTabs';
|
|
393
|
+
}
|
|
394
|
+
export default KeepAliveTabs;
|
|
@@ -5,5 +5,8 @@ type PropsType = {
|
|
|
5
5
|
menuItems: CCS.MenuType[];
|
|
6
6
|
className?: string;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
declare function SinglePage({ appName, menuItems, className }: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare namespace SinglePage {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
export default SinglePage;
|
|
@@ -7,7 +7,7 @@ import CcsResult from "../result";
|
|
|
7
7
|
import "./index.less";
|
|
8
8
|
import Page from "./page";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
|
|
10
|
+
function SinglePage(_ref) {
|
|
11
11
|
var appName = _ref.appName,
|
|
12
12
|
_ref$menuItems = _ref.menuItems,
|
|
13
13
|
menuItems = _ref$menuItems === void 0 ? [] : _ref$menuItems,
|
|
@@ -53,11 +53,12 @@ export default function SinglePage(_ref) {
|
|
|
53
53
|
urlAuthList: menuInfo.auth,
|
|
54
54
|
breadcrumb: menuInfo.breadcrumb,
|
|
55
55
|
children: outlet
|
|
56
|
-
}) : /*#__PURE__*/_jsx(CcsResult.
|
|
57
|
-
|
|
58
|
-
marginTop: 100
|
|
59
|
-
},
|
|
60
|
-
iconWidth: 200
|
|
56
|
+
}) : /*#__PURE__*/_jsx(CcsResult.Page404, {
|
|
57
|
+
subTitle: "\u9875\u9762\u4E0D\u5B58\u5728"
|
|
61
58
|
})
|
|
62
59
|
});
|
|
63
|
-
}
|
|
60
|
+
}
|
|
61
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
62
|
+
SinglePage.displayName = 'CcsSinglePage';
|
|
63
|
+
}
|
|
64
|
+
export default SinglePage;
|
package/es/loading/index.d.ts
CHANGED
|
@@ -7,5 +7,8 @@ type CcsLoadingProps = {
|
|
|
7
7
|
/** loading 文字说明 */
|
|
8
8
|
loadingTip?: string;
|
|
9
9
|
};
|
|
10
|
-
declare const Loading:
|
|
10
|
+
declare const Loading: {
|
|
11
|
+
({ loading, loadingTip }: CcsLoadingProps): import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
11
14
|
export default Loading;
|
package/es/loading/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var Loading = function Loading(_ref) {
|
|
|
11
11
|
position: 'absolute',
|
|
12
12
|
inset: 0,
|
|
13
13
|
background: 'rgba(0, 0, 0, 0.1)',
|
|
14
|
-
zIndex:
|
|
14
|
+
zIndex: 9999
|
|
15
15
|
},
|
|
16
16
|
children: /*#__PURE__*/_jsxs("div", {
|
|
17
17
|
style: {
|
|
@@ -37,4 +37,7 @@ var Loading = function Loading(_ref) {
|
|
|
37
37
|
})
|
|
38
38
|
}) : null;
|
|
39
39
|
};
|
|
40
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
41
|
+
Loading.displayName = 'CcsLoading';
|
|
42
|
+
}
|
|
40
43
|
export default Loading;
|
package/es/pro-table/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import './index.less';
|
|
2
|
+
import SelectionAlert from './selection-alert';
|
|
3
|
+
import TableSummary from './summary';
|
|
2
4
|
import { CcsProTableProps } from './table';
|
|
3
5
|
type TableProps<T> = Omit<CcsProTableProps<T>, 'parentFieldName'>;
|
|
4
6
|
type TableTreeProps<T> = CcsProTableProps<T> & {
|
|
@@ -14,5 +16,8 @@ type TableTreeProps<T> = CcsProTableProps<T> & {
|
|
|
14
16
|
declare const ProTable: {
|
|
15
17
|
<T extends object = any>(props: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
16
18
|
Tree: <T_1 extends object = any>(props: TableTreeProps<T_1>) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
SelectionAlert: typeof SelectionAlert;
|
|
20
|
+
Summary: typeof TableSummary;
|
|
21
|
+
displayName: string;
|
|
17
22
|
};
|
|
18
23
|
export default ProTable;
|
package/es/pro-table/index.js
CHANGED
|
@@ -5,6 +5,8 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import "./index.less";
|
|
8
|
+
import SelectionAlert from "./selection-alert";
|
|
9
|
+
import TableSummary from "./summary";
|
|
8
10
|
import InternalProTable from "./table";
|
|
9
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
12
|
/**
|
|
@@ -27,4 +29,9 @@ var ProTableTree = function ProTableTree(props) {
|
|
|
27
29
|
return /*#__PURE__*/_jsx(InternalProTable, _objectSpread({}, props));
|
|
28
30
|
};
|
|
29
31
|
ProTable.Tree = ProTableTree;
|
|
32
|
+
ProTable.SelectionAlert = SelectionAlert;
|
|
33
|
+
ProTable.Summary = TableSummary;
|
|
34
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
35
|
+
ProTable.displayName = 'CcsProTable';
|
|
36
|
+
}
|
|
30
37
|
export default ProTable;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TagProps } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface PropsType {
|
|
4
|
+
data: any[];
|
|
5
|
+
color?: TagProps['color'];
|
|
6
|
+
fieldNames: {
|
|
7
|
+
key: string;
|
|
8
|
+
label: string;
|
|
9
|
+
};
|
|
10
|
+
onClear: (key?: React.Key) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 显示table行选中项
|
|
14
|
+
* @param PropsType
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export default function SelectionAlert({ data, color, fieldNames, onClear, }: PropsType): import("react/jsx-runtime").JSX.Element | undefined;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DeleteOutlined } from '@ant-design/icons';
|
|
2
|
+
import { Button, Space, Tag } from 'antd';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
/**
|
|
7
|
+
* 显示table行选中项
|
|
8
|
+
* @param PropsType
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export default function SelectionAlert(_ref) {
|
|
12
|
+
var data = _ref.data,
|
|
13
|
+
color = _ref.color,
|
|
14
|
+
_ref$fieldNames = _ref.fieldNames,
|
|
15
|
+
fieldNames = _ref$fieldNames === void 0 ? {
|
|
16
|
+
key: 'key',
|
|
17
|
+
label: 'label'
|
|
18
|
+
} : _ref$fieldNames,
|
|
19
|
+
onClear = _ref.onClear;
|
|
20
|
+
if (!data || data.length === 0) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return /*#__PURE__*/_jsxs(Space, {
|
|
24
|
+
size: 4,
|
|
25
|
+
style: {
|
|
26
|
+
padding: '6px 12px'
|
|
27
|
+
},
|
|
28
|
+
wrap: true,
|
|
29
|
+
children: [data.map(function () {
|
|
30
|
+
var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
31
|
+
return /*#__PURE__*/_jsx(Tag, {
|
|
32
|
+
color: color,
|
|
33
|
+
closable: true,
|
|
34
|
+
onClose: function onClose(e) {
|
|
35
|
+
onClear(row[fieldNames.key]);
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
},
|
|
38
|
+
children: row[fieldNames.label || 'name']
|
|
39
|
+
}, row[fieldNames.key || 'key']);
|
|
40
|
+
}), data.length > 1 && /*#__PURE__*/_jsx(Button, {
|
|
41
|
+
size: "small",
|
|
42
|
+
onClick: function onClick(e) {
|
|
43
|
+
onClear();
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
},
|
|
46
|
+
icon: /*#__PURE__*/_jsx(DeleteOutlined, {}),
|
|
47
|
+
danger: true,
|
|
48
|
+
type: "text",
|
|
49
|
+
children: "\u6E05\u7A7A"
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import CCS from '..';
|
|
2
|
+
interface PropsType {
|
|
3
|
+
data: Record<string, any>;
|
|
4
|
+
columns: CCS.TableColumns;
|
|
5
|
+
hasRowSelection: boolean;
|
|
6
|
+
}
|
|
7
|
+
export default function TableSummary({ data, columns, hasRowSelection, }: PropsType): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Table } from 'antd';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
var SummaryIndex = -1;
|
|
5
|
+
export default function TableSummary(_ref) {
|
|
6
|
+
var _ref$data = _ref.data,
|
|
7
|
+
data = _ref$data === void 0 ? {} : _ref$data,
|
|
8
|
+
columns = _ref.columns,
|
|
9
|
+
hasRowSelection = _ref.hasRowSelection;
|
|
10
|
+
SummaryIndex = -1;
|
|
11
|
+
var renderCell = function renderCell(cs) {
|
|
12
|
+
return cs.map(function (d) {
|
|
13
|
+
if (d.children && d.children.length > 0) {
|
|
14
|
+
return renderCell(d.children);
|
|
15
|
+
}
|
|
16
|
+
SummaryIndex += 1;
|
|
17
|
+
return /*#__PURE__*/_jsx(Table.Summary.Cell, {
|
|
18
|
+
index: 0,
|
|
19
|
+
children: data[d.dataIndex]
|
|
20
|
+
}, SummaryIndex);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
if (hasRowSelection) SummaryIndex += 1;
|
|
24
|
+
return /*#__PURE__*/_jsx(Table.Summary, {
|
|
25
|
+
fixed: true,
|
|
26
|
+
children: /*#__PURE__*/_jsxs(Table.Summary.Row, {
|
|
27
|
+
children: [hasRowSelection && /*#__PURE__*/_jsx(Table.Summary.Cell, {
|
|
28
|
+
index: SummaryIndex
|
|
29
|
+
}), renderCell(columns)]
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}
|
package/es/pro-table/table.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TableProps } from 'antd';
|
|
2
2
|
import { ColumnGroupType, ColumnType } from 'antd/es/table';
|
|
3
3
|
import { TableSticky } from 'rc-table/lib/interface';
|
|
4
|
-
import React, { CSSProperties,
|
|
4
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
5
5
|
import CCS from '..';
|
|
6
6
|
import { PropsWithCss, PropsWithNodeChildren, TableColumns } from '../ccs';
|
|
7
7
|
import { CcsFieldNamesType } from '../context';
|
|
@@ -12,7 +12,16 @@ export type ShowDependType = {
|
|
|
12
12
|
name: string;
|
|
13
13
|
value: any;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export declare enum TableEvent {
|
|
16
|
+
Search = "search",
|
|
17
|
+
Reset = "reset",
|
|
18
|
+
Reload = "reload",
|
|
19
|
+
ChangePage = "changePage",
|
|
20
|
+
InitSearch = "initSearch",
|
|
21
|
+
FullScreen = "fullScreen",
|
|
22
|
+
ColumnFilter = "columnFilter",
|
|
23
|
+
SelectedRows = "SelectedRows"
|
|
24
|
+
}
|
|
16
25
|
export type TableColumn<RecordType = any> = (Omit<ColumnGroupType<RecordType>, 'ellipsis'> | Omit<ColumnType<RecordType>, 'ellipsis'>) & {
|
|
17
26
|
dataIndex?: keyof RecordType;
|
|
18
27
|
/** 隐藏列 */
|
|
@@ -21,11 +30,17 @@ export type TableColumn<RecordType = any> = (Omit<ColumnGroupType<RecordType>, '
|
|
|
21
30
|
ellipsis?: Omit<EllipsisProps, 'content'> | boolean | number;
|
|
22
31
|
};
|
|
23
32
|
type TableTitleType<T> = {
|
|
24
|
-
|
|
33
|
+
/** 选中Key */
|
|
34
|
+
selectedRowKeys?: React.Key[];
|
|
35
|
+
/** 选中记录 */
|
|
36
|
+
selectedRows?: T[];
|
|
37
|
+
/** table datasource */
|
|
25
38
|
data: T[];
|
|
26
|
-
|
|
39
|
+
/** 清空选择,传入key取消指定选中,否清空所有 */
|
|
40
|
+
onClear: (key?: React.Key) => void;
|
|
27
41
|
};
|
|
28
|
-
export type
|
|
42
|
+
export type TableExtraNode<T> = ReactNode | (({ selectedRowKeys, selectedRows, data, onClear, }: TableTitleType<T>) => ReactNode);
|
|
43
|
+
export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title' | 'summary'> & {
|
|
29
44
|
data?: CCS.TableData<T>;
|
|
30
45
|
/** 为空时,默认一条数据 */
|
|
31
46
|
emptyDefaultOne?: boolean;
|
|
@@ -44,9 +59,12 @@ export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title'> & {
|
|
|
44
59
|
/** 列配置 */
|
|
45
60
|
columns?: TableColumns<T>;
|
|
46
61
|
/** table title */
|
|
47
|
-
title?:
|
|
62
|
+
title?: TableExtraNode<T>;
|
|
63
|
+
/** table summary */
|
|
64
|
+
summary?: (data: readonly T[], columns: TableColumn<T>[]) => React.ReactNode;
|
|
48
65
|
};
|
|
49
|
-
export type
|
|
66
|
+
export type TableEventHandle = (eventName: TableEvent, options?: any) => void;
|
|
67
|
+
export type CcsProTableProps<RecordType = any> = Pick<PropsWithCss, 'className'> & PropsWithNodeChildren & {
|
|
50
68
|
/** api权限标识 */
|
|
51
69
|
auth?: string | 'ignore';
|
|
52
70
|
/** 是否初始查询,默认true */
|
|
@@ -60,9 +78,7 @@ export type CcsProTableProps<RecordType> = Pick<PropsWithCss, 'className'> & Pro
|
|
|
60
78
|
/** 查询form 初始值 */
|
|
61
79
|
formInitValues?: ParamType;
|
|
62
80
|
/** 按钮 操作部分 */
|
|
63
|
-
toolbar?:
|
|
64
|
-
/** 操作按钮扩展 */
|
|
65
|
-
toolbarExtra?: ReactElement;
|
|
81
|
+
toolbar?: TableExtraNode<RecordType>;
|
|
66
82
|
/** 边框 */
|
|
67
83
|
bordered?: boolean;
|
|
68
84
|
/** 展开查询条件,默认false */
|
|
@@ -82,19 +98,13 @@ export type CcsProTableProps<RecordType> = Pick<PropsWithCss, 'className'> & Pro
|
|
|
82
98
|
proRef?: CCS.TableInstanceRef<RecordType>;
|
|
83
99
|
/** 显示序号 */
|
|
84
100
|
showNumber?: boolean;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
key: 'columnFilter' | 'fullScreen';
|
|
88
|
-
columnHiddenKeys?: any;
|
|
89
|
-
full?: any;
|
|
101
|
+
/** table 事件 */
|
|
102
|
+
onEvent?: TableEventHandle;
|
|
90
103
|
};
|
|
91
104
|
export type TableStickyProps = boolean | (TableSticky & {
|
|
92
105
|
isInDialog?: boolean;
|
|
93
106
|
});
|
|
94
107
|
export declare const classPrefix = "ccs-pl";
|
|
95
|
-
export declare const TableSelectionContext: React.Context<{
|
|
96
|
-
selectedRows?: any[] | undefined;
|
|
97
|
-
}>;
|
|
98
108
|
/**
|
|
99
109
|
* 布局组件 包括form、查询、toolbar、table 自动初始化数据
|
|
100
110
|
* @param CcsProTableType
|