@transferwise/components 46.27.0 → 46.29.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 (206) hide show
  1. package/build/i18n/th.json +2 -2
  2. package/build/index.js +344 -1147
  3. package/build/index.js.map +1 -1
  4. package/build/index.mjs +346 -1147
  5. package/build/index.mjs.map +1 -1
  6. package/build/main.css +16 -5
  7. package/build/styles/logo/Logo.css +16 -0
  8. package/build/styles/main.css +16 -5
  9. package/build/types/alert/Alert.d.ts +47 -58
  10. package/build/types/alert/Alert.d.ts.map +1 -1
  11. package/build/types/alert/index.d.ts +2 -1
  12. package/build/types/alert/index.d.ts.map +1 -1
  13. package/build/types/button/Button.d.ts +7 -9
  14. package/build/types/button/Button.d.ts.map +1 -1
  15. package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
  16. package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
  17. package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
  18. package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
  19. package/build/types/common/propsValues/sentiment.d.ts +0 -1
  20. package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
  21. package/build/types/dateLookup/DateLookup.d.ts +75 -28
  22. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  23. package/build/types/dateLookup/DateLookup.messages.d.ts +42 -63
  24. package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -1
  25. package/build/types/dateLookup/dateHeader/DateHeader.d.ts +9 -22
  26. package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
  27. package/build/types/dateLookup/dateHeader/index.d.ts +1 -1
  28. package/build/types/dateLookup/dateHeader/index.d.ts.map +1 -1
  29. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts +13 -31
  30. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
  31. package/build/types/dateLookup/dateTrigger/index.d.ts +1 -1
  32. package/build/types/dateLookup/dateTrigger/index.d.ts.map +1 -1
  33. package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts +19 -2
  34. package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts.map +1 -1
  35. package/build/types/dateLookup/dayCalendar/index.d.ts +1 -1
  36. package/build/types/dateLookup/dayCalendar/index.d.ts.map +1 -1
  37. package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts +12 -2
  38. package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts.map +1 -1
  39. package/build/types/dateLookup/dayCalendar/table/index.d.ts +1 -1
  40. package/build/types/dateLookup/dayCalendar/table/index.d.ts.map +1 -1
  41. package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts +1 -1
  42. package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts.map +1 -1
  43. package/build/types/dateLookup/getStartOfDay/index.d.ts +1 -1
  44. package/build/types/dateLookup/getStartOfDay/index.d.ts.map +1 -1
  45. package/build/types/dateLookup/index.d.ts +2 -1
  46. package/build/types/dateLookup/index.d.ts.map +1 -1
  47. package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts +17 -2
  48. package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts.map +1 -1
  49. package/build/types/dateLookup/monthCalendar/index.d.ts +1 -1
  50. package/build/types/dateLookup/monthCalendar/index.d.ts.map +1 -1
  51. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +10 -26
  52. package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
  53. package/build/types/dateLookup/monthCalendar/table/index.d.ts +1 -1
  54. package/build/types/dateLookup/monthCalendar/table/index.d.ts.map +1 -1
  55. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +15 -2
  56. package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
  57. package/build/types/dateLookup/yearCalendar/index.d.ts +1 -1
  58. package/build/types/dateLookup/yearCalendar/index.d.ts.map +1 -1
  59. package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts +10 -26
  60. package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
  61. package/build/types/dateLookup/yearCalendar/table/index.d.ts +1 -1
  62. package/build/types/dateLookup/yearCalendar/table/index.d.ts.map +1 -1
  63. package/build/types/dimmer/Dimmer.d.ts.map +1 -1
  64. package/build/types/index.d.ts +2 -2
  65. package/build/types/index.d.ts.map +1 -1
  66. package/build/types/inlineAlert/InlineAlert.d.ts +2 -4
  67. package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
  68. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  69. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  70. package/build/types/loader/Loader.d.ts.map +1 -1
  71. package/build/types/logo/Logo.d.ts.map +1 -1
  72. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  73. package/build/types/popover/Popover.d.ts.map +1 -1
  74. package/build/types/segmentedControl/SegmentedControl.d.ts +2 -2
  75. package/build/types/segmentedControl/SegmentedControl.d.ts.map +1 -1
  76. package/build/types/select/Select.d.ts.map +1 -1
  77. package/build/types/statusIcon/StatusIcon.d.ts +1 -1
  78. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  79. package/build/types/stepper/deviceDetection.d.ts.map +1 -1
  80. package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
  81. package/package.json +3 -3
  82. package/src/accordion/Accordion.story.tsx +1 -1
  83. package/src/alert/{Alert.spec.js → Alert.spec.tsx} +43 -40
  84. package/src/alert/Alert.story.tsx +1 -2
  85. package/src/alert/Alert.tsx +219 -0
  86. package/src/alert/index.ts +2 -0
  87. package/src/avatar/colors/colors.ts +1 -1
  88. package/src/body/Body.spec.tsx +1 -1
  89. package/src/body/Body.story.tsx +8 -8
  90. package/src/button/Button.tsx +6 -10
  91. package/src/checkbox/Checkbox.js +1 -1
  92. package/src/checkboxButton/CheckboxButton.spec.tsx +0 -1
  93. package/src/common/Option/Option.tsx +1 -1
  94. package/src/common/dateUtils/isWithinRange/isWithinRange.spec.ts +21 -0
  95. package/src/common/dateUtils/isWithinRange/isWithinRange.ts +2 -2
  96. package/src/common/dateUtils/moveToWithinRange/moveToWithinRange.ts +8 -4
  97. package/src/common/deviceDetection/deviceDetection.js +1 -1
  98. package/src/common/deviceDetection/deviceDetection.spec.js +4 -2
  99. package/src/common/propsValues/sentiment.ts +0 -10
  100. package/src/common/responsivePanel/ResponsivePanel.spec.js +11 -15
  101. package/src/dateLookup/DateLookup.state.spec.js +7 -0
  102. package/src/dateLookup/{DateLookup.story.js → DateLookup.story.tsx} +13 -14
  103. package/src/dateLookup/DateLookup.tests.story.tsx +70 -0
  104. package/src/dateLookup/{DateLookup.js → DateLookup.tsx} +115 -81
  105. package/src/dateLookup/dateHeader/{DateHeader.js → DateHeader.tsx} +15 -15
  106. package/src/dateLookup/dateTrigger/DateTrigger.spec.js +0 -22
  107. package/src/dateLookup/dateTrigger/{DateTrigger.js → DateTrigger.tsx} +15 -32
  108. package/src/dateLookup/dayCalendar/{DayCalendar.js → DayCalendar.tsx} +14 -21
  109. package/src/dateLookup/dayCalendar/table/{DayCalendarTable.js → DayCalendarTable.tsx} +26 -37
  110. package/src/dateLookup/getStartOfDay/{getStartOfDay.js → getStartOfDay.tsx} +1 -1
  111. package/src/dateLookup/index.ts +2 -0
  112. package/src/dateLookup/monthCalendar/{MonthCalendar.js → MonthCalendar.tsx} +19 -22
  113. package/src/dateLookup/monthCalendar/table/{MonthCalendarTable.js → MonthCalendarTable.tsx} +31 -30
  114. package/src/dateLookup/yearCalendar/{YearCalendar.js → YearCalendar.tsx} +18 -21
  115. package/src/dateLookup/yearCalendar/table/{YearCalendarTable.js → YearCalendarTable.tsx} +26 -28
  116. package/src/decision/Decision.spec.js +0 -1
  117. package/src/dimmer/Dimmer.tsx +6 -2
  118. package/src/i18n/th.json +2 -2
  119. package/src/index.ts +2 -2
  120. package/src/inlineAlert/InlineAlert.spec.tsx +0 -7
  121. package/src/inlineAlert/InlineAlert.story.tsx +8 -7
  122. package/src/inlineAlert/InlineAlert.tsx +19 -47
  123. package/src/inputs/InputGroup.tsx +3 -3
  124. package/src/inputs/SelectInput.tsx +2 -0
  125. package/src/inputs/_BottomSheet.tsx +21 -26
  126. package/src/inputs/_Popover.tsx +4 -4
  127. package/src/link/Link.story.tsx +16 -16
  128. package/src/loader/Loader.tsx +0 -1
  129. package/src/logo/Logo.css +16 -0
  130. package/src/logo/Logo.js +4 -9
  131. package/src/logo/Logo.less +16 -0
  132. package/src/logo/__snapshots__/Logo.spec.js.snap +104 -8
  133. package/src/main.css +16 -5
  134. package/src/main.less +0 -1
  135. package/src/moneyInput/MoneyInput.story.tsx +3 -3
  136. package/src/nudge/Nudge.spec.tsx +5 -5
  137. package/src/phoneNumberInput/PhoneNumberInput.tsx +2 -1
  138. package/src/phoneNumberInput/utils/cleanNumber/cleanNumber.ts +1 -1
  139. package/src/popover/Popover.tsx +2 -1
  140. package/src/promoCard/PromoCard.tsx +1 -1
  141. package/src/radioGroup/RadioGroup.spec.js +1 -1
  142. package/src/section/Section.story.tsx +2 -1
  143. package/src/segmentedControl/SegmentedControl.spec.tsx +88 -2
  144. package/src/segmentedControl/SegmentedControl.story.tsx +54 -16
  145. package/src/segmentedControl/SegmentedControl.tsx +21 -33
  146. package/src/select/Select.js +2 -3
  147. package/src/statusIcon/StatusIcon.tsx +14 -14
  148. package/src/stepper/deviceDetection.js +1 -2
  149. package/src/stepper/deviceDetection.spec.js +8 -3
  150. package/src/test-utils/index.js +1 -1
  151. package/src/test-utils/story-config.ts +1 -1
  152. package/src/title/Title.spec.tsx +1 -1
  153. package/src/typeahead/Typeahead.spec.js +4 -2
  154. package/src/upload/Upload.spec.js +8 -4
  155. package/src/uploadInput/uploadButton/UploadButton.tsx +1 -0
  156. package/build/styles/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +0 -5
  157. package/build/types/alert/withArrow/alertArrowPositions.d.ts +0 -9
  158. package/build/types/alert/withArrow/alertArrowPositions.d.ts.map +0 -1
  159. package/build/types/alert/withArrow/index.d.ts +0 -3
  160. package/build/types/alert/withArrow/index.d.ts.map +0 -1
  161. package/build/types/alert/withArrow/withArrow.d.ts +0 -11
  162. package/build/types/alert/withArrow/withArrow.d.ts.map +0 -1
  163. package/build/types/common/requirements.d.ts +0 -3
  164. package/build/types/common/requirements.d.ts.map +0 -1
  165. package/build/types/dynamicFieldDefinitionList/DynamicFieldDefinitionList.d.ts +0 -21
  166. package/build/types/dynamicFieldDefinitionList/DynamicFieldDefinitionList.d.ts.map +0 -1
  167. package/build/types/dynamicFieldDefinitionList/FormattedValue/FormattedValue.d.ts +0 -12
  168. package/build/types/dynamicFieldDefinitionList/FormattedValue/FormattedValue.d.ts.map +0 -1
  169. package/build/types/dynamicFieldDefinitionList/FormattedValue/index.d.ts +0 -2
  170. package/build/types/dynamicFieldDefinitionList/FormattedValue/index.d.ts.map +0 -1
  171. package/build/types/dynamicFieldDefinitionList/index.d.ts +0 -2
  172. package/build/types/dynamicFieldDefinitionList/index.d.ts.map +0 -1
  173. package/build/types/dynamicFieldDefinitionList/utils/createDefinitions.d.ts +0 -2
  174. package/build/types/dynamicFieldDefinitionList/utils/createDefinitions.d.ts.map +0 -1
  175. package/build/types/dynamicFieldDefinitionList/utils/text-format.d.ts +0 -2
  176. package/build/types/dynamicFieldDefinitionList/utils/text-format.d.ts.map +0 -1
  177. package/src/alert/Alert.js +0 -196
  178. package/src/alert/index.js +0 -1
  179. package/src/alert/withArrow/alertArrowPositions.ts +0 -9
  180. package/src/alert/withArrow/index.js +0 -2
  181. package/src/alert/withArrow/withArrow.js +0 -50
  182. package/src/alert/withArrow/withArrow.spec.js +0 -51
  183. package/src/dateLookup/index.js +0 -1
  184. package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.js +0 -41
  185. package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.spec.js +0 -21
  186. package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.story.js +0 -134
  187. package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +0 -5
  188. package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.js +0 -73
  189. package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.less +0 -4
  190. package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.spec.js +0 -200
  191. package/src/dynamicFieldDefinitionList/FormattedValue/index.js +0 -1
  192. package/src/dynamicFieldDefinitionList/index.js +0 -1
  193. package/src/dynamicFieldDefinitionList/utils/createDefinitions.js +0 -33
  194. package/src/dynamicFieldDefinitionList/utils/createDefinitions.spec.js +0 -83
  195. package/src/dynamicFieldDefinitionList/utils/text-format.js +0 -46
  196. package/src/dynamicFieldDefinitionList/utils/text-format.spec.js +0 -43
  197. /package/src/dateLookup/{DateLookup.messages.js → DateLookup.messages.ts} +0 -0
  198. /package/src/dateLookup/dateHeader/{index.js → index.ts} +0 -0
  199. /package/src/dateLookup/dateTrigger/{index.js → index.ts} +0 -0
  200. /package/src/dateLookup/dayCalendar/{index.js → index.ts} +0 -0
  201. /package/src/dateLookup/dayCalendar/table/{index.js → index.ts} +0 -0
  202. /package/src/dateLookup/getStartOfDay/{index.js → index.ts} +0 -0
  203. /package/src/dateLookup/monthCalendar/{index.js → index.ts} +0 -0
  204. /package/src/dateLookup/monthCalendar/table/{index.js → index.ts} +0 -0
  205. /package/src/dateLookup/yearCalendar/{index.js → index.ts} +0 -0
  206. /package/src/dateLookup/yearCalendar/table/{index.js → index.ts} +0 -0
