@cloudtower/eagle 0.33.16 → 0.33.18
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/core/CTModalFooterError/CTModalFooterError.style.js +5 -0
- package/dist/cjs/core/CTModalFooterError/index.js +46 -0
- package/dist/cjs/core/ConfigProvider/index.js +8 -2
- package/dist/cjs/coreX/KubeConfigModal/KubeConfigModal.style.js +29 -0
- package/dist/cjs/coreX/KubeConfigModal/index.js +102 -0
- package/dist/cjs/coreX/KubeConfigModal/utils.js +25 -0
- package/dist/cjs/hooks/useCTErrorMsg.js +25 -0
- package/dist/cjs/index.js +117 -112
- package/dist/cjs/stats1.html +1 -1
- package/dist/cjs/utils/cterror.js +62 -0
- package/dist/components.css +2973 -2969
- package/dist/esm/core/CTModalFooterError/CTModalFooterError.style.js +3 -0
- package/dist/esm/core/CTModalFooterError/index.js +40 -0
- package/dist/esm/core/ConfigProvider/index.js +9 -4
- package/dist/esm/coreX/KubeConfigModal/KubeConfigModal.style.js +20 -0
- package/dist/esm/coreX/KubeConfigModal/index.js +96 -0
- package/dist/esm/coreX/KubeConfigModal/utils.js +22 -0
- package/dist/esm/hooks/useCTErrorMsg.js +23 -0
- package/dist/esm/index.js +3 -1
- package/dist/esm/stats1.html +1 -1
- package/dist/esm/utils/cterror.js +56 -0
- package/dist/linaria.merged.scss +3311 -3306
- package/dist/src/core/CTModalFooterError/CTModalFooterError.style.d.ts +1 -0
- package/dist/src/core/CTModalFooterError/CTModalFooterError.type.d.ts +56 -0
- package/dist/src/core/CTModalFooterError/index.d.ts +3 -0
- package/dist/src/core/ConfigProvider/index.d.ts +6 -1
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/coreX/index.d.ts +1 -0
- package/dist/src/hooks/__tests__/useCTErrorMsg.test.d.ts +1 -0
- package/dist/src/hooks/index.d.ts +1 -0
- package/dist/src/hooks/useCTErrorMsg.d.ts +7 -0
- package/dist/src/utils/__test__/cterror.test.d.ts +1 -0
- package/dist/src/utils/cterror.d.ts +29 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/type.d.ts +32 -0
- package/dist/stories/docs/core/CTModalFooterError.stories.d.ts +47 -0
- package/dist/style.css +2861 -2857
- package/package.json +5 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CTModalFooterErrorStyle: import("@linaria/core").LinariaClassName;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CTError } from "../../utils/cterror";
|
|
3
|
+
import { UseCTErrorMsgOptions } from "../../hooks/useCTErrorMsg";
|
|
4
|
+
/**
|
|
5
|
+
* 错误详情渲染器的 props
|
|
6
|
+
*/
|
|
7
|
+
export interface ErrorItemRenderProps {
|
|
8
|
+
/** 单条错误消息 */
|
|
9
|
+
errorMsg: string | undefined;
|
|
10
|
+
/** 错误索引 */
|
|
11
|
+
index: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 错误容器渲染器的 props
|
|
15
|
+
*/
|
|
16
|
+
export interface ErrorContainerRenderProps {
|
|
17
|
+
/** 自定义类名 */
|
|
18
|
+
className?: string;
|
|
19
|
+
/** 子元素 */
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
/** 错误信息 */
|
|
22
|
+
errorMsgs: (string | undefined)[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* CTModalFooterError 组件的 props
|
|
26
|
+
*/
|
|
27
|
+
export interface CTModalFooterErrorProps {
|
|
28
|
+
/**
|
|
29
|
+
* 错误对象,支持多种格式的错误
|
|
30
|
+
* - AxiosError: Axios 请求错误
|
|
31
|
+
* - CloudTowerErrorResponse: 服务端响应错误
|
|
32
|
+
* - 其他类型: 会被转换为字符串显示
|
|
33
|
+
*/
|
|
34
|
+
error: CTError;
|
|
35
|
+
/**
|
|
36
|
+
* 自定义类名,会应用到错误容器上
|
|
37
|
+
*/
|
|
38
|
+
className?: string;
|
|
39
|
+
/**
|
|
40
|
+
* 自定义错误容器渲染器
|
|
41
|
+
* 用于自定义整个错误信息的容器样式和结构
|
|
42
|
+
* @default 使用内置的 span 容器,应用了默认样式
|
|
43
|
+
*/
|
|
44
|
+
ErrorContainerRender?: React.FC<ErrorContainerRenderProps>;
|
|
45
|
+
/**
|
|
46
|
+
* 自定义错误详情渲染器
|
|
47
|
+
* 用于自定义单条错误信息的渲染方式
|
|
48
|
+
* 如果不提供,多条错误会被拼接成一个字符串显示
|
|
49
|
+
*/
|
|
50
|
+
ErrorItemRender?: React.FC<ErrorItemRenderProps>;
|
|
51
|
+
/**
|
|
52
|
+
* 错误消息处理选项
|
|
53
|
+
* 用于配置国际化命名空间和其他翻译选项
|
|
54
|
+
*/
|
|
55
|
+
errorMsgOptions?: UseCTErrorMsgOptions;
|
|
56
|
+
}
|
|
@@ -6,5 +6,10 @@ import React from "react";
|
|
|
6
6
|
export type ConfigProps = {
|
|
7
7
|
antd4Configs?: ConfigProviderProps;
|
|
8
8
|
antd5Configs?: Antd5ConfigProviderProps;
|
|
9
|
+
config?: {
|
|
10
|
+
/** CTError i18n 命名空间 */
|
|
11
|
+
ctErrorI18nNs?: string;
|
|
12
|
+
};
|
|
9
13
|
};
|
|
10
|
-
export declare const
|
|
14
|
+
export declare const useConfig: () => ConfigProps["config"];
|
|
15
|
+
export declare const ConfigProvider: React.FC<React.PropsWithChildren<ConfigProps>>;
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from "./Card";
|
|
|
21
21
|
export * from "./Cascader";
|
|
22
22
|
export * from "./Checkbox";
|
|
23
23
|
export * from "./ConfigProvider";
|
|
24
|
+
export * from "./CTModalFooterError";
|
|
24
25
|
export * from "./DeprecatedProgress";
|
|
25
26
|
export * from "./DetailCard";
|
|
26
27
|
export * from "./DonutChart";
|
|
@@ -46,3 +46,4 @@ export { default as SummaryTable } from "./SummaryTable";
|
|
|
46
46
|
export { default as SwitchWithText } from "./SwitchWithText";
|
|
47
47
|
export { default as TabMenu } from "./TabMenu";
|
|
48
48
|
export { default as UnitWithChart } from "./UnitWithChart";
|
|
49
|
+
export { default as KubeConfigModal } from "./KubeConfigModal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CTError } from "../utils/cterror";
|
|
2
|
+
import { TOptions } from "i18next";
|
|
3
|
+
export type UseCTErrorMsgOptions = {
|
|
4
|
+
CTErrorI18nNs?: string;
|
|
5
|
+
tOptions?: TOptions;
|
|
6
|
+
};
|
|
7
|
+
export declare const useCTErrorMsg: (error: CTError, options?: UseCTErrorMsgOptions) => (string | undefined)[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CTErrorType as CloudTowerErrorResponse } from "../utils/type";
|
|
2
|
+
import { AxiosError } from "axios";
|
|
3
|
+
type ParsedCTErrorItem = {
|
|
4
|
+
code?: string;
|
|
5
|
+
params?: CloudTowerErrorResponse["params"];
|
|
6
|
+
message?: string;
|
|
7
|
+
} | {
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
type ParsedCTError = ParsedCTErrorItem[];
|
|
11
|
+
export type CTError = AxiosError<CloudTowerErrorResponse> | CloudTowerErrorResponse;
|
|
12
|
+
export declare const isResponseCTError: (error: unknown) => error is CloudTowerErrorResponse;
|
|
13
|
+
/**
|
|
14
|
+
* 处理响应错误
|
|
15
|
+
*/
|
|
16
|
+
export declare const handleResponseCTError: (error: CloudTowerErrorResponse) => ParsedCTError;
|
|
17
|
+
type AxiosCTError = AxiosError<CloudTowerErrorResponse>;
|
|
18
|
+
export declare const isAxiosCTError: (error: unknown) => error is AxiosCTError;
|
|
19
|
+
/**
|
|
20
|
+
* 处理 Axios 错误
|
|
21
|
+
*/
|
|
22
|
+
export declare const handleAxiosCTError: (error: AxiosCTError) => ParsedCTError;
|
|
23
|
+
/**
|
|
24
|
+
* 统一错误处理函数
|
|
25
|
+
* @param error - 各种类型的错误对象
|
|
26
|
+
* @returns 解析后的错误信息,包含 code 或 message
|
|
27
|
+
*/
|
|
28
|
+
export declare const parseCTError: (error: CTError) => ParsedCTError;
|
|
29
|
+
export {};
|
package/dist/src/utils/type.d.ts
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
1
|
export type { SizeType as Antd5SizeType } from "antd5/lib/config-provider/SizeContext";
|
|
2
|
+
export type CTErrorType = {
|
|
3
|
+
code?: string;
|
|
4
|
+
/**
|
|
5
|
+
* @type array | undefined
|
|
6
|
+
*/
|
|
7
|
+
details?: {
|
|
8
|
+
/**
|
|
9
|
+
* @type string | undefined
|
|
10
|
+
*/
|
|
11
|
+
message?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @type object | undefined
|
|
14
|
+
*/
|
|
15
|
+
params?: {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @type string | undefined
|
|
20
|
+
*/
|
|
21
|
+
reason?: string;
|
|
22
|
+
}[];
|
|
23
|
+
/**
|
|
24
|
+
* @type string
|
|
25
|
+
*/
|
|
26
|
+
message?: string;
|
|
27
|
+
/**
|
|
28
|
+
* @type object | undefined
|
|
29
|
+
*/
|
|
30
|
+
params?: {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { CTModalFooterError } from "../../../src/core/CTModalFooterError";
|
|
3
|
+
/**
|
|
4
|
+
* CTModalFooterError 组件用于在 Modal 底部显示错误信息,支持多种错误格式和自定义渲染。
|
|
5
|
+
*
|
|
6
|
+
* - 支持多种错误格式(Axios 错误、服务端响应错误等)
|
|
7
|
+
* - 内置 i18n 支持
|
|
8
|
+
* - 支持自定义容器和详情渲染器
|
|
9
|
+
*/
|
|
10
|
+
declare const meta: Meta<typeof CTModalFooterError>;
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof CTModalFooterError>;
|
|
13
|
+
/**
|
|
14
|
+
* 基本用法 - 显示简单的错误消息
|
|
15
|
+
*
|
|
16
|
+
* 传入一个简单的 Error 对象,组件会自动提取并显示错误消息。
|
|
17
|
+
*/
|
|
18
|
+
export declare const Basic: Story;
|
|
19
|
+
/**
|
|
20
|
+
* 显示来自服务端的结构化错误,传入一个包含错误代码和消息的服务端响应错误对象,组件会自动提取并显示错误消息。
|
|
21
|
+
*/
|
|
22
|
+
export declare const ServerError: Story;
|
|
23
|
+
/**
|
|
24
|
+
* 多条错误 - 显示包含多个错误详情的错误
|
|
25
|
+
*/
|
|
26
|
+
export declare const MultipleErrors: Story;
|
|
27
|
+
/**
|
|
28
|
+
* Axios 请求错误
|
|
29
|
+
*/
|
|
30
|
+
export declare const NetworkError: Story;
|
|
31
|
+
/**
|
|
32
|
+
* 自定义容器渲染器
|
|
33
|
+
*/
|
|
34
|
+
export declare const CustomContainer: Story;
|
|
35
|
+
/**
|
|
36
|
+
* 自定义错误详情渲染器
|
|
37
|
+
*/
|
|
38
|
+
export declare const CustomErrorDetail: Story;
|
|
39
|
+
/**
|
|
40
|
+
* 空错误处理
|
|
41
|
+
* 当传入 null 或 undefined 时,组件会自动处理并显示默认信息。
|
|
42
|
+
*/
|
|
43
|
+
export declare const EmptyError: Story;
|
|
44
|
+
/**
|
|
45
|
+
* 可以通过 ConfigProvider 配置 i18n 命名空间和组件 options 配置 i18n 的命名空间。 优先使用组件 options 配置的命名空间。都不配置时,默认使用 CTError 命名空间。
|
|
46
|
+
*/
|
|
47
|
+
export declare const Intl: Story;
|