@transferwise/components 0.0.0-experimental-4553cce → 0.0.0-experimental-03e1dec

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/build/index.js +133 -290
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +135 -292
  4. package/build/index.mjs.map +1 -1
  5. package/build/types/alert/Alert.d.ts +47 -58
  6. package/build/types/alert/Alert.d.ts.map +1 -1
  7. package/build/types/alert/index.d.ts +2 -1
  8. package/build/types/alert/index.d.ts.map +1 -1
  9. package/build/types/common/propsValues/sentiment.d.ts +0 -1
  10. package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
  11. package/build/types/index.d.ts +1 -1
  12. package/build/types/index.d.ts.map +1 -1
  13. package/build/types/inlineAlert/InlineAlert.d.ts +2 -4
  14. package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
  15. package/build/types/statusIcon/StatusIcon.d.ts +1 -1
  16. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  17. package/package.json +2 -2
  18. package/src/alert/{Alert.spec.js → Alert.spec.tsx} +42 -44
  19. package/src/alert/Alert.story.tsx +1 -2
  20. package/src/alert/Alert.tsx +222 -0
  21. package/src/alert/index.ts +2 -0
  22. package/src/common/propsValues/sentiment.ts +0 -10
  23. package/src/index.ts +1 -1
  24. package/src/inlineAlert/InlineAlert.spec.tsx +0 -7
  25. package/src/inlineAlert/InlineAlert.tsx +19 -47
  26. package/src/statusIcon/StatusIcon.tsx +14 -14
  27. package/build/types/alert/withArrow/alertArrowPositions.d.ts +0 -9
  28. package/build/types/alert/withArrow/alertArrowPositions.d.ts.map +0 -1
  29. package/build/types/alert/withArrow/index.d.ts +0 -3
  30. package/build/types/alert/withArrow/index.d.ts.map +0 -1
  31. package/build/types/alert/withArrow/withArrow.d.ts +0 -11
  32. package/build/types/alert/withArrow/withArrow.d.ts.map +0 -1
  33. package/src/alert/Alert.js +0 -196
  34. package/src/alert/index.js +0 -1
  35. package/src/alert/withArrow/alertArrowPositions.ts +0 -9
  36. package/src/alert/withArrow/index.js +0 -2
  37. package/src/alert/withArrow/withArrow.js +0 -50
  38. package/src/alert/withArrow/withArrow.spec.js +0 -51