@@ -8,7 +8,7 @@ import Upload from '.';
8
8
 
9
9
  jest.useFakeTimers();
10
10
  jest.mock('./utils/postData', () => ({
11
- postData: () => new Promise((resolve) => resolve('ServerResponse')),
11
+ postData: async () => 'ServerResponse',
12
12
  }));
13
13
 
14
14
  jest.mock('./utils/asyncFileRead');
@@ -88,7 +88,7 @@ describe('Upload', () => {
88
88
  let component;
89
89
  beforeEach(() => {
90
90
  component = shallow(<Upload {...props} />).dive();
91
- asyncFileRead.mockImplementation(() => new Promise((resolve) => resolve('a value')));
91
+ asyncFileRead.mockImplementation(async () => 'a value');
92
92
  });
93
93
 
94
94
  afterEach(() => {
@@ -183,7 +183,9 @@ describe('Upload', () => {
183
183
  });
184
184
 
185
185
  it('step ProcessingStep is called with error props', async () => {
186
- asyncFileRead.mockImplementation(() => new Promise((resolve, reject) => reject('An error')));
186
+ asyncFileRead.mockImplementation(async () => {
187
+ throw 'An error';
188
+ });
187
189
 
188
190
  await component.instance().fileDropped(TEST_FILE);
189
191
  jest.advanceTimersByTime(props.animationDelay);
@@ -230,7 +232,9 @@ describe('Upload', () => {
230
232
  it('step CompleteStep is called with error props', async () => {
231
233
  component = mount(<Upload {...props} />);
232
234
  const upload = component.children();
233
- asyncFileRead.mockImplementation(() => new Promise((resolve, reject) => reject('An error')));
235
+ asyncFileRead.mockImplementation(async () => {
236
+ throw 'An error';
237
+ });
234
238
 
235
239
  await upload.instance().fileDropped(TEST_FILE);
236
240
  jest.advanceTimersByTime(props.animationDelay + ANIMATION_DELAY);
@@ -225,6 +225,7 @@ const UploadButton = ({
225
225
  data-testid={TEST_IDS.uploadInput}
226
226
  onChange={filesSelected}
227
227
  />
228
+ {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
228
229
  <label
229
230
  htmlFor={id}
230
231
  className={classNames('btn', 'np-upload-accent', 'np-upload-button', {
@@ -1,5 +0,0 @@
1
- .formatted-value__h3-custom-alignment {
2
- margin-bottom: 16px;
3
- margin-bottom: var(--size-16);
4
- line-height: 24px;
5
- }
@@ -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,3 +0,0 @@
1
- export function prepFields(fields: any, model: any, validationMessages: any): any;
2
- export function getControlType(field: any): any;
3
- //# sourceMappingURL=requirements.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"requirements.d.ts","sourceRoot":"","sources":["../../../src/common/requirements.js"],"names":[],"mappings":"AAqCA,kFAgBC;AAuTD,gDAsBC"}
@@ -1,21 +0,0 @@
1
- import * as React from 'react';
2
-
3
- export interface DynamicFieldDefinitionListModel {
4
- }
5
-
6
- export interface DynamicFieldDefinitionListFields {
7
- }
8
-
9
- export type DynamicFieldDefinitionListLayout = "VERTICAL_TWO_COLUMN" | "VERTICAL_ONE_COLUMN" | "HORIZONTAL_JUSTIFIED" | "HORIZONTAL_LEFT_ALIGNED";
10
-
11
- export interface DynamicFieldDefinitionListProps {
12
- model: DynamicFieldDefinitionListModel;
13
- fields: DynamicFieldDefinitionListFields;
14
- title?: string;
15
- layout?: DynamicFieldDefinitionListLayout;
16
- }
17
-
18
- declare const DynamicFieldDefinitionList: React.FC<DynamicFieldDefinitionListProps>;
19
-
20
- export default DynamicFieldDefinitionList;
21
-
@@ -1 +0,0 @@
1
- {"version":3,"file":"DynamicFieldDefinitionList.d.ts","sourceRoot":"","sources":["../../../src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.js"],"names":[],"mappings":";AASA;;;;;gCAYC"}
@@ -1,12 +0,0 @@
1
- export default FormattedValue;
2
- declare function FormattedValue({ field, value }: {
3
- field: any;
4
- value: any;
5
- }): import("react").JSX.Element;
6
- declare namespace FormattedValue {
7
- namespace propTypes {
8
- const field: any;
9
- const value: any;
10
- }
11
- }
12
- //# sourceMappingURL=FormattedValue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormattedValue.d.ts","sourceRoot":"","sources":["../../../../src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.js"],"names":[],"mappings":";AAuBA;;;gCA+BC"}
@@ -1,2 +0,0 @@
1
- export { default } from "./FormattedValue";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/dynamicFieldDefinitionList/FormattedValue/index.js"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export { default } from "./DynamicFieldDefinitionList";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dynamicFieldDefinitionList/index.js"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export default function createDefinitions(fields: any, model: any): any;
2
- //# sourceMappingURL=createDefinitions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createDefinitions.d.ts","sourceRoot":"","sources":["../../../../src/dynamicFieldDefinitionList/utils/createDefinitions.js"],"names":[],"mappings":"AAIA,wEAIC"}
@@ -1,2 +0,0 @@
1
- export function formatUsingPattern(value: string | undefined, pattern: any): string;
2
- //# sourceMappingURL=text-format.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text-format.d.ts","sourceRoot":"","sources":["../../../../src/dynamicFieldDefinitionList/utils/text-format.js"],"names":[],"mappings":"AAAA,oFAgCC"}
@@ -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';
@@ -1,41 +0,0 @@
1
- import PropTypes from 'prop-types';
2
-
3
- import { Typography, Layout } from '../common';
4
- import { prepFields } from '../common/requirements';
5
- import DefinitionList from '../definitionList';
6
- import Title from '../title';
7
-
8
- import createDefinitions from './utils/createDefinitions';
9
-
10
- const DynamicFieldDefinitionList = ({ model, title, layout, fields }) => (
11
- <>
12
- {title && (
13
- <div className="m-t-1 m-b-3">
14
- <Title type={Typography.TITLE_BODY} className="p-t-3">
15
- {title}
16
- </Title>
17
- </div>
18
- )}
19
-
20
- <DefinitionList layout={layout} definitions={createDefinitions(prepFields(fields), model)} />
21
- </>
22
- );
23
-
24
- DynamicFieldDefinitionList.propTypes = {
25
- model: PropTypes.shape({}).isRequired,
26
- fields: PropTypes.shape({}).isRequired,
27
- title: PropTypes.string,
28
- layout: PropTypes.oneOf([
29
- 'VERTICAL_TWO_COLUMN',
30
- 'VERTICAL_ONE_COLUMN',
31
- 'HORIZONTAL_JUSTIFIED',
32
- 'HORIZONTAL_LEFT_ALIGNED',
33
- ]),
34
- };
35
-
36
- DynamicFieldDefinitionList.defaultProps = {
37
- title: null,
38
- layout: Layout.VERTICAL_TWO_COLUMN,
39
- };
40
-
41
- export default DynamicFieldDefinitionList;
@@ -1,21 +0,0 @@
1
- import { shallow } from 'enzyme';
2
-
3
- import { DynamicFieldDefinitionList } from '..';
4
- import Title from '../title';
5
-
6
- describe('DynamicFieldDefinitionList', () => {
7
- it('has title when title is passed', () => {
8
- const component = shallow(
9
- <DynamicFieldDefinitionList model={{}} fields={{}} title="A title" />,
10
- );
11
-
12
- expect(component.find(Title).exists()).toBe(true);
13
- expect(component.find(Title).props().children).toBe('A title');
14
- });
15
-
16
- it('has no title when no title is passed', () => {
17
- const component = shallow(<DynamicFieldDefinitionList model={{}} fields={{}} />);
18
-
19
- expect(component.find('.np-text-body-title').exists()).toBe(false);
20
- });
21
- });