@transferwise/components 0.0.0-experimental-bb41164 → 0.0.0-experimental-f7a4236

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 (84) hide show
  1. package/build/index.js +50 -92
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +50 -92
  4. package/build/index.mjs.map +1 -1
  5. package/build/main.css +109 -108
  6. package/build/styles/main.css +109 -108
  7. package/build/styles/uploadInput/UploadInput.css +19 -27
  8. package/build/styles/uploadInput/uploadButton/UploadButton.css +24 -38
  9. package/build/styles/uploadInput/uploadItem/UploadItem.css +68 -45
  10. package/build/types/drawer/Drawer.d.ts +19 -36
  11. package/build/types/drawer/Drawer.d.ts.map +1 -1
  12. package/build/types/drawer/index.d.ts +2 -1
  13. package/build/types/drawer/index.d.ts.map +1 -1
  14. package/build/types/index.d.ts +1 -0
  15. package/build/types/index.d.ts.map +1 -1
  16. package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
  17. package/build/types/uploadInput/types.d.ts +9 -1
  18. package/build/types/uploadInput/types.d.ts.map +1 -1
  19. package/build/types/uploadInput/uploadButton/UploadButton.d.ts +1 -5
  20. package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
  21. package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
  22. package/package.json +6 -5
  23. package/src/accordion/Accordion.spec.js +5 -5
  24. package/src/accordion/AccordionItem/AccordionItem.spec.js +2 -2
  25. package/src/actionButton/ActionButton.spec.tsx +5 -4
  26. package/src/alert/Alert.spec.tsx +4 -4
  27. package/src/button/Button.spec.js +5 -4
  28. package/src/card/Card.spec.tsx +4 -4
  29. package/src/carousel/Carousel.spec.tsx +17 -17
  30. package/src/checkbox/Checkbox.spec.tsx +2 -0
  31. package/src/checkboxButton/CheckboxButton.spec.tsx +2 -0
  32. package/src/checkboxOption/CheckboxOption.spec.tsx +2 -0
  33. package/src/chevron/Chevron.spec.tsx +1 -0
  34. package/src/chips/Chips.spec.tsx +1 -0
  35. package/src/circularButton/CircularButton.spec.tsx +5 -4
  36. package/src/common/RadioButton/RadioButton.spec.tsx +2 -2
  37. package/src/common/closeButton/CloseButton.spec.tsx +1 -0
  38. package/src/common/flowHeader/FlowHeader.spec.tsx +1 -0
  39. package/src/dateLookup/DateLookup.rtl.spec.tsx +16 -18
  40. package/src/dateLookup/DateLookup.testingLibrary.spec.js +44 -47
  41. package/src/decision/Decision.spec.js +2 -0
  42. package/src/dimmer/Dimmer.rtl.spec.js +10 -10
  43. package/src/drawer/{Drawer.rtl.spec.js → Drawer.rtl.spec.tsx} +6 -4
  44. package/src/drawer/{Drawer.story.js → Drawer.story.tsx} +20 -28
  45. package/src/drawer/{Drawer.js → Drawer.tsx} +26 -31
  46. package/src/drawer/index.ts +2 -0
  47. package/src/emphasis/Emphasis.spec.tsx +1 -0
  48. package/src/field/Field.spec.tsx +2 -2
  49. package/src/flowNavigation/FlowNavigation.spec.js +2 -0
  50. package/src/flowNavigation/animatedLabel/AnimatedLabel.spec.js +1 -0
  51. package/src/header/Header.spec.tsx +6 -6
  52. package/src/image/Image.spec.tsx +1 -0
  53. package/src/index.ts +1 -0
  54. package/src/inlineAlert/InlineAlert.spec.tsx +1 -0
  55. package/src/inputs/SelectInput.spec.tsx +47 -26
  56. package/src/link/Link.spec.tsx +1 -0
  57. package/src/listItem/ListItem.spec.tsx +1 -0
  58. package/src/main.css +109 -108
  59. package/src/moneyInput/MoneyInput.rtl.spec.tsx +2 -2
  60. package/src/popover/Popover.spec.tsx +10 -10
  61. package/src/progress/Progress.spec.tsx +1 -0
  62. package/src/progressBar/ProgressBar.spec.tsx +1 -0
  63. package/src/segmentedControl/SegmentedControl.spec.tsx +11 -10
  64. package/src/select/Select.spec.js +71 -71
  65. package/src/test-utils/index.js +1 -1
  66. package/src/test-utils/jest.setup.js +0 -2
  67. package/src/tooltip/Tooltip.spec.tsx +16 -15
  68. package/src/uploadInput/UploadInput.css +19 -27
  69. package/src/uploadInput/UploadInput.less +20 -23
  70. package/src/uploadInput/UploadInput.spec.tsx +10 -9
  71. package/src/uploadInput/UploadInput.story.tsx +60 -10
  72. package/src/uploadInput/UploadInput.tsx +1 -4
  73. package/src/uploadInput/types.ts +11 -1
  74. package/src/uploadInput/uploadButton/UploadButton.css +24 -38
  75. package/src/uploadInput/uploadButton/UploadButton.less +27 -40
  76. package/src/uploadInput/uploadButton/UploadButton.spec.tsx +4 -5
  77. package/src/uploadInput/uploadButton/UploadButton.tsx +12 -37
  78. package/src/uploadInput/uploadItem/UploadItem.css +68 -45
  79. package/src/uploadInput/uploadItem/UploadItem.less +67 -40
  80. package/src/uploadInput/uploadItem/UploadItem.spec.tsx +4 -4
  81. package/src/uploadInput/uploadItem/UploadItem.tsx +30 -25
  82. package/src/uploadInput/uploadItem/UploadItemBody.tsx +1 -1
  83. package/src/drawer/index.js +0 -1
  84. /package/src/drawer/__snapshots__/{Drawer.rtl.spec.js.snap → Drawer.rtl.spec.tsx.snap} +0 -0
