@akinon/ui-alert 0.5.0 → 1.0.1

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.
@@ -1,12 +1,14 @@
1
1
  import * as React from 'react';
2
- import type { AlertProps } from './types';
3
- export type { AlertProps } from './types';
4
- export declare enum AlertStatus {
5
- Success = "success",
6
- Info1 = "info-1",
7
- Info2 = "info-2",
8
- Info3 = "info-3",
9
- Error = "error"
10
- }
11
- export declare const Alert: ({ status, ...restAlertProps }: AlertProps) => React.JSX.Element;
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,KAAK,WAAW;IAChB,KAAK,WAAW;IAChB,KAAK,WAAW;IAChB,KAAK,UAAU;CAChB;AAED,eAAO,MAAM,KAAK,kCAAmC,UAAU,sBAwE9D,CAAC"}
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 = exports.AlertStatus = void 0;
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
- var AlertStatus;
20
- (function (AlertStatus) {
21
- AlertStatus["Success"] = "success";
22
- AlertStatus["Info1"] = "info-1";
23
- AlertStatus["Info2"] = "info-2";
24
- AlertStatus["Info3"] = "info-3";
25
- AlertStatus["Error"] = "error";
26
- })(AlertStatus || (exports.AlertStatus = AlertStatus = {}));
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 { status } = _a, restAlertProps = __rest(_a, ["status"]);
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
- [`${prefixCls}-${AlertStatus.Success}`]: {
42
- color: alertToken.defaultColorSuccess,
43
- borderColor: alertToken.defaultBorderColorSuccess,
44
- backgroundColor: alertToken.defaultBgSuccess,
45
- ['.anticon.anticon-close']: {
46
- color: alertToken.defaultBorderColorSuccess
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
- [`${prefixCls}-${AlertStatus.Info1}`]: {
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
- return useStyle(React.createElement(antd_1.Alert, Object.assign({ className: status && `akinon-alert-${status}` }, restAlertProps)));
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;
@@ -1,88 +1,144 @@
1
- import { AlertStatus } from './';
2
-
3
- export type AlertProps = Omit<
4
- AntAlertProps,
5
- | 'prefixCls'
6
- | 'style'
7
- | 'styles'
8
- | 'closeIcon'
9
- | 'onMouseEnter'
10
- | 'onMouseLeave'
11
- | 'onClick'
12
- | 'id'
13
- | 'role'
14
- > & {
15
- /**
16
- * The status of the alert.
17
- */
18
- status?: AlertStatus;
19
- };
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];
20
19
 
21
- interface AntAlertProps {
22
- /** Type of Alert styles */
23
- type?: 'success' | 'info' | 'warning' | 'error';
24
- /** Whether Alert can be closed */
20
+ /**
21
+ * Whether Alert can be closed
22
+ */
25
23
  closable?: ClosableType;
26
- /** Content of Alert */
24
+
25
+ /**
26
+ * Content of Alert
27
+ */
27
28
  message?: React.ReactNode;
28
- /** Additional content of Alert */
29
+
30
+ /**
31
+ * Additional content of Alert
32
+ */
29
33
  description?: React.ReactNode;
30
- /** Callback when close Alert */
34
+
35
+ /**
36
+ * Callback when close Alert
37
+ */
31
38
  onClose?: React.MouseEventHandler<HTMLButtonElement>;
32
- /** Trigger when animation ending of Alert */
39
+
40
+ /**
41
+ * Trigger when animation ending of Alert
42
+ */
33
43
  afterClose?: () => void;
34
- /** Whether to show icon */
44
+
45
+ /**
46
+ * Whether to show icon
47
+ */
35
48
  showIcon?: boolean;
36
- /** https://www.w3.org/TR/2014/REC-html5-20141028/dom.html#aria-role-attribute */
37
- role?: string;
38
- style?: React.CSSProperties;
39
- prefixCls?: string;
49
+
40
50
  /**
41
- * The additional css class
51
+ * https://www.w3.org/TR/2014/REC-html5-20141028/dom.html#aria-role-attribute
42
52
  */
43
- className?: string;
53
+ role?: AriaRole;
54
+
44
55
  /**
45
- * ClassName on the root element
56
+ * Never use this prop. Akinon design system does not allow custom styles.
57
+ * @ignore
46
58
  */
47
- rootClassName?: string;
59
+ style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
60
+
48
61
  /**
49
62
  * Whether to show as banner
50
63
  */
51
64
  banner?: boolean;
65
+
52
66
  /**
53
- * Custom icon, effective when showIcon is true
54
- */
55
- icon?: React.ReactNode;
56
- /**
57
- * Custom close icon
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.
58
69
  */
59
- closeIcon?: React.ReactNode;
70
+ icon?: IconName;
71
+
60
72
  /**
61
73
  * The action of Alert
62
74
  */
63
75
  action?: React.ReactNode;
76
+
77
+ /**
78
+ * Mouse enter event handler
79
+ */
64
80
  onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
81
+
82
+ /**
83
+ * Mouse leave event handler
84
+ */
65
85
  onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
86
+
87
+ /**
88
+ * Click event handler
89
+ */
66
90
  onClick?: React.MouseEventHandler<HTMLDivElement>;
91
+
92
+ /**
93
+ * ID for the alert container
94
+ */
67
95
  id?: string;
68
- }
96
+ };
69
97
 
70
98
  type BaseClosableType = {
99
+ /**
100
+ * Custom close icon for the alert.
101
+ */
71
102
  closeIcon?: React.ReactNode;
72
103
  } & React.AriaAttributes;
73
104
 
74
105
  type ClosableType = boolean | BaseClosableType;
75
106
 
76
107
  interface ErrorBoundaryProps {
108
+ /**
109
+ * Error message to display.
110
+ */
77
111
  message?: React.ReactNode;
112
+
113
+ /**
114
+ * Additional description for the error.
115
+ */
78
116
  description?: React.ReactNode;
117
+
118
+ /**
119
+ * Child components to render.
120
+ */
79
121
  children?: React.ReactNode;
122
+
123
+ /**
124
+ * ID for the error boundary.
125
+ */
80
126
  id?: string;
81
127
  }
82
128
 
83
129
  interface ErrorBoundaryStates {
130
+ /**
131
+ * Captured error information.
132
+ */
84
133
  error?: Error | null;
134
+
135
+ /**
136
+ * Additional info about the error.
137
+ */
85
138
  info?: {
139
+ /**
140
+ * Component stack trace.
141
+ */
86
142
  componentStack?: string;
87
143
  };
88
144
  }
@@ -91,13 +147,24 @@ declare class ErrorBoundary extends React.Component<
91
147
  ErrorBoundaryProps,
92
148
  ErrorBoundaryStates
93
149
  > {
150
+ /**
151
+ * Component state.
152
+ */
94
153
  state: {
95
154
  error: undefined;
96
155
  info: {
97
156
  componentStack: string;
98
157
  };
99
158
  };
159
+
160
+ /**
161
+ * Lifecycle method to capture errors.
162
+ */
100
163
  componentDidCatch(error: Error | null, info: object): void;
164
+
165
+ /**
166
+ * Render method for the component.
167
+ */
101
168
  render():
102
169
  | string
103
170
  | number
@@ -1,12 +1,14 @@
1
1
  import * as React from 'react';
2
- import type { AlertProps } from './types';
3
- export type { AlertProps } from './types';
4
- export declare enum AlertStatus {
5
- Success = "success",
6
- Info1 = "info-1",
7
- Info2 = "info-2",
8
- Info3 = "info-3",
9
- Error = "error"
10
- }
11
- export declare const Alert: ({ status, ...restAlertProps }: AlertProps) => React.JSX.Element;
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,KAAK,WAAW;IAChB,KAAK,WAAW;IAChB,KAAK,WAAW;IAChB,KAAK,UAAU;CAChB;AAED,eAAO,MAAM,KAAK,kCAAmC,UAAU,sBAwE9D,CAAC"}
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
- export var AlertStatus;
17
- (function (AlertStatus) {
18
- AlertStatus["Success"] = "success";
19
- AlertStatus["Info1"] = "info-1";
20
- AlertStatus["Info2"] = "info-2";
21
- AlertStatus["Info3"] = "info-3";
22
- AlertStatus["Error"] = "error";
23
- })(AlertStatus || (AlertStatus = {}));
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 { status } = _a, restAlertProps = __rest(_a, ["status"]);
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
- [`${prefixCls}-${AlertStatus.Success}`]: {
39
- color: alertToken.defaultColorSuccess,
40
- borderColor: alertToken.defaultBorderColorSuccess,
41
- backgroundColor: alertToken.defaultBgSuccess,
42
- ['.anticon.anticon-close']: {
43
- color: alertToken.defaultBorderColorSuccess
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
- [`${prefixCls}-${AlertStatus.Info1}`]: {
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
- return useStyle(React.createElement(AntAlert, Object.assign({ className: status && `akinon-alert-${status}` }, restAlertProps)));
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
  };
@@ -1,88 +1,144 @@
1
- import { AlertStatus } from './';
2
-
3
- export type AlertProps = Omit<
4
- AntAlertProps,
5
- | 'prefixCls'
6
- | 'style'
7
- | 'styles'
8
- | 'closeIcon'
9
- | 'onMouseEnter'
10
- | 'onMouseLeave'
11
- | 'onClick'
12
- | 'id'
13
- | 'role'
14
- > & {
15
- /**
16
- * The status of the alert.
17
- */
18
- status?: AlertStatus;
19
- };
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];
20
19
 
21
- interface AntAlertProps {
22
- /** Type of Alert styles */
23
- type?: 'success' | 'info' | 'warning' | 'error';
24
- /** Whether Alert can be closed */
20
+ /**
21
+ * Whether Alert can be closed
22
+ */
25
23
  closable?: ClosableType;
26
- /** Content of Alert */
24
+
25
+ /**
26
+ * Content of Alert
27
+ */
27
28
  message?: React.ReactNode;
28
- /** Additional content of Alert */
29
+
30
+ /**
31
+ * Additional content of Alert
32
+ */
29
33
  description?: React.ReactNode;
30
- /** Callback when close Alert */
34
+
35
+ /**
36
+ * Callback when close Alert
37
+ */
31
38
  onClose?: React.MouseEventHandler<HTMLButtonElement>;
32
- /** Trigger when animation ending of Alert */
39
+
40
+ /**
41
+ * Trigger when animation ending of Alert
42
+ */
33
43
  afterClose?: () => void;
34
- /** Whether to show icon */
44
+
45
+ /**
46
+ * Whether to show icon
47
+ */
35
48
  showIcon?: boolean;
36
- /** https://www.w3.org/TR/2014/REC-html5-20141028/dom.html#aria-role-attribute */
37
- role?: string;
38
- style?: React.CSSProperties;
39
- prefixCls?: string;
49
+
40
50
  /**
41
- * The additional css class
51
+ * https://www.w3.org/TR/2014/REC-html5-20141028/dom.html#aria-role-attribute
42
52
  */
43
- className?: string;
53
+ role?: AriaRole;
54
+
44
55
  /**
45
- * ClassName on the root element
56
+ * Never use this prop. Akinon design system does not allow custom styles.
57
+ * @ignore
46
58
  */
47
- rootClassName?: string;
59
+ style?: DO_NOT_USE_OR_YOU_WILL_BE_FIRED_INTERNAL_STYLE;
60
+
48
61
  /**
49
62
  * Whether to show as banner
50
63
  */
51
64
  banner?: boolean;
65
+
52
66
  /**
53
- * Custom icon, effective when showIcon is true
54
- */
55
- icon?: React.ReactNode;
56
- /**
57
- * Custom close icon
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.
58
69
  */
59
- closeIcon?: React.ReactNode;
70
+ icon?: IconName;
71
+
60
72
  /**
61
73
  * The action of Alert
62
74
  */
63
75
  action?: React.ReactNode;
76
+
77
+ /**
78
+ * Mouse enter event handler
79
+ */
64
80
  onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
81
+
82
+ /**
83
+ * Mouse leave event handler
84
+ */
65
85
  onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
86
+
87
+ /**
88
+ * Click event handler
89
+ */
66
90
  onClick?: React.MouseEventHandler<HTMLDivElement>;
91
+
92
+ /**
93
+ * ID for the alert container
94
+ */
67
95
  id?: string;
68
- }
96
+ };
69
97
 
70
98
  type BaseClosableType = {
99
+ /**
100
+ * Custom close icon for the alert.
101
+ */
71
102
  closeIcon?: React.ReactNode;
72
103
  } & React.AriaAttributes;
73
104
 
74
105
  type ClosableType = boolean | BaseClosableType;
75
106
 
76
107
  interface ErrorBoundaryProps {
108
+ /**
109
+ * Error message to display.
110
+ */
77
111
  message?: React.ReactNode;
112
+
113
+ /**
114
+ * Additional description for the error.
115
+ */
78
116
  description?: React.ReactNode;
117
+
118
+ /**
119
+ * Child components to render.
120
+ */
79
121
  children?: React.ReactNode;
122
+
123
+ /**
124
+ * ID for the error boundary.
125
+ */
80
126
  id?: string;
81
127
  }
82
128
 
83
129
  interface ErrorBoundaryStates {
130
+ /**
131
+ * Captured error information.
132
+ */
84
133
  error?: Error | null;
134
+
135
+ /**
136
+ * Additional info about the error.
137
+ */
85
138
  info?: {
139
+ /**
140
+ * Component stack trace.
141
+ */
86
142
  componentStack?: string;
87
143
  };
88
144
  }
@@ -91,13 +147,24 @@ declare class ErrorBoundary extends React.Component<
91
147
  ErrorBoundaryProps,
92
148
  ErrorBoundaryStates
93
149
  > {
150
+ /**
151
+ * Component state.
152
+ */
94
153
  state: {
95
154
  error: undefined;
96
155
  info: {
97
156
  componentStack: string;
98
157
  };
99
158
  };
159
+
160
+ /**
161
+ * Lifecycle method to capture errors.
162
+ */
100
163
  componentDidCatch(error: Error | null, info: object): void;
164
+
165
+ /**
166
+ * Render method for the component.
167
+ */
101
168
  render():
102
169
  | string
103
170
  | number
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/ui-alert",
3
- "version": "0.5.0",
3
+ "version": "1.0.1",
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.17.0",
13
- "@akinon/ui-theme": "0.7.0"
12
+ "antd": "5.22.6",
13
+ "@akinon/icons": "1.0.1",
14
+ "@akinon/ui-theme": "1.0.1"
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": "^5.2.2",
20
- "@akinon/typescript-config": "0.4.0"
20
+ "typescript": "*",
21
+ "@akinon/typescript-config": "1.0.1"
21
22
  },
22
23
  "peerDependencies": {
23
24
  "react": ">=18",