@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
@@ -0,0 +1,28 @@
1
+ import { RowSelectMethod } from 'antd/es/table/interface';
2
+ import React from 'react';
3
+ interface PropsType<T> {
4
+ /** 表单受控 value */
5
+ value?: any[];
6
+ /** 默认选择行数据,一般用于回显数据 */
7
+ defaultRows?: T[];
8
+ /** 是否多选 */
9
+ multiple?: boolean;
10
+ /** 字段配置,默认 { key: 'key'; label: 'label' } */
11
+ keyField: string;
12
+ /** 表单受控 onChange*/
13
+ onChange?: (value: any) => void;
14
+ /** 设置选项 */
15
+ onChangeRows?: (options: any[]) => void;
16
+ }
17
+ export default function useTableSelection<T = any>(props: PropsType<T>): {
18
+ onChange: (keys: React.Key[], rows: T[], info: {
19
+ type: RowSelectMethod;
20
+ }) => void;
21
+ onClear: (key?: React.Key) => void;
22
+ selectedRowKeys?: React.Key[] | undefined;
23
+ selectedRows?: T[] | undefined;
24
+ info: {
25
+ type: RowSelectMethod;
26
+ };
27
+ };
28
+ export {};
@@ -0,0 +1,148 @@
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
+ onChangeRows = _ref.onChangeRows;
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,
45
+ _selectionRef$current2 = _selectionRef$current.selectedRowKeys,
46
+ selectedRowKeys = _selectionRef$current2 === void 0 ? [] : _selectionRef$current2,
47
+ selectedRows = _selectionRef$current.selectedRows;
48
+ if (multiple) {
49
+ // 受控调用onChange
50
+ onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys);
51
+ } else {
52
+ onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys[0]);
53
+ }
54
+ onChangeRows === null || onChangeRows === void 0 || onChangeRows(selectedRows || []);
55
+ if (!onChangeValue) setUpdate({});
56
+ });
57
+
58
+ // 生成默认选中数据
59
+ useEffect(function () {
60
+ if (defaultRows && !selectionRef.current.selectedRows) {
61
+ selectionRef.current.selectedRows = defaultRows;
62
+
63
+ // 生成选项
64
+ if (onChangeRows) onChangeRows(defaultRows);
65
+ setUpdate({});
66
+ }
67
+ }, [defaultRows]);
68
+
69
+ // value 变更,与当前选中数据不匹配
70
+ useUpdateEffect(function () {
71
+ if (isEq(value, selectionRef.current.selectedRowKeys)) {
72
+ var _selectionRef$current3;
73
+ var rows = (_selectionRef$current3 = selectionRef.current.selectedRows) === null || _selectionRef$current3 === void 0 ? void 0 : _selectionRef$current3.filter(function () {
74
+ var _ref2;
75
+ var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
76
+ return (_ref2 = value || []) === null || _ref2 === void 0 ? void 0 : _ref2.includes(row[keyField]);
77
+ });
78
+ selectionRef.current = {
79
+ selectedRowKeys: value,
80
+ selectedRows: rows,
81
+ info: {
82
+ type: 'none'
83
+ }
84
+ };
85
+ setUpdate({});
86
+ }
87
+ }, [value]);
88
+
89
+ // 选中改变
90
+ var onChange = useMemoizedFn(function (keys, rows, info) {
91
+ selectionRef.current = {
92
+ selectedRowKeys: keys,
93
+ selectedRows: rows,
94
+ info: info
95
+ };
96
+ // 未知选中数据,在初始化传入数据中匹配
97
+ if (defaultRows && defaultRows.length > 0) {
98
+ rows.forEach(function (row, index) {
99
+ if (!row) {
100
+ var defaultRow = defaultRows.find(function (r) {
101
+ return r[keyField] === keys[index];
102
+ });
103
+ if (defaultRow) rows[index] = defaultRow;
104
+ }
105
+ });
106
+ }
107
+ handleOnChange();
108
+ });
109
+
110
+ // 删除
111
+ var onClear = useMemoizedFn(function (key) {
112
+ // 未传入key,删除全部
113
+ if (!key) {
114
+ selectionRef.current = {
115
+ selectedRowKeys: undefined,
116
+ selectedRows: undefined,
117
+ info: {
118
+ type: 'none'
119
+ }
120
+ };
121
+ } else {
122
+ var _selectionRef$current4 = selectionRef.current,
123
+ _selectionRef$current5 = _selectionRef$current4.selectedRowKeys,
124
+ selectedRowKeys = _selectionRef$current5 === void 0 ? [] : _selectionRef$current5,
125
+ _selectionRef$current6 = _selectionRef$current4.selectedRows,
126
+ selectedRows = _selectionRef$current6 === void 0 ? [] : _selectionRef$current6;
127
+ var newRows = selectedRows.filter(function () {
128
+ var r = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
129
+ return r[keyField] !== key;
130
+ });
131
+ var newKey = selectedRowKeys.filter(function (k) {
132
+ return k !== key;
133
+ });
134
+ selectionRef.current = {
135
+ selectedRowKeys: newKey,
136
+ selectedRows: newRows,
137
+ info: {
138
+ type: 'none'
139
+ }
140
+ };
141
+ }
142
+ handleOnChange();
143
+ });
144
+ return _objectSpread(_objectSpread({}, selectionRef.current), {}, {
145
+ onChange: onChange,
146
+ onClear: onClear
147
+ });
148
+ }
package/es/index.d.ts CHANGED
@@ -7,11 +7,12 @@ export { default as CcsAppConfig } from './config';
7
7
  export { default as CcsDatePicker } from './date-picker';
