@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.
- package/build/index.js +56 -39
- package/build/index.js.map +1 -1
- package/build/index.mjs +57 -40
- package/build/index.mjs.map +1 -1
- package/build/main.css +108 -121
- package/build/styles/main.css +108 -121
- package/build/styles/uploadInput/UploadInput.css +27 -19
- package/build/styles/uploadInput/uploadButton/UploadButton.css +38 -24
- package/build/styles/uploadInput/uploadItem/UploadItem.css +46 -81
- package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
- package/build/types/uploadInput/types.d.ts +1 -9
- package/build/types/uploadInput/types.d.ts.map +1 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts +5 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
- package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
- package/package.json +18 -19
- package/src/chips/Chips.story.tsx +5 -3
- package/src/dateLookup/DateLookup.tests.story.tsx +4 -2
- package/src/main.css +108 -121
- package/src/moneyInput/MoneyInput.story.tsx +1 -3
- package/src/phoneNumberInput/PhoneNumberInput.story.tsx +1 -0
- package/src/uploadInput/UploadInput.css +27 -19
- package/src/uploadInput/UploadInput.less +23 -20
- package/src/uploadInput/UploadInput.story.tsx +27 -75
- package/src/uploadInput/UploadInput.tsx +4 -1
- package/src/uploadInput/types.ts +1 -11
- package/src/uploadInput/uploadButton/UploadButton.css +38 -24
- package/src/uploadInput/uploadButton/UploadButton.less +40 -27
- package/src/uploadInput/uploadButton/UploadButton.spec.tsx +1 -0
- package/src/uploadInput/uploadButton/UploadButton.tsx +37 -12
- package/src/uploadInput/uploadItem/UploadItem.css +46 -81
- package/src/uploadInput/uploadItem/UploadItem.less +40 -75
- package/src/uploadInput/uploadItem/UploadItem.tsx +25 -30
- package/src/uploadInput/uploadItem/UploadItemBody.tsx +1 -1
package/build/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import React__default, { forwardRef, useId, cloneElement, useState, useEffect, useRef, useMemo, Component, createContext, useContext, useSyncExternalStore, useCallback, useImperativeHandle, createElement, PureComponent, createRef, isValidElement, Children, Fragment as Fragment$1 } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import { ChevronUp, CrossCircleFill, Cross, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, NavigateAway, Briefcase, Person, ArrowRight, Download, ChevronLeft, ChevronRight, AlertCircleFill, AlertCircle, ArrowLeft, QuestionMarkCircle, Search, CrossCircle, ChevronDown, CheckCircleFill, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle
|
|
5
|
+
import { ChevronUp, CrossCircleFill, Cross, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, NavigateAway, Briefcase, Person, ArrowRight, Download, ChevronLeft, ChevronRight, AlertCircleFill, AlertCircle, ArrowLeft, QuestionMarkCircle, Search, CrossCircle, ChevronDown, CheckCircleFill, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle } from '@transferwise/icons';
|
|
6
6
|
import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
|
|
7
7
|
import commonmark from 'commonmark';
|
|
8
8
|
import { useTheme, ThemeProvider } from '@wise/components-theming';
|
|
@@ -13001,8 +13001,13 @@ const UploadButton = ({
|
|
|
13001
13001
|
maxFiles,
|
|
13002
13002
|
onChange,
|
|
13003
13003
|
id = DEFAULT_FILE_INPUT_ID,
|
|
13004
|
-
uploadButtonTitle
|
|
13004
|
+
uploadButtonTitle,
|
|
13005
|
+
multipleFileInputWithFilesAdded
|
|
13005
13006
|
}) => {
|
|
13007
|
+
const {
|
|
13008
|
+
isModern
|
|
13009
|
+
} = useTheme();
|
|
13010
|
+
useDirection();
|
|
13006
13011
|
const {
|
|
13007
13012
|
formatMessage
|
|
13008
13013
|
} = useIntl();
|
|
@@ -13065,7 +13070,7 @@ const UploadButton = ({
|
|
|
13065
13070
|
function getAcceptedTypes() {
|
|
13066
13071
|
const areAllFilesAllowed = getFileTypesDescription() === '*';
|
|
13067
13072
|
if (areAllFilesAllowed) {
|
|
13068
|
-
return {}; //
|
|
13073
|
+
return {}; //file input by default allows all files
|
|
13069
13074
|
}
|
|
13070
13075
|
if (Array.isArray(fileTypes)) {
|
|
13071
13076
|
return {
|
|
@@ -13077,13 +13082,17 @@ const UploadButton = ({
|
|
|
13077
13082
|
};
|
|
13078
13083
|
}
|
|
13079
13084
|
function renderDescription() {
|
|
13080
|
-
return /*#__PURE__*/
|
|
13081
|
-
|
|
13082
|
-
|
|
13083
|
-
|
|
13084
|
-
|
|
13085
|
-
|
|
13086
|
-
|
|
13085
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
13086
|
+
children: /*#__PURE__*/jsxs(Body, {
|
|
13087
|
+
className: classNames({
|
|
13088
|
+
'text-primary': !disabled,
|
|
13089
|
+
small: !isModern,
|
|
13090
|
+
'font-weight-normal': !isModern
|
|
13091
|
+
}),
|
|
13092
|
+
children: [getDescription(), maxFiles && /*#__PURE__*/jsxs(Fragment, {
|
|
13093
|
+
children: [/*#__PURE__*/jsx("br", {}), `Maximum ${maxFiles} files.`]
|
|
13094
|
+
})]
|
|
13095
|
+
})
|
|
13087
13096
|
});
|
|
13088
13097
|
}
|
|
13089
13098
|
function renderButtonTitle() {
|
|
@@ -13117,11 +13126,14 @@ const UploadButton = ({
|
|
|
13117
13126
|
onChange: filesSelected
|
|
13118
13127
|
}), /*#__PURE__*/jsx("label", {
|
|
13119
13128
|
htmlFor: id,
|
|
13120
|
-
className: classNames('btn', 'np-upload-button'
|
|
13129
|
+
className: classNames('btn', 'np-upload-accent', 'np-upload-button', {
|
|
13130
|
+
disabled,
|
|
13131
|
+
'np-upload-input--square-top': multipleFileInputWithFilesAdded
|
|
13132
|
+
}),
|
|
13121
13133
|
children: /*#__PURE__*/jsxs("div", {
|
|
13122
13134
|
className: "media",
|
|
13123
13135
|
children: [/*#__PURE__*/jsx("div", {
|
|
13124
|
-
className: "np-upload-icon media-
|
|
13136
|
+
className: "np-upload-icon media-left",
|
|
13125
13137
|
children: /*#__PURE__*/jsx(Upload$2, {
|
|
13126
13138
|
size: 24,
|
|
13127
13139
|
className: "text-link"
|
|
@@ -13137,7 +13149,9 @@ const UploadButton = ({
|
|
|
13137
13149
|
})]
|
|
13138
13150
|
})
|
|
13139
13151
|
}), isDropping && /*#__PURE__*/jsxs("div", {
|
|
13140
|
-
className: classNames('droppable-card', 'droppable-dropping-card', 'droppable-card-content'
|
|
13152
|
+
className: classNames('droppable-card', 'droppable-dropping-card', 'droppable-card-content', {
|
|
13153
|
+
'np-upload-input--square-top': multipleFileInputWithFilesAdded
|
|
13154
|
+
}),
|
|
13141
13155
|
children: [/*#__PURE__*/jsx(PlusCircle, {
|
|
13142
13156
|
className: "m-x-1",
|
|
13143
13157
|
size: 24
|
|
@@ -13184,7 +13198,7 @@ const UploadItemBody = ({
|
|
|
13184
13198
|
href: url,
|
|
13185
13199
|
target: "_blank",
|
|
13186
13200
|
rel: "noopener noreferrer",
|
|
13187
|
-
className: singleFileUpload ? 'np-upload-item--single-file' : '
|
|
13201
|
+
className: singleFileUpload ? 'np-upload-item--single-file' : '',
|
|
13188
13202
|
onClick: onDownload,
|
|
13189
13203
|
children: children
|
|
13190
13204
|
});
|
|
@@ -13209,15 +13223,20 @@ const UploadItem = ({
|
|
|
13209
13223
|
status,
|
|
13210
13224
|
filename,
|
|
13211
13225
|
error,
|
|
13212
|
-
errors,
|
|
13213
13226
|
url
|
|
13214
13227
|
} = file;
|
|
13228
|
+
const {
|
|
13229
|
+
isModern
|
|
13230
|
+
} = useTheme();
|
|
13215
13231
|
const isSucceeded = [Status.SUCCEEDED, undefined].includes(status) && !!url;
|
|
13216
13232
|
const getIcon = () => {
|
|
13217
|
-
if (error ||
|
|
13218
|
-
return /*#__PURE__*/jsx(StatusIcon, {
|
|
13233
|
+
if (error || status === Status.FAILED) {
|
|
13234
|
+
return isModern ? /*#__PURE__*/jsx(StatusIcon, {
|
|
13219
13235
|
size: Size.SMALL,
|
|
13220
13236
|
sentiment: Sentiment.NEGATIVE
|
|
13237
|
+
}) : /*#__PURE__*/jsx(AlertCircle, {
|
|
13238
|
+
size: 24,
|
|
13239
|
+
className: "text-negative"
|
|
13221
13240
|
});
|
|
13222
13241
|
}
|
|
13223
13242
|
let processIndicator;
|
|
@@ -13232,37 +13251,31 @@ const UploadItem = ({
|
|
|
13232
13251
|
case Status.SUCCEEDED:
|
|
13233
13252
|
case Status.DONE:
|
|
13234
13253
|
default:
|
|
13235
|
-
processIndicator = /*#__PURE__*/jsx(StatusIcon, {
|
|
13254
|
+
processIndicator = isModern ? /*#__PURE__*/jsx(StatusIcon, {
|
|
13236
13255
|
size: Size.SMALL,
|
|
13237
13256
|
sentiment: Sentiment.POSITIVE
|
|
13257
|
+
}) : /*#__PURE__*/jsx(ProcessIndicator, {
|
|
13258
|
+
size: Size.EXTRA_SMALL,
|
|
13259
|
+
status: Status.SUCCEEDED
|
|
13238
13260
|
});
|
|
13239
13261
|
}
|
|
13240
|
-
|
|
13241
|
-
|
|
13242
|
-
const getErrorMessage = error => typeof error === 'object' ? error.message : error || formatMessage(MESSAGES.uploadingFailed);
|
|
13243
|
-
const getMultipleErrors = errors => {
|
|
13244
|
-
if (!errors?.length) {
|
|
13245
|
-
return null;
|
|
13246
|
-
}
|
|
13247
|
-
if (errors?.length === 1) {
|
|
13248
|
-
return getErrorMessage(errors[0]);
|
|
13262
|
+
if (isModern) {
|
|
13263
|
+
return processIndicator;
|
|
13249
13264
|
}
|
|
13250
|
-
return /*#__PURE__*/jsx("
|
|
13251
|
-
|
|
13252
|
-
|
|
13253
|
-
|
|
13254
|
-
|
|
13255
|
-
|
|
13256
|
-
}, index);
|
|
13257
|
-
})
|
|
13258
|
-
});
|
|
13265
|
+
return /*#__PURE__*/jsx("span", {
|
|
13266
|
+
style: {
|
|
13267
|
+
transform: 'scale(0.8335)'
|
|
13268
|
+
},
|
|
13269
|
+
children: processIndicator
|
|
13270
|
+
}); // Scale down ProcessIndicator to be 20px*20px to match `icons`
|
|
13259
13271
|
};
|
|
13272
|
+
const getErrorMessage = () => typeof error === 'object' ? error.message : error || formatMessage(MESSAGES.uploadingFailed);
|
|
13260
13273
|
const getDescription = () => {
|
|
13261
|
-
if (error ||
|
|
13274
|
+
if (error || status === Status.FAILED) {
|
|
13262
13275
|
return /*#__PURE__*/jsx(Body, {
|
|
13263
13276
|
type: Typography.BODY_DEFAULT_BOLD,
|
|
13264
13277
|
className: "text-negative",
|
|
13265
|
-
children:
|
|
13278
|
+
children: getErrorMessage()
|
|
13266
13279
|
});
|
|
13267
13280
|
}
|
|
13268
13281
|
switch (status) {
|
|
@@ -13332,7 +13345,7 @@ const UploadItem = ({
|
|
|
13332
13345
|
}),
|
|
13333
13346
|
type: "button",
|
|
13334
13347
|
onClick: () => onDelete(),
|
|
13335
|
-
children: /*#__PURE__*/jsx(
|
|
13348
|
+
children: /*#__PURE__*/jsx(CrossCircleFill, {
|
|
13336
13349
|
size: 16
|
|
13337
13350
|
})
|
|
13338
13351
|
})]
|
|
@@ -13369,6 +13382,9 @@ const UploadInput = ({
|
|
|
13369
13382
|
sizeLimitErrorMessage,
|
|
13370
13383
|
uploadButtonTitle
|
|
13371
13384
|
}) => {
|
|
13385
|
+
const {
|
|
13386
|
+
isModern
|
|
13387
|
+
} = useTheme();
|
|
13372
13388
|
const [markedFileForDelete, setMarkedFileForDelete] = useState(null);
|
|
13373
13389
|
const [mounted, setMounted] = useState(false);
|
|
13374
13390
|
const {
|
|
@@ -13526,7 +13542,7 @@ const UploadInput = ({
|
|
|
13526
13542
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
13527
13543
|
children: [/*#__PURE__*/jsxs("div", {
|
|
13528
13544
|
className: classNames('np-upload-input', className, {
|
|
13529
|
-
disabled
|
|
13545
|
+
disabled: isModern && disabled
|
|
13530
13546
|
}),
|
|
13531
13547
|
children: [uploadedFiles.map(file => /*#__PURE__*/jsx(UploadItem, {
|
|
13532
13548
|
file: file,
|
|
@@ -13543,6 +13559,7 @@ const UploadInput = ({
|
|
|
13543
13559
|
sizeLimit: sizeLimit,
|
|
13544
13560
|
description: description,
|
|
13545
13561
|
maxFiles: maxFiles,
|
|
13562
|
+
multipleFileInputWithFilesAdded: multiple && uploadedFiles.length > 0,
|
|
13546
13563
|
onChange: addFiles
|
|
13547
13564
|
})]
|
|
13548
13565
|
}), /*#__PURE__*/jsx(Modal, {
|