package/build/index.js CHANGED
@@ -11,13 +11,13 @@ var reactTransitionGroup = require('react-transition-group');
11
11
  var focus = require('@react-aria/focus');
12
12
  var reactDom = require('react-dom');
13
13
  var neptuneValidation = require('@transferwise/neptune-validation');
14
- var PropTypes = require('prop-types');
15
14
  var formatting = require('@transferwise/formatting');
16
15
  var react$1 = require('@headlessui/react');
17
16
  var mergeProps = require('merge-props');
18
17
  var react = require('@floating-ui/react');
19
18
  var overlays = require('@react-aria/overlays');
20
19
  var reactPopper = require('react-popper');
20
+ var PropTypes = require('prop-types');
21
21
  var art = require('@wise/art');
22
22
  var clamp$2 = require('lodash.clamp');
23
23
  var debounce = require('lodash.debounce');
@@ -46,8 +46,8 @@ function _interopNamespace(e) {
46
46
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
47
47
  var classNames__default = /*#__PURE__*/_interopDefault(classNames);
48
48
  var commonmark__default = /*#__PURE__*/_interopDefault(commonmark);
49
- var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
50
49
  var mergeProps__default = /*#__PURE__*/_interopDefault(mergeProps);
50
+ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
51
51
  var clamp__default = /*#__PURE__*/_interopDefault(clamp$2);
52
52
  var debounce__default = /*#__PURE__*/_interopDefault(debounce);
53
53
 
@@ -2744,15 +2744,15 @@ const SlidingPanel = /*#__PURE__*/React.forwardRef(({
2744
2744
  }));
2745
2745
  });
2746
2746
 
2747
- const Drawer = ({
2747
+ function Drawer({
2748
2748
  children,
2749
2749
  className,
2750
2750
  footerContent,
2751
2751
  headerTitle,
2752
2752
  onClose,
2753
- open,
2754
- position
2755
- }) => {
2753
+ open = false,
2754
+ position = 'right'
2755
+ }) {
2756
2756
  logActionRequiredIf('Drawer now expects `onClose`, and will soon make this prop required. Please update your usage to provide it.', !onClose);
2757
2757
  const {
2758
2758
  isMobile
@@ -2790,32 +2790,7 @@ const Drawer = ({
2790
2790
  })
2791
2791
  })
2792
2792
  });
