@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.
Files changed (125) hide show
  1. package/build/i18n/th.json +2 -2
  2. package/build/index.js +327 -630
  3. package/build/index.js.map +1 -1
  4. package/build/index.mjs +328 -631
  5. package/build/index.mjs.map +1 -1
  6. package/build/types/alert/Alert.d.ts +47 -58
  7. package/build/types/alert/Alert.d.ts.map +1 -1
  8. package/build/types/alert/index.d.ts +2 -1
  9. package/build/types/alert/index.d.ts.map +1 -1
  10. package/build/types/button/Button.d.ts +7 -9
  11. package/build/types/button/Button.d.ts.map +1 -1
  12. package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
  13. package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
  14. package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
  15. package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
  16. package/build/types/common/propsValues/sentiment.d.ts +0 -1
  17. package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
  18. package/build/types/dateLookup/DateLookup.d.ts +75 -28
  19. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  20. package/build/types/dateLookup/DateLookup.messages.d.ts +42 -63
  21. package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -1
  22. package/build/types/dateLookup/dateHeader/DateHeader.d.ts +9 -22
  23. package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
  24. package/build/types/dateLookup/dateHeader/index.d.ts +1 -1
  25. package/build/types/dateLookup/dateHeader/index.d.ts.map +1 -1
  26. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts +13 -31
  27. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
  28. package/build/types/dateLookup/dateTrigger/index.d.ts +1 -1
  29. package/build/types/dateLookup/dateTrigger/index.d.ts.map +1 -1
  30. package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts +19 -2
  31. package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts.map +1 -1
  32. package/build/types/dateLookup/dayCalendar/index.d.ts +1 -1
  33. package/build/types/dateLookup/dayCalendar/index.d.ts.map +1 -1
  34. package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts +12 -2
  35. package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts.map +1 -1
  36. package/build/types/dateLookup/dayCalendar/table/index.d.ts +1 -1
  37. package/build/types/dateLookup/dayCalendar/table/index.d.ts.map +1 -1
  38. package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts +1 -1
  39. package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts.map +1 -1
  40. package/build/types/dateLookup/getStartOfDay/index.d.ts +1 -1
  41. package/build/types/dateLookup/getStartOfDay/index.d.ts.map +1 -1
  42. package/build/types/dateLookup/index.d.ts +2 -1
  43. package/build/types/dateLookup/index.d.ts.map +1 -1
  44. package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts +17 -2
  45. package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts.map +1 -1
  46. package/build/types/dateLookup/monthCalendar/index.d.ts +1 -1
  47. package/build/types/dateLookup/monthCalendar/index.d.ts.map +1 -1
  48. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +10 -26
  49. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
  50. package/build/types/dateLookup/monthCalendar/table/index.d.ts +1 -1
  51. package/build/types/dateLookup/monthCalendar/table/index.d.ts.map +1 -1
  52. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +15 -2
  53. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
  54. package/build/types/dateLookup/yearCalendar/index.d.ts +1 -1
  55. package/build/types/dateLookup/yearCalendar/index.d.ts.map +1 -1
  56. package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts +10 -26
  57. package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
  58. package/build/types/dateLookup/yearCalendar/table/index.d.ts +1 -1
  59. package/build/types/dateLookup/yearCalendar/table/index.d.ts.map +1 -1
  60. package/build/types/index.d.ts +2 -1
  61. package/build/types/index.d.ts.map +1 -1
  62. package/build/types/inlineAlert/InlineAlert.d.ts +2 -4
  63. package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
  64. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  65. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  66. package/build/types/inputs/_Popover.d.ts.map +1 -1
  67. package/build/types/statusIcon/StatusIcon.d.ts +1 -1
  68. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  69. package/package.json +1 -1
  70. package/src/alert/{Alert.spec.js → Alert.spec.tsx} +43 -40
  71. package/src/alert/Alert.story.tsx +1 -2
  72. package/src/alert/Alert.tsx +218 -0
  73. package/src/alert/index.ts +2 -0
  74. package/src/button/Button.tsx +6 -10
  75. package/src/common/dateUtils/isWithinRange/isWithinRange.spec.ts +21 -0
  76. package/src/common/dateUtils/isWithinRange/isWithinRange.ts +2 -2
  77. package/src/common/dateUtils/moveToWithinRange/moveToWithinRange.ts +8 -4
  78. package/src/common/propsValues/sentiment.ts +0 -10
  79. package/src/dateLookup/DateLookup.state.spec.js +7 -0
  80. package/src/dateLookup/{DateLookup.story.js → DateLookup.story.tsx} +13 -14
  81. package/src/dateLookup/DateLookup.tests.story.tsx +70 -0
  82. package/src/dateLookup/{DateLookup.js → DateLookup.tsx} +115 -81
  83. package/src/dateLookup/dateHeader/{DateHeader.js → DateHeader.tsx} +15 -15
  84. package/src/dateLookup/dateTrigger/DateTrigger.spec.js +0 -22
  85. package/src/dateLookup/dateTrigger/{DateTrigger.js → DateTrigger.tsx} +15 -32
  86. package/src/dateLookup/dayCalendar/{DayCalendar.js → DayCalendar.tsx} +14 -21
  87. package/src/dateLookup/dayCalendar/table/{DayCalendarTable.js → DayCalendarTable.tsx} +26 -37
  88. package/src/dateLookup/getStartOfDay/{getStartOfDay.js → getStartOfDay.tsx} +1 -1
  89. package/src/dateLookup/index.ts +2 -0
  90. package/src/dateLookup/monthCalendar/{MonthCalendar.js → MonthCalendar.tsx} +19 -22
  91. package/src/dateLookup/monthCalendar/table/{MonthCalendarTable.js → MonthCalendarTable.tsx} +31 -30
  92. package/src/dateLookup/yearCalendar/{YearCalendar.js → YearCalendar.tsx} +18 -21
  93. package/src/dateLookup/yearCalendar/table/{YearCalendarTable.js → YearCalendarTable.tsx} +26 -28
  94. package/src/i18n/th.json +2 -2
  95. package/src/index.ts +2 -1
  96. package/src/inlineAlert/InlineAlert.spec.tsx +0 -7
  97. package/src/inlineAlert/InlineAlert.tsx +19 -47
  98. package/src/inputs/InputGroup.tsx +3 -3
  99. package/src/inputs/SelectInput.tsx +1 -0
  100. package/src/inputs/_BottomSheet.tsx +44 -54
  101. package/src/inputs/_Popover.tsx +20 -23
  102. package/src/statusIcon/StatusIcon.tsx +14 -14
  103. package/build/types/alert/withArrow/alertArrowPositions.d.ts +0 -9
  104. package/build/types/alert/withArrow/alertArrowPositions.d.ts.map +0 -1
  105. package/build/types/alert/withArrow/index.d.ts +0 -3
  106. package/build/types/alert/withArrow/index.d.ts.map +0 -1
  107. package/build/types/alert/withArrow/withArrow.d.ts +0 -11
  108. package/build/types/alert/withArrow/withArrow.d.ts.map +0 -1
  109. package/src/alert/Alert.js +0 -196
  110. package/src/alert/index.js +0 -1
  111. package/src/alert/withArrow/alertArrowPositions.ts +0 -9
  112. package/src/alert/withArrow/index.js +0 -2
  113. package/src/alert/withArrow/withArrow.js +0 -50
  114. package/src/alert/withArrow/withArrow.spec.js +0 -51
  115. package/src/dateLookup/index.js +0 -1
  116. /package/src/dateLookup/{DateLookup.messages.js → DateLookup.messages.ts} +0 -0
  117. /package/src/dateLookup/dateHeader/{index.js → index.ts} +0 -0
  118. /package/src/dateLookup/dateTrigger/{index.js → index.ts} +0 -0
  119. /package/src/dateLookup/dayCalendar/{index.js → index.ts} +0 -0
  120. /package/src/dateLookup/dayCalendar/table/{index.js → index.ts} +0 -0
  121. /package/src/dateLookup/getStartOfDay/{index.js → index.ts} +0 -0
  122. /package/src/dateLookup/monthCalendar/{index.js → index.ts} +0 -0
  123. /package/src/dateLookup/monthCalendar/table/{index.js → index.ts} +0 -0
  124. /package/src/dateLookup/yearCalendar/{index.js → index.ts} +0 -0
  125. /package/src/dateLookup/yearCalendar/table/{index.js → index.ts} +0 -0
@@ -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
- <FocusBoundary>
108
- <FloatingFocusManager context={context} guards={false} modal={false}>
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
- key={floatingKey} // Force inner state invalidation on open
111
- ref={refs.setFloating}
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
- <div
121
- className={classNames('np-popover-v2', title && 'np-popover-v2--has-title', {
122
- 'np-popover-v2--padding-md': padding === 'md',
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
- </FloatingFocusManager>
132
- </FocusBoundary>
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, 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';
@@ -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
- });
@@ -1 +0,0 @@
1
- export { default } from './DateLookup';