@@ -0,0 +1,222 @@
1
+ import classNames from 'classnames';
2
+ import { useState, useRef, useEffect } from 'react';
3
+
4
+ import Body from '../body/Body';
5
+ import { Sentiment, Size, Typography, Variant } from '../common';
6
+ import { CloseButton } from '../common/closeButton';
7
+ import Link from '../link';
8
+ import StatusIcon from '../statusIcon';
9
+ import Title from '../title/Title';
10
+ import { logActionRequired } from '../utilities';
11
+
12
+ import InlineMarkdown from './inlineMarkdown';
13
+
14
+ export type AlertAction = {
15
+ 'aria-label'?: string;
16
+ href: string;
17
+ target?: string;
18
+ text: React.ReactNode;
19
+ };
20
+
21
+ /** @deprecated Use `"top" | "bottom"` instead. */
22
+ type AlertTypeDeprecated = `${Sentiment.SUCCESS | Sentiment.INFO | Sentiment.ERROR}`;
23
+ type AlertTypeResolved = `${
24
+ | Sentiment.POSITIVE
25
+ | Sentiment.NEUTRAL
26
+ | Sentiment.WARNING
27
+ | Sentiment.NEGATIVE}`;
28
+ export type AlertType = AlertTypeResolved | AlertTypeDeprecated;
29
+
30
+ export enum AlertArrowPosition {
31
+ TOP_LEFT = 'up-left',
32
+ TOP = 'up-center',
33
+ TOP_RIGHT = 'up-right',
34
+ BOTTOM_LEFT = 'down-left',
35
+ BOTTOM = 'down-center',
36
+ BOTTOM_RIGHT = 'down-right',
37
+ }
38
+
39
+ export interface AlertProps {
40
+ /** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */
41
+ action?: AlertAction;
42
+ className?: string;
43
+ /** An optional icon. If not provided, we will default the icon to something appropriate for the type */
44
+ icon?: React.ReactElement;
45
+ /** Title for the alert component */
46
+ title?: string;
47
+ /** The main body of the alert. Accepts plain text and bold words specified with **double stars*/
48
+ message?: string;
49
+ /** The presence of the onDismiss handler will trigger the visibility of the close button */
50
+ onDismiss?: React.MouseEventHandler<HTMLButtonElement>;
51
+ /** The type dictates which icon and colour will be used */
52
+ type?: AlertType;
53
+ variant?: `${Variant}`;
54
+ /** @deprecated Use `InlineAlert` instead. */
55
+ arrow?: `${AlertArrowPosition}`;
56
+ /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */
57
+ children?: React.ReactNode;
58
+ /** @deprecated Use `onDismiss` instead. */
59
+ dismissible?: boolean;
60
+ /** @deprecated Alert component doesn't support `size` anymore, please remove this prop. */
61
+ size?: `${Size}`;
62
+ }
63
+
64
+ function resolveType(type: AlertType): AlertTypeResolved {
65
+ switch (type) {
66
+ case 'success':
67
+ return 'positive';
68
+ case 'info':
69
+ return 'neutral';
70
+ case 'error':
71
+ return 'negative';
72
+ }
73
+ return type;
74
+ }
75
+
76
+ export default function Alert({
77
+ arrow,
78
+ action,
79
+ children,
80
+ className,
81
+ dismissible,
82
+ icon,
83
+ onDismiss,
84
+ message,
85
+ size,
86
+ title,
87
+ type = 'neutral',
88
+ variant = 'desktop',
89
+ }: AlertProps) {
90
+ useEffect(() => {
91
+ if (arrow !== undefined) {
92
+ logActionRequired(
93
+ "Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.",
94
+ );
95
+ }
96
+ }, [arrow]);
97
+
98
+ useEffect(() => {
99
+ if (children !== undefined) {
100
+ logActionRequired(
101
+ "Alert component doesn't support 'children' anymore, use 'message' instead.",
102
+ );
103
+ }
104
+ }, [children]);
105
+
106
+ useEffect(() => {
107
+ if (dismissible !== undefined) {
108
+ logActionRequired(
109
+ "Alert component doesn't support 'dismissible' anymore, use 'onDismiss' instead.",
110
+ );
111
+ }
112
+ }, [dismissible]);
113
+
114
+ useEffect(() => {
115
+ if (size !== undefined) {
116
+ logActionRequired("Alert component doesn't support 'size' anymore, please remove that prop.");
117
+ }
118
+ }, [size]);
119
+
120
+ const resolvedType = resolveType(type);
121
+ useEffect(() => {
122
+ if (resolvedType !== type) {
123
+ logActionRequired(
124
+ `Alert component has deprecated '${type}' value for the 'type' prop. Please use '${resolvedType}' instead.`,
125
+ );
126
+ }
127
+ }, [resolvedType, type]);
128
+
129
+ const [shouldFire, setShouldFire] = useState(false);
130
+
131
+ const closeButtonReference = useRef<HTMLButtonElement>(null);
132
+
133
+ return (
134
+ <div
135
+ className={classNames(
136
+ 'alert d-flex',
137
+ `alert-${resolvedType}`,
138
+ arrow != null && alertArrowClassNames(arrow),
139
+ className,
140
+ )}
141
+ data-testid="alert"
142
+ onTouchStart={() => setShouldFire(true)}
143
+ onTouchEnd={(event) => {
144
+ if (
145
+ shouldFire &&
146
+ action &&
147
+ // Check if current event is triggered from closeButton
148
+ closeButtonReference.current &&
149
+ !closeButtonReference.current.contains(event.currentTarget)
150
+ ) {
151
+ if (action.target === '_blank') {
152
+ window.top?.open(action.href);
153
+ } else {
154
+ window.top?.location.assign(action.href);
155
+ }
156
+ }
157
+ setShouldFire(false);
158
+ }}
159
+ onTouchMove={() => setShouldFire(false)}
160
+ >
161
+ <div
162
+ className={classNames('alert__content', 'd-flex', 'flex-grow-1', variant)}
163
+ data-testid={variant}
164
+ >
165
+ {icon ? (
166
+ <div className="alert__icon">{icon}</div>
167
+ ) : (
168
+ <StatusIcon size={Size.LARGE} sentiment={resolvedType} />
169
+ )}
170
+ <div className="alert__message">
171
+ <div role={Sentiment.NEGATIVE === resolvedType ? 'alert' : 'status'}>
172
+ {title && (
173
+ <Title className="m-b-1" type={Typography.TITLE_BODY}>
174
+ {title}
175
+ </Title>
176
+ )}
177
+ <Body as="span" className="d-block" type={Typography.BODY_LARGE}>
178
+ {children || <InlineMarkdown>{message}</InlineMarkdown>}
179
+ </Body>
180
+ </div>
181
+ {action && (
182
+ <Link
183
+ href={action.href}
184
+ className="m-t-1"
185
+ aria-label={action['aria-label']}
186
+ target={action.target}
187
+ type={Typography.LINK_LARGE}
188
+ >
189
+ {action.text}
190
+ </Link>
191
+ )}
192
+ </div>
193
+ </div>
194
+ {onDismiss && (
195
+ <CloseButton ref={closeButtonReference} className="m-l-2" onClick={onDismiss} />
196
+ )}
197
+ </div>
198
+ );
199
+ }
200
+
201
+ function alertArrowClassNames(arrow: `${AlertArrowPosition}`) {
202
+ if (arrow) {
203
+ const classes = 'arrow';
204
+
205
+ switch (arrow) {
206
+ case 'down-center':
207
+ return `${classes} arrow-bottom arrow-center`;
208
+ case 'down-left':
209
+ return `${classes} arrow-bottom arrow-left`;
210
+ case 'down-right':
211
+ return `${classes} arrow-bottom arrow-right`;
212
+ case 'up-center':
213
+ return `${classes} arrow-center`;
214
+ case 'up-right':
215
+ return `${classes} arrow-right`;
216
+ case 'up-left':
217
+ default:
218
+ return classes;
219
+ }
220
+ }
221
+ return '';
222
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './Alert';
2
+ export type { AlertProps, AlertAction, AlertArrowPosition, AlertType } from './Alert';
@@ -18,13 +18,3 @@ export enum Sentiment {
18
18
  */
19
19
  SUCCESS = 'success',
20
20
  }
21
-
22
- export type SentimentString =
23
- | 'negative'
24
- | 'neutral'
25
- | 'positive'
26
- | 'warning'
27
- | 'pending'
28
- | 'info'
29
- | 'error'
30
- | 'success';
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  export type { AccordionProps, AccordionItem } from './accordion';
5
5
  export type { AvatarProps } from './avatar';
6
6
  export type { ActionOptionProps } from './actionOption';
7
+ export type { AlertProps, AlertAction, AlertArrowPosition, AlertType } from './alert';
7
8
  export type { BadgeProps } from './badge';
8
9
  export type { CircularButtonProps } from './circularButton';
9
10
  export type { DecisionProps } from './decision/Decision';
@@ -194,7 +195,6 @@ export { AvatarType } from './avatar';
194
195
  export { InfoPresentation } from './info';
195
196
  export { UploadStep } from './upload';
196
197
  export { DecisionPresentation, DecisionType } from './decision';
197
- export { AlertArrowPosition } from './alert/withArrow';
198
198
  export { LogoType } from './logo';
199
199
  export { FileType } from './common';
200
200
 
@@ -21,13 +21,6 @@ describe('InlineAlert', () => {
21
21
 
22
22
  expect(component).toHaveClass('alert-neutral');
23
23
  });
24
-
25
- it('has a top left arrow', () => {
26
- render(<InlineAlert>{message}</InlineAlert>);
27
- const component = screen.getByRole('alert');
28
-
29
- expect(component).toHaveClass('arrow');
30
- });
31
24
  });