2793
- };
2794
- Drawer.propTypes = {
2795
- /** The content to appear in the drawer body. */
2796
- children: PropTypes__default.default.node,
2797
- className: PropTypes__default.default.string,
2798
- /** The content to appear in the drawer footer. */
2799
- footerContent: PropTypes__default.default.node,
2800
- /** The content to appear in the drawer header. */
2801
- headerTitle: PropTypes__default.default.node,
2802
- /** The status of Drawer either open or not. */
2803
- open: PropTypes__default.default.bool,
2804
- /** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */
2805
- position: PropTypes__default.default.oneOf(['left', 'right', 'bottom']),
2806
- /** The action to perform on close click. */
2807
- onClose: PropTypes__default.default.func
2808
- };
2809
- Drawer.defaultProps = {
2810
- children: null,
2811
- className: undefined,
2812
- footerContent: null,
2813
- headerTitle: null,
2814
- onClose: null,
2815
- open: false,
2816
- position: exports.Position.RIGHT
2817
- };
2818
- var Drawer$1 = Drawer;
2793
+ }
2819
2794
 
2820
2795
  const INITIAL_Y_POSITION = 0;
2821
2796
  const CONTENT_SCROLL_THRESHOLD = 1;
@@ -2945,7 +2920,7 @@ const BottomSheet$1 = props => {
2945
2920
  };
2946
2921
  }
2947
2922
  const is400Zoom = useMedia(`(max-width: ${exports.Breakpoint.ZOOM_400}px)`);
