@akinon/ui-alert 0.4.0 → 1.0.0
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/index.d.ts +12 -10
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +50 -50
- package/dist/cjs/types.d.ts +176 -0
- package/dist/esm/index.d.ts +12 -10
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +49 -49
- package/dist/esm/types.d.ts +176 -0
- package/package.json +7 -6
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import { type IAlertProps } from './types.d';
|
|
3
|
+
/**
|
|
4
|
+
* Alert component for Akinon UI.
|
|
5
|
+
*
|
|
6
|
+
* The Alert component is designed to display important messages to users with varying styles and configurations.
|
|
7
|
+
* It supports multiple types such as success, info, warning, and error, providing flexibility for different scenarios.
|
|
8
|
+
*
|
|
9
|
+
* The component allows customization of its content, icons, actions, and interaction handlers, ensuring it meets
|
|
10
|
+
* diverse requirements. It integrates seamlessly with the Akinon design system for a consistent user experience.
|
|
11
|
+
*/
|
|
12
|
+
export declare const Alert: ({ ...restAlertProps }: IAlertProps) => React.JSX.Element;
|
|
13
|
+
export type * from './types';
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE5D;;;;;;;;GAQG;AAEH,eAAO,MAAM,KAAK,0BAA2B,WAAW,sBA4EvD,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -11,21 +11,25 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.Alert =
|
|
14
|
+
exports.Alert = void 0;
|
|
15
|
+
const icons_1 = require("@akinon/icons");
|
|
15
16
|
const ui_theme_1 = require("@akinon/ui-theme");
|
|
16
17
|
const cssinjs_1 = require("@ant-design/cssinjs");
|
|
17
18
|
const antd_1 = require("antd");
|
|
18
19
|
const React = require("react");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const types_d_1 = require("./types.d");
|
|
21
|
+
/**
|
|
22
|
+
* Alert component for Akinon UI.
|
|
23
|
+
*
|
|
24
|
+
* The Alert component is designed to display important messages to users with varying styles and configurations.
|
|
25
|
+
* It supports multiple types such as success, info, warning, and error, providing flexibility for different scenarios.
|
|
26
|
+
*
|
|
27
|
+
* The component allows customization of its content, icons, actions, and interaction handlers, ensuring it meets
|
|
28
|
+
* diverse requirements. It integrates seamlessly with the Akinon design system for a consistent user experience.
|
|
29
|
+
*/
|
|
27
30
|
const Alert = (_a) => {
|
|
28
|
-
var
|
|
31
|
+
var _b;
|
|
32
|
+
var restAlertProps = __rest(_a, []);
|
|
29
33
|
const { getPrefixCls, theme } = React.useContext(antd_1.ConfigProvider.ConfigContext);
|
|
30
34
|
const { token, hashId } = (0, ui_theme_1.useToken)();
|
|
31
35
|
const alertToken = token.Alert;
|
|
@@ -38,49 +42,45 @@ const Alert = (_a) => {
|
|
|
38
42
|
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-alert`;
|
|
39
43
|
const prefixClsWithoutHash = `.${getPrefixCls()}-alert`;
|
|
40
44
|
return {
|
|
41
|
-
[
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
[prefixCls]: {
|
|
46
|
+
[`&${prefixCls}-${types_d_1.AlertTypeKeys.success}`]: {
|
|
47
|
+
color: alertToken.defaultColorSuccess,
|
|
48
|
+
borderColor: alertToken.defaultBorderColorSuccess,
|
|
49
|
+
backgroundColor: alertToken.defaultBgSuccess
|
|
50
|
+
},
|
|
51
|
+
[`&${prefixCls}-${types_d_1.AlertTypeKeys.infoOne}`]: {
|
|
52
|
+
color: alertToken.defaultColorWaiting1,
|
|
53
|
+
borderColor: alertToken.defaultBorderColorWaiting1,
|
|
54
|
+
backgroundColor: alertToken.defaultBgWaiting1
|
|
55
|
+
},
|
|
56
|
+
[`&${prefixCls}-${types_d_1.AlertTypeKeys.infoTwo}`]: {
|
|
57
|
+
color: alertToken.defaultColorWaiting2,
|
|
58
|
+
borderColor: alertToken.defaultBorderColorWaiting2,
|
|
59
|
+
backgroundColor: alertToken.defaultBgWaiting2
|
|
60
|
+
},
|
|
61
|
+
[`&${prefixCls}-${types_d_1.AlertTypeKeys.infoThree}`]: {
|
|
62
|
+
color: alertToken.defaultColorWaiting3,
|
|
63
|
+
borderColor: alertToken.defaultBorderColorWaiting3,
|
|
64
|
+
backgroundColor: alertToken.defaultBgWaiting3
|
|
65
|
+
},
|
|
66
|
+
[`&${prefixCls}-${types_d_1.AlertTypeKeys.error}`]: {
|
|
67
|
+
color: alertToken.defaultColorFailed,
|
|
68
|
+
borderColor: alertToken.defaultBorderColorFailed,
|
|
69
|
+
backgroundColor: alertToken.defaultBgFailed
|
|
47
70
|
}
|
|
48
71
|
},
|
|
49
|
-
[`${
|
|
50
|
-
color: alertToken.defaultColorWaiting1,
|
|
51
|
-
borderColor: alertToken.defaultBorderColorWaiting1,
|
|
52
|
-
backgroundColor: alertToken.defaultBgWaiting1,
|
|
53
|
-
['.anticon.anticon-close']: {
|
|
54
|
-
color: alertToken.defaultBorderColorWaiting1
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
[`${prefixCls}-${AlertStatus.Info2}`]: {
|
|
58
|
-
color: alertToken.defaultColorWaiting2,
|
|
59
|
-
borderColor: alertToken.defaultBorderColorWaiting2,
|
|
60
|
-
backgroundColor: alertToken.defaultBgWaiting2,
|
|
61
|
-
['.anticon.anticon-close']: {
|
|
62
|
-
color: alertToken.defaultBorderColorWaiting2
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
[`${prefixCls}-${AlertStatus.Info3}`]: {
|
|
66
|
-
color: alertToken.defaultColorWaiting3,
|
|
67
|
-
borderColor: alertToken.defaultBorderColorWaiting3,
|
|
68
|
-
backgroundColor: alertToken.defaultBgWaiting3,
|
|
69
|
-
['.anticon.anticon-close']: {
|
|
70
|
-
color: alertToken.defaultBorderColorWaiting3
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
[`${prefixCls}-${AlertStatus.Error}`]: {
|
|
74
|
-
color: alertToken.defaultColorFailed,
|
|
75
|
-
borderColor: alertToken.defaultBorderColorFailed,
|
|
76
|
-
backgroundColor: alertToken.defaultBgFailed,
|
|
77
|
-
['.anticon.anticon-close']: {
|
|
78
|
-
color: alertToken.defaultBorderColorFailed
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
[prefixClsWithoutHash]: {}
|
|
72
|
+
[`${prefixClsWithoutHash}`]: {}
|
|
82
73
|
};
|
|
83
74
|
});
|
|
84
|
-
|
|
75
|
+
const iconNameMap = {
|
|
76
|
+
[types_d_1.AlertTypeKeys.success]: 'yes',
|
|
77
|
+
[types_d_1.AlertTypeKeys.infoOne]: 'info',
|
|
78
|
+
[types_d_1.AlertTypeKeys.infoTwo]: 'info',
|
|
79
|
+
[types_d_1.AlertTypeKeys.infoThree]: 'info',
|
|
80
|
+
[types_d_1.AlertTypeKeys.error]: 'no',
|
|
81
|
+
info: 'info'
|
|
82
|
+
};
|
|
83
|
+
const iconName = React.useMemo(() => { var _a; return iconNameMap[(_a = restAlertProps.type) !== null && _a !== void 0 ? _a : 'success']; }, [restAlertProps.type]);
|
|
84
|
+
return useStyle(React.createElement(antd_1.Alert, Object.assign({ type: types_d_1.AlertTypeKeys.success }, restAlertProps, { icon: React.createElement(icons_1.Icon, { size: 14, icon: ((_b = restAlertProps.icon) !== null && _b !== void 0 ? _b : iconName) }) })));
|
|
85
85
|
};
|
|
86
86
|
exports.Alert = Alert;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { IconName } from '@akinon/icons';
|
|
2
|
+
import { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
|
|
3
|
+
import { AriaRole } from 'react';
|
|
4
|
+
|
|
5
|
+
export const AlertTypeKeys = {
|
|
6
|
+
success: 'success',
|
|
7
|
+
infoOne: 'info-one',
|
|
8
|
+
infoTwo: 'info-two',
|
|
9
|
+
infoThree: 'info-three',
|
|
10
|
+
error: 'error'
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
export type IAlertProps = {
|
|
14
|
+
/**
|
|
15
|
+
* Type of Alert styles
|
|
16
|
+
* @default success
|
|
17
|
+
*/
|
|
18
|
+
type?: (typeof AlertTypeKeys)[keyof typeof AlertTypeKeys];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Whether Alert can be closed
|
|
22
|
+
*/
|
|
23
|
+
closable?: ClosableType;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Content of Alert
|
|
27
|
+
*/
|
|
28
|
+
message?: React.ReactNode;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Additional content of Alert
|
|
32
|
+
*/
|
|
33
|
+
description?: React.ReactNode;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Callback when close Alert
|
|
37
|
+
*/
|
|
38
|
+
onClose?: React.MouseEventHandler<HTMLButtonElement>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Trigger when animation ending of Alert
|
|
42
|
+
*/
|
|
43
|
+
afterClose?: () => void;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether to show icon
|
|
47
|
+
*/
|
|
48
|
+
showIcon?: boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* https://www.w3.org/TR/2014/REC-html5-20141028/dom.html#aria-role-attribute
|
|
52
|
+
*/
|
|
53
|
+
role?: AriaRole;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Never use this prop. Akinon design system does not allow custom styles.
|
|
57
|
+
* @ignore
|
|
58
|
+
*/
|
|
59
|
+
style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Whether to show as banner
|
|
63
|
+
*/
|
|
64
|
+
banner?: boolean;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The icon name of the button. Only icons from `akinon/icons` are supported.
|
|
68
|
+
* If there is no icon which you want to use, please open an issue.
|
|
69
|
+
*/
|
|
70
|
+
icon?: IconName;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The action of Alert
|
|
74
|
+
*/
|
|
75
|
+
action?: React.ReactNode;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Mouse enter event handler
|
|
79
|
+
*/
|
|
80
|
+
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Mouse leave event handler
|
|
84
|
+
*/
|
|
85
|
+
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Click event handler
|
|
89
|
+
*/
|
|
90
|
+
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* ID for the alert container
|
|
94
|
+
*/
|
|
95
|
+
id?: string;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type BaseClosableType = {
|
|
99
|
+
/**
|
|
100
|
+
* Custom close icon for the alert.
|
|
101
|
+
*/
|
|
102
|
+
closeIcon?: React.ReactNode;
|
|
103
|
+
} & React.AriaAttributes;
|
|
104
|
+
|
|
105
|
+
type ClosableType = boolean | BaseClosableType;
|
|
106
|
+
|
|
107
|
+
interface ErrorBoundaryProps {
|
|
108
|
+
/**
|
|
109
|
+
* Error message to display.
|
|
110
|
+
*/
|
|
111
|
+
message?: React.ReactNode;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Additional description for the error.
|
|
115
|
+
*/
|
|
116
|
+
description?: React.ReactNode;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Child components to render.
|
|
120
|
+
*/
|
|
121
|
+
children?: React.ReactNode;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* ID for the error boundary.
|
|
125
|
+
*/
|
|
126
|
+
id?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface ErrorBoundaryStates {
|
|
130
|
+
/**
|
|
131
|
+
* Captured error information.
|
|
132
|
+
*/
|
|
133
|
+
error?: Error | null;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Additional info about the error.
|
|
137
|
+
*/
|
|
138
|
+
info?: {
|
|
139
|
+
/**
|
|
140
|
+
* Component stack trace.
|
|
141
|
+
*/
|
|
142
|
+
componentStack?: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare class ErrorBoundary extends React.Component<
|
|
147
|
+
ErrorBoundaryProps,
|
|
148
|
+
ErrorBoundaryStates
|
|
149
|
+
> {
|
|
150
|
+
/**
|
|
151
|
+
* Component state.
|
|
152
|
+
*/
|
|
153
|
+
state: {
|
|
154
|
+
error: undefined;
|
|
155
|
+
info: {
|
|
156
|
+
componentStack: string;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Lifecycle method to capture errors.
|
|
162
|
+
*/
|
|
163
|
+
componentDidCatch(error: Error | null, info: object): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Render method for the component.
|
|
167
|
+
*/
|
|
168
|
+
render():
|
|
169
|
+
| string
|
|
170
|
+
| number
|
|
171
|
+
| boolean
|
|
172
|
+
| Iterable<React.ReactNode>
|
|
173
|
+
| React.JSX.Element
|
|
174
|
+
| null
|
|
175
|
+
| undefined;
|
|
176
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import { type IAlertProps } from './types.d';
|
|
3
|
+
/**
|
|
4
|
+
* Alert component for Akinon UI.
|
|
5
|
+
*
|
|
6
|
+
* The Alert component is designed to display important messages to users with varying styles and configurations.
|
|
7
|
+
* It supports multiple types such as success, info, warning, and error, providing flexibility for different scenarios.
|
|
8
|
+
*
|
|
9
|
+
* The component allows customization of its content, icons, actions, and interaction handlers, ensuring it meets
|
|
10
|
+
* diverse requirements. It integrates seamlessly with the Akinon design system for a consistent user experience.
|
|
11
|
+
*/
|
|
12
|
+
export declare const Alert: ({ ...restAlertProps }: IAlertProps) => React.JSX.Element;
|
|
13
|
+
export type * from './types';
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE5D;;;;;;;;GAQG;AAEH,eAAO,MAAM,KAAK,0BAA2B,WAAW,sBA4EvD,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -9,20 +9,24 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
+
import { Icon } from '@akinon/icons';
|
|
12
13
|
import { useToken } from '@akinon/ui-theme';
|
|
13
14
|
import { useStyleRegister } from '@ant-design/cssinjs';
|
|
14
15
|
import { Alert as AntAlert, ConfigProvider } from 'antd';
|
|
15
16
|
import * as React from 'react';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
import { AlertTypeKeys } from './types.d';
|
|
18
|
+
/**
|
|
19
|
+
* Alert component for Akinon UI.
|
|
20
|
+
*
|
|
21
|
+
* The Alert component is designed to display important messages to users with varying styles and configurations.
|
|
22
|
+
* It supports multiple types such as success, info, warning, and error, providing flexibility for different scenarios.
|
|
23
|
+
*
|
|
24
|
+
* The component allows customization of its content, icons, actions, and interaction handlers, ensuring it meets
|
|
25
|
+
* diverse requirements. It integrates seamlessly with the Akinon design system for a consistent user experience.
|
|
26
|
+
*/
|
|
24
27
|
export const Alert = (_a) => {
|
|
25
|
-
var
|
|
28
|
+
var _b;
|
|
29
|
+
var restAlertProps = __rest(_a, []);
|
|
26
30
|
const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
|
|
27
31
|
const { token, hashId } = useToken();
|
|
28
32
|
const alertToken = token.Alert;
|
|
@@ -35,48 +39,44 @@ export const Alert = (_a) => {
|
|
|
35
39
|
const prefixCls = `:where(.${hashId}).${getPrefixCls()}-alert`;
|
|
36
40
|
const prefixClsWithoutHash = `.${getPrefixCls()}-alert`;
|
|
37
41
|
return {
|
|
38
|
-
[
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
[prefixCls]: {
|
|
43
|
+
[`&${prefixCls}-${AlertTypeKeys.success}`]: {
|
|
44
|
+
color: alertToken.defaultColorSuccess,
|
|
45
|
+
borderColor: alertToken.defaultBorderColorSuccess,
|
|
46
|
+
backgroundColor: alertToken.defaultBgSuccess
|
|
47
|
+
},
|
|
48
|
+
[`&${prefixCls}-${AlertTypeKeys.infoOne}`]: {
|
|
49
|
+
color: alertToken.defaultColorWaiting1,
|
|
50
|
+
borderColor: alertToken.defaultBorderColorWaiting1,
|
|
51
|
+
backgroundColor: alertToken.defaultBgWaiting1
|
|
52
|
+
},
|
|
53
|
+
[`&${prefixCls}-${AlertTypeKeys.infoTwo}`]: {
|
|
54
|
+
color: alertToken.defaultColorWaiting2,
|
|
55
|
+
borderColor: alertToken.defaultBorderColorWaiting2,
|
|
56
|
+
backgroundColor: alertToken.defaultBgWaiting2
|
|
57
|
+
},
|
|
58
|
+
[`&${prefixCls}-${AlertTypeKeys.infoThree}`]: {
|
|
59
|
+
color: alertToken.defaultColorWaiting3,
|
|
60
|
+
borderColor: alertToken.defaultBorderColorWaiting3,
|
|
61
|
+
backgroundColor: alertToken.defaultBgWaiting3
|
|
62
|
+
},
|
|
63
|
+
[`&${prefixCls}-${AlertTypeKeys.error}`]: {
|
|
64
|
+
color: alertToken.defaultColorFailed,
|
|
65
|
+
borderColor: alertToken.defaultBorderColorFailed,
|
|
66
|
+
backgroundColor: alertToken.defaultBgFailed
|
|
44
67
|
}
|
|
45
68
|
},
|
|
46
|
-
[`${
|
|
47
|
-
color: alertToken.defaultColorWaiting1,
|
|
48
|
-
borderColor: alertToken.defaultBorderColorWaiting1,
|
|
49
|
-
backgroundColor: alertToken.defaultBgWaiting1,
|
|
50
|
-
['.anticon.anticon-close']: {
|
|
51
|
-
color: alertToken.defaultBorderColorWaiting1
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
[`${prefixCls}-${AlertStatus.Info2}`]: {
|
|
55
|
-
color: alertToken.defaultColorWaiting2,
|
|
56
|
-
borderColor: alertToken.defaultBorderColorWaiting2,
|
|
57
|
-
backgroundColor: alertToken.defaultBgWaiting2,
|
|
58
|
-
['.anticon.anticon-close']: {
|
|
59
|
-
color: alertToken.defaultBorderColorWaiting2
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
[`${prefixCls}-${AlertStatus.Info3}`]: {
|
|
63
|
-
color: alertToken.defaultColorWaiting3,
|
|
64
|
-
borderColor: alertToken.defaultBorderColorWaiting3,
|
|
65
|
-
backgroundColor: alertToken.defaultBgWaiting3,
|
|
66
|
-
['.anticon.anticon-close']: {
|
|
67
|
-
color: alertToken.defaultBorderColorWaiting3
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
[`${prefixCls}-${AlertStatus.Error}`]: {
|
|
71
|
-
color: alertToken.defaultColorFailed,
|
|
72
|
-
borderColor: alertToken.defaultBorderColorFailed,
|
|
73
|
-
backgroundColor: alertToken.defaultBgFailed,
|
|
74
|
-
['.anticon.anticon-close']: {
|
|
75
|
-
color: alertToken.defaultBorderColorFailed
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
[prefixClsWithoutHash]: {}
|
|
69
|
+
[`${prefixClsWithoutHash}`]: {}
|
|
79
70
|
};
|
|
80
71
|
});
|
|
81
|
-
|
|
72
|
+
const iconNameMap = {
|
|
73
|
+
[AlertTypeKeys.success]: 'yes',
|
|
74
|
+
[AlertTypeKeys.infoOne]: 'info',
|
|
75
|
+
[AlertTypeKeys.infoTwo]: 'info',
|
|
76
|
+
[AlertTypeKeys.infoThree]: 'info',
|
|
77
|
+
[AlertTypeKeys.error]: 'no',
|
|
78
|
+
info: 'info'
|
|
79
|
+
};
|
|
80
|
+
const iconName = React.useMemo(() => { var _a; return iconNameMap[(_a = restAlertProps.type) !== null && _a !== void 0 ? _a : 'success']; }, [restAlertProps.type]);
|
|
81
|
+
return useStyle(React.createElement(AntAlert, Object.assign({ type: AlertTypeKeys.success }, restAlertProps, { icon: React.createElement(Icon, { size: 14, icon: ((_b = restAlertProps.icon) !== null && _b !== void 0 ? _b : iconName) }) })));
|
|
82
82
|
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { IconName } from '@akinon/icons';
|
|
2
|
+
import { DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE } from '@akinon/ui-theme';
|
|
3
|
+
import { AriaRole } from 'react';
|
|
4
|
+
|
|
5
|
+
export const AlertTypeKeys = {
|
|
6
|
+
success: 'success',
|
|
7
|
+
infoOne: 'info-one',
|
|
8
|
+
infoTwo: 'info-two',
|
|
9
|
+
infoThree: 'info-three',
|
|
10
|
+
error: 'error'
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
export type IAlertProps = {
|
|
14
|
+
/**
|
|
15
|
+
* Type of Alert styles
|
|
16
|
+
* @default success
|
|
17
|
+
*/
|
|
18
|
+
type?: (typeof AlertTypeKeys)[keyof typeof AlertTypeKeys];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Whether Alert can be closed
|
|
22
|
+
*/
|
|
23
|
+
closable?: ClosableType;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Content of Alert
|
|
27
|
+
*/
|
|
28
|
+
message?: React.ReactNode;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Additional content of Alert
|
|
32
|
+
*/
|
|
33
|
+
description?: React.ReactNode;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Callback when close Alert
|
|
37
|
+
*/
|
|
38
|
+
onClose?: React.MouseEventHandler<HTMLButtonElement>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Trigger when animation ending of Alert
|
|
42
|
+
*/
|
|
43
|
+
afterClose?: () => void;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether to show icon
|
|
47
|
+
*/
|
|
48
|
+
showIcon?: boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* https://www.w3.org/TR/2014/REC-html5-20141028/dom.html#aria-role-attribute
|
|
52
|
+
*/
|
|
53
|
+
role?: AriaRole;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Never use this prop. Akinon design system does not allow custom styles.
|
|
57
|
+
* @ignore
|
|
58
|
+
*/
|
|
59
|
+
style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Whether to show as banner
|
|
63
|
+
*/
|
|
64
|
+
banner?: boolean;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The icon name of the button. Only icons from `akinon/icons` are supported.
|
|
68
|
+
* If there is no icon which you want to use, please open an issue.
|
|
69
|
+
*/
|
|
70
|
+
icon?: IconName;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The action of Alert
|
|
74
|
+
*/
|
|
75
|
+
action?: React.ReactNode;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Mouse enter event handler
|
|
79
|
+
*/
|
|
80
|
+
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Mouse leave event handler
|
|
84
|
+
*/
|
|
85
|
+
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Click event handler
|
|
89
|
+
*/
|
|
90
|
+
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* ID for the alert container
|
|
94
|
+
*/
|
|
95
|
+
id?: string;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type BaseClosableType = {
|
|
99
|
+
/**
|
|
100
|
+
* Custom close icon for the alert.
|
|
101
|
+
*/
|
|
102
|
+
closeIcon?: React.ReactNode;
|
|
103
|
+
} & React.AriaAttributes;
|
|
104
|
+
|
|
105
|
+
type ClosableType = boolean | BaseClosableType;
|
|
106
|
+
|
|
107
|
+
interface ErrorBoundaryProps {
|
|
108
|
+
/**
|
|
109
|
+
* Error message to display.
|
|
110
|
+
*/
|
|
111
|
+
message?: React.ReactNode;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Additional description for the error.
|
|
115
|
+
*/
|
|
116
|
+
description?: React.ReactNode;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Child components to render.
|
|
120
|
+
*/
|
|
121
|
+
children?: React.ReactNode;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* ID for the error boundary.
|
|
125
|
+
*/
|
|
126
|
+
id?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface ErrorBoundaryStates {
|
|
130
|
+
/**
|
|
131
|
+
* Captured error information.
|
|
132
|
+
*/
|
|
133
|
+
error?: Error | null;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Additional info about the error.
|
|
137
|
+
*/
|
|
138
|
+
info?: {
|
|
139
|
+
/**
|
|
140
|
+
* Component stack trace.
|
|
141
|
+
*/
|
|
142
|
+
componentStack?: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare class ErrorBoundary extends React.Component<
|
|
147
|
+
ErrorBoundaryProps,
|
|
148
|
+
ErrorBoundaryStates
|
|
149
|
+
> {
|
|
150
|
+
/**
|
|
151
|
+
* Component state.
|
|
152
|
+
*/
|
|
153
|
+
state: {
|
|
154
|
+
error: undefined;
|
|
155
|
+
info: {
|
|
156
|
+
componentStack: string;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Lifecycle method to capture errors.
|
|
162
|
+
*/
|
|
163
|
+
componentDidCatch(error: Error | null, info: object): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Render method for the component.
|
|
167
|
+
*/
|
|
168
|
+
render():
|
|
169
|
+
| string
|
|
170
|
+
| number
|
|
171
|
+
| boolean
|
|
172
|
+
| Iterable<React.ReactNode>
|
|
173
|
+
| React.JSX.Element
|
|
174
|
+
| null
|
|
175
|
+
| undefined;
|
|
176
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/ui-alert",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -9,15 +9,16 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"antd": "5.
|
|
13
|
-
"@akinon/
|
|
12
|
+
"antd": "5.22.6",
|
|
13
|
+
"@akinon/icons": "1.0.0",
|
|
14
|
+
"@akinon/ui-theme": "1.0.0"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"clean-package": "2.2.0",
|
|
17
18
|
"copyfiles": "^2.4.1",
|
|
18
19
|
"rimraf": "^5.0.5",
|
|
19
|
-
"typescript": "
|
|
20
|
-
"@akinon/typescript-config": "0.
|
|
20
|
+
"typescript": "*",
|
|
21
|
+
"@akinon/typescript-config": "1.0.0"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
23
24
|
"react": ">=18",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
|
|
38
39
|
"build:esm": "tsc --outDir dist/esm",
|
|
39
40
|
"build:commonjs": "tsc --module commonjs --outDir dist/cjs",
|
|
40
|
-
"copy:files": "copyfiles -u 1 src
|
|
41
|
+
"copy:files": "copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/esm && copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/cjs",
|
|
41
42
|
"clean": "rimraf dist/",
|
|
42
43
|
"typecheck": "tsc --noEmit"
|
|
43
44
|
}
|