@ccs-ui/rc-pro 2.3.5 → 2.3.6-alpha-2

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.
Files changed (89) hide show
  1. package/es/aj-captcha/index.d.ts +5 -2
  2. package/es/aj-captcha/index.js +6 -2
  3. package/es/auth/index.d.ts +3 -0
  4. package/es/auth/index.js +3 -0
  5. package/es/button/dropdown.js +5 -17
  6. package/es/button/group.js +47 -65
  7. package/es/button/index.d.ts +4 -11
  8. package/es/button/index.js +10 -13
  9. package/es/cascader/index.d.ts +6 -3
  10. package/es/cascader/index.js +11 -7
  11. package/es/ccs.d.ts +9 -10
  12. package/es/color-picker/index.d.ts +5 -1
  13. package/es/color-picker/index.js +6 -2
  14. package/es/context/index.d.ts +24 -2
  15. package/es/date-picker/index.d.ts +1 -0
  16. package/es/date-picker/index.js +3 -0
  17. package/es/dialog/HookDrawer.js +3 -1
  18. package/es/dialog/HookModal.js +3 -1
  19. package/es/dialog/button.d.ts +1 -1
  20. package/es/dialog/context.d.ts +2 -1
  21. package/es/dialog/hook.d.ts +10 -0
  22. package/es/dialog/index.d.ts +3 -1
  23. package/es/dialog/index.js +3 -0
  24. package/es/editor/index.d.ts +1 -0
  25. package/es/editor/index.js +3 -0
  26. package/es/ellipsis/index.d.ts +21 -5
  27. package/es/ellipsis/index.js +117 -28
  28. package/es/ellipsis/index.less +5 -0
  29. package/es/ellipsis/useMeasure.d.ts +9 -0
  30. package/es/ellipsis/useMeasure.js +142 -0
  31. package/es/ellipsis/useResizeEffect.d.ts +2 -0
  32. package/es/ellipsis/useResizeEffect.js +28 -0
  33. package/es/ellipsis/withStopPropagation.d.ts +4 -0
  34. package/es/ellipsis/withStopPropagation.js +38 -0
  35. package/es/hooks/use-app.d.ts +7 -2
  36. package/es/hooks/use-app.js +8 -3
  37. package/es/hooks/use-selection.d.ts +28 -0
  38. package/es/hooks/use-selection.js +148 -0
  39. package/es/index.d.ts +3 -2
  40. package/es/index.js +3 -2
  41. package/es/interval-button/index.js +3 -0
  42. package/es/layout-keep-alive/index.d.ts +8 -4
  43. package/es/layout-keep-alive/index.js +94 -49
  44. package/es/layout-keep-alive/page.d.ts +2 -2
  45. package/es/layout-keep-alive/page.js +4 -4
  46. package/es/layout-single-page/index.d.ts +5 -2
  47. package/es/layout-single-page/index.js +8 -7
  48. package/es/layout-single-page/page.d.ts +2 -2
  49. package/es/loading/index.d.ts +4 -1
  50. package/es/loading/index.js +4 -1
  51. package/es/pro-table/head.d.ts +8 -7
  52. package/es/pro-table/head.js +54 -100
  53. package/es/pro-table/index.d.ts +8 -8
  54. package/es/pro-table/index.js +8 -3
  55. package/es/pro-table/index.less +8 -3
  56. package/es/pro-table/selection-alert.d.ts +18 -0
  57. package/es/pro-table/selection-alert.js +52 -0
  58. package/es/pro-table/summary.d.ts +8 -0
  59. package/es/pro-table/summary.js +32 -0
  60. package/es/pro-table/table.d.ts +37 -30
  61. package/es/pro-table/table.js +485 -265
  62. package/es/pro-table/tree.d.ts +1 -1
  63. package/es/pro-table/tree.js +9 -15
  64. package/es/pro-tabs/index.d.ts +5 -2
  65. package/es/pro-tabs/index.js +16 -6
  66. package/es/resize-observer.d.ts +2 -2
  67. package/es/resize-observer.js +2 -2
  68. package/es/result/index.d.ts +11 -15
  69. package/es/result/index.js +57 -54
  70. package/es/select/ modal.d.ts +16 -0
  71. package/es/select/ modal.js +100 -0
  72. package/es/select/api.d.ts +25 -0
  73. package/es/select/api.js +67 -0
  74. package/es/select/customize.d.ts +37 -0
  75. package/es/select/customize.js +146 -0
  76. package/es/select/index.d.ts +20 -20
  77. package/es/select/index.js +70 -80
  78. package/es/status-tag/index.d.ts +5 -1
  79. package/es/status-tag/index.js +6 -2
  80. package/es/table/index.d.ts +5 -2
  81. package/es/table/index.js +82 -42
  82. package/es/table/index.less +27 -42
  83. package/es/trigger/index.d.ts +1 -0
  84. package/es/trigger/index.js +1 -0
  85. package/es/upload/index.d.ts +4 -3
  86. package/es/upload/index.js +6 -3
  87. package/es/water-mark/index.d.ts +4 -1
  88. package/es/water-mark/index.js +3 -0
  89. package/package.json +5 -4
