@transferwise/components 0.0.0-experimental-5ac3a46 → 0.0.0-experimental-215a547

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 (34) hide show
  1. package/build/index.js +56 -39
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +57 -40
  4. package/build/index.mjs.map +1 -1
  5. package/build/main.css +108 -121
  6. package/build/styles/main.css +108 -121
  7. package/build/styles/uploadInput/UploadInput.css +27 -19
  8. package/build/styles/uploadInput/uploadButton/UploadButton.css +38 -24
  9. package/build/styles/uploadInput/uploadItem/UploadItem.css +46 -81
  10. package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
  11. package/build/types/uploadInput/types.d.ts +1 -9
  12. package/build/types/uploadInput/types.d.ts.map +1 -1
  13. package/build/types/uploadInput/uploadButton/UploadButton.d.ts +5 -1
  14. package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
  15. package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
  16. package/package.json +18 -19
  17. package/src/chips/Chips.story.tsx +5 -3
  18. package/src/dateLookup/DateLookup.tests.story.tsx +4 -2
  19. package/src/main.css +108 -121
  20. package/src/moneyInput/MoneyInput.story.tsx +1 -3
  21. package/src/phoneNumberInput/PhoneNumberInput.story.tsx +1 -0
  22. package/src/uploadInput/UploadInput.css +27 -19
  23. package/src/uploadInput/UploadInput.less +23 -20
  24. package/src/uploadInput/UploadInput.story.tsx +27 -75
  25. package/src/uploadInput/UploadInput.tsx +4 -1
  26. package/src/uploadInput/types.ts +1 -11
  27. package/src/uploadInput/uploadButton/UploadButton.css +38 -24
  28. package/src/uploadInput/uploadButton/UploadButton.less +40 -27
  29. package/src/uploadInput/uploadButton/UploadButton.spec.tsx +1 -0
  30. package/src/uploadInput/uploadButton/UploadButton.tsx +37 -12
  31. package/src/uploadInput/uploadItem/UploadItem.css +46 -81
  32. package/src/uploadInput/uploadItem/UploadItem.less +40 -75
  33. package/src/uploadInput/uploadItem/UploadItem.tsx +25 -30
  34. package/src/uploadInput/uploadItem/UploadItemBody.tsx +1 -1
package/build/index.js CHANGED
@@ -13030,8 +13030,13 @@ const UploadButton = ({
13030
13030
  maxFiles,
13031
13031
  onChange,
13032
13032
  id = DEFAULT_FILE_INPUT_ID,
13033
- uploadButtonTitle
13033
+ uploadButtonTitle,
13034
+ multipleFileInputWithFilesAdded
13034
13035
  }) => {
13036
+ const {
13037
+ isModern
13038
+ } = componentsTheming.useTheme();
13039
+ useDirection();
13035
13040
  const {
13036
13041
  formatMessage
13037
13042
  } = reactIntl.useIntl();
@@ -13094,7 +13099,7 @@ const UploadButton = ({
13094
13099
  function getAcceptedTypes() {
13095
13100
  const areAllFilesAllowed = getFileTypesDescription() === '*';
13096
13101
  if (areAllFilesAllowed) {
13097
- return {}; // file input by default allows all files
13102
+ return {}; //file input by default allows all files
13098
13103
  }
13099
13104
  if (Array.isArray(fileTypes)) {
13100
13105
  return {
@@ -13106,13 +13111,17 @@ const UploadButton = ({
13106
13111
  };
13107
13112
  }
13108
13113
  function renderDescription() {
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
- })]
13114
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
13115
+ children: /*#__PURE__*/jsxRuntime.jsxs(Body, {
13116
+ className: classNames__default.default({
13117
+ 'text-primary': !disabled,
13118
+ small: !isModern,
13119
+ 'font-weight-normal': !isModern
13120
+ }),
13121
+ children: [getDescription(), maxFiles && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
13122
+ children: [/*#__PURE__*/jsxRuntime.jsx("br", {}), `Maximum ${maxFiles} files.`]
13123
+ })]
13124
+ })
13116
13125
  });
13117
13126
  }
