@transferwise/components 46.27.0 → 46.28.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/build/i18n/th.json +2 -2
- package/build/index.js +327 -630
- package/build/index.js.map +1 -1
- package/build/index.mjs +328 -631
- package/build/index.mjs.map +1 -1
- package/build/types/alert/Alert.d.ts +47 -58
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/alert/index.d.ts +2 -1
- package/build/types/alert/index.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +7 -9
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
- package/build/types/common/propsValues/sentiment.d.ts +0 -1
- package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +75 -28
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.messages.d.ts +42 -63
- package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -1
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts +9 -22
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
- package/build/types/dateLookup/dateHeader/index.d.ts +1 -1
- package/build/types/dateLookup/dateHeader/index.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts +13 -31
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/index.d.ts +1 -1
- package/build/types/dateLookup/dateTrigger/index.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts +19 -2
- package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/dayCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts +12 -2
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/dayCalendar/table/index.d.ts.map +1 -1
- package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts +1 -1
- package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts.map +1 -1
- package/build/types/dateLookup/getStartOfDay/index.d.ts +1 -1
- package/build/types/dateLookup/getStartOfDay/index.d.ts.map +1 -1
- package/build/types/dateLookup/index.d.ts +2 -1
- package/build/types/dateLookup/index.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts +17 -2
- package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +10 -26
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/table/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +15 -2
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/yearCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts +10 -26
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/yearCalendar/table/index.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inlineAlert/InlineAlert.d.ts +2 -4
- package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
- package/build/types/inputs/_Popover.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/alert/{Alert.spec.js → Alert.spec.tsx} +43 -40
- package/src/alert/Alert.story.tsx +1 -2
- package/src/alert/Alert.tsx +218 -0
- package/src/alert/index.ts +2 -0
- package/src/button/Button.tsx +6 -10
- package/src/common/dateUtils/isWithinRange/isWithinRange.spec.ts +21 -0
- package/src/common/dateUtils/isWithinRange/isWithinRange.ts +2 -2
- package/src/common/dateUtils/moveToWithinRange/moveToWithinRange.ts +8 -4
- package/src/common/propsValues/sentiment.ts +0 -10
- package/src/dateLookup/DateLookup.state.spec.js +7 -0
- package/src/dateLookup/{DateLookup.story.js → DateLookup.story.tsx} +13 -14
- package/src/dateLookup/DateLookup.tests.story.tsx +70 -0
- package/src/dateLookup/{DateLookup.js → DateLookup.tsx} +115 -81
- package/src/dateLookup/dateHeader/{DateHeader.js → DateHeader.tsx} +15 -15
- package/src/dateLookup/dateTrigger/DateTrigger.spec.js +0 -22
- package/src/dateLookup/dateTrigger/{DateTrigger.js → DateTrigger.tsx} +15 -32
- package/src/dateLookup/dayCalendar/{DayCalendar.js → DayCalendar.tsx} +14 -21
- package/src/dateLookup/dayCalendar/table/{DayCalendarTable.js → DayCalendarTable.tsx} +26 -37
- package/src/dateLookup/getStartOfDay/{getStartOfDay.js → getStartOfDay.tsx} +1 -1
- package/src/dateLookup/index.ts +2 -0
- package/src/dateLookup/monthCalendar/{MonthCalendar.js → MonthCalendar.tsx} +19 -22
- package/src/dateLookup/monthCalendar/table/{MonthCalendarTable.js → MonthCalendarTable.tsx} +31 -30
- package/src/dateLookup/yearCalendar/{YearCalendar.js → YearCalendar.tsx} +18 -21
- package/src/dateLookup/yearCalendar/table/{YearCalendarTable.js → YearCalendarTable.tsx} +26 -28
- package/src/i18n/th.json +2 -2
- package/src/index.ts +2 -1
- package/src/inlineAlert/InlineAlert.spec.tsx +0 -7
- package/src/inlineAlert/InlineAlert.tsx +19 -47
- package/src/inputs/InputGroup.tsx +3 -3
- package/src/inputs/SelectInput.tsx +1 -0
- package/src/inputs/_BottomSheet.tsx +44 -54
- package/src/inputs/_Popover.tsx +20 -23
- package/src/statusIcon/StatusIcon.tsx +14 -14
- package/build/types/alert/withArrow/alertArrowPositions.d.ts +0 -9
- package/build/types/alert/withArrow/alertArrowPositions.d.ts.map +0 -1
- package/build/types/alert/withArrow/index.d.ts +0 -3
- package/build/types/alert/withArrow/index.d.ts.map +0 -1
- package/build/types/alert/withArrow/withArrow.d.ts +0 -11
- package/build/types/alert/withArrow/withArrow.d.ts.map +0 -1
- package/src/alert/Alert.js +0 -196
- package/src/alert/index.js +0 -1
- package/src/alert/withArrow/alertArrowPositions.ts +0 -9
- package/src/alert/withArrow/index.js +0 -2
- package/src/alert/withArrow/withArrow.js +0 -50
- package/src/alert/withArrow/withArrow.spec.js +0 -51
- package/src/dateLookup/index.js +0 -1
- /package/src/dateLookup/{DateLookup.messages.js → DateLookup.messages.ts} +0 -0
- /package/src/dateLookup/dateHeader/{index.js → index.ts} +0 -0
- /package/src/dateLookup/dateTrigger/{index.js → index.ts} +0 -0
- /package/src/dateLookup/dayCalendar/{index.js → index.ts} +0 -0
- /package/src/dateLookup/dayCalendar/table/{index.js → index.ts} +0 -0
- /package/src/dateLookup/getStartOfDay/{index.js → index.ts} +0 -0
- /package/src/dateLookup/monthCalendar/{index.js → index.ts} +0 -0
- /package/src/dateLookup/monthCalendar/table/{index.js → index.ts} +0 -0
- /package/src/dateLookup/yearCalendar/{index.js → index.ts} +0 -0
- /package/src/dateLookup/yearCalendar/table/{index.js → index.ts} +0 -0
package/src/inputs/_Popover.tsx
CHANGED
|
@@ -17,7 +17,6 @@ import { ThemeProvider, useTheme } from '@wise/components-theming';
|
|
|
17
17
|
import classNames from 'classnames';
|
|
18
18
|
import { useState } from 'react';
|
|
19
19
|
|
|
20
|
-
import FocusBoundary from '../common/focusBoundary/FocusBoundary';
|
|
21
20
|
import { PreventScroll } from '../common/preventScroll/PreventScroll';
|
|
22
21
|
|
|
23
22
|
export interface PopoverProps {
|
|
@@ -104,32 +103,30 @@ export function Popover({
|
|
|
104
103
|
}}
|
|
105
104
|
afterLeave={onCloseEnd}
|
|
106
105
|
>
|
|
107
|
-
<
|
|
108
|
-
<
|
|
106
|
+
<FloatingFocusManager context={context}>
|
|
107
|
+
<div
|
|
108
|
+
key={floatingKey} // Force inner state invalidation on open
|
|
109
|
+
ref={refs.setFloating}
|
|
110
|
+
className={classNames('np-popover-v2-container', {
|
|
111
|
+
'np-popover-v2-container--size-md': size === 'md',
|
|
112
|
+
'np-popover-v2-container--size-lg': size === 'lg',
|
|
113
|
+
})}
|
|
114
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
115
|
+
style={floatingStyles}
|
|
116
|
+
{...getFloatingProps()}
|
|
117
|
+
>
|
|
109
118
|
<div
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
className={classNames('np-popover-v2-container', {
|
|
113
|
-
'np-popover-v2-container--size-md': size === 'md',
|
|
114
|
-
'np-popover-v2-container--size-lg': size === 'lg',
|
|
119
|
+
className={classNames('np-popover-v2', title && 'np-popover-v2--has-title', {
|
|
120
|
+
'np-popover-v2--padding-md': padding === 'md',
|
|
115
121
|
})}
|
|
116
|
-
// eslint-disable-next-line react/forbid-dom-props
|
|
117
|
-
style={floatingStyles}
|
|
118
|
-
{...getFloatingProps()}
|
|
119
122
|
>
|
|
120
|
-
|
|
121
|
-
className=
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
>
|
|
125
|
-
{title ? (
|
|
126
|
-
<h2 className="np-popover-v2-title np-text-title-body">{title}</h2>
|
|
127
|
-
) : null}
|
|
128
|
-
<div className="np-popover-v2-content np-text-body-default">{children}</div>
|
|
129
|
-
</div>
|
|
123
|
+
{title ? (
|
|
124
|
+
<h2 className="np-popover-v2-title np-text-title-body">{title}</h2>
|
|
125
|
+
) : null}
|
|
126
|
+
<div className="np-popover-v2-content np-text-body-default">{children}</div>
|
|
130
127
|
</div>
|
|
131
|
-
</
|
|
132
|
-
</
|
|
128
|
+
</div>
|
|
129
|
+
</FloatingFocusManager>
|
|
133
130
|
</Transition>
|
|
134
131
|
</ThemeProvider>
|
|
135
132
|
</FloatingPortal>
|
|
@@ -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
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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 +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 +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"}
|
package/src/alert/Alert.js
DELETED
|
@@ -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;
|
package/src/alert/index.js
DELETED
|
@@ -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,50 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
|
|
4
|
-
import { ArrowPosition } from './alertArrowPositions';
|
|
5
|
-
|
|
6
|
-
function withArrow(Alert, arrow) {
|
|
7
|
-
const AlertWithArrow = (props) => (
|
|
8
|
-
<Alert
|
|
9
|
-
{...props}
|
|
10
|
-
className={classNames(props.className, arrowClasses(arrow))}
|
|
11
|
-
arrow={undefined}
|
|
12
|
-
/>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
AlertWithArrow.propTypes = {
|
|
16
|
-
className: PropTypes.string,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
AlertWithArrow.defaultProps = {
|
|
20
|
-
className: undefined,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
return AlertWithArrow;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function arrowClasses(arrow) {
|
|
27
|
-
if (arrow) {
|
|
28
|
-
const classes = ['arrow'];
|
|
29
|
-
const { BOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT, TOP, TOP_RIGHT, TOP_LEFT } = ArrowPosition;
|
|
30
|
-
|
|
31
|
-
switch (arrow) {
|
|
32
|
-
case BOTTOM:
|
|
33
|
-
return classes.concat('arrow-bottom', 'arrow-center');
|
|
34
|
-
case BOTTOM_LEFT:
|
|
35
|
-
return classes.concat('arrow-bottom', 'arrow-left');
|
|
36
|
-
case BOTTOM_RIGHT:
|
|
37
|
-
return classes.concat('arrow-bottom', 'arrow-right');
|
|
38
|
-
case TOP:
|
|
39
|
-
return classes.concat('arrow-center');
|
|
40
|
-
case TOP_RIGHT:
|
|
41
|
-
return classes.concat('arrow-right');
|
|
42
|
-
case TOP_LEFT:
|
|
43
|
-
default:
|
|
44
|
-
return classes;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return '';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default withArrow;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '../../test-utils';
|
|
2
|
-
import Alert from '../Alert';
|
|
3
|
-
|
|
4
|
-
import { ArrowPosition } from './alertArrowPositions';
|
|
5
|
-
import withArrow from './withArrow';
|
|
6
|
-
|
|
7
|
-
describe('withArrow', () => {
|
|
8
|
-
const message = 'I hope you have a nice day today';
|
|
9
|
-
|
|
10
|
-
describe('default props', () => {
|
|
11
|
-
it(`returns an arrowless alert if you don't pass an arrow`, () => {
|
|
12
|
-
const ArrowLessAlert = withArrow(Alert);
|
|
13
|
-
|
|
14
|
-
render(<ArrowLessAlert message={message} />);
|
|
15
|
-
const component = screen.getByTestId('alert');
|
|
16
|
-
|
|
17
|
-
expect(component).not.toHaveClass('arrow');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it(`ignores the arrow prop passed to the new alert`, () => {
|
|
21
|
-
const AlertTopArrow = withArrow(Alert, ArrowPosition.TOP_LEFT);
|
|
22
|
-
|
|
23
|
-
render(<AlertTopArrow message={message} arrow={ArrowPosition.BOTTOM_LEFT} />);
|
|
24
|
-
const component = screen.getByTestId('alert');
|
|
25
|
-
expect(component).toHaveClass('arrow');
|
|
26
|
-
expect(component).not.toHaveClass('arrow-bottom');
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('renders arrows', () => {
|
|
31
|
-
const getPointyAlert = (arrow) => withArrow(Alert, arrow);
|
|
32
|
-
|
|
33
|
-
it(`returns an bottom arrowed alert if you pass a bottom arrow`, () => {
|
|
34
|
-
const BottomArrowAlert = getPointyAlert(ArrowPosition.BOTTOM);
|
|
35
|
-
render(<BottomArrowAlert message={message} />);
|
|
36
|
-
const component = screen.getByTestId('alert');
|
|
37
|
-
|
|
38
|
-
expect(component).toHaveClass('arrow');
|
|
39
|
-
expect(component).toHaveClass('arrow-bottom');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it(`returns an top-right arrowed alert if you pass a top right arrow`, () => {
|
|
43
|
-
const BottomArrowAlert = getPointyAlert(ArrowPosition.TOP_RIGHT);
|
|
44
|
-
render(<BottomArrowAlert message={message} />);
|
|
45
|
-
const component = screen.getByTestId('alert');
|
|
46
|
-
|
|
47
|
-
expect(component).toHaveClass('arrow');
|
|
48
|
-
expect(component).toHaveClass('arrow-right');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
package/src/dateLookup/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './DateLookup';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|