@@ -6,9 +6,9 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { DownOutlined, UpOutlined } from '@ant-design/icons';
8
8
  import { useUpdateEffect } from 'ahooks';
9
- import { Button, Card, Form, theme } from 'antd';
9
+ import { Button, Form, theme } from 'antd';
10
10
  import _debounce from 'lodash.debounce';
11
- import React, { useEffect, useMemo, useRef, useState } from 'react';
11
+ import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
12
12
  import { CcsResizeObserver } from '..';
13
13
  import { getShowDpends } from "./_utils";
14
14
  import HeadFormItem from "./form-item";
@@ -17,10 +17,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
17
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
18
18
  /** 操作按钮、查询,重置、列筛选、 */
19
19
  function HeadComponent(_ref) {
20
- var form = _ref.form,
21
- title = _ref.title,
22
- toolbar = _ref.toolbar,
23
- children = _ref.children,
20
+ var toolbar = _ref.toolbar,
24
21
  _ref$expandForm = _ref.expandForm,
25
22
  expandForm = _ref$expandForm === void 0 ? false : _ref$expandForm,
26
23
  _ref$formItems = _ref.formItems,
@@ -28,20 +25,29 @@ function HeadComponent(_ref) {
28
25
  formInitValues = _ref.formInitValues,
29
26
  formItemLabelWidth = _ref.formItemLabelWidth,
30
27
  tableOperation = _ref.tableOperation,
28
+ formRef = _ref.formRef,
31
29
  onSearch = _ref.onSearch;
30
+ var _Form$useForm = Form.useForm(),
31
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
32
+ form = _Form$useForm2[0];
32
33
  var formItemsRef = useRef(null);
34
+ // 根据位置判断是否换行ref
35
+ var endItemRef = useRef(null);
33
36
  // 查询条件是否展开
34
37
  var _useState = useState(expandForm),
35
38
  _useState2 = _slicedToArray(_useState, 2),
36
39
  isExpand = _useState2[0],
37
40
  setIsExpand = _useState2[1];
38
- var _useState3 = useState('hidden'),
41
+ var _useState3 = useState(false),
39
42
  _useState4 = _slicedToArray(_useState3, 2),
40
- visible = _useState4[0],
41
- setVisible = _useState4[1];
43
+ hasMore = _useState4[0],
44
+ onToggle = _useState4[1];
42
45
  useUpdateEffect(function () {
43
46
  setIsExpand(expandForm);
44
47
  }, [expandForm]);
48
+ useImperativeHandle(formRef, function () {
49
+ return form;
50
+ });
45
51
 
46
52
  // 处理form item 依赖
47
53
  var allFormItems = useMemo(function () {
@@ -54,33 +60,26 @@ function HeadComponent(_ref) {
54
60
  return formItems;
55
61
  }, [formItems]);
56
62
 
57
- // 查询条件记录数
58
- var itemLen = allFormItems.length;
59
- var hasItem = itemLen > 0;
60
-
61
- // 尺寸变化重设尺寸
62
- var resizeFn = _debounce(function (hm) {
63
- setVisible(hm);
64
- }, 500);
63
+ // 判断是否有更多条件无法一行显示
64
+ var onEventMore = function onEventMore() {
65
+ var _endItemRef$current, _formItemsRef$current;
66
+ if (!endItemRef.current || !formItemsRef.current || isExpand) return;
67
+ var hasMore = ((_endItemRef$current = endItemRef.current) === null || _endItemRef$current === void 0 || (_endItemRef$current = _endItemRef$current.getClientRects()[0]) === null || _endItemRef$current === void 0 ? void 0 : _endItemRef$current.top) !== ((_formItemsRef$current = formItemsRef.current) === null || _formItemsRef$current === void 0 || (_formItemsRef$current = _formItemsRef$current.getClientRects()[0]) === null || _formItemsRef$current === void 0 ? void 0 : _formItemsRef$current.top);
68
+ onToggle(hasMore);
69
+ };
65
70
 
66
71
  // 监听dom尺寸变化
67
- var onResize = function onResize() {
68
- var _formItemsRef$current;
69
- if (visible === 'hidden') return;
70
- var scrollHeight = ((_formItemsRef$current = formItemsRef.current) === null || _formItemsRef$current === void 0 ? void 0 : _formItemsRef$current.scrollHeight) || 0;
71
- if (scrollHeight === 0) return;
72
- var hm = scrollHeight > 40 ? 'more' : 'visible';
73
- resizeFn(hm);
72
+ var resizeFn = function resizeFn(e) {
73
+ if (e.width === 0) return;
74
+ onEventMore();
74
75
  };
76
+
77
+ // 监听容器尺寸变化
78
+ var onResize = _debounce(resizeFn, 500);
75
79
  useEffect(function () {
76
- var _formItemsRef$current2;
77
- var scrollHeight = ((_formItemsRef$current2 = formItemsRef.current) === null || _formItemsRef$current2 === void 0 ? void 0 : _formItemsRef$current2.scrollHeight) || 0;
78
- setVisible(scrollHeight > 40 ? 'more' : 'visible');
80
+ onEventMore();
79
81
  }, []);
80
82
 
81
- // 是否有更多
82
- var hasMore = itemLen > 1 && visible === 'more';
83
-
84
83
  // 操作按钮
85
84
  var renderSearchBtn = /*#__PURE__*/_jsxs("div", {
86
85
  style: {
@@ -102,9 +101,6 @@ function HeadComponent(_ref) {
102
101
  onClick: function onClick() {
103
102
  return form.submit();
104
103
  },
105
- style: {
106
- marginLeft: !hasMore ? 10 : undefined
107
- },
108
104
  children: "\u67E5\u8BE2"
109
105
  }), toolbar ? null : tableOperation]
110
106
  });
@@ -170,77 +166,35 @@ function HeadComponent(_ref) {
170
166
  // 获取Input的高度
171
167
  var token = theme.useToken().token;
172
168
  var controlHeight = token.rootValue ? "".concat((token.controlHeight / token.rootValue).toFixed(3), "rem") : token.controlHeight;
173
- return /*#__PURE__*/_jsxs(_Fragment, {
174
- children: [hasItem && /*#__PURE__*/_jsxs(_Fragment, {
169
+ return /*#__PURE__*/_jsx(_Fragment, {
170
+ children: allFormItems.length > 0 && /*#__PURE__*/_jsxs(_Fragment, {
175
171
  children: [/*#__PURE__*/_jsx(CcsResizeObserver.Target, {
176
172
  targetRef: formItemsRef,
177
173
  onResize: onResize
178
- }), /*#__PURE__*/_jsx(Card, {
179
- className: "ccs-pl-adaptation",
180
- style: {
181
- boxShadow: 'none',
182
- visibility: visible === 'hidden' ? 'hidden' : 'visible'
183
- },
184
- styles: {
185
- body: {
186
- padding: 16
187
- }
188
- },
189
- bordered: false,
190
- title: title,
191
- children: /*#__PURE__*/_jsxs(Form, {
192
- initialValues: formInitValues,
193
- form: form,
194
- onFinish: onSearch,
195
- layout: "inline",
196
- style: formStyles,
197
- children: [/*#__PURE__*/_jsxs("div", {
198
- style: {
199
- justifyContent: isExpand && hasMore ? 'flex-start' : 'flex-end',
200
- height: isExpand ? 'auto' : controlHeight
201
- },
202
- className: "ccs-pl-adaptation-form",
203
- ref: formItemsRef,
204
- children: [renderFormItems(), isExpand && renderSearchBtn]
205
- }), !isExpand && /*#__PURE__*/_jsx("div", {
206
- style: {
207
- flex: '0 0 auto'
208
- },
209
- children: renderSearchBtn
210
- })]
211
- })
212
- })]
213
- }), toolbar && /*#__PURE__*/_jsxs(Card, {
214
- styles: {
215
- cover: {
216
- borderRadius: 0
217
- },
218
- body: {
219
- display: 'flex',
220
- justifyContent: 'space-between',
221
- width: '100%',
222
- padding: '12px 16px',
223
- alignContent: 'center'
224
- }
225
- },
226
- style: {
227
- borderRadius: 0,
228
- borderLeft: 0,
229
- borderBottom: 0,
230
- borderRight: 0
231
- },
232
- children: [/*#__PURE__*/_jsx("div", {
233
- style: {
234
- flex: '1 1 auto'
235
- },
236
- children: toolbar
237
- }), /*#__PURE__*/_jsx("div", {
238
- style: {
239
- flex: '0 0 auto'
240
- },
241
- children: tableOperation
174
+ }), /*#__PURE__*/_jsxs(Form, {
175
+ initialValues: formInitValues,
176
+ form: form,
177
+ onFinish: onSearch,
178
+ layout: "inline",
179
+ style: formStyles,
180
+ children: [/*#__PURE__*/_jsxs("div", {
181
+ style: {
182
+ justifyContent: isExpand && hasMore ? 'flex-start' : 'flex-end',
183
+ height: isExpand ? 'auto' : controlHeight
184
+ },
185
+ className: "ccs-pl-adaptation-form",
186
+ ref: formItemsRef,
187
+ children: [renderFormItems(), /*#__PURE__*/_jsx("div", {
188
+ ref: endItemRef
189
+ }), isExpand && renderSearchBtn]
190
+ }), !isExpand && /*#__PURE__*/_jsx("div", {
191
+ style: {
192
+ flex: '0 0 auto'
193
+ },
194
+ children: renderSearchBtn
195
+ })]
242
196
  })]
243
- }), children]
197
+ })
244
198
  });
245
199
  }
246
200
  export default HeadComponent;
@@ -1,14 +1,11 @@
1
1
  import './index.less';
2
- import { CcsProTableProps, SearchEventType } from './table';
3
- type TableProps<T> = Omit<CcsProTableProps<T>, 'onSearchAfter' | 'parentFieldName'> & {
4
- /** 请求后格式化结果 */
5
- onSearchAfter?: (data: any, eventType?: SearchEventType) => any;
6
- };
7
- type TableTreeProps<T> = Omit<CcsProTableProps<T>, 'onSearchAfter'> & {
2
+ import SelectionAlert from './selection-alert';
3
+ import TableSummary from './summary';
4
+ import { CcsProTableProps } from './table';
5
+ type TableProps<T> = Omit<CcsProTableProps<T>, 'parentFieldName'>;
6
+ type TableTreeProps<T> = CcsProTableProps<T> & {
8
7
  /** 父级值字段 */
9
8
  parentFieldName: string;
10
- /** 请求后格式化结果 */
11
- onSearchAfter?: (data: any, eventType?: SearchEventType) => any;
12
9
  };
13
10
  /**
14
11
  * 查询表格组件
@@ -19,5 +16,8 @@ type TableTreeProps<T> = Omit<CcsProTableProps<T>, 'onSearchAfter'> & {
19
16
  declare const ProTable: {
20
17
  <T extends object = any>(props: TableProps<T>): import("react/jsx-runtime").JSX.Element;
21
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;
22
22
  };
23
23
  export default ProTable;
@@ -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
  /**
@@ -24,9 +26,12 @@ var ProTable = function ProTable(props) {
24
26
  * @returns
25
27
  */
26
28
  var ProTableTree = function ProTableTree(props) {
27
- return /*#__PURE__*/_jsx(InternalProTable, _objectSpread(_objectSpread({}, props), {}, {
28
- onSearchAfter: props.onSearchAfter
29
- }));
29
+ return /*#__PURE__*/_jsx(InternalProTable, _objectSpread({}, props));
30
30
  };
31
31
  ProTable.Tree = ProTableTree;
32
+ ProTable.SelectionAlert = SelectionAlert;
33
+ ProTable.Summary = TableSummary;
34
+ if (process.env.NODE_ENV !== 'production') {
35
+ ProTable.displayName = 'CcsProTable';
36
+ }
32
37
  export default ProTable;
@@ -49,6 +49,10 @@
49
49
  &-table-content {
50
50
  position: relative;
51
51
  flex: auto;
52
+
53
+ .ant-table-title {
54
+ padding: 0 !important;
55
+ }
52
56
  }
53
57
 
54
58
  &-adaptation {
@@ -61,13 +65,14 @@
61
65
  &-adaptation-form {
62
66
  flex: 1 1 auto;
63
67
  display: flex;
68
+ justify-content: flex-end;
64
69
  flex-wrap: wrap;
65
70
  gap: 16px 10px;
66
71
  overflow: hidden;
67
72
 
68
- // &::-webkit-scrollbar {
69
- // display: none;
70
- // }
73
+ &::-webkit-scrollbar {
74
+ display: none;
75
+ }
71
76
  }
72
77
 
73
78
  .ant-form-item {
@@ -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
+ }
@@ -1,36 +1,52 @@
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, ReactElement, ReactNode } from 'react';
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';
8
+ import { EllipsisProps } from '../ellipsis';
8
9
  import './index.less';
9
10
  type ParamType = Record<string, any>;
10
11
  export type ShowDependType = {
11
12
  name: string;
12
13
  value: any;
13
14
  };
14
- export type SearchEventType = 'search' | 'reset' | 'reload' | 'changePage' | 'initSearch';
15
- type SearchBeforeType = ParamType & {
16
- query: ParamType;
17
- };
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
+ }
18
25
  export type TableColumn<RecordType = any> = (Omit<ColumnGroupType<RecordType>, 'ellipsis'> | Omit<ColumnType<RecordType>, 'ellipsis'>) & {
26
+ dataIndex?: keyof RecordType;
19
27
  /** 隐藏列 */
20
28
  hidden?: boolean;
21
29
  /** 省略显示行数,最大支持10行 */
22
- ellipsis?: boolean | number;
30
+ ellipsis?: Omit<EllipsisProps, 'content'> | boolean | number;
23
31
  };
24
32
  type TableTitleType<T> = {
25
- selectedRows: T[];
33
+ /** 选中Key */
34
+ selectedRowKeys?: React.Key[];
35
+ /** 选中记录 */
36
+ selectedRows?: T[];
37
+ /** table datasource */
26
38
  data: T[];
27
- onClear: () => void;
39
+ /** 清空选择,传入key取消指定选中,否清空所有 */
40
+ onClear: (key?: React.Key) => void;
28
41
  };
29
- export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title'> & {
42
+ export type TableExtraNode<T> = ReactNode | (({ selectedRowKeys, selectedRows, data, onClear, }: TableTitleType<T>) => ReactNode);
43
+ export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title' | 'summary'> & {
30
44
  data?: CCS.TableData<T>;
45
+ /** 为空时,默认一条数据 */
46
+ emptyDefaultOne?: boolean;
31
47
  /** request 方法 */
32
48
  request?: (params: any) => Promise<any>;
33
- /** request 额外参数 dataSource: ['data', 'result']; current: ['data', 'pageNo']; pageSize: ['data', 'pageSize']; total: ['data', 'totalNum'] */
49
+ /** request 额外参数 */
34
50
  requestParam?: ParamType;
35
51
  /** 接口字段指定,默认: */
36
52
  fieldNames?: CcsFieldNamesType;
@@ -43,9 +59,12 @@ export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title'> & {
43
59
  /** 列配置 */
44
60
  columns?: TableColumns<T>;
45
61
  /** table title */
46
- title?: ({ selectedRows, data, onClear }: TableTitleType<T>) => ReactNode;
62
+ title?: TableExtraNode<T>;
63
+ /** table summary */
64
+ summary?: (data: readonly T[], columns: TableColumn<T>[]) => React.ReactNode;
47
65
  };
48
- export type CcsProTableProps<RecordType> = Pick<PropsWithCss, 'className'> & PropsWithNodeChildren & {
66
+ export type TableEventHandle = (eventName: TableEvent, options?: any) => void;
67
+ export type CcsProTableProps<RecordType = any> = Pick<PropsWithCss, 'className'> & PropsWithNodeChildren & {
49
68
  /** api权限标识 */
50
69
  auth?: string | 'ignore';
51
70
  /** 是否初始查询,默认true */
@@ -59,9 +78,9 @@ export type CcsProTableProps<RecordType> = Pick<PropsWithCss, 'className'> & Pro
59
78
  /** 查询form 初始值 */
60
79
  formInitValues?: ParamType;
61
80
  /** 按钮 操作部分 */
62
- toolbar?: ReactElement;
63
- /** 操作按钮扩展 */
64
- toolbarExtra?: ReactElement;
81
+ toolbar?: TableExtraNode<RecordType>;
82
+ /** 边框 */
83
+ bordered?: boolean;
65
84
  /** 展开查询条件,默认false */
66
85
  expandForm?: boolean;
67
86
  /** table 数据区域 */
@@ -79,30 +98,18 @@ export type CcsProTableProps<RecordType> = Pick<PropsWithCss, 'className'> & Pro
79
98
  proRef?: CCS.TableInstanceRef<RecordType>;
80
99
  /** 显示序号 */
81
100
  showNumber?: boolean;
82
- /** 执行search 后回调函数 */
83
- searchEvent?: () => void;
84
- /** 请求前格式化参数 */
85
- onSearchBefore?: (params: SearchBeforeType, eventType?: SearchEventType) => SearchBeforeType;
86
- /** 请求后格式化结果 */
87
- onSearchAfter?: (result: any, eventType?: SearchEventType) => any;
88
- };
89
- export type TableEventType = {
90
- key: 'columnFilter' | 'fullScreen';
91
- columnHiddenKeys?: any;
92
- full?: any;
101
+ /** table 事件 */
102
+ onEvent?: TableEventHandle;
93
103
  };
94
104
  export type TableStickyProps = boolean | (TableSticky & {
95
105
  isInDialog?: boolean;
96
106
  });
97
107
  export declare const classPrefix = "ccs-pl";
98
- export declare const TableSelectionContext: React.Context<{
99
- selectedRows?: any[] | undefined;
100
- }>;
101
108
  /**
102
109
  * 布局组件 包括form、查询、toolbar、table 自动初始化数据
103
110
  * @param CcsProTableType
104
111
  * @param ref
105
112
  * @returns
106
113
  */
107
- declare const InternalProTable: <RecordType extends object = any>(props: CcsProTableProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
114
+ declare const InternalProTable: <RecordType_1 extends object = any>(props: CcsProTableProps<RecordType_1>) => import("react/jsx-runtime").JSX.Element;
108
115
  export default InternalProTable;