13118
13127
  function renderButtonTitle() {
@@ -13146,11 +13155,14 @@ const UploadButton = ({
13146
13155
  onChange: filesSelected
13147
13156
  }), /*#__PURE__*/jsxRuntime.jsx("label", {
13148
13157
  htmlFor: id,
13149
- className: classNames__default.default('btn', 'np-upload-button'),
13158
+ className: classNames__default.default('btn', 'np-upload-accent', 'np-upload-button', {
13159
+ disabled,
13160
+ 'np-upload-input--square-top': multipleFileInputWithFilesAdded
13161
+ }),
13150
13162
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
13151
13163
  className: "media",
13152
13164
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
13153
- className: "np-upload-icon media-middle media-left",
13165
+ className: "np-upload-icon media-left",
13154
13166
  children: /*#__PURE__*/jsxRuntime.jsx(icons.Upload, {
13155
13167
  size: 24,
13156
13168
  className: "text-link"
@@ -13166,7 +13178,9 @@ const UploadButton = ({
13166
13178
  })]
13167
13179
  })
13168
13180
  }), isDropping && /*#__PURE__*/jsxRuntime.jsxs("div", {
13169
- className: classNames__default.default('droppable-card', 'droppable-dropping-card', 'droppable-card-content'),
13181
+ className: classNames__default.default('droppable-card', 'droppable-dropping-card', 'droppable-card-content', {
13182
+ 'np-upload-input--square-top': multipleFileInputWithFilesAdded
13183
+ }),
13170
13184
  children: [/*#__PURE__*/jsxRuntime.jsx(icons.PlusCircle, {
13171
13185
  className: "m-x-1",
13172
13186
  size: 24
@@ -13213,7 +13227,7 @@ const UploadItemBody = ({
13213
13227
  href: url,
13214
13228
  target: "_blank",
13215
13229
  rel: "noopener noreferrer",
13216
- className: singleFileUpload ? 'np-upload-item--single-file' : 'np-upload-item--link',
13230
+ className: singleFileUpload ? 'np-upload-item--single-file' : '',
13217
13231
  onClick: onDownload,
13218
13232
  children: children
13219
13233
  });
@@ -13238,15 +13252,20 @@ const UploadItem = ({
13238
13252
  status,
13239
13253
  filename,
13240
13254
  error,
13241
- errors,
13242
13255
  url
13243
13256
  } = file;
13257
+ const {
13258
+ isModern
13259
+ } = componentsTheming.useTheme();
13244
13260
  const isSucceeded = [exports.Status.SUCCEEDED, undefined].includes(status) && !!url;
13245
13261
  const getIcon = () => {
13246
- if (error || errors?.length || status === exports.Status.FAILED) {
13247
- return /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
13262
+ if (error || status === exports.Status.FAILED) {
13263
+ return isModern ? /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
13248
13264
  size: exports.Size.SMALL,
13249
13265
  sentiment: exports.Sentiment.NEGATIVE
13266
+ }) : /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {
13267
+ size: 24,
13268
+ className: "text-negative"
13250
13269
  });
13251
13270
  }
13252
13271
  let processIndicator;
@@ -13261,37 +13280,31 @@ const UploadItem = ({
13261
13280
  case exports.Status.SUCCEEDED:
13262
13281
  case exports.Status.DONE:
13263
13282
  default:
13264
- processIndicator = /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
13283
+ processIndicator = isModern ? /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
13265
13284
  size: exports.Size.SMALL,
13266
13285
  sentiment: exports.Sentiment.POSITIVE
13286
+ }) : /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
13287
+ size: exports.Size.EXTRA_SMALL,
13288
+ status: exports.Status.SUCCEEDED
13267
13289
  });
13268
13290
  }
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;
13275
- }
13276
- if (errors?.length === 1) {
13277
- return getErrorMessage(errors[0]);
13291
+ if (isModern) {
13292
+ return processIndicator;
13278
13293
  }
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
- });
13294
+ return /*#__PURE__*/jsxRuntime.jsx("span", {
13295
+ style: {
13296
+ transform: 'scale(0.8335)'
13297
+ },
13298
+ children: processIndicator
13299
+ }); // Scale down ProcessIndicator to be 20px*20px to match `icons`
13288
13300
  };
13301
+ const getErrorMessage = () => typeof error === 'object' ? error.message : error || formatMessage(MESSAGES.uploadingFailed);
13289
13302
  const getDescription = () => {
13290
- if (error || errors?.length || status === exports.Status.FAILED) {
13303
+ if (error || status === exports.Status.FAILED) {
13291
13304
  return /*#__PURE__*/jsxRuntime.jsx(Body, {
13292
13305
  type: exports.Typography.BODY_DEFAULT_BOLD,
13293
13306
  className: "text-negative",
13294
- children: errors?.length ? getMultipleErrors(errors) : getErrorMessage(error)
13307
+ children: getErrorMessage()
13295
13308
  });
13296
13309
  }
13297
13310
  switch (status) {
@@ -13361,7 +13374,7 @@ const UploadItem = ({
13361
13374
  }),
13362
13375
  type: "button",
13363
13376
  onClick: () => onDelete(),
13364
- children: /*#__PURE__*/jsxRuntime.jsx(icons.Bin, {
13377
+ children: /*#__PURE__*/jsxRuntime.jsx(icons.CrossCircleFill, {
13365
13378
  size: 16
13366
13379
  })
13367
13380
  })]
@@ -13398,6 +13411,9 @@ const UploadInput = ({
13398
13411
  sizeLimitErrorMessage,
13399
13412
  uploadButtonTitle
13400
13413
  }) => {
13414
+ const {
13415
+ isModern
13416
+ } = componentsTheming.useTheme();
13401
13417
  const [markedFileForDelete, setMarkedFileForDelete] = React.useState(null);
13402
13418
  const [mounted, setMounted] = React.useState(false);
13403
13419
  const {
@@ -13555,7 +13571,7 @@ const UploadInput = ({
13555
13571
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
13556
13572
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
13557
13573
  className: classNames__default.default('np-upload-input', className, {
13558
- disabled
13574
+ disabled: isModern && disabled
13559
13575
  }),
13560
13576
  children: [uploadedFiles.map(file => /*#__PURE__*/jsxRuntime.jsx(UploadItem, {
13561
13577
  file: file,
@@ -13572,6 +13588,7 @@ const UploadInput = ({
13572
13588
  sizeLimit: sizeLimit,
13573
13589
  description: description,
13574
13590
  maxFiles: maxFiles,
13591
+ multipleFileInputWithFilesAdded: multiple && uploadedFiles.length > 0,
13575
13592
  onChange: addFiles
13576
13593
  })]
13577
13594
  }), /*#__PURE__*/jsxRuntime.jsx(Modal, {