2948
- return is400Zoom ? /*#__PURE__*/jsxRuntime.jsx(Drawer$1, {
2923
+ return is400Zoom ? /*#__PURE__*/jsxRuntime.jsx(Drawer, {
2949
2924
  open: props.open,
2950
2925
  className: props.className,
2951
2926
  onClose: close,
@@ -5538,7 +5513,7 @@ const Modal = ({
5538
5513
  const noDivider = checkSpecialClasses('no-divider');
5539
5514
  const contentReference = React.useRef(null);
5540
5515
  const titleId = React.useId();
5541
- return !isMedium ? /*#__PURE__*/jsxRuntime.jsx(Drawer$1, {
5516
+ return !isMedium ? /*#__PURE__*/jsxRuntime.jsx(Drawer, {
5542
5517
  open: open,
5543
5518
  headerTitle: title,
5544
5519
  footerContent: footer,
@@ -10366,7 +10341,7 @@ function Select({
10366
10341
  , {
10367
10342
  className: classNames__default.default(s('tw-icon'), s('tw-chevron-up-icon'), s('tw-chevron'), s('bottom'), s('np-select-chevron'))
10368
10343
  })]
10369
- }), isMobile ? isSearchEnabled ? /*#__PURE__*/jsxRuntime.jsx(Drawer$1, {
10344
+ }), isMobile ? isSearchEnabled ? /*#__PURE__*/jsxRuntime.jsx(Drawer, {
10370
10345
  open: open,
10371
10346
  headerTitle: searchPlaceholder || formatMessage(messages$2.searchPlaceholder),
10372
10347
  onClose: handleCloseOptions,
@@ -13055,13 +13030,8 @@ const UploadButton = ({
13055
13030
  maxFiles,
13056
13031
  onChange,
13057
13032
  id = DEFAULT_FILE_INPUT_ID,
13058
- uploadButtonTitle,
13059
- multipleFileInputWithFilesAdded
13033
+ uploadButtonTitle
13060
13034
  }) => {
13061
- const {
13062
- isModern
13063
- } = componentsTheming.useTheme();
13064
- useDirection();
13065
13035
  const {
13066
13036
  formatMessage
13067
13037
  } = reactIntl.useIntl();
@@ -13124,7 +13094,7 @@ const UploadButton = ({
13124
13094
  function getAcceptedTypes() {
13125
13095
  const areAllFilesAllowed = getFileTypesDescription() === '*';
13126
13096
  if (areAllFilesAllowed) {
13127
- return {}; //file input by default allows all files
13097
+ return {}; // file input by default allows all files
13128
13098
  }
13129
13099
  if (Array.isArray(fileTypes)) {
13130
13100
  return {
@@ -13136,17 +13106,13 @@ const UploadButton = ({
13136
13106
  };
13137
13107
  }
13138
13108
  function renderDescription() {
13139
- return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
13140
- children: /*#__PURE__*/jsxRuntime.jsxs(Body, {
13141
- className: classNames__default.default({
13142
- 'text-primary': !disabled,
13143
- small: !isModern,
13144
- 'font-weight-normal': !isModern
13145
- }),
13146
- children: [getDescription(), maxFiles && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
13147
- children: [/*#__PURE__*/jsxRuntime.jsx("br", {}), `Maximum ${maxFiles} files.`]
13148
- })]
13149
- })
13109
+ return /*#__PURE__*/jsxRuntime.jsxs(Body, {
13110
+ className: classNames__default.default({
13111
+ 'text-primary': !disabled
13112
+ }),
13113
+ children: [getDescription(), maxFiles && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
13114
+ children: [/*#__PURE__*/jsxRuntime.jsx("br", {}), `Maximum ${maxFiles} files.`]
13115
+ })]
13150
13116
  });
13151
13117
  }
13152
13118
  function renderButtonTitle() {
@@ -13180,14 +13146,11 @@ const UploadButton = ({
13180
13146
  onChange: filesSelected
13181
13147
  }), /*#__PURE__*/jsxRuntime.jsx("label", {
13182
13148
  htmlFor: id,
13183
- className: classNames__default.default('btn', 'np-upload-accent', 'np-upload-button', {
13184
- disabled,
13185
- 'np-upload-input--square-top': multipleFileInputWithFilesAdded
13186
- }),
13149
+ className: classNames__default.default('btn', 'np-upload-button'),
13187
13150
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
13188
13151
  className: "media",
13189
13152
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
13190
- className: "np-upload-icon media-left",
13153
+ className: "np-upload-icon media-middle media-left",
13191
13154
  children: /*#__PURE__*/jsxRuntime.jsx(icons.Upload, {
13192
13155
  size: 24,
13193
13156
  className: "text-link"
@@ -13203,9 +13166,7 @@ const UploadButton = ({
13203
13166
  })]
13204
13167
  })
13205
13168
  }), isDropping && /*#__PURE__*/jsxRuntime.jsxs("div", {
13206
- className: classNames__default.default('droppable-card', 'droppable-dropping-card', 'droppable-card-content', {
13207
- 'np-upload-input--square-top': multipleFileInputWithFilesAdded
13208
- }),
13169
+ className: classNames__default.default('droppable-card', 'droppable-dropping-card', 'droppable-card-content'),
13209
13170
  children: [/*#__PURE__*/jsxRuntime.jsx(icons.PlusCircle, {
13210
13171
  className: "m-x-1",
13211
13172
  size: 24
@@ -13252,7 +13213,7 @@ const UploadItemBody = ({
13252
13213
  href: url,
13253
13214
  target: "_blank",
13254
13215
  rel: "noopener noreferrer",
13255
- className: singleFileUpload ? 'np-upload-item--single-file' : '',
13216
+ className: singleFileUpload ? 'np-upload-item--single-file' : 'np-upload-item--link',
13256
13217
  onClick: onDownload,
13257
13218
  children: children
13258
13219
  });
@@ -13277,20 +13238,15 @@ const UploadItem = ({
13277
13238
  status,
13278
13239
  filename,
13279
13240
  error,
13241
+ errors,
13280
13242
  url
13281
13243
  } = file;
13282
- const {
13283
- isModern
13284
- } = componentsTheming.useTheme();
13285
13244
  const isSucceeded = [exports.Status.SUCCEEDED, undefined].includes(status) && !!url;
13286
13245
  const getIcon = () => {
13287
- if (error || status === exports.Status.FAILED) {
13288
- return isModern ? /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
13246
+ if (error || errors?.length || status === exports.Status.FAILED) {
13247
+ return /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
13289
13248
  size: exports.Size.SMALL,
13290
13249
  sentiment: exports.Sentiment.NEGATIVE
13291
- }) : /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {
13292
- size: 24,
13293
- className: "text-negative"
13294
13250
  });
13295
13251
  }
13296
13252
  let processIndicator;
@@ -13305,31 +13261,37 @@ const UploadItem = ({
13305
13261
  case exports.Status.SUCCEEDED:
13306
13262
  case exports.Status.DONE:
13307
13263
  default:
13308
- processIndicator = isModern ? /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
13264
+ processIndicator = /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
13309
13265
  size: exports.Size.SMALL,
13310
13266
  sentiment: exports.Sentiment.POSITIVE
13311
- }) : /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
13312
- size: exports.Size.EXTRA_SMALL,
13313
- status: exports.Status.SUCCEEDED
13314
13267
  });
13315
13268
  }
13316
- if (isModern) {
13317
- return processIndicator;
13269
+ return processIndicator;
13270
+ };
13271
+ const getErrorMessage = error => typeof error === 'object' ? error.message : error || formatMessage(MESSAGES.uploadingFailed);
13272
+ const getMultipleErrors = errors => {
13273
+ if (!errors?.length) {
13274
+ return null;
13318
13275
  }
13319
- return /*#__PURE__*/jsxRuntime.jsx("span", {
13320
- style: {
13321
- transform: 'scale(0.8335)'
13322
- },
13323
- children: processIndicator
13324
- }); // Scale down ProcessIndicator to be 20px*20px to match `icons`
13276
+ if (errors?.length === 1) {
13277
+ return getErrorMessage(errors[0]);
13278
+ }
13279
+ return /*#__PURE__*/jsxRuntime.jsx("ul", {
13280
+ className: "np-upload-input-errors m-b-0",
13281
+ children: errors.map((error, index) => {
13282
+ // eslint-disable-next-line react/no-array-index-key
13283
+ return /*#__PURE__*/jsxRuntime.jsx("li", {
13284
+ children: getErrorMessage(error)
13285
+ }, index);
13286
+ })
13287
+ });
13325
13288
  };
13326
- const getErrorMessage = () => typeof error === 'object' ? error.message : error || formatMessage(MESSAGES.uploadingFailed);
13327
13289
  const getDescription = () => {
13328
- if (error || status === exports.Status.FAILED) {
13290
+ if (error || errors?.length || status === exports.Status.FAILED) {
13329
13291
  return /*#__PURE__*/jsxRuntime.jsx(Body, {
13330
13292
  type: exports.Typography.BODY_DEFAULT_BOLD,
13331
13293
  className: "text-negative",
13332
- children: getErrorMessage()
13294
+ children: errors?.length ? getMultipleErrors(errors) : getErrorMessage(error)
13333
13295
  });
13334
13296
  }
13335
13297
  switch (status) {
@@ -13399,7 +13361,7 @@ const UploadItem = ({
13399
13361
  }),
13400
13362
  type: "button",
13401
13363
  onClick: () => onDelete(),
13402
- children: /*#__PURE__*/jsxRuntime.jsx(icons.CrossCircleFill, {
13364
+ children: /*#__PURE__*/jsxRuntime.jsx(icons.Bin, {
13403
13365
  size: 16
13404
13366
  })
13405
13367
  })]
@@ -13436,9 +13398,6 @@ const UploadInput = ({
13436
13398
  sizeLimitErrorMessage,
13437
13399
  uploadButtonTitle
13438
13400
  }) => {
13439
- const {
13440
- isModern
13441
- } = componentsTheming.useTheme();
13442
13401
  const [markedFileForDelete, setMarkedFileForDelete] = React.useState(null);
13443
13402
  const [mounted, setMounted] = React.useState(false);
13444
13403
  const {
@@ -13596,7 +13555,7 @@ const UploadInput = ({
13596
13555
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
13597
13556
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
13598
13557
  className: classNames__default.default('np-upload-input', className, {
13599
- disabled: isModern && disabled
13558
+ disabled
13600
13559
  }),
13601
13560
  children: [uploadedFiles.map(file => /*#__PURE__*/jsxRuntime.jsx(UploadItem, {
13602
13561
  file: file,
@@ -13613,7 +13572,6 @@ const UploadInput = ({
13613
13572
  sizeLimit: sizeLimit,
13614
13573
  description: description,
13615
13574
  maxFiles: maxFiles,
13616
- multipleFileInputWithFilesAdded: multiple && uploadedFiles.length > 0,
13617
13575
  onChange: addFiles
13618
13576
  })]
13619
13577
  }), /*#__PURE__*/jsxRuntime.jsx(Modal, {
@@ -14690,7 +14648,7 @@ exports.DefinitionList = DefinitionList;
14690
14648
  exports.Dimmer = Dimmer$1;
14691
14649
  exports.DirectionProvider = DirectionProvider;
14692
14650
  exports.Display = Display;
14693
- exports.Drawer = Drawer$1;
14651
+ exports.Drawer = Drawer;
14694
14652
  exports.DropFade = DropFade;
14695
14653
  exports.Emphasis = Emphasis;
14696
14654
  exports.Field = Field;