@nokecy/qc-ui 1.0.69 → 1.0.71
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/dist/cjs/ag-grid-plus/ag-gridPlus.js +394 -206
- package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +30 -5
- package/dist/cjs/ag-grid-plus/context/gridContext.js +6 -1
- package/dist/cjs/ag-grid-plus/errors/ErrorBoundary.d.ts +36 -0
- package/dist/cjs/ag-grid-plus/errors/ErrorBoundary.js +143 -0
- package/dist/cjs/ag-grid-plus/errors/index.d.ts +3 -0
- package/dist/cjs/ag-grid-plus/errors/index.js +31 -0
- package/dist/cjs/ag-grid-plus/errors/types.d.ts +71 -0
- package/dist/cjs/ag-grid-plus/errors/types.js +137 -0
- package/dist/cjs/ag-grid-plus/hooks/index.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/hooks/index.js +51 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.d.ts +88 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.js +224 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.d.ts +91 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.js +230 -0
- package/dist/cjs/ag-grid-plus/hooks/useGridPlusColumnState.d.ts +1 -8
- package/dist/cjs/ag-grid-plus/hooks/useGridState.d.ts +153 -0
- package/dist/cjs/ag-grid-plus/hooks/useGridState.js +258 -0
- package/dist/cjs/ag-grid-plus/index.d.ts +3 -0
- package/dist/cjs/ag-grid-plus/index.js +85 -0
- package/dist/cjs/ag-grid-plus/interface.d.ts +27 -0
- package/dist/cjs/ag-grid-plus/queryForm/index.js +18 -7
- package/dist/cjs/ag-grid-plus/queryForm/index.less +24 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.d.ts +21 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.js +580 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +86 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.d.ts +5 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.js +12 -0
- package/dist/cjs/ag-grid-plus/querySchemes/constants.d.ts +17 -0
- package/dist/cjs/ag-grid-plus/querySchemes/constants.js +30 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +10 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +65 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +6 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.js +542 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.js +32 -0
- package/dist/cjs/ag-grid-plus/querySchemes/index.d.ts +11 -0
- package/dist/cjs/ag-grid-plus/querySchemes/index.js +113 -0
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +44 -0
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +261 -0
- package/dist/cjs/ag-grid-plus/querySchemes/types.d.ts +143 -0
- package/dist/cjs/ag-grid-plus/querySchemes/types.js +5 -0
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.d.ts +36 -0
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.js +155 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.d.ts +16 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.js +342 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.less +35 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.d.ts +20 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.js +289 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.less +39 -0
- package/dist/cjs/ag-grid-plus/schemes/components/index.d.ts +4 -0
- package/dist/cjs/ag-grid-plus/schemes/components/index.js +19 -0
- package/dist/cjs/ag-grid-plus/schemes/constants.d.ts +23 -0
- package/dist/cjs/ag-grid-plus/schemes/constants.js +39 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +6 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.js +542 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.js +32 -0
- package/dist/cjs/ag-grid-plus/schemes/index.d.ts +16 -0
- package/dist/cjs/ag-grid-plus/schemes/index.js +124 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +64 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.js +368 -0
- package/dist/cjs/ag-grid-plus/schemes/types.d.ts +126 -0
- package/dist/cjs/ag-grid-plus/schemes/types.js +5 -0
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.d.ts +27 -0
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.js +113 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.d.ts +17 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +955 -0
- package/dist/cjs/ag-grid-plus/setting/index.d.ts +1 -1
- package/dist/cjs/ag-grid-plus/setting/index.js +74 -111
- package/dist/cjs/ag-grid-plus/shared/hooks/useSchemeManager.d.ts +66 -0
- package/dist/cjs/ag-grid-plus/shared/hooks/useSchemeManager.js +648 -0
- package/dist/cjs/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +76 -0
- package/dist/cjs/ag-grid-plus/storage/MemoryStorageAdapter.js +276 -0
- package/dist/cjs/ag-grid-plus/storage/SchemeSyncManager.d.ts +104 -0
- package/dist/cjs/ag-grid-plus/storage/SchemeSyncManager.js +593 -0
- package/dist/cjs/ag-grid-plus/storage/globalSyncManager.d.ts +74 -0
- package/dist/cjs/ag-grid-plus/storage/globalSyncManager.js +287 -0
- package/dist/cjs/ag-grid-plus/storage/index.d.ts +8 -0
- package/dist/cjs/ag-grid-plus/storage/index.js +49 -0
- package/dist/cjs/ag-grid-plus/storage/types.d.ts +113 -0
- package/dist/cjs/ag-grid-plus/storage/types.js +5 -0
- package/dist/cjs/ag-grid-plus/types.d.ts +310 -0
- package/dist/cjs/ag-grid-plus/types.js +5 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.d.ts +95 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +265 -0
- package/dist/cjs/ag-grid-plus/utils/constants.d.ts +41 -0
- package/dist/cjs/ag-grid-plus/utils/constants.js +56 -0
- package/dist/cjs/ag-grid-plus/utils/logger.d.ts +34 -0
- package/dist/cjs/ag-grid-plus/utils/logger.js +119 -0
- package/dist/cjs/ag-grid-plus/utils/sanitize.d.ts +15 -0
- package/dist/cjs/ag-grid-plus/utils/sanitize.js +39 -0
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +84 -0
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +395 -206
- package/dist/esm/ag-grid-plus/context/gridContext.d.ts +30 -5
- package/dist/esm/ag-grid-plus/context/gridContext.js +6 -1
- package/dist/esm/ag-grid-plus/errors/ErrorBoundary.d.ts +36 -0
- package/dist/esm/ag-grid-plus/errors/ErrorBoundary.js +137 -0
- package/dist/esm/ag-grid-plus/errors/index.d.ts +3 -0
- package/dist/esm/ag-grid-plus/errors/index.js +2 -0
- package/dist/esm/ag-grid-plus/errors/types.d.ts +71 -0
- package/dist/esm/ag-grid-plus/errors/types.js +135 -0
- package/dist/esm/ag-grid-plus/hooks/index.d.ts +7 -0
- package/dist/esm/ag-grid-plus/hooks/index.js +10 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.d.ts +88 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.js +217 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.d.ts +91 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.js +225 -0
- package/dist/esm/ag-grid-plus/hooks/useGridPlusColumnState.d.ts +1 -8
- package/dist/esm/ag-grid-plus/hooks/useGridState.d.ts +153 -0
- package/dist/esm/ag-grid-plus/hooks/useGridState.js +258 -0
- package/dist/esm/ag-grid-plus/index.d.ts +3 -0
- package/dist/esm/ag-grid-plus/index.js +4 -1
- package/dist/esm/ag-grid-plus/interface.d.ts +27 -0
- package/dist/esm/ag-grid-plus/queryForm/index.less +7 -2
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.d.ts +21 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.js +572 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +86 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/index.d.ts +5 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/index.js +5 -0
- package/dist/esm/ag-grid-plus/querySchemes/constants.d.ts +17 -0
- package/dist/esm/ag-grid-plus/querySchemes/constants.js +24 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +10 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +60 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +6 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.js +537 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.d.ts +7 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.js +27 -0
- package/dist/esm/ag-grid-plus/querySchemes/index.d.ts +11 -0
- package/dist/esm/ag-grid-plus/querySchemes/index.js +20 -0
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +44 -0
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +256 -0
- package/dist/esm/ag-grid-plus/querySchemes/types.d.ts +143 -0
- package/dist/esm/ag-grid-plus/querySchemes/types.js +1 -0
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.d.ts +36 -0
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.js +144 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.d.ts +16 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.js +334 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.less +35 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.d.ts +20 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.js +281 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.less +39 -0
- package/dist/esm/ag-grid-plus/schemes/components/index.d.ts +4 -0
- package/dist/esm/ag-grid-plus/schemes/components/index.js +2 -0
- package/dist/esm/ag-grid-plus/schemes/constants.d.ts +23 -0
- package/dist/esm/ag-grid-plus/schemes/constants.js +33 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +6 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.js +537 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.d.ts +7 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.js +27 -0
- package/dist/esm/ag-grid-plus/schemes/index.d.ts +16 -0
- package/dist/esm/ag-grid-plus/schemes/index.js +25 -0
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +64 -0
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.js +363 -0
- package/dist/esm/ag-grid-plus/schemes/types.d.ts +126 -0
- package/dist/esm/ag-grid-plus/schemes/types.js +1 -0
- package/dist/esm/ag-grid-plus/schemes/utils/validator.d.ts +27 -0
- package/dist/esm/ag-grid-plus/schemes/utils/validator.js +104 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.d.ts +17 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +946 -0
- package/dist/esm/ag-grid-plus/setting/index.d.ts +1 -1
- package/dist/esm/ag-grid-plus/setting/index.js +69 -107
- package/dist/esm/ag-grid-plus/shared/hooks/useSchemeManager.d.ts +66 -0
- package/dist/esm/ag-grid-plus/shared/hooks/useSchemeManager.js +643 -0
- package/dist/esm/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +76 -0
- package/dist/esm/ag-grid-plus/storage/MemoryStorageAdapter.js +273 -0
- package/dist/esm/ag-grid-plus/storage/SchemeSyncManager.d.ts +104 -0
- package/dist/esm/ag-grid-plus/storage/SchemeSyncManager.js +587 -0
- package/dist/esm/ag-grid-plus/storage/globalSyncManager.d.ts +74 -0
- package/dist/esm/ag-grid-plus/storage/globalSyncManager.js +275 -0
- package/dist/esm/ag-grid-plus/storage/index.d.ts +8 -0
- package/dist/esm/ag-grid-plus/storage/index.js +9 -0
- package/dist/esm/ag-grid-plus/storage/types.d.ts +113 -0
- package/dist/esm/ag-grid-plus/storage/types.js +1 -0
- package/dist/esm/ag-grid-plus/types.d.ts +310 -0
- package/dist/esm/ag-grid-plus/types.js +1 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.d.ts +95 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.js +251 -0
- package/dist/esm/ag-grid-plus/utils/constants.d.ts +41 -0
- package/dist/esm/ag-grid-plus/utils/constants.js +50 -0
- package/dist/esm/ag-grid-plus/utils/logger.d.ts +34 -0
- package/dist/esm/ag-grid-plus/utils/logger.js +114 -0
- package/dist/esm/ag-grid-plus/utils/sanitize.d.ts +15 -0
- package/dist/esm/ag-grid-plus/utils/sanitize.js +32 -0
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +8 -2
- package/dist/esm/standardFormDialog/withStandardForm.d.ts +2 -2
- package/dist/umd/qc-ui.min.css +1 -1
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +3 -2
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
import type { UseColumnSchemesReturn } from "../schemes/types";
|
|
3
|
+
import type { UseQuerySchemesReturn } from "../querySchemes/types";
|
|
4
|
+
export interface GridPlusContextValue {
|
|
3
5
|
/**
|
|
4
6
|
* 扩展列,允许运行时动态添加,用于展示用户自定义的列
|
|
5
7
|
*/
|
|
@@ -15,17 +17,40 @@ export declare const GridPlusContext: React.Context<{
|
|
|
15
17
|
*/
|
|
16
18
|
onSaveColumnState: (gridKey: string, columnState: any[]) => void;
|
|
17
19
|
/**
|
|
18
|
-
*
|
|
20
|
+
* 将当前列配置应用为"全局默认",影响所有表格
|
|
19
21
|
* @param columnState 要应用的列配置
|
|
20
22
|
*/
|
|
21
23
|
applyToGlobal: (gridKey: string) => void;
|
|
22
24
|
/**
|
|
23
|
-
*
|
|
25
|
+
* 恢复当前用户当前表格为"默认列配置"
|
|
24
26
|
* @param gridKey 表格唯一标识
|
|
25
27
|
*/
|
|
26
28
|
resetCurrent: (gridKey: string) => void;
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
30
|
+
* 恢复所有用户当前表格为"默认列配置"
|
|
29
31
|
*/
|
|
30
32
|
resetAll: (gridKey: string) => void;
|
|
31
|
-
|
|
33
|
+
/**
|
|
34
|
+
* 列配置方案管理器(可选,新功能)
|
|
35
|
+
* 提供方案的增删改查、切换、保存等功能
|
|
36
|
+
*/
|
|
37
|
+
schemeManager?: UseColumnSchemesReturn;
|
|
38
|
+
/**
|
|
39
|
+
* 查询方案管理器(可选,新功能)
|
|
40
|
+
* 提供查询表单项顺序的方案管理功能
|
|
41
|
+
*/
|
|
42
|
+
querySchemeManager?: UseQuerySchemesReturn;
|
|
43
|
+
/**
|
|
44
|
+
* 当前查询表单项顺序
|
|
45
|
+
*/
|
|
46
|
+
currentQueryOrder?: string[];
|
|
47
|
+
/**
|
|
48
|
+
* 更新查询表单项顺序
|
|
49
|
+
*/
|
|
50
|
+
updateQueryOrder?: (order: string[]) => void;
|
|
51
|
+
/**
|
|
52
|
+
* 查询表单项列表(用于查询方案管理器)
|
|
53
|
+
*/
|
|
54
|
+
queryFormItems?: any[];
|
|
55
|
+
}
|
|
56
|
+
export declare const GridPlusContext: React.Context<GridPlusContextValue>;
|
|
@@ -12,5 +12,10 @@ var GridPlusContext = exports.GridPlusContext = /*#__PURE__*/_react.default.crea
|
|
|
12
12
|
onSaveColumnState: function onSaveColumnState() {},
|
|
13
13
|
applyToGlobal: function applyToGlobal() {},
|
|
14
14
|
resetCurrent: function resetCurrent() {},
|
|
15
|
-
resetAll: function resetAll() {}
|
|
15
|
+
resetAll: function resetAll() {},
|
|
16
|
+
schemeManager: undefined,
|
|
17
|
+
querySchemeManager: undefined,
|
|
18
|
+
currentQueryOrder: undefined,
|
|
19
|
+
updateQueryOrder: function updateQueryOrder() {},
|
|
20
|
+
queryFormItems: []
|
|
16
21
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AG-Grid Plus 错误边界组件
|
|
3
|
+
* 用于捕获 React 渲染错误并提供友好的错误提示
|
|
4
|
+
*/
|
|
5
|
+
import React, { Component, ReactNode } from 'react';
|
|
6
|
+
import { GridPlusError } from './types';
|
|
7
|
+
interface ErrorBoundaryProps {
|
|
8
|
+
/** 子组件 */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** 自定义错误渲染函数 */
|
|
11
|
+
fallback?: (error: GridPlusError, errorInfo: React.ErrorInfo, retry: () => void) => ReactNode;
|
|
12
|
+
/** 错误回调 */
|
|
13
|
+
onError?: (error: GridPlusError, errorInfo: React.ErrorInfo) => void;
|
|
14
|
+
/** 是否显示错误详情(开发环境默认显示) */
|
|
15
|
+
showErrorDetails?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface ErrorBoundaryState {
|
|
18
|
+
hasError: boolean;
|
|
19
|
+
error: GridPlusError | null;
|
|
20
|
+
errorInfo: React.ErrorInfo | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Grid Plus 错误边界组件
|
|
24
|
+
* 捕获子组件树中的 JavaScript 错误,记录错误并展示降级 UI
|
|
25
|
+
*/
|
|
26
|
+
export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
27
|
+
constructor(props: ErrorBoundaryProps);
|
|
28
|
+
static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
|
|
29
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
30
|
+
/**
|
|
31
|
+
* 重置错误状态,重新渲染组件
|
|
32
|
+
*/
|
|
33
|
+
handleRetry: () => void;
|
|
34
|
+
render(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ErrorBoundary = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _antd = require("antd");
|
|
9
|
+
var _types = require("./types");
|
|
10
|
+
var _logger = require("../utils/logger");
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
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); }
|
|
14
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
18
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
19
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
20
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
21
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
22
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
23
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
24
|
+
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; }
|
|
25
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
26
|
+
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); } /**
|
|
27
|
+
* AG-Grid Plus 错误边界组件
|
|
28
|
+
* 用于捕获 React 渲染错误并提供友好的错误提示
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Grid Plus 错误边界组件
|
|
32
|
+
* 捕获子组件树中的 JavaScript 错误,记录错误并展示降级 UI
|
|
33
|
+
*/
|
|
34
|
+
var ErrorBoundary = exports.ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
35
|
+
_inherits(ErrorBoundary, _Component);
|
|
36
|
+
var _super = _createSuper(ErrorBoundary);
|
|
37
|
+
function ErrorBoundary(props) {
|
|
38
|
+
var _this;
|
|
39
|
+
_classCallCheck(this, ErrorBoundary);
|
|
40
|
+
_this = _super.call(this, props);
|
|
41
|
+
/**
|
|
42
|
+
* 重置错误状态,重新渲染组件
|
|
43
|
+
*/
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "handleRetry", function () {
|
|
45
|
+
_this.setState({
|
|
46
|
+
hasError: false,
|
|
47
|
+
error: null,
|
|
48
|
+
errorInfo: null
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
_this.state = {
|
|
52
|
+
hasError: false,
|
|
53
|
+
error: null,
|
|
54
|
+
errorInfo: null
|
|
55
|
+
};
|
|
56
|
+
return _this;
|
|
57
|
+
}
|
|
58
|
+
_createClass(ErrorBoundary, [{
|
|
59
|
+
key: "componentDidCatch",
|
|
60
|
+
value: function componentDidCatch(error, errorInfo) {
|
|
61
|
+
// 将错误包装为 GridPlusError
|
|
62
|
+
var gridError = error instanceof _types.GridPlusError ? error : new _types.GridPlusError(error.message || '组件渲染错误', _types.ErrorType.RENDER_ERROR, _types.ErrorSeverity.HIGH, {
|
|
63
|
+
componentStack: errorInfo.componentStack
|
|
64
|
+
}, error);
|
|
65
|
+
|
|
66
|
+
// 记录错误
|
|
67
|
+
_logger.logger.error('组件渲染错误', gridError.getDetails());
|
|
68
|
+
|
|
69
|
+
// 更新状态
|
|
70
|
+
this.setState({
|
|
71
|
+
error: gridError,
|
|
72
|
+
errorInfo: errorInfo
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// 调用用户提供的错误处理函数
|
|
76
|
+
if (this.props.onError) {
|
|
77
|
+
this.props.onError(gridError, errorInfo);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "render",
|
|
82
|
+
value: function render() {
|
|
83
|
+
var _this$state = this.state,
|
|
84
|
+
hasError = _this$state.hasError,
|
|
85
|
+
error = _this$state.error,
|
|
86
|
+
errorInfo = _this$state.errorInfo;
|
|
87
|
+
var _this$props = this.props,
|
|
88
|
+
children = _this$props.children,
|
|
89
|
+
fallback = _this$props.fallback,
|
|
90
|
+
_this$props$showError = _this$props.showErrorDetails,
|
|
91
|
+
showErrorDetails = _this$props$showError === void 0 ? process.env.NODE_ENV === 'development' : _this$props$showError;
|
|
92
|
+
if (hasError && error) {
|
|
93
|
+
// 如果提供了自定义降级 UI
|
|
94
|
+
if (fallback && errorInfo) {
|
|
95
|
+
return fallback(error, errorInfo, this.handleRetry);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 默认错误 UI
|
|
99
|
+
return /*#__PURE__*/_react.default.createElement(_antd.Result, {
|
|
100
|
+
status: "error",
|
|
101
|
+
title: "\u7EC4\u4EF6\u52A0\u8F7D\u5931\u8D25",
|
|
102
|
+
subTitle: error.getUserMessage(),
|
|
103
|
+
extra: [/*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
104
|
+
type: "primary",
|
|
105
|
+
key: "retry",
|
|
106
|
+
onClick: this.handleRetry
|
|
107
|
+
}, "\u91CD\u8BD5"), /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
108
|
+
key: "refresh",
|
|
109
|
+
onClick: function onClick() {
|
|
110
|
+
return window.location.reload();
|
|
111
|
+
}
|
|
112
|
+
}, "\u5237\u65B0\u9875\u9762")]
|
|
113
|
+
}, showErrorDetails && /*#__PURE__*/_react.default.createElement("div", {
|
|
114
|
+
style: {
|
|
115
|
+
textAlign: 'left',
|
|
116
|
+
padding: '16px',
|
|
117
|
+
backgroundColor: '#f5f5f5',
|
|
118
|
+
borderRadius: '4px',
|
|
119
|
+
maxWidth: '800px',
|
|
120
|
+
margin: '0 auto'
|
|
121
|
+
}
|
|
122
|
+
}, /*#__PURE__*/_react.default.createElement("h4", null, "\u9519\u8BEF\u8BE6\u60C5:"), /*#__PURE__*/_react.default.createElement("pre", {
|
|
123
|
+
style: {
|
|
124
|
+
whiteSpace: 'pre-wrap',
|
|
125
|
+
wordBreak: 'break-word',
|
|
126
|
+
fontSize: '12px',
|
|
127
|
+
color: '#666'
|
|
128
|
+
}
|
|
129
|
+
}, error.message, '\n\n', error.stack, (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.componentStack) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, '\n\n组件堆栈:', errorInfo.componentStack))));
|
|
130
|
+
}
|
|
131
|
+
return children;
|
|
132
|
+
}
|
|
133
|
+
}], [{
|
|
134
|
+
key: "getDerivedStateFromError",
|
|
135
|
+
value: function getDerivedStateFromError(error) {
|
|
136
|
+
// 更新 state 使下一次渲染能够显示降级 UI
|
|
137
|
+
return {
|
|
138
|
+
hasError: true
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}]);
|
|
142
|
+
return ErrorBoundary;
|
|
143
|
+
}(_react.Component);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ErrorBoundary", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _ErrorBoundary.ErrorBoundary;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ErrorSeverity", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _types.ErrorSeverity;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ErrorType", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _types.ErrorType;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "GridPlusError", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _types.GridPlusError;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _types = require("./types");
|
|
31
|
+
var _ErrorBoundary = require("./ErrorBoundary");
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AG-Grid Plus 错误处理类型定义
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="react" />
|
|
5
|
+
/**
|
|
6
|
+
* 错误类型枚举
|
|
7
|
+
*/
|
|
8
|
+
export declare enum ErrorType {
|
|
9
|
+
/** 网络错误 - 请求超时、网络中断 */
|
|
10
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
11
|
+
/** 服务器错误 - 5xx 错误 */
|
|
12
|
+
SERVER_ERROR = "SERVER_ERROR",
|
|
13
|
+
/** 业务错误 - 4xx 错误、业务逻辑错误 */
|
|
14
|
+
BUSINESS_ERROR = "BUSINESS_ERROR",
|
|
15
|
+
/** 数据格式错误 - 响应数据不符合预期 */
|
|
16
|
+
DATA_FORMAT_ERROR = "DATA_FORMAT_ERROR",
|
|
17
|
+
/** 渲染错误 - React 组件错误 */
|
|
18
|
+
RENDER_ERROR = "RENDER_ERROR",
|
|
19
|
+
/** 验证错误 - 输入验证失败 */
|
|
20
|
+
VALIDATION_ERROR = "VALIDATION_ERROR"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 错误严重级别
|
|
24
|
+
*/
|
|
25
|
+
export declare enum ErrorSeverity {
|
|
26
|
+
/** 低 - 不影响功能使用 */
|
|
27
|
+
LOW = "low",
|
|
28
|
+
/** 中 - 部分功能受影响 */
|
|
29
|
+
MEDIUM = "medium",
|
|
30
|
+
/** 高 - 核心功能受影响 */
|
|
31
|
+
HIGH = "high",
|
|
32
|
+
/** 严重 - 组件无法使用 */
|
|
33
|
+
CRITICAL = "critical"
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Grid Plus 错误类
|
|
37
|
+
*/
|
|
38
|
+
export declare class GridPlusError extends Error {
|
|
39
|
+
/** 错误类型 */
|
|
40
|
+
type: ErrorType;
|
|
41
|
+
/** 严重级别 */
|
|
42
|
+
severity: ErrorSeverity;
|
|
43
|
+
/** 错误上下文信息 */
|
|
44
|
+
context?: any;
|
|
45
|
+
/** 原始错误对象 */
|
|
46
|
+
originalError?: Error;
|
|
47
|
+
/** 错误发生时间 */
|
|
48
|
+
timestamp: Date;
|
|
49
|
+
constructor(message: string, type: ErrorType, severity?: ErrorSeverity, context?: any, originalError?: Error);
|
|
50
|
+
/**
|
|
51
|
+
* 获取用户友好的错误消息
|
|
52
|
+
*/
|
|
53
|
+
getUserMessage(): string;
|
|
54
|
+
/**
|
|
55
|
+
* 获取错误详情(用于日志)
|
|
56
|
+
*/
|
|
57
|
+
getDetails(): Record<string, any>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 错误处理配置
|
|
61
|
+
*/
|
|
62
|
+
export interface ErrorHandlingConfig {
|
|
63
|
+
/** 是否显示错误提示 */
|
|
64
|
+
showErrorMessage?: boolean;
|
|
65
|
+
/** 是否记录错误日志 */
|
|
66
|
+
logErrors?: boolean;
|
|
67
|
+
/** 自定义错误处理函数 */
|
|
68
|
+
onError?: (error: GridPlusError) => void;
|
|
69
|
+
/** 自定义错误渲染 */
|
|
70
|
+
renderError?: (error: GridPlusError, retry?: () => void) => React.ReactNode;
|
|
71
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GridPlusError = exports.ErrorType = exports.ErrorSeverity = void 0;
|
|
7
|
+
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); }
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
12
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
13
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
14
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
15
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
16
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
17
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
+
function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
|
|
19
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
20
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
21
|
+
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; }
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
23
|
+
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); }
|
|
24
|
+
/**
|
|
25
|
+
* AG-Grid Plus 错误处理类型定义
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* 错误类型枚举
|
|
29
|
+
*/
|
|
30
|
+
var ErrorType = exports.ErrorType = /*#__PURE__*/function (ErrorType) {
|
|
31
|
+
ErrorType["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
32
|
+
ErrorType["SERVER_ERROR"] = "SERVER_ERROR";
|
|
33
|
+
ErrorType["BUSINESS_ERROR"] = "BUSINESS_ERROR";
|
|
34
|
+
ErrorType["DATA_FORMAT_ERROR"] = "DATA_FORMAT_ERROR";
|
|
35
|
+
ErrorType["RENDER_ERROR"] = "RENDER_ERROR";
|
|
36
|
+
ErrorType["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
37
|
+
return ErrorType;
|
|
38
|
+
}({});
|
|
39
|
+
/**
|
|
40
|
+
* 错误严重级别
|
|
41
|
+
*/
|
|
42
|
+
var ErrorSeverity = exports.ErrorSeverity = /*#__PURE__*/function (ErrorSeverity) {
|
|
43
|
+
ErrorSeverity["LOW"] = "low";
|
|
44
|
+
ErrorSeverity["MEDIUM"] = "medium";
|
|
45
|
+
ErrorSeverity["HIGH"] = "high";
|
|
46
|
+
ErrorSeverity["CRITICAL"] = "critical";
|
|
47
|
+
return ErrorSeverity;
|
|
48
|
+
}({});
|
|
49
|
+
/**
|
|
50
|
+
* Grid Plus 错误类
|
|
51
|
+
*/
|
|
52
|
+
var GridPlusError = exports.GridPlusError = /*#__PURE__*/function (_Error) {
|
|
53
|
+
_inherits(GridPlusError, _Error);
|
|
54
|
+
var _super = _createSuper(GridPlusError);
|
|
55
|
+
function GridPlusError(message, type) {
|
|
56
|
+
var _this;
|
|
57
|
+
var severity = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ErrorSeverity.MEDIUM;
|
|
58
|
+
var context = arguments.length > 3 ? arguments[3] : undefined;
|
|
59
|
+
var originalError = arguments.length > 4 ? arguments[4] : undefined;
|
|
60
|
+
_classCallCheck(this, GridPlusError);
|
|
61
|
+
_this = _super.call(this, message);
|
|
62
|
+
/** 错误类型 */
|
|
63
|
+
_defineProperty(_assertThisInitialized(_this), "type", void 0);
|
|
64
|
+
/** 严重级别 */
|
|
65
|
+
_defineProperty(_assertThisInitialized(_this), "severity", void 0);
|
|
66
|
+
/** 错误上下文信息 */
|
|
67
|
+
_defineProperty(_assertThisInitialized(_this), "context", void 0);
|
|
68
|
+
/** 原始错误对象 */
|
|
69
|
+
_defineProperty(_assertThisInitialized(_this), "originalError", void 0);
|
|
70
|
+
/** 错误发生时间 */
|
|
71
|
+
_defineProperty(_assertThisInitialized(_this), "timestamp", void 0);
|
|
72
|
+
_this.name = 'GridPlusError';
|
|
73
|
+
_this.type = type;
|
|
74
|
+
_this.severity = severity;
|
|
75
|
+
_this.context = context;
|
|
76
|
+
_this.originalError = originalError;
|
|
77
|
+
_this.timestamp = new Date();
|
|
78
|
+
|
|
79
|
+
// 维护正确的原型链
|
|
80
|
+
Object.setPrototypeOf(_assertThisInitialized(_this), GridPlusError.prototype);
|
|
81
|
+
return _this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 获取用户友好的错误消息
|
|
86
|
+
*/
|
|
87
|
+
_createClass(GridPlusError, [{
|
|
88
|
+
key: "getUserMessage",
|
|
89
|
+
value: function getUserMessage() {
|
|
90
|
+
// 在生产环境下,返回更友好的消息
|
|
91
|
+
if (process.env.NODE_ENV === 'production') {
|
|
92
|
+
switch (this.type) {
|
|
93
|
+
case ErrorType.NETWORK_ERROR:
|
|
94
|
+
return '网络连接失败,请检查网络设置后重试';
|
|
95
|
+
case ErrorType.SERVER_ERROR:
|
|
96
|
+
return '服务器暂时无法响应,请稍后重试';
|
|
97
|
+
case ErrorType.BUSINESS_ERROR:
|
|
98
|
+
return this.message || '操作失败,请重试';
|
|
99
|
+
case ErrorType.DATA_FORMAT_ERROR:
|
|
100
|
+
return '数据格式错误,请联系技术支持';
|
|
101
|
+
case ErrorType.RENDER_ERROR:
|
|
102
|
+
return '组件加载失败,请刷新页面重试';
|
|
103
|
+
case ErrorType.VALIDATION_ERROR:
|
|
104
|
+
return this.message || '输入数据不符合要求';
|
|
105
|
+
default:
|
|
106
|
+
return '操作失败,请重试';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return this.message;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 获取错误详情(用于日志)
|
|
114
|
+
*/
|
|
115
|
+
}, {
|
|
116
|
+
key: "getDetails",
|
|
117
|
+
value: function getDetails() {
|
|
118
|
+
return {
|
|
119
|
+
type: this.type,
|
|
120
|
+
severity: this.severity,
|
|
121
|
+
message: this.message,
|
|
122
|
+
timestamp: this.timestamp.toISOString(),
|
|
123
|
+
context: this.context,
|
|
124
|
+
stack: this.stack,
|
|
125
|
+
originalError: this.originalError ? {
|
|
126
|
+
name: this.originalError.name,
|
|
127
|
+
message: this.originalError.message,
|
|
128
|
+
stack: this.originalError.stack
|
|
129
|
+
} : undefined
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}]);
|
|
133
|
+
return GridPlusError;
|
|
134
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
135
|
+
/**
|
|
136
|
+
* 错误处理配置
|
|
137
|
+
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
useGridPlusColumnState: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "useGridPlusColumnState", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function get() {
|
|
12
|
+
return _useGridPlusColumnState.useGridPlusColumnState;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var _useAgGridData = require("./useAgGridData");
|
|
16
|
+
Object.keys(_useAgGridData).forEach(function (key) {
|
|
17
|
+
if (key === "default" || key === "__esModule") return;
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
+
if (key in exports && exports[key] === _useAgGridData[key]) return;
|
|
20
|
+
Object.defineProperty(exports, key, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _useAgGridData[key];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
var _useAgGridCalculation = require("./useAgGridCalculation");
|
|
28
|
+
Object.keys(_useAgGridCalculation).forEach(function (key) {
|
|
29
|
+
if (key === "default" || key === "__esModule") return;
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
|
+
if (key in exports && exports[key] === _useAgGridCalculation[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return _useAgGridCalculation[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _useGridState = require("./useGridState");
|
|
40
|
+
Object.keys(_useGridState).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
43
|
+
if (key in exports && exports[key] === _useGridState[key]) return;
|
|
44
|
+
Object.defineProperty(exports, key, {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function get() {
|
|
47
|
+
return _useGridState[key];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
var _useGridPlusColumnState = require("./useGridPlusColumnState");
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { GridApi } from 'ag-grid-community';
|
|
2
|
+
/**
|
|
3
|
+
* 计算类型
|
|
4
|
+
*/
|
|
5
|
+
export type CalculationType = 'sum' | 'avg' | 'standardDeviation' | false;
|
|
6
|
+
/**
|
|
7
|
+
* 计算列配置
|
|
8
|
+
*/
|
|
9
|
+
export interface CalculationColumn {
|
|
10
|
+
field: string;
|
|
11
|
+
calculateType: CalculationType;
|
|
12
|
+
/** 小数位数,默认 2 */
|
|
13
|
+
transactionAmount?: number;
|
|
14
|
+
/** 是否使用千分位格式化 */
|
|
15
|
+
formatWithCommas?: boolean;
|
|
16
|
+
/** 自定义渲染器(如果存在则跳过计算) */
|
|
17
|
+
cellRenderer?: any;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Hook 配置接口
|
|
21
|
+
*/
|
|
22
|
+
export interface UseAgGridCalculationConfig {
|
|
23
|
+
/** Grid API 引用 */
|
|
24
|
+
gridApi?: GridApi;
|
|
25
|
+
/** 所有列定义 */
|
|
26
|
+
allColDefs?: any[];
|
|
27
|
+
/** 行数据 */
|
|
28
|
+
rowData: any[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Hook 返回值接口
|
|
32
|
+
*/
|
|
33
|
+
export interface UseAgGridCalculationReturn {
|
|
34
|
+
/** 计算并更新底部固定行 */
|
|
35
|
+
calculateSum: () => void;
|
|
36
|
+
/** 处理筛选变化 */
|
|
37
|
+
onFilterChanged: () => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 验证数值有效性
|
|
41
|
+
*/
|
|
42
|
+
declare function isValidNumber(value: any): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 格式化数字(添加千分位)
|
|
45
|
+
*/
|
|
46
|
+
declare function formatNumber(value: number, decimalPlaces?: number): string;
|
|
47
|
+
/**
|
|
48
|
+
* 求和函数
|
|
49
|
+
*/
|
|
50
|
+
declare function sumFn(field: string, displayedData: any[]): number;
|
|
51
|
+
/**
|
|
52
|
+
* 平均值函数
|
|
53
|
+
*/
|
|
54
|
+
declare function avgFn(field: string, displayedData: any[]): number;
|
|
55
|
+
/**
|
|
56
|
+
* 标准差函数
|
|
57
|
+
*/
|
|
58
|
+
declare function standardDeviationFn(field: string, displayedData: any[]): number;
|
|
59
|
+
/**
|
|
60
|
+
* AG-Grid 计算列管理 Hook
|
|
61
|
+
*
|
|
62
|
+
* @description
|
|
63
|
+
* 处理 AG-Grid 底部固定行的聚合计算(求和、平均值、标准差)
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* const { calculateSum, onFilterChanged } = useAgGridCalculation({
|
|
68
|
+
* gridApi,
|
|
69
|
+
* allColDefs,
|
|
70
|
+
* rowData
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* // 在筛选变化时调用
|
|
74
|
+
* <AgGridReact onFilterChanged={onFilterChanged} />
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function useAgGridCalculation(config: UseAgGridCalculationConfig): UseAgGridCalculationReturn;
|
|
78
|
+
/**
|
|
79
|
+
* 导出工具函数供外部使用
|
|
80
|
+
*/
|
|
81
|
+
export declare const calculationUtils: {
|
|
82
|
+
isValidNumber: typeof isValidNumber;
|
|
83
|
+
formatNumber: typeof formatNumber;
|
|
84
|
+
sumFn: typeof sumFn;
|
|
85
|
+
avgFn: typeof avgFn;
|
|
86
|
+
standardDeviationFn: typeof standardDeviationFn;
|
|
87
|
+
};
|
|
88
|
+
export {};
|