8
8
  export { default as CcsDialog } from './dialog';
9
9
  export { default as CcsEditor } from './editor';
10
- export { default as CcsLinesEllipsis } from './ellipsis';
10
+ export { default as CcsEllipsis } from './ellipsis';
11
11
  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,7 +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 CcsApiSelect } from './select';
27
+ export { default as CcsSelect } from './select';
27
28
  export { default as CcsStatusTag } from './status-tag';
28
29
  export { default as CcsTable } from './table';
29
30
  export { default as CcsTimePicker } from './time-picker';
package/es/index.js CHANGED
@@ -7,11 +7,12 @@ export { default as CcsAppConfig } from "./config";
7
7
  export { default as CcsDatePicker } from "./date-picker";
8
8
  export { default as CcsDialog } from "./dialog";
9
9
  export { default as CcsEditor } from "./editor";
10
- export { default as CcsLinesEllipsis } from "./ellipsis";
10
+ export { default as CcsEllipsis } from "./ellipsis";
11
11
  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,7 +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 CcsApiSelect } from "./select";
27
+ export { default as CcsSelect } from "./select";
27
28
  export { default as CcsStatusTag } from "./status-tag";
28
29
  export { default as CcsTable } from "./table";
29
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);
@@ -1,17 +1,18 @@
1
1
  import { BreadcrumbProps } from 'antd';
2
2
  import { JSXElementConstructor, ReactElement } from 'react';
3
+ import { Location } from 'react-router';
3
4
  import CCS from '..';
4
5
  import { MenuType } from '../ccs';
5
6
  import './index.less';