32
25
 
33
26
  describe('render with types', () => {
@@ -1,59 +1,31 @@
1
1
  import { AlertCircle as AlertCircleIcon } from '@transferwise/icons';
2
- import { useTheme } from '@wise/components-theming';
3
2
  import classNames from 'classnames';
4
3
  import { ReactNode } from 'react';
5
4
 
6
- import withArrow, { AlertArrowPosition } from '../alert/withArrow';
7
5
  import { Sentiment } from '../common';
8
- import { SentimentString } from '../common/propsValues/sentiment';
9
6
 
10
7
  export interface InlineAlertProps {
11
8
  id?: string;
12
- type?: Sentiment | SentimentString;
9
+ type?: `${Sentiment}`;
13
10
  className?: string;
14
11
  children: ReactNode;
15
12
  }
16
13
 
17
- const typeClassMap: Record<Sentiment.ERROR | Sentiment.NEGATIVE, string> = {
18
- [Sentiment.ERROR]: 'danger',
19
- [Sentiment.NEGATIVE]: 'danger',
20
- };
21
-
22
- const InlineAlert = ({ id, type = Sentiment.NEUTRAL, className, children }: InlineAlertProps) => {
23
- const { isModern } = useTheme();
24
-
25
- const typeClass = `alert-${typeClassMap[type as Sentiment.ERROR | Sentiment.NEGATIVE] || type}`;
26
-
27
- if (isModern) {
28
- return (
29
- <div role="alert" id={id} className={classNames('alert alert-detach', typeClass, className)}>
30
- {(type === 'error' || type === 'negative') && <AlertCircleIcon />}
31
- <div>{children}</div>
32
- </div>
33
- );
34
- }
35
-
36
- const getAlertContents = ({
37
- children,
38
- className,
39
- }: {
40
- children: ReactNode;
41
- className?: string;
42
- }) => {
43
- return (
44
- <div
45
- role="alert"
46
- id={id}
47
- className={classNames('alert alert-detach p-x-2 p-y-1', typeClass, className)}
48
- >
49
- {children}
50
- </div>
51
- );
52
- };
53
-
54
- const AlertWithArrow = withArrow(getAlertContents, AlertArrowPosition.TOP_LEFT);
55
-
56
- return <AlertWithArrow {...{ id, type, className, children }} />;
57
- };
58
-
59
- export default InlineAlert;
14
+ export default function InlineAlert({
15
+ id,
16
+ type = Sentiment.NEUTRAL,
17
+ className,
18
+ children,
19
+ }: InlineAlertProps) {
20
+ const danger = type === 'negative' || type === 'error';
21
+ return (
22
+ <div
23
+ role="alert"
24
+ id={id}
25
+ className={classNames('alert alert-detach', `alert-${danger ? 'danger' : type}`, className)}
26
+ >
27
+ {danger && <AlertCircleIcon />}
28
+ <div>{children}</div>
29
+ </div>
30
+ );
31
+ }
@@ -1,27 +1,27 @@
1
1
  import { Info, Alert, Cross, Check, ClockBorderless } from '@transferwise/icons';
2
2
  import classNames from 'classnames';
3
3
 
4
- import { SizeSmall, SizeMedium, SizeLarge, Sentiment, Size } from '../common';
4
+ import { SizeSmall, SizeMedium, SizeLarge, Sentiment } from '../common';
5
5
 
6
6
  export type StatusIconProps = {
7
- sentiment: Sentiment;
7
+ sentiment: `${Sentiment}`;
8
8
  size: SizeSmall | SizeMedium | SizeLarge;
9
9
  };
10
10
 
11
- const StatusIcon = ({ sentiment = Sentiment.NEUTRAL, size = Size.MEDIUM }: StatusIconProps) => {
12
- const iconTypeMap = {
13
- [Sentiment.POSITIVE]: Check,
14
- [Sentiment.NEUTRAL]: Info,
15
- [Sentiment.WARNING]: Alert,
16
- [Sentiment.NEGATIVE]: Cross,
17
- [Sentiment.PENDING]: ClockBorderless,
18
- [Sentiment.INFO]: Info,
19
- [Sentiment.ERROR]: Cross,
20
- [Sentiment.SUCCESS]: Check,
21
- };
11
+ const iconTypeMap = {
12
+ positive: Check,
13
+ neutral: Info,
14
+ warning: Alert,
15
+ negative: Cross,
16
+ pending: ClockBorderless,
17
+ info: Info,
18
+ error: Cross,
19
+ success: Check,
20
+ } satisfies Record<`${Sentiment}`, React.ElementType>;
22
21
 
23
- const iconColor = [Sentiment.WARNING, Sentiment.PENDING].includes(sentiment) ? 'dark' : 'light';
22
+ const StatusIcon = ({ sentiment = 'neutral', size = 'md' }: StatusIconProps) => {
24
23
  const Icon = iconTypeMap[sentiment];
24
+ const iconColor = sentiment === 'warning' || sentiment === 'pending' ? 'dark' : 'light';
25
25
 
26
26
  return (
27
27
  <span
@@ -1,9 +0,0 @@
1
- export declare enum ArrowPosition {
2
- TOP_LEFT = "up-left",
3
- TOP = "up-center",
4
- TOP_RIGHT = "up-right",
5
- BOTTOM_LEFT = "down-left",
6
- BOTTOM = "down-center",
7
- BOTTOM_RIGHT = "down-right"
8
- }
9
- //# sourceMappingURL=alertArrowPositions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"alertArrowPositions.d.ts","sourceRoot":"","sources":["../../../../src/alert/withArrow/alertArrowPositions.ts"],"names":[],"mappings":"AACA,oBAAY,aAAa;IACvB,QAAQ,YAAY;IACpB,GAAG,cAAc;IACjB,SAAS,aAAa;IACtB,WAAW,cAAc;IACzB,MAAM,gBAAgB;IACtB,YAAY,eAAe;CAC5B"}
@@ -1,3 +0,0 @@
1
- export { ArrowPosition as AlertArrowPosition } from "./alertArrowPositions";
2
- export { default } from "./withArrow";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/alert/withArrow/index.js"],"names":[],"mappings":""}
@@ -1,11 +0,0 @@
1
- export default withArrow;
2
- declare function withArrow(Alert: any, arrow: any): {
3
- (props: any): import("react").JSX.Element;
4
- propTypes: {
5
- className: any;
6
- };
7
- defaultProps: {
8
- className: undefined;
9
- };
10
- };
11
- //# sourceMappingURL=withArrow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withArrow.d.ts","sourceRoot":"","sources":["../../../../src/alert/withArrow/withArrow.js"],"names":[],"mappings":";AAKA;;;;;;;;EAkBC"}
@@ -1,196 +0,0 @@
1
- import {
2
- InfoCircle,
3
- Warning as AlertTriangle,
4
- CrossCircle,
5
- CheckCircle,
6
- Clock,
7
- } from '@transferwise/icons';
8
- import { useTheme } from '@wise/components-theming';
9
- import classNames from 'classnames';
10
- import PropTypes from 'prop-types';
11
- import { useState, useRef } from 'react';
12
- import requiredIf from 'react-required-if';
13
-
14
- import Body from '../body/Body';
15
- import { Sentiment, Size, Typography, Variant } from '../common';
16
- import { CloseButton } from '../common/closeButton';
17
- import Link from '../link';
18
- import StatusIcon from '../statusIcon';
19
- import Title from '../title/Title';
20
- import { logActionRequiredIf, deprecated } from '../utilities';
21
-
22
- import InlineMarkdown from './inlineMarkdown';
23
- import withArrow from './withArrow';
24
-
25
- const deprecatedTypeMap = {
26
- [Sentiment.SUCCESS]: Sentiment.POSITIVE,
27
- [Sentiment.INFO]: Sentiment.NEUTRAL,
28
- [Sentiment.ERROR]: Sentiment.NEGATIVE,
29
- };
30
-
31
- const Alert = (props) => {
32
- const { isModern } = useTheme();
33
-
34
- const iconTypeMap = {
35
- [Sentiment.POSITIVE]: CheckCircle,
36
- [Sentiment.NEUTRAL]: InfoCircle,
37
- [Sentiment.WARNING]: AlertTriangle,
38
- [Sentiment.NEGATIVE]: CrossCircle,
39
- [Sentiment.PENDING]: Clock,
40
- };
41
-
42
- const [shouldFire, setShouldFire] = useState(false);
43
- const { arrow, action, children, className, icon, onDismiss, message, title, type, variant } =
44
- props;
45
- const closeButtonReference = useRef(null);
46
- if (arrow) {
47
- const AlertWithArrow = withArrow(Alert, arrow);
48
- return <AlertWithArrow {...props} />;
49
- }
50
- logActionRequired(props);
51
- const mappedType = deprecatedTypeMap[type] || type;
52
- const Icon = iconTypeMap[mappedType];
53
-
54
- function generateIcon() {
55
- if (icon) {
56
- return <div className="alert__icon">{icon}</div>;
57
- }
58
- if (isModern) {
59
- return <StatusIcon size={Size.LARGE} sentiment={mappedType} />;
60
- } else {
61
- return <Icon size={24} />;
62
- }
63
- }
64
-
65
- const handleTouchStart = () => setShouldFire(true);
66
- const handleTouchMove = () => setShouldFire(false);
67
- const handleTouchEnd = (event) => {
68
- if (shouldFire && action) {
69
- // Check if current event is triggered from closeButton
70
- if (closeButtonReference?.current && !closeButtonReference.current.contains(event.target)) {
71
- if (action?.target === '_blank') {
72
- window.top.open(action.href);
73
- } else {
74
- window.top.location.assign(action.href);
75
- }
76
- }
77
- }
78
- setShouldFire(false);
79
- };
80
- return (
81
- <div
82
- className={classNames('alert d-flex', `alert-${mappedType}`, className)}
83
- data-testid="alert"
84
- onTouchStart={handleTouchStart}
85
- onTouchEnd={handleTouchEnd}
86
- onTouchMove={handleTouchMove}
87
- >
88
- <div
89
- className={classNames('alert__content', 'd-flex', 'flex-grow-1', variant)}
90
- data-testid={variant}
91
- >
92
- {generateIcon()}
93
- <div className="alert__message">
94
- <div role={Sentiment.NEGATIVE === mappedType ? 'alert' : 'status'}>
95
- {title && (
96
- <Title className="m-b-1" type={Typography.TITLE_BODY}>
97
- {title}
98
- </Title>
99
- )}
100
- <Body as="span" className="d-block" type={Typography.BODY_LARGE}>
101
- {children || <InlineMarkdown>{message}</InlineMarkdown>}
102
- </Body>
103
- </div>
104
- {action && (
105
- <Link
106
- href={action.href}
107
- className="m-t-1"
108
- aria-label={action['aria-label']}
109
- target={action.target}
110
- type={Typography.LINK_LARGE}
111
- >
112
- {action.text}
113
- </Link>
114
- )}
115
- </div>
116
- </div>
117
- {onDismiss && (
118
- <CloseButton ref={closeButtonReference} className="m-l-2" onClick={onDismiss} />
119
- )}
120
- </div>
121
- );
122
- };
123
-
124
- const deprecatedTypeMapMessage = {
125
- [Sentiment.SUCCESS]: 'Sentiment.POSITIVE',
126
- [Sentiment.INFO]: 'Sentiment.NEUTRAL',
127
- [Sentiment.ERROR]: 'Sentiment.NEGATIVE',
128
- };
129
-
130
- const deprecatedTypes = Object.keys(deprecatedTypeMap);
131
-
132
- function logActionRequired({ size, type }) {
133
- logActionRequiredIf(
134
- 'Alert no longer supports any possible variations in size. Please remove the `size` prop.',
135
- !!size,
136
- );
137
- logActionRequiredIf(
138
- `Alert has deprecated the ${type} value for the \`type\` prop. Please update to ${deprecatedTypeMapMessage[type]}.`,
139
- deprecatedTypes.includes(type),
140
- );
141
- }
142
-
143
- Alert.propTypes = {
144
- /** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */
145
- action: PropTypes.shape({
146
- 'aria-label': PropTypes.string,
147
- href: PropTypes.string.isRequired,
148
- target: PropTypes.string,
149
- text: PropTypes.node.isRequired,
150
- }),
151
- className: PropTypes.string,
152
- /** An optional icon. If not provided, we will default the icon to something appropriate for the type */
153
- icon: PropTypes.element,
154
- /** Title for the alert component */
155
- title: PropTypes.string,
156
- /** The main body of the alert. Accepts plain text and bold words specified with **double stars*/
157
- message: requiredIf(PropTypes.node, ({ children }) => !children),
158
- /** The presence of the onDismiss handler will trigger the visibility of the close button */
159
- onDismiss: PropTypes.func,
160
- /** The type dictates which icon and colour will be used */
161
- type: PropTypes.oneOf(['negative', 'neutral', 'positive', 'warning', 'info', 'error', 'success']),
162
- variant: PropTypes.oneOf(['desktop', 'mobile']),
163
- /** @deprecated no arrow for `Alert` component anymore, consider to use [`InlineAlert`](https://transferwise.github.io/neptune-web/components/alerts/InlineAlert) component */
164
- arrow: deprecated(
165
- PropTypes.oneOf(['up-left', 'up-center', 'up-right', 'down-left', 'down-center', 'down-right']),
166
- { component: 'Alert', expiryDate: new Date('03-01-2021') },
167
- ),
168
- /** @deprecated use `message` property instead */
169
- children: deprecated(
170
- requiredIf(PropTypes.node, ({ message }) => !message),
171
- {
172
- component: 'Alert',
173
- message:
174
- 'You should now use the `message` prop. Be aware `message` only accepts plain text or text with **bold** markdown.',
175
- expiryDate: new Date('03-01-2021'),
176
- },
177
- ),
178
- /** @deprecated use `onDismiss` instead */
179
- dismissible: deprecated(PropTypes.bool, {
180
- component: 'Alert',
181
- message: 'The Alert will now be considered dismissible if an `onDismiss` hander is present.',
182
- expiryDate: new Date('03-01-2021'),
183
- }),
184
- };
185
-
186
- Alert.defaultProps = {
187
- action: undefined,
188
- arrow: undefined,
189
- className: undefined,
190
- dismissible: undefined,
191
- icon: undefined,
192
- type: Sentiment.NEUTRAL,
193
- variant: Variant.DESKTOP,
194
- };
195
-
196
- export default Alert;
@@ -1 +0,0 @@
1
- export { default } from './Alert';
@@ -1,9 +0,0 @@
1
- // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
2
- export enum ArrowPosition {
3
- TOP_LEFT = 'up-left',
4
- TOP = 'up-center',
5
- TOP_RIGHT = 'up-right',
6
- BOTTOM_LEFT = 'down-left',
7
- BOTTOM = 'down-center',
8
- BOTTOM_RIGHT = 'down-right',
9
- }
@@ -1,2 +0,0 @@
1
- export { ArrowPosition as AlertArrowPosition } from './alertArrowPositions';
2
- export { default } from './withArrow';