6
- export type CacheComponent = {
7
+ export type CacheRouter = {
7
8
  key: string;
8
9
  label: string;
9
- locationKey: string;
10
10
  urlAuthList: string[];
11
11
  timestamp: number;
12
12
  outlet: ReactElement<any, string | JSXElementConstructor<any>> | null;
13
13
  children?: ReactElement<any, string | JSXElementConstructor<any>> | null;
14
14
  breadcrumb: BreadcrumbProps['items'];
15
+ pageLocation: Location;
15
16
  };
16
17
  type PropsType = {
17
18
  maxLen?: number;
@@ -21,5 +22,8 @@ type PropsType = {
21
22
  history: any;
22
23
  };
23
24
  export declare function findMenusByUrl(tree: MenuType | MenuType[], targetUrl: string, parents?: MenuType[]): MenuType[] | null;
24
- export default function KeepAliveTabs({ maxLen, appName, history, menuItems, className, }: PropsType): import("react/jsx-runtime").JSX.Element;
25
- export {};
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;
@@ -19,6 +19,7 @@ import CcsUtils from '@ccs-ui/utils';
19
19
  import { useUpdate, useUpdateEffect } from 'ahooks';
20
20
  import { Button, Dropdown, Empty, Tabs } from 'antd';
21
21
  import classnames from 'classnames';
22
+ import updateHelper from 'immutability-helper';
22
23
  import { useMemo, useRef } from 'react';
23
24
  import { useLocation } from 'react-router';
24
25
  import { useOutlet } from 'react-router-dom';
@@ -123,7 +124,7 @@ export function findMenusByUrl(tree, targetUrl) {
123
124
  }
124
125
  return null;
125
126
  }
126
- export default function KeepAliveTabs(_ref) {
127
+ function KeepAliveTabs(_ref) {
127
128
  var _ref$maxLen = _ref.maxLen,
128
129
  maxLen = _ref$maxLen === void 0 ? 10 : _ref$maxLen,
129
130
  appName = _ref.appName,
@@ -131,10 +132,9 @@ export default function KeepAliveTabs(_ref) {
131
132
  _ref$menuItems = _ref.menuItems,
132
133
  menuItems = _ref$menuItems === void 0 ? [] : _ref$menuItems,
133
134
  className = _ref.className;
134
- var components = useRef([]);
135
+ var routers = useRef([]);
135
136
  var location = useLocation();
136
- var pathname = location.pathname,
137
- locationKey = location.key;
137
+ var pathname = location.pathname;
138
138
  var outlet = useOutlet();
139
139
  var update = useUpdate();
140
140
  var _useAppConfig = useAppConfig(),
@@ -143,19 +143,19 @@ export default function KeepAliveTabs(_ref) {
143
143
  var isColorful = theme === 'colorful';
144
144
 
145
145
  // 超过缓存数量,删除第一个
146
- if (components.current.length >= maxLen) {
147
- components.current = components.current.slice(1);
146
+ if (routers.current.length >= maxLen) {
147
+ routers.current = routers.current.slice(1);
148
148
  }
149
149
 
150
150
  // 菜单改变,更新用户权限信息
151
151
  useUpdateEffect(function () {
152
- components.current.forEach(function (component) {
152
+ routers.current.forEach(function (router) {
153
153
  var _menu$btnAuth;
154
- var menu = findMenuById(menuItems, component.key);
155
- component.urlAuthList = (menu === null || menu === void 0 || (_menu$btnAuth = menu.btnAuth) === null || _menu$btnAuth === void 0 ? void 0 : _menu$btnAuth.map(function (b) {
154
+ var menu = findMenuById(menuItems, router.key);
155
+ router.urlAuthList = (menu === null || menu === void 0 || (_menu$btnAuth = menu.btnAuth) === null || _menu$btnAuth === void 0 ? void 0 : _menu$btnAuth.map(function (b) {
156
156
  return b.code;
157
157
  })) || [];
158
- component.timestamp = new Date().getTime();
158
+ router.timestamp = new Date().getTime();
159
159
  });
160
160
  update();
161
161
  }, [menuItems]);
@@ -234,68 +234,110 @@ export default function KeepAliveTabs(_ref) {
234
234
  breadcrumb: breadcrumb
235
235
  });
236
236
  }, [pathname]);
237
- var component = components.current.find(function (c) {
238
- return c.key === pathname;
237
+ var activeKey = location.key;
238
+ // 路由数据
239
+ var routerIndex = routers.current.findIndex(function (c) {
240
+ return c.pageLocation.pathname === pathname;
239
241
  });
240
- if (!component) {
242
+ if (routerIndex > -1) {
243
+ // 路由已存在、判断search,state是否改变,如改变则更新路由数据
244
+ var router = routers.current[routerIndex];
245
+ if (router.pageLocation.search !== location.search || CcsUtils.jsonStringify(router.pageLocation.state) !== CcsUtils.jsonStringify(location.state)) {
246
+ // 更新路由数据,变更key,路由将重新加载
247
+ routers.current = updateHelper(routers.current, _defineProperty({}, routerIndex, {
248
+ key: {
249
+ $set: location.key
250
+ },
251
+ pageLocation: {
252
+ $set: location
253
+ }
254
+ }));
255
+ } else {
256
+ activeKey = router.pageLocation.key;
257
+ }
258
+ } else {
259
+ // 路由不存在,保存路由数据
241
260
  var _ref3 = curMenu || {},
242
261
  _ref3$btnAuth = _ref3.btnAuth,
243
262
  btnAuth = _ref3$btnAuth === void 0 ? [] : _ref3$btnAuth,
244
263
  _ref3$breadcrumb = _ref3.breadcrumb,
245
264
  breadcrumb = _ref3$breadcrumb === void 0 ? [] : _ref3$breadcrumb;
246
- components.current = [].concat(_toConsumableArray(components.current), [{
247
- locationKey: locationKey,
248
- key: pathname,
249
- timestamp: new Date().getTime(),
250
- label: (curMenu === null || curMenu === void 0 ? void 0 : curMenu.label) || '未知',
251
- outlet: curMenu ? outlet : /*#__PURE__*/_jsx(Empty, {
252
- description: "\u672A\u77E5\u9875\u9762"
253
- }),
254
- urlAuthList: btnAuth.map(function (b) {
255
- return b.code;
256
- }),
257
- breadcrumb: breadcrumb
258
- }]);
265
+ routers.current = updateHelper(routers.current, {
266
+ $push: [{
267
+ key: location.key,
268
+ timestamp: new Date().getTime(),
269
+ label: (curMenu === null || curMenu === void 0 ? void 0 : curMenu.label) || '未知',
270
+ outlet: curMenu ? outlet : /*#__PURE__*/_jsx(Empty, {
271
+ description: "\u672A\u77E5\u9875\u9762"
272
+ }),
273
+ urlAuthList: btnAuth.map(function (b) {
274
+ return b.code;
275
+ }),
276
+ breadcrumb: breadcrumb,
277
+ pageLocation: location
278
+ }]
279
+ });
259
280
  }
260
281
 
282
+ // tab路由切换,携带search,state参数
283
+ var onHistory = function onHistory(key) {
284
+ var tab = routers.current.find(function (c) {
285
+ return c.key === key;
286
+ });
287
+ if (tab) {
288
+ var _tab$pageLocation = tab.pageLocation,
289
+ _pathname = _tab$pageLocation.pathname,
290
+ state = _tab$pageLocation.state,
291
+ search = _tab$pageLocation.search;
292
+ history.push("".concat(_pathname).concat(search), state);
293
+ }
294
+ };
295
+
261
296
  // 页面主动销毁或关闭tab
262
- var onDestroy = function onDestroy(path) {
263
- var index = components.current.findIndex(function (c) {
264
- return c.key === path;
297
+ var onDestroy = function onDestroy(key) {
298
+ var index = routers.current.findIndex(function (c) {
299
+ return c.key === key;
265
300
  });
301
+ // 删除的路由
302
+ var delRouter = routers.current[index];
266
303
  if (index >= 0) {
267
- components.current.splice(index, 1);
268
- components.current = _toConsumableArray(components.current);
269
- if (path !== pathname) {
304
+ routers.current = updateHelper(routers.current, {
305
+ $splice: [[index, 1]]
306
+ });
307
+
308
+ // 不是删的自己
309
+ if (delRouter.key !== key) {
270
310
  update();
271
311
  return;
272
312
  }
273
313
 
274
314
  // 显示首页
275
- if (components.current.length === 0) {
315
+ if (routers.current.length === 0) {
276
316
  history.push('/');
277
317
  return;
278
318
  }
279
319
 
280
320
  // 显示前一个
281
- if (index === components.current.length) {
282
- history.push(components.current[index - 1].key);
321
+ if (index === routers.current.length) {
322
+ onHistory(routers.current[index - 1].key);
283
323
  return;
284
324
  }
285
325
 
286
326
  // 显示后一个
287
- history.push(components.current[index].key);
327
+ onHistory(routers.current[index].key);
288
328
  }
289
329
  };
330
+
331
+ // 扩展操作
290
332
  var onCloseTab = function onCloseTab(key) {
291
333
  // 关闭其他标签
292
334
  if (key === '1') {
293
- components.current = components.current.filter(function (c) {
335
+ routers.current = routers.current.filter(function (c) {
294
336
  return c.key === pathname;
295
337
  });
296
338
  update();
297
339
  } else {
298
- components.current = [];
340
+ routers.current = [];
299
341
  history.push('/');
300
342
  }
301
343
  };
@@ -318,26 +360,25 @@ export default function KeepAliveTabs(_ref) {
318
360
  id: "keep-alive-tabs",
319
361
  hideAdd: true,
320
362
  size: "small",
321
- onChange: function onChange(e) {
322
- history.push(e);
323
- },
363
+ onChange: onHistory,
324
364
  className: classnames(_defineProperty(_defineProperty(_defineProperty({}, 'ccs-keep-alive-tabs', !isColorful), 'dark', isDark), 'ccs-keep-alive-tabs-colorful', isColorful)),
325
- activeKey: pathname,
365
+ activeKey: activeKey,
326
366
  type: "editable-card",
327
367
  onEdit: function onEdit(e) {
328
368
  return onDestroy(e);
329
369
  },
330
- items: components.current,
331
- tabBarExtraContent: components.current.length > 2 ? tabBarExtraContent : null
332
- }), components.current.map(function (_ref4) {
370
+ items: routers.current,
371
+ tabBarExtraContent: routers.current.length > 2 ? tabBarExtraContent : null
372
+ }), routers.current.map(function (_ref4) {
333
373
  var key = _ref4.key,
334
374
  urlAuthList = _ref4.urlAuthList,
335
375
  timestamp = _ref4.timestamp,
336
376
  outlet = _ref4.outlet,
337
- breadcrumb = _ref4.breadcrumb;
377
+ breadcrumb = _ref4.breadcrumb,
378
+ pageLocation = _ref4.pageLocation;
338
379
  return /*#__PURE__*/_jsx(Page, {
339
- active: key === pathname,
340
- location: location,
380
+ active: pageLocation.pathname === pathname,
381
+ location: pageLocation,
341
382
  onDestroy: onDestroy,
342
383
  urlAuthList: urlAuthList,
343
384
  timestamp: timestamp,
@@ -346,4 +387,8 @@ export default function KeepAliveTabs(_ref) {
346
387
  }, key);
347
388
  })]
348
389
  });
349
- }
390
+ }
391
+ if (process.env.NODE_ENV !== 'production') {
392
+ KeepAliveTabs.displayName = 'CcsKeepAliveTabs';
393
+ }
394
+ export default KeepAliveTabs;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { Location } from 'react-router';
3
- import { CacheComponent } from '.';
4
- export type CachePageProps = Pick<CacheComponent, 'breadcrumb' | 'urlAuthList' | 'children' | 'timestamp'> & {
3
+ import { CacheRouter } from '.';
4
+ export type CachePageProps = Pick<CacheRouter, 'breadcrumb' | 'urlAuthList' | 'children' | 'timestamp'> & {
5
5
  /** 选中状态 */
6
6
  active: boolean;
7
7
  /** router location */
@@ -7,20 +7,20 @@ import { DialogElementsHolder } from "../dialog/hook";
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  import { jsxs as _jsxs } from "react/jsx-runtime";
9
9
  export default /*#__PURE__*/memo(function (props) {
10
- var locationRef = useRef(props.location);
11
10
  var children = props.children,
12
11
  active = props.active,
13
12
  urlAuthList = props.urlAuthList,
14
13
  onDestroy = props.onDestroy,
15
- breadcrumb = props.breadcrumb;
16
- var id = "_tab_content_".concat(locationRef.current.key);
14
+ breadcrumb = props.breadcrumb,
15
+ location = props.location;
16
+ var id = "_tab_content_".concat(location.key);
17
17
  var dialogHolderRef = useRef(null);
18
18
  return /*#__PURE__*/_jsx(PageContext.Provider, {
19
19
  value: {
20
20
  id: id,
21
21
  dialogHolderRef: dialogHolderRef,
22
22
  isActive: active,
23
- location: locationRef.current,
23
+ location: location,
24
24
  onDestroy: onDestroy,
25
25
  onAuth: function onAuth(e) {
26
26
  return urlAuthList.includes(e);
@@ -5,5 +5,8 @@ type PropsType = {
5
5
  menuItems: CCS.MenuType[];
6
6
  className?: string;
7
7
  };
8
- export default function SinglePage({ appName, menuItems, className, }: PropsType): import("react/jsx-runtime").JSX.Element;
9
- export {};
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
- export default function SinglePage(_ref) {
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.NotFound, {
57
- style: {
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;
@@ -1,7 +1,7 @@
1
1
  import { JSXElementConstructor, ReactElement } from 'react';
2
2
  import { Location } from 'react-router';
3
- import { CacheComponent } from '../layout-keep-alive';
4
- export type SinglePageProps = Pick<CacheComponent, 'breadcrumb' | 'urlAuthList'> & {
3
+ import { CacheRouter } from '../layout-keep-alive';
4
+ export type SinglePageProps = Pick<CacheRouter, 'breadcrumb' | 'urlAuthList'> & {
5
5
  /** router location */
6
6
  location: Location;
7
7
  /** children */
@@ -7,5 +7,8 @@ type CcsLoadingProps = {
7
7
  /** loading 文字说明 */
8
8
  loadingTip?: string;
9
9
  };
10
- declare const Loading: ({ loading, loadingTip }: CcsLoadingProps) => import("react/jsx-runtime").JSX.Element | null;
10
+ declare const Loading: {
11
+ ({ loading, loadingTip }: CcsLoadingProps): import("react/jsx-runtime").JSX.Element | null;
12
+ displayName: string;
13
+ };
11
14
  export default Loading;
@@ -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: 1000
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;
@@ -1,15 +1,16 @@
1
- import { FormInstance } from 'antd/lib/form';
2
- import { ReactElement } from 'react';
3
- import { PropsWithElementChildren } from '../ccs';
1
+ import { FormInstance } from 'antd';
2
+ import React, { ReactElement } from 'react';
4
3
  import { CcsProTableProps } from './table';
5
- type PropsType<T> = Pick<CcsProTableProps<T>, 'toolbar' | 'formItems' | 'formInitValues' | 'expandForm' | 'title' | 'formItemLabelWidth'> & PropsWithElementChildren & {
4
+ type PropsType<T> = Pick<CcsProTableProps<T>, 'toolbar' | 'formItems' | 'formInitValues' | 'expandForm' | 'formItemLabelWidth'> & {
6
5
  /** 更多查询条件 */
7
6
  hasMore?: boolean;
8
- form: FormInstance<any>;
9
7
  /** table 操作栏 */
10
- tableOperation: ReactElement;
8
+ tableOperation?: ReactElement;
9
+ /** 查询 */
11
10
  onSearch: () => void;
11
+ /** form */
12
+ formRef: React.RefObject<FormInstance<any>>;
12
13
  };
13
14
  /** 操作按钮、查询,重置、列筛选、 */
14
- declare function HeadComponent<T>({ form, title, toolbar, children, expandForm, formItems, formInitValues, formItemLabelWidth, tableOperation, onSearch, }: PropsType<T>): import("react/jsx-runtime").JSX.Element;
15
+ declare function HeadComponent<T>({ toolbar, expandForm, formItems, formInitValues, formItemLabelWidth, tableOperation, formRef, onSearch, }: PropsType<T>): import("react/jsx-runtime").JSX.Element;
15
16
  export default HeadComponent;