@transferwise/components 46.39.0 → 46.41.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.
- package/build/index.js +244 -493
- package/build/index.js.map +1 -1
- package/build/index.mjs +245 -494
- package/build/index.mjs.map +1 -1
- package/build/main.css +4 -2
- package/build/styles/main.css +4 -2
- package/build/styles/statusIcon/StatusIcon.css +4 -2
- package/build/types/dateInput/DateInput.d.ts.map +1 -1
- package/build/types/field/Field.d.ts +6 -1
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inlineAlert/InlineAlert.d.ts +2 -2
- package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
- package/build/types/processIndicator/ProcessIndicator.d.ts +1 -1
- package/build/types/processIndicator/ProcessIndicator.d.ts.map +1 -1
- package/build/types/upload/Upload.d.ts +91 -55
- package/build/types/upload/Upload.d.ts.map +1 -1
- package/build/types/upload/Upload.messages.d.ts +42 -60
- package/build/types/upload/Upload.messages.d.ts.map +1 -1
- package/build/types/upload/index.d.ts +2 -2
- package/build/types/upload/index.d.ts.map +1 -1
- package/build/types/upload/steps/completeStep/completeStep.d.ts +11 -18
- package/build/types/upload/steps/completeStep/completeStep.d.ts.map +1 -1
- package/build/types/upload/steps/completeStep/index.d.ts +2 -1
- package/build/types/upload/steps/completeStep/index.d.ts.map +1 -1
- package/build/types/upload/steps/index.d.ts +3 -4
- package/build/types/upload/steps/index.d.ts.map +1 -1
- package/build/types/upload/steps/processingStep/index.d.ts +2 -1
- package/build/types/upload/steps/processingStep/index.d.ts.map +1 -1
- package/build/types/upload/steps/processingStep/processingStep.d.ts +11 -13
- package/build/types/upload/steps/processingStep/processingStep.d.ts.map +1 -1
- package/build/types/upload/steps/uploadImageStep/index.d.ts +2 -1
- package/build/types/upload/steps/uploadImageStep/index.d.ts.map +1 -1
- package/build/types/upload/steps/uploadImageStep/uploadImageStep.d.ts +14 -18
- package/build/types/upload/steps/uploadImageStep/uploadImageStep.d.ts.map +1 -1
- package/build/types/upload/utils/asyncFileRead/asyncFileRead.d.ts +1 -1
- package/build/types/upload/utils/asyncFileRead/asyncFileRead.d.ts.map +1 -1
- package/build/types/upload/utils/asyncFileRead/index.d.ts +1 -1
- package/build/types/upload/utils/asyncFileRead/index.d.ts.map +1 -1
- package/build/types/upload/utils/getFileType/getFileType.d.ts +1 -1
- package/build/types/upload/utils/getFileType/getFileType.d.ts.map +1 -1
- package/build/types/upload/utils/getFileType/index.d.ts +1 -1
- package/build/types/upload/utils/getFileType/index.d.ts.map +1 -1
- package/build/types/upload/utils/index.d.ts +5 -7
- package/build/types/upload/utils/index.d.ts.map +1 -1
- package/build/types/upload/utils/isSizeValid/index.d.ts +1 -1
- package/build/types/upload/utils/isSizeValid/index.d.ts.map +1 -1
- package/build/types/upload/utils/isSizeValid/isSizeValid.d.ts +1 -1
- package/build/types/upload/utils/isSizeValid/isSizeValid.d.ts.map +1 -1
- package/build/types/upload/utils/isTypeValid/index.d.ts +1 -1
- package/build/types/upload/utils/isTypeValid/index.d.ts.map +1 -1
- package/build/types/upload/utils/isTypeValid/isTypeValid.d.ts +1 -1
- package/build/types/upload/utils/isTypeValid/isTypeValid.d.ts.map +1 -1
- package/build/types/upload/utils/postData/index.d.ts +1 -1
- package/build/types/upload/utils/postData/index.d.ts.map +1 -1
- package/build/types/upload/utils/postData/postData.d.ts +11 -1
- package/build/types/upload/utils/postData/postData.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/dateInput/DateInput.spec.tsx +220 -0
- package/src/dateInput/DateInput.story.tsx +3 -76
- package/src/dateInput/DateInput.tests.story.tsx +238 -0
- package/src/dateInput/DateInput.tsx +50 -53
- package/src/field/Field.story.tsx +17 -36
- package/src/field/Field.tests.story.tsx +33 -0
- package/src/field/Field.tsx +23 -13
- package/src/index.ts +2 -1
- package/src/inlineAlert/InlineAlert.story.tsx +13 -5
- package/src/inlineAlert/InlineAlert.tsx +14 -7
- package/src/main.css +4 -2
- package/src/processIndicator/ProcessIndicator.tsx +1 -1
- package/src/statusIcon/StatusIcon.css +4 -2
- package/src/statusIcon/StatusIcon.less +4 -2
- package/src/statusIcon/StatusIcon.tsx +1 -1
- package/src/upload/Upload.spec.js +3 -14
- package/src/upload/Upload.story.tsx +37 -0
- package/src/upload/{Upload.js → Upload.tsx} +164 -169
- package/src/upload/index.ts +2 -0
- package/src/upload/steps/completeStep/completeStep.spec.js +3 -2
- package/src/upload/steps/completeStep/completeStep.tsx +74 -0
- package/src/upload/steps/completeStep/index.ts +2 -0
- package/src/upload/steps/{index.js → index.ts} +0 -1
- package/src/upload/steps/processingStep/index.ts +2 -0
- package/src/upload/steps/processingStep/processingStep.tsx +53 -0
- package/src/upload/steps/uploadImageStep/index.ts +2 -0
- package/src/upload/steps/uploadImageStep/{uploadImageStep.js → uploadImageStep.tsx} +17 -23
- package/src/upload/utils/asyncFileRead/asyncFileRead.spec.ts +14 -0
- package/src/upload/utils/asyncFileRead/asyncFileRead.ts +12 -0
- package/src/upload/utils/getFileType/getFileType.spec.ts +22 -0
- package/src/upload/utils/getFileType/getFileType.ts +16 -0
- package/src/upload/utils/{index.js → index.ts} +0 -2
- package/src/upload/utils/isSizeValid/{isSizeValid.spec.js → isSizeValid.spec.ts} +3 -3
- package/src/upload/utils/isSizeValid/isSizeValid.ts +3 -0
- package/src/upload/utils/isTypeValid/isTypeValid.spec.ts +62 -0
- package/src/upload/utils/isTypeValid/isTypeValid.ts +19 -0
- package/src/upload/utils/postData/postData.spec.ts +65 -0
- package/src/upload/utils/postData/postData.ts +36 -0
- package/src/uploadInput/UploadInput.tsx +1 -1
- package/build/types/upload/steps/mediaUploadStep/index.d.ts +0 -2
- package/build/types/upload/steps/mediaUploadStep/index.d.ts.map +0 -1
- package/build/types/upload/steps/mediaUploadStep/mediaUploadStep.d.ts +0 -24
- package/build/types/upload/steps/mediaUploadStep/mediaUploadStep.d.ts.map +0 -1
- package/build/types/upload/uploadSteps.d.ts +0 -5
- package/build/types/upload/uploadSteps.d.ts.map +0 -1
- package/build/types/upload/utils/getSupportedSpotMimeTypes/getSupportedSpotMimeTypes.d.ts +0 -2
- package/build/types/upload/utils/getSupportedSpotMimeTypes/getSupportedSpotMimeTypes.d.ts.map +0 -1
- package/build/types/upload/utils/getSupportedSpotMimeTypes/index.d.ts +0 -2
- package/build/types/upload/utils/getSupportedSpotMimeTypes/index.d.ts.map +0 -1
- package/build/types/upload/utils/requestMedia/index.d.ts +0 -2
- package/build/types/upload/utils/requestMedia/index.d.ts.map +0 -1
- package/build/types/upload/utils/requestMedia/requestMedia.d.ts +0 -2
- package/build/types/upload/utils/requestMedia/requestMedia.d.ts.map +0 -1
- package/src/dateInput/DateInput.rtl.spec.tsx +0 -17
- package/src/dateInput/DateInput.spec.js +0 -477
- package/src/upload/Upload.story.js +0 -36
- package/src/upload/index.js +0 -2
- package/src/upload/steps/completeStep/completeStep.js +0 -98
- package/src/upload/steps/completeStep/index.js +0 -1
- package/src/upload/steps/mediaUploadStep/index.js +0 -1
- package/src/upload/steps/mediaUploadStep/mediaUploadStep.js +0 -80
- package/src/upload/steps/mediaUploadStep/mediaUploadStep.spec.js +0 -77
- package/src/upload/steps/processingStep/index.js +0 -1
- package/src/upload/steps/processingStep/processingStep.js +0 -73
- package/src/upload/steps/uploadImageStep/index.js +0 -1
- package/src/upload/uploadSteps.ts +0 -5
- package/src/upload/utils/asyncFileRead/asyncFileRead.js +0 -11
- package/src/upload/utils/asyncFileRead/asyncFileRead.spec.js +0 -17
- package/src/upload/utils/getFileType/getFileType.js +0 -19
- package/src/upload/utils/getFileType/getFileType.spec.js +0 -33
- package/src/upload/utils/getSupportedSpotMimeTypes/getSupportedSpotMimeTypes.js +0 -18
- package/src/upload/utils/getSupportedSpotMimeTypes/getSupportedSpotMimeTypes.spec.js +0 -22
- package/src/upload/utils/getSupportedSpotMimeTypes/index.js +0 -1
- package/src/upload/utils/isSizeValid/isSizeValid.js +0 -1
- package/src/upload/utils/isTypeValid/isTypeValid.js +0 -26
- package/src/upload/utils/isTypeValid/isTypeValid.spec.js +0 -68
- package/src/upload/utils/postData/postData.js +0 -18
- package/src/upload/utils/postData/postData.spec.js +0 -109
- package/src/upload/utils/requestMedia/index.js +0 -1
- package/src/upload/utils/requestMedia/requestMedia.js +0 -26
- package/src/upload/utils/requestMedia/requestMedia.spec.js +0 -44
- /package/src/upload/{Upload.messages.js → Upload.messages.ts} +0 -0
- /package/src/upload/utils/asyncFileRead/{index.js → index.ts} +0 -0
- /package/src/upload/utils/getFileType/{index.js → index.ts} +0 -0
- /package/src/upload/utils/isSizeValid/{index.js → index.ts} +0 -0
- /package/src/upload/utils/isTypeValid/{index.js → index.ts} +0 -0
- /package/src/upload/utils/postData/{index.js → index.ts} +0 -0
package/build/index.js
CHANGED
|
@@ -746,7 +746,7 @@ const StatusIcon = ({
|
|
|
746
746
|
const iconColor = sentiment === 'warning' || sentiment === 'pending' ? 'dark' : 'light';
|
|
747
747
|
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
748
748
|
"data-testid": "status-icon",
|
|
749
|
-
className: classNames__default.default('status-circle',
|
|
749
|
+
className: classNames__default.default('status-circle', `status-circle-${size}`, sentiment),
|
|
750
750
|
children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
|
|
751
751
|
className: classNames__default.default('status-icon', iconColor)
|
|
752
752
|
})
|
|
@@ -3188,8 +3188,10 @@ const DateInput = ({
|
|
|
3188
3188
|
return null;
|
|
3189
3189
|
};
|
|
3190
3190
|
const [day, setDay] = React.useState(() => getInitialDate('day'));
|
|
3191
|
+
const [displayDay, setDisplayDay] = React.useState(day?.toString());
|
|
3191
3192
|
const [month, setMonth] = React.useState(() => getInitialDate('month'));
|
|
3192
3193
|
const [year, setYear] = React.useState(() => getInitialDate('year'));
|
|
3194
|
+
const [displayYear, setDisplayYear] = React.useState(year?.toString());
|
|
3193
3195
|
const [lastBroadcastedValue, setLastBroadcastedValue] = React.useState(getDateObject);
|
|
3194
3196
|
const monthNames = getMonthNames(locale, monthFormat);
|
|
3195
3197
|
dayLabel ||= formatMessage(messages$9.dayLabel);
|
|
@@ -3215,8 +3217,8 @@ const DateInput = ({
|
|
|
3215
3217
|
const getSelectElement = () => {
|
|
3216
3218
|
return /*#__PURE__*/jsxRuntime.jsxs("label", {
|
|
3217
3219
|
className: "d-flex flex-column",
|
|
3218
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
3219
|
-
|
|
3220
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
3221
|
+
type: exports.Typography.BODY_DEFAULT,
|
|
3220
3222
|
children: monthLabel
|
|
3221
3223
|
}), /*#__PURE__*/jsxRuntime.jsx(SelectInput, {
|
|
3222
3224
|
name: "month",
|
|
@@ -3238,12 +3240,23 @@ const DateInput = ({
|
|
|
3238
3240
|
})]
|
|
3239
3241
|
});
|
|
3240
3242
|
};
|
|
3243
|
+
const isDayValid = (newDay, newMonth, newYear) => {
|
|
3244
|
+
const maxDay = new Date(newYear, newMonth + 1, 0).getDate();
|
|
3245
|
+
return newDay <= maxDay;
|
|
3246
|
+
};
|
|
3241
3247
|
const handleInternalValue = (newDay = day, newMonth = month, newYear = year) => {
|
|
3242
|
-
if (newDay == null || newMonth == null || newYear == null) {
|
|
3248
|
+
if (newDay == null || newDay === 0 || newMonth == null || newYear == null || newYear === 0) {
|
|
3249
|
+
broadcastNewValue(null);
|
|
3250
|
+
return;
|
|
3251
|
+
}
|
|
3252
|
+
if (!isDayValid(newDay, newMonth, newYear)) {
|
|
3243
3253
|
broadcastNewValue(null);
|
|
3244
3254
|
return;
|
|
3245
3255
|
}
|
|
3246
3256
|
const dateValue = new Date(newYear, newMonth, newDay);
|
|
3257
|
+
if (newYear < 100) {
|
|
3258
|
+
dateValue.setFullYear(newYear);
|
|
3259
|
+
}
|
|
3247
3260
|
if (!isDateValid(dateValue)) {
|
|
3248
3261
|
broadcastNewValue(null);
|
|
3249
3262
|
return;
|
|
@@ -3257,11 +3270,11 @@ const DateInput = ({
|
|
|
3257
3270
|
}
|
|
3258
3271
|
};
|
|
3259
3272
|
const handleDayChange = event => {
|
|
3260
|
-
const
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
handleInternalValue(
|
|
3273
|
+
const newDayString = event.target.value.replace(/\D/g, '');
|
|
3274
|
+
const newDayNumber = Number.parseInt(newDayString, 10);
|
|
3275
|
+
setDay(newDayNumber);
|
|
3276
|
+
setDisplayDay(newDayString);
|
|
3277
|
+
handleInternalValue(newDayNumber, month, year);
|
|
3265
3278
|
};
|
|
3266
3279
|
const handleMonthChange = selectedMonth => {
|
|
3267
3280
|
if (selectedMonth === null) {
|
|
@@ -3269,30 +3282,19 @@ const DateInput = ({
|
|
|
3269
3282
|
handleInternalValue(day, null, year);
|
|
3270
3283
|
return;
|
|
3271
3284
|
}
|
|
3272
|
-
const {
|
|
3273
|
-
checkedDay
|
|
3274
|
-
} = checkDate(day, selectedMonth, year);
|
|
3275
3285
|
setMonth(selectedMonth);
|
|
3276
|
-
|
|
3277
|
-
setDay(checkedDay);
|
|
3278
|
-
}
|
|
3279
|
-
handleInternalValue(checkedDay, selectedMonth, year);
|
|
3286
|
+
handleInternalValue(day, selectedMonth, year);
|
|
3280
3287
|
};
|
|
3281
3288
|
const handleYearChange = event => {
|
|
3282
|
-
const
|
|
3283
|
-
const
|
|
3284
|
-
if (
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
} = checkDate(day, month, Number.parseInt(newValue, 10));
|
|
3289
|
-
if (day && checkedDay !== day) {
|
|
3290
|
-
setDay(checkedDay);
|
|
3291
|
-
}
|
|
3292
|
-
setYear(Number.parseInt(slicedYear, 10));
|
|
3293
|
-
handleInternalValue(checkedDay, month, Number.parseInt(slicedYear, 10));
|
|
3289
|
+
const newYearString = event.target.value.replace(/\D/g, '');
|
|
3290
|
+
const newYearNumber = Number.parseInt(newYearString, 10);
|
|
3291
|
+
if (newYearString.length >= 4 && newYearString.length <= 6) {
|
|
3292
|
+
setYear(newYearNumber);
|
|
3293
|
+
setDisplayYear(newYearString);
|
|
3294
|
+
handleInternalValue(day, month, newYearNumber);
|
|
3294
3295
|
} else {
|
|
3295
|
-
setYear(
|
|
3296
|
+
setYear(null);
|
|
3297
|
+
setDisplayYear(newYearString);
|
|
3296
3298
|
handleInternalValue(day, month, null);
|
|
3297
3299
|
}
|
|
3298
3300
|
};
|
|
@@ -3302,24 +3304,6 @@ const DateInput = ({
|
|
|
3302
3304
|
onChange(newValue != null ? getDateAsString(newValue) : null);
|
|
3303
3305
|
}
|
|
3304
3306
|
};
|
|
3305
|
-
const checkDate = (newDay = null, newMonth = 0, newYear = null) => {
|
|
3306
|
-
let checkedDay = newDay;
|
|
3307
|
-
const maxDay = new Date(newYear || 2000, newMonth != null ? newMonth + 1 : 1, 0).getDate();
|
|
3308
|
-
if (!newDay) {
|
|
3309
|
-
checkedDay = null;
|
|
3310
|
-
}
|
|
3311
|
-
if (newDay && newDay < 0) {
|
|
3312
|
-
checkedDay = 1;
|
|
3313
|
-
}
|
|
3314
|
-
if (newDay && newMonth || newDay && newDay > 31) {
|
|
3315
|
-
checkedDay = newDay > maxDay ? maxDay : newDay;
|
|
3316
|
-
}
|
|
3317
|
-
return {
|
|
3318
|
-
checkedDay,
|
|
3319
|
-
checkedMonth: newMonth,
|
|
3320
|
-
checkedYear: newYear
|
|
3321
|
-
};
|
|
3322
|
-
};
|
|
3323
3307
|
const monthYearOnly = mode === exports.DateMode.MONTH_YEAR;
|
|
3324
3308
|
const monthWidth = classNames__default.default({
|
|
3325
3309
|
'col-sm-8': monthYearOnly,
|
|
@@ -3335,8 +3319,8 @@ const DateInput = ({
|
|
|
3335
3319
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3336
3320
|
className: "col-sm-3",
|
|
3337
3321
|
children: /*#__PURE__*/jsxRuntime.jsxs("label", {
|
|
3338
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
3339
|
-
|
|
3322
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
3323
|
+
type: exports.Typography.BODY_DEFAULT,
|
|
3340
3324
|
children: dayLabel
|
|
3341
3325
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3342
3326
|
className: `input-group input-group-${size}`,
|
|
@@ -3346,10 +3330,12 @@ const DateInput = ({
|
|
|
3346
3330
|
pattern: "[0-9]*",
|
|
3347
3331
|
name: "day",
|
|
3348
3332
|
autoComplete: dayAutoComplete,
|
|
3349
|
-
value:
|
|
3333
|
+
value: displayDay || '',
|
|
3350
3334
|
placeholder: placeholders?.day,
|
|
3351
3335
|
disabled: disabled,
|
|
3352
3336
|
min: 1,
|
|
3337
|
+
max: 31,
|
|
3338
|
+
maxLength: 2,
|
|
3353
3339
|
onChange: event => handleDayChange(event)
|
|
3354
3340
|
})
|
|
3355
3341
|
})]
|
|
@@ -3360,8 +3346,8 @@ const DateInput = ({
|
|
|
3360
3346
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3361
3347
|
className: "col-sm-4",
|
|
3362
3348
|
children: /*#__PURE__*/jsxRuntime.jsxs("label", {
|
|
3363
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
3364
|
-
|
|
3349
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
3350
|
+
type: exports.Typography.BODY_DEFAULT,
|
|
3365
3351
|
children: yearLabel
|
|
3366
3352
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3367
3353
|
className: `input-group input-group-${size}`,
|
|
@@ -3372,9 +3358,11 @@ const DateInput = ({
|
|
|
3372
3358
|
name: "year",
|
|
3373
3359
|
autoComplete: yearAutoComplete,
|
|
3374
3360
|
placeholder: placeholders?.year,
|
|
3375
|
-
value:
|
|
3361
|
+
value: displayYear || '',
|
|
3376
3362
|
disabled: disabled,
|
|
3377
|
-
min:
|
|
3363
|
+
min: 0,
|
|
3364
|
+
max: 9999,
|
|
3365
|
+
maxLength: 6,
|
|
3378
3366
|
onChange: event => handleYearChange(event)
|
|
3379
3367
|
})
|
|
3380
3368
|
})]
|
|
@@ -4878,14 +4866,20 @@ function InlineAlert({
|
|
|
4878
4866
|
className,
|
|
4879
4867
|
children
|
|
4880
4868
|
}) {
|
|
4881
|
-
|
|
4882
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
4869
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4883
4870
|
role: "alert",
|
|
4884
4871
|
id: id,
|
|
4885
|
-
className: classNames__default.default('alert alert-detach', `alert-${
|
|
4886
|
-
children:
|
|
4887
|
-
|
|
4888
|
-
|
|
4872
|
+
className: classNames__default.default('alert alert-detach', `alert-${type === exports.Sentiment.NEGATIVE || type === exports.Sentiment.ERROR ? 'danger' : type}`, className),
|
|
4873
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
4874
|
+
className: "d-inline-flex",
|
|
4875
|
+
children: [type !== exports.Sentiment.NEUTRAL && type !== exports.Sentiment.PENDING && /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
|
|
4876
|
+
sentiment: type,
|
|
4877
|
+
size: exports.Size.SMALL
|
|
4878
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4879
|
+
className: "np-text-body-default",
|
|
4880
|
+
children: children
|
|
4881
|
+
})]
|
|
4882
|
+
})
|
|
4889
4883
|
});
|
|
4890
4884
|
}
|
|
4891
4885
|
|
|
@@ -4906,13 +4900,15 @@ const Label = ({
|
|
|
4906
4900
|
const Field = ({
|
|
4907
4901
|
id,
|
|
4908
4902
|
label,
|
|
4909
|
-
|
|
4910
|
-
|
|
4903
|
+
message: propMessage,
|
|
4904
|
+
sentiment: propType = exports.Sentiment.NEUTRAL,
|
|
4911
4905
|
className,
|
|
4912
|
-
children
|
|
4906
|
+
children,
|
|
4907
|
+
...props
|
|
4913
4908
|
}) => {
|
|
4914
|
-
const
|
|
4915
|
-
const
|
|
4909
|
+
const sentiment = props.error ? exports.Sentiment.NEGATIVE : propType;
|
|
4910
|
+
const message = props.error || props.hint || propMessage;
|
|
4911
|
+
const hasError = sentiment === exports.Sentiment.NEGATIVE;
|
|
4916
4912
|
const labelId = React.useId();
|
|
4917
4913
|
const fallbackInputId = React.useId();
|
|
4918
4914
|
const inputId = id !== null ? id ?? fallbackInputId : undefined;
|
|
@@ -4922,26 +4918,24 @@ const Field = ({
|
|
|
4922
4918
|
children: /*#__PURE__*/jsxRuntime.jsx(InputIdContextProvider, {
|
|
4923
4919
|
value: inputId,
|
|
4924
4920
|
children: /*#__PURE__*/jsxRuntime.jsx(InputDescribedByProvider, {
|
|
4925
|
-
value:
|
|
4921
|
+
value: message ? descriptionId : undefined,
|
|
4926
4922
|
children: /*#__PURE__*/jsxRuntime.jsx(InputInvalidProvider, {
|
|
4927
4923
|
value: hasError,
|
|
4928
4924
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
4929
4925
|
className: classNames__default.default('form-group d-block', {
|
|
4926
|
+
'has-success': sentiment === exports.Sentiment.POSITIVE,
|
|
4927
|
+
'has-warning': sentiment === exports.Sentiment.WARNING,
|
|
4930
4928
|
'has-error': hasError,
|
|
4931
|
-
'has-info':
|
|
4929
|
+
'has-info': sentiment === exports.Sentiment.NEUTRAL
|
|
4932
4930
|
}, className),
|
|
4933
4931
|
children: [/*#__PURE__*/jsxRuntime.jsxs(Label, {
|
|
4934
4932
|
id: labelId,
|
|
4935
4933
|
htmlFor: inputId,
|
|
4936
4934
|
children: [label, children]
|
|
4937
|
-
}),
|
|
4938
|
-
type:
|
|
4939
|
-
id: descriptionId,
|
|
4940
|
-
children: hint
|
|
4941
|
-
}), hasError && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
|
|
4942
|
-
type: exports.Sentiment.NEGATIVE,
|
|
4935
|
+
}), message && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
|
|
4936
|
+
type: sentiment,
|
|
4943
4937
|
id: descriptionId,
|
|
4944
|
-
children:
|
|
4938
|
+
children: message
|
|
4945
4939
|
})]
|
|
4946
4940
|
})
|
|
4947
4941
|
})
|
|
@@ -12088,13 +12082,6 @@ var Typeahead$1 = withInputAttributes(Typeahead, {
|
|
|
12088
12082
|
nonLabelable: true
|
|
12089
12083
|
});
|
|
12090
12084
|
|
|
12091
|
-
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
12092
|
-
exports.UploadStep = void 0;
|
|
12093
|
-
(function (UploadStep) {
|
|
12094
|
-
UploadStep["UPLOAD_IMAGE_STEP"] = "uploadImageStep";
|
|
12095
|
-
UploadStep["MEDIA_UPLOAD_STEP"] = "mediaUploadStep";
|
|
12096
|
-
})(exports.UploadStep || (exports.UploadStep = {}));
|
|
12097
|
-
|
|
12098
12085
|
var messages = reactIntl.defineMessages({
|
|
12099
12086
|
csButtonText: {
|
|
12100
12087
|
id: "neptune.Upload.csButtonText"
|
|
@@ -12129,16 +12116,13 @@ var messages = reactIntl.defineMessages({
|
|
|
12129
12116
|
});
|
|
12130
12117
|
|
|
12131
12118
|
class UploadImageStep extends React.PureComponent {
|
|
12132
|
-
|
|
12133
|
-
super();
|
|
12134
|
-
this.uploadInputRef = /*#__PURE__*/React.createRef();
|
|
12135
|
-
}
|
|
12119
|
+
uploadInputRef = /*#__PURE__*/React.createRef();
|
|
12136
12120
|
onManualUpload = () => {
|
|
12137
12121
|
const {
|
|
12138
12122
|
fileDropped
|
|
12139
12123
|
} = this.props;
|
|
12140
|
-
|
|
12141
|
-
|
|
12124
|
+
const file = this.uploadInputRef.current?.files?.[0];
|
|
12125
|
+
if (file != null) {
|
|
12142
12126
|
fileDropped(file);
|
|
12143
12127
|
}
|
|
12144
12128
|
};
|
|
@@ -12187,7 +12171,7 @@ class UploadImageStep extends React.PureComponent {
|
|
|
12187
12171
|
children: usLabel
|
|
12188
12172
|
}), usPlaceholder && /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
12189
12173
|
className: "np-text-body-large m-b-3",
|
|
12190
|
-
children:
|
|
12174
|
+
children: String(usPlaceholder)
|
|
12191
12175
|
}), /*#__PURE__*/jsxRuntime.jsxs("label", {
|
|
12192
12176
|
className: `btn btn-primary btn-md ${usDisabled ? 'disabled' : ''}`,
|
|
12193
12177
|
children: [usButtonText ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
@@ -12198,7 +12182,7 @@ class UploadImageStep extends React.PureComponent {
|
|
|
12198
12182
|
}), /*#__PURE__*/jsxRuntime.jsx("input", {
|
|
12199
12183
|
ref: this.uploadInputRef,
|
|
12200
12184
|
type: "file",
|
|
12201
|
-
accept: usAccept === '*' ?
|
|
12185
|
+
accept: usAccept === '*' ? undefined : usAccept,
|
|
12202
12186
|
className: "tw-droppable-input hidden",
|
|
12203
12187
|
disabled: usDisabled,
|
|
12204
12188
|
name: "file-upload",
|
|
@@ -12210,213 +12194,17 @@ class UploadImageStep extends React.PureComponent {
|
|
|
12210
12194
|
});
|
|
12211
12195
|
}
|
|
12212
12196
|
}
|
|
12213
|
-
UploadImageStep.propTypes = {
|
|
12214
|
-
fileDropped: PropTypes__default.default.func.isRequired,
|
|
12215
|
-
isComplete: PropTypes__default.default.bool.isRequired,
|
|
12216
|
-
usAccept: PropTypes__default.default.string.isRequired,
|
|
12217
|
-
usButtonText: PropTypes__default.default.string.isRequired,
|
|
12218
|
-
usDisabled: PropTypes__default.default.bool.isRequired,
|
|
12219
|
-
usHelpImage: PropTypes__default.default.node.isRequired,
|
|
12220
|
-
usLabel: PropTypes__default.default.string.isRequired,
|
|
12221
|
-
usPlaceholder: PropTypes__default.default.string.isRequired
|
|
12222
|
-
};
|
|
12223
|
-
|
|
12224
|
-
const postData = (httpOptions, data = {}, fetcher = fetch) => fetcher(`${httpOptions.url}`, {
|
|
12225
|
-
method: 'POST',
|
|
12226
|
-
body: data,
|
|
12227
|
-
...httpOptions
|
|
12228
|
-
}).then(response => {
|
|
12229
|
-
if (!response.ok) {
|
|
12230
|
-
const error = new Error(response.statusText);
|
|
12231
|
-
error.status = response.status;
|
|
12232
|
-
error.response = response;
|
|
12233
|
-
throw error;
|
|
12234
|
-
}
|
|
12235
|
-
return response;
|
|
12236
|
-
}).catch(error => {
|
|
12237
|
-
throw error;
|
|
12238
|
-
});
|
|
12239
12197
|
|
|
12240
|
-
|
|
12241
|
-
const reader = new FileReader();
|
|
12242
|
-
reader.readAsDataURL(file);
|
|
12243
|
-
reader.addEventListener('load', event => {
|
|
12244
|
-
resolve(event.target.result);
|
|
12245
|
-
});
|
|
12246
|
-
reader.addEventListener('error', event => {
|
|
12247
|
-
reject(event);
|
|
12248
|
-
});
|
|
12249
|
-
});
|
|
12250
|
-
|
|
12251
|
-
const isSizeValid = (file, maxSize) => Number.isInteger(maxSize) && file.size <= maxSize;
|
|
12252
|
-
|
|
12253
|
-
const getFileType = (file, file64) => {
|
|
12254
|
-
if (!file && !file64) {
|
|
12255
|
-
return '';
|
|
12256
|
-
}
|
|
12257
|
-
if (file && file.type && file.type !== '') {
|
|
12258
|
-
return file.type ?? '';
|
|
12259
|
-
}
|
|
12260
|
-
if (file64) {
|
|
12261
|
-
const regex = /^data:([a-z]+\/[a-z]+);/;
|
|
12262
|
-
const typeFromEncoded = file64.match(regex);
|
|
12263
|
-
if (typeFromEncoded && typeFromEncoded[1]) {
|
|
12264
|
-
return typeFromEncoded[1] ?? '';
|
|
12265
|
-
}
|
|
12266
|
-
}
|
|
12267
|
-
return '';
|
|
12268
|
-
};
|
|
12269
|
-
|
|
12270
|
-
const isTypeValid = (file, rule, file64) => {
|
|
12271
|
-
if (!file || !rule) {
|
|
12272
|
-
return false;
|
|
12273
|
-
}
|
|
12274
|
-
const allowedTypes = rule.replace(/\s/g, '').split(',');
|
|
12275
|
-
const fileType = getFileType(file, file64);
|
|
12276
|
-
if (rule === '*' || allowedTypes.includes(fileType)) {
|
|
12277
|
-
return true;
|
|
12278
|
-
}
|
|
12279
|
-
return allowedTypes.some(type => {
|
|
12280
|
-
const splittedRule = type.split('/');
|
|
12281
|
-
const typeAllowed = splittedRule[0];
|
|
12282
|
-
const extensionAllowed = splittedRule[1];
|
|
12283
|
-
if (extensionAllowed !== '*') {
|
|
12284
|
-
return false;
|
|
12285
|
-
}
|
|
12286
|
-
return fileType.includes(typeAllowed);
|
|
12287
|
-
});
|
|
12288
|
-
};
|
|
12289
|
-
|
|
12290
|
-
// Spot Platform's Media API only support these MIME types
|
|
12291
|
-
const SUPPORTED_MIME_TYPES = ['image/jpeg', 'video/*', 'application/pdf'];
|
|
12292
|
-
const getSupportedSpotMimeTypes = mimeTypes => {
|
|
12293
|
-
if (mimeTypes === '*') {
|
|
12294
|
-
return SUPPORTED_MIME_TYPES;
|
|
12295
|
-
}
|
|
12296
|
-
const mimeTypesArray = mimeTypes.split(',');
|
|
12297
|
-
const mimeMapping = {
|
|
12298
|
-
'image/*': 'image/jpeg',
|
|
12299
|
-
'application/*': 'application/pdf'
|
|
12300
|
-
};
|
|
12301
|
-
const mapSupportedMimeTypes = mimeTypesArray.map(type => mimeMapping[type] || type);
|
|
12302
|
-
return mapSupportedMimeTypes.filter(type => SUPPORTED_MIME_TYPES.includes(type));
|
|
12303
|
-
};
|
|
12304
|
-
|
|
12305
|
-
const requestMedia = mediaRequest => new Promise((resolve, reject) => {
|
|
12306
|
-
if (typeof window === 'undefined' || typeof window.microapps === 'undefined') {
|
|
12307
|
-
reject(`microapps must be available in window to use Spot Platform's Media API`);
|
|
12308
|
-
}
|
|
12309
|
-
window.microapps.requestMedia(mediaRequest).then(response => {
|
|
12310
|
-
const fileByteArray = base64ToByteArray(response.bytes);
|
|
12311
|
-
const blob = new Blob([fileByteArray], {
|
|
12312
|
-
type: response.mimeType
|
|
12313
|
-
});
|
|
12314
|
-
resolve(blob);
|
|
12315
|
-
}).catch(error => reject(error));
|
|
12316
|
-
});
|
|
12317
|
-
const base64ToByteArray = base64String => {
|
|
12318
|
-
const byteCharacters = atob(base64String);
|
|
12319
|
-
const byteCharactersLength = byteCharacters.length;
|
|
12320
|
-
const byteArray = new Array(byteCharactersLength);
|
|
12321
|
-
for (let i = 0; i < byteCharactersLength; i += 1) {
|
|
12322
|
-
byteArray[i] = byteCharacters.charCodeAt(i);
|
|
12323
|
-
}
|
|
12324
|
-
return new Uint8Array(byteArray);
|
|
12325
|
-
};
|
|
12326
|
-
|
|
12327
|
-
const MediaUploadStep = ({
|
|
12198
|
+
function ProcessingStep({
|
|
12328
12199
|
isComplete,
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12335
|
-
|
|
12336
|
-
})
|
|
12337
|
-
const getMediaFile = () => {
|
|
12338
|
-
const allowedMimeTypes = getSupportedSpotMimeTypes(usAccept);
|
|
12339
|
-
if (allowedMimeTypes.length === 0) {
|
|
12340
|
-
throw new Error('provided mimeTypes not supported');
|
|
12341
|
-
}
|
|
12342
|
-
const mediaRequest = {
|
|
12343
|
-
allowedMimeTypes
|
|
12344
|
-
};
|
|
12345
|
-
requestMedia(mediaRequest).then(file => fileDropped(file));
|
|
12346
|
-
};
|
|
12347
|
-
const getImage = () => {
|
|
12348
|
-
if (!usHelpImage) {
|
|
12349
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
12350
|
-
className: "circle circle-sm circle-inverse p-t-1",
|
|
12351
|
-
children: /*#__PURE__*/jsxRuntime.jsx(icons.Upload, {
|
|
12352
|
-
size: 24
|
|
12353
|
-
})
|
|
12354
|
-
});
|
|
12355
|
-
}
|
|
12356
|
-
if (typeof usHelpImage === 'string') {
|
|
12357
|
-
return /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
12358
|
-
src: usHelpImage,
|
|
12359
|
-
alt: usLabel,
|
|
12360
|
-
className: "thumbnail text-xs-center"
|
|
12361
|
-
});
|
|
12362
|
-
}
|
|
12363
|
-
return usHelpImage;
|
|
12364
|
-
};
|
|
12365
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
12366
|
-
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
12367
|
-
className: "droppable-default-card",
|
|
12368
|
-
"aria-hidden": isComplete,
|
|
12369
|
-
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
12370
|
-
className: "droppable-card-content",
|
|
12371
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
12372
|
-
className: "m-b-3",
|
|
12373
|
-
children: getImage()
|
|
12374
|
-
}), usLabel && /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
12375
|
-
type: exports.Typography.TITLE_BODY,
|
|
12376
|
-
className: "m-b-1",
|
|
12377
|
-
children: usLabel
|
|
12378
|
-
}), usPlaceholder && /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
12379
|
-
as: "p",
|
|
12380
|
-
type: exports.Typography.BODY_LARGE,
|
|
12381
|
-
className: "m-b-3",
|
|
12382
|
-
children: `${usPlaceholder}`
|
|
12383
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
12384
|
-
disabled: usDisabled,
|
|
12385
|
-
onClick: getMediaFile,
|
|
12386
|
-
children: usButtonText || /*#__PURE__*/jsxRuntime.jsx(icons.Upload, {
|
|
12387
|
-
size: 24,
|
|
12388
|
-
className: "m-r-0"
|
|
12389
|
-
})
|
|
12390
|
-
})]
|
|
12391
|
-
})
|
|
12392
|
-
})
|
|
12393
|
-
});
|
|
12394
|
-
};
|
|
12395
|
-
MediaUploadStep.propTypes = {
|
|
12396
|
-
fileDropped: PropTypes__default.default.func.isRequired,
|
|
12397
|
-
isComplete: PropTypes__default.default.bool.isRequired,
|
|
12398
|
-
usAccept: PropTypes__default.default.string.isRequired,
|
|
12399
|
-
usButtonText: PropTypes__default.default.string.isRequired,
|
|
12400
|
-
usDisabled: PropTypes__default.default.bool.isRequired,
|
|
12401
|
-
usHelpImage: PropTypes__default.default.node.isRequired,
|
|
12402
|
-
usLabel: PropTypes__default.default.string.isRequired,
|
|
12403
|
-
usPlaceholder: PropTypes__default.default.string.isRequired
|
|
12404
|
-
};
|
|
12405
|
-
|
|
12406
|
-
const ProcessingStep = props => {
|
|
12407
|
-
const {
|
|
12408
|
-
isComplete,
|
|
12409
|
-
isError,
|
|
12410
|
-
isSuccess,
|
|
12411
|
-
onAnimationCompleted,
|
|
12412
|
-
onClear,
|
|
12413
|
-
psButtonText,
|
|
12414
|
-
psProcessingText,
|
|
12415
|
-
psButtonDisabled
|
|
12416
|
-
} = props;
|
|
12417
|
-
const {
|
|
12418
|
-
isModern
|
|
12419
|
-
} = componentsTheming.useTheme();
|
|
12200
|
+
isError,
|
|
12201
|
+
isSuccess,
|
|
12202
|
+
onAnimationCompleted,
|
|
12203
|
+
onClear,
|
|
12204
|
+
psButtonText,
|
|
12205
|
+
psProcessingText,
|
|
12206
|
+
psButtonDisabled
|
|
12207
|
+
}) {
|
|
12420
12208
|
let processStatus = exports.Status.PROCESSING;
|
|
12421
12209
|
if (isError) {
|
|
12422
12210
|
processStatus = exports.Status.FAILED;
|
|
@@ -12430,53 +12218,33 @@ const ProcessingStep = props => {
|
|
|
12430
12218
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
12431
12219
|
className: "droppable-card-content",
|
|
12432
12220
|
children: [/*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
|
|
12433
|
-
size: exports.Size.Small,
|
|
12434
12221
|
status: processStatus,
|
|
12435
12222
|
onAnimationCompleted: status => onAnimationCompleted(status)
|
|
12436
12223
|
}), /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
12437
|
-
className:
|
|
12438
|
-
'm-t-3': !isModern,
|
|
12439
|
-
'm-b-3': !isModern,
|
|
12440
|
-
'm-t-2': isModern,
|
|
12441
|
-
'm-b-2': isModern
|
|
12442
|
-
}),
|
|
12224
|
+
className: "m-y-2",
|
|
12443
12225
|
type: exports.Typography.TITLE_BODY,
|
|
12444
12226
|
"aria-live": "polite",
|
|
12445
12227
|
children: psProcessingText
|
|
12446
12228
|
}), psButtonText && /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
12447
12229
|
disabled: psButtonDisabled,
|
|
12448
|
-
onClick:
|
|
12230
|
+
onClick: onClear,
|
|
12449
12231
|
children: psButtonText
|
|
12450
12232
|
})]
|
|
12451
12233
|
})
|
|
12452
12234
|
});
|
|
12453
|
-
}
|
|
12454
|
-
ProcessingStep.propTypes = {
|
|
12455
|
-
isComplete: PropTypes__default.default.bool.isRequired,
|
|
12456
|
-
isError: PropTypes__default.default.bool.isRequired,
|
|
12457
|
-
isSuccess: PropTypes__default.default.bool.isRequired,
|
|
12458
|
-
onAnimationCompleted: PropTypes__default.default.func.isRequired,
|
|
12459
|
-
onClear: PropTypes__default.default.func.isRequired,
|
|
12460
|
-
psButtonText: PropTypes__default.default.string.isRequired,
|
|
12461
|
-
psProcessingText: PropTypes__default.default.string.isRequired,
|
|
12462
|
-
psButtonDisabled: PropTypes__default.default.bool.isRequired
|
|
12463
|
-
};
|
|
12235
|
+
}
|
|
12464
12236
|
|
|
12465
|
-
|
|
12466
|
-
|
|
12467
|
-
|
|
12468
|
-
|
|
12469
|
-
|
|
12470
|
-
|
|
12471
|
-
|
|
12472
|
-
|
|
12473
|
-
|
|
12474
|
-
|
|
12475
|
-
|
|
12476
|
-
isImage,
|
|
12477
|
-
onClear,
|
|
12478
|
-
uploadedImage
|
|
12479
|
-
} = props;
|
|
12237
|
+
function CompleteStep({
|
|
12238
|
+
csButtonText,
|
|
12239
|
+
csFailureText,
|
|
12240
|
+
csSuccessText,
|
|
12241
|
+
fileName,
|
|
12242
|
+
isComplete,
|
|
12243
|
+
isError,
|
|
12244
|
+
isImage,
|
|
12245
|
+
onClear,
|
|
12246
|
+
uploadedImage
|
|
12247
|
+
}) {
|
|
12480
12248
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
12481
12249
|
className: "droppable-complete-card droppable-card",
|
|
12482
12250
|
"aria-hidden": !isComplete,
|
|
@@ -12486,16 +12254,11 @@ const CompleteStep = props => {
|
|
|
12486
12254
|
className: "droppable-card-content d-flex flex-column align-items-center",
|
|
12487
12255
|
"aria-live": "polite",
|
|
12488
12256
|
children: isError ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
12489
|
-
children: [
|
|
12257
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
|
|
12490
12258
|
size: exports.Size.LARGE,
|
|
12491
12259
|
sentiment: exports.Sentiment.NEGATIVE
|
|
12492
|
-
}) : /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {
|
|
12493
|
-
size: 24,
|
|
12494
|
-
className: "text-negative"
|
|
12495
12260
|
}), csFailureText && /*#__PURE__*/jsxRuntime.jsx("p", {
|
|
12496
|
-
className:
|
|
12497
|
-
'm-b-0': isModern
|
|
12498
|
-
}),
|
|
12261
|
+
className: "m-t-2 m-b-0",
|
|
12499
12262
|
children: csFailureText
|
|
12500
12263
|
})]
|
|
12501
12264
|
}) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
@@ -12514,71 +12277,135 @@ const CompleteStep = props => {
|
|
|
12514
12277
|
})]
|
|
12515
12278
|
})
|
|
12516
12279
|
}), csButtonText && /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
12517
|
-
|
|
12518
|
-
|
|
12519
|
-
'm-t-1': isModern && !isError,
|
|
12520
|
-
'm-t-2': isModern && isError,
|
|
12521
|
-
'm-t-3': !isModern
|
|
12522
|
-
}),
|
|
12523
|
-
onClick: event => onClear(event),
|
|
12280
|
+
className: isError ? 'm-t-2' : 'm-t-1',
|
|
12281
|
+
onClick: onClear,
|
|
12524
12282
|
children: csButtonText
|
|
12525
12283
|
})]
|
|
12526
12284
|
})
|
|
12527
12285
|
});
|
|
12528
|
-
}
|
|
12529
|
-
CompleteStep.propTypes = {
|
|
12530
|
-
csButtonText: PropTypes__default.default.string.isRequired,
|
|
12531
|
-
csSuccessText: PropTypes__default.default.string.isRequired,
|
|
12532
|
-
csFailureText: PropTypes__default.default.string.isRequired,
|
|
12533
|
-
fileName: PropTypes__default.default.string.isRequired,
|
|
12534
|
-
isComplete: PropTypes__default.default.bool.isRequired,
|
|
12535
|
-
isError: PropTypes__default.default.bool.isRequired,
|
|
12536
|
-
isImage: PropTypes__default.default.bool.isRequired,
|
|
12537
|
-
onClear: PropTypes__default.default.func.isRequired,
|
|
12538
|
-
uploadedImage: PropTypes__default.default.string
|
|
12539
|
-
};
|
|
12540
|
-
CompleteStep.defaultProps = {
|
|
12541
|
-
uploadedImage: null
|
|
12542
|
-
};
|
|
12286
|
+
}
|
|
12543
12287
|
|
|
12544
|
-
|
|
12288
|
+
class ResponseError extends Error {
|
|
12289
|
+
response;
|
|
12290
|
+
status;
|
|
12291
|
+
constructor(response, message) {
|
|
12292
|
+
super(message);
|
|
12293
|
+
this.name = 'ResponseError';
|
|
12294
|
+
this.response = response;
|
|
12295
|
+
this.status = response.status;
|
|
12296
|
+
}
|
|
12297
|
+
}
|
|
12298
|
+
async function postData({
|
|
12299
|
+
url,
|
|
12300
|
+
method = 'POST',
|
|
12301
|
+
...httpOptions
|
|
12302
|
+
}, data, fetcher = fetch) {
|
|
12303
|
+
const response = await fetcher(url, {
|
|
12304
|
+
method,
|
|
12305
|
+
body: data,
|
|
12306
|
+
...httpOptions
|
|
12307
|
+
});
|
|
12308
|
+
if (!response.ok) {
|
|
12309
|
+
throw new ResponseError(response, response.statusText);
|
|
12310
|
+
}
|
|
12311
|
+
return response;
|
|
12312
|
+
}
|
|
12313
|
+
|
|
12314
|
+
async function asyncFileRead(file) {
|
|
12315
|
+
return new Promise((resolve, reject) => {
|
|
12316
|
+
const reader = new FileReader();
|
|
12317
|
+
reader.addEventListener('load', () => {
|
|
12318
|
+
resolve(reader.result);
|
|
12319
|
+
});
|
|
12320
|
+
reader.addEventListener('error', () => {
|
|
12321
|
+
reject(reader.error ?? new Error('Cannot read file'));
|
|
12322
|
+
});
|
|
12323
|
+
reader.readAsDataURL(file);
|
|
12324
|
+
});
|
|
12325
|
+
}
|
|
12326
|
+
|
|
12327
|
+
function isSizeValid(file, maxSize) {
|
|
12328
|
+
return Number.isInteger(maxSize) && file.size <= maxSize;
|
|
12329
|
+
}
|
|
12330
|
+
|
|
12331
|
+
function getFileType(file, file64) {
|
|
12332
|
+
if (file.type) {
|
|
12333
|
+
return file.type;
|
|
12334
|
+
}
|
|
12335
|
+
if (file64) {
|
|
12336
|
+
const regex = /^data:([a-z]+\/[a-z]+);/;
|
|
12337
|
+
const typeFromEncoded = regex.exec(file64);
|
|
12338
|
+
if (typeFromEncoded?.[1]) {
|
|
12339
|
+
return typeFromEncoded[1];
|
|
12340
|
+
}
|
|
12341
|
+
}
|
|
12342
|
+
return '';
|
|
12343
|
+
}
|
|
12344
|
+
|
|
12345
|
+
function isTypeValid(file, rule, file64) {
|
|
12346
|
+
if (!rule) {
|
|
12347
|
+
return false;
|
|
12348
|
+
}
|
|
12349
|
+
const allowedTypes = rule.replace(/\s/g, '').split(',');
|
|
12350
|
+
const fileType = getFileType(file, file64);
|
|
12351
|
+
if (rule === '*' || allowedTypes.includes(fileType)) {
|
|
12352
|
+
return true;
|
|
12353
|
+
}
|
|
12354
|
+
return allowedTypes.some(type => {
|
|
12355
|
+
const [typeAllowed, extensionAllowed] = type.split('/');
|
|
12356
|
+
return extensionAllowed === '*' && fileType.includes(typeAllowed);
|
|
12357
|
+
});
|
|
12358
|
+
}
|
|
12545
12359
|
|
|
12546
|
-
/*
|
|
12547
|
-
* This delay is required for the isError/isSuccess to be fired after isProcessing so the processIndicator, will be
|
|
12548
|
-
* rendered first and then updated with the right status.
|
|
12549
|
-
*/
|
|
12550
12360
|
const ANIMATION_FIX = 10;
|
|
12551
12361
|
const MAX_SIZE_DEFAULT = 5000000;
|
|
12552
|
-
|
|
12553
|
-
|
|
12554
|
-
[
|
|
12555
|
-
};
|
|
12362
|
+
exports.UploadStep = void 0;
|
|
12363
|
+
(function (UploadStep) {
|
|
12364
|
+
UploadStep["UPLOAD_IMAGE_STEP"] = "uploadImageStep";
|
|
12365
|
+
})(exports.UploadStep || (exports.UploadStep = {}));
|
|
12556
12366
|
class Upload extends React.Component {
|
|
12367
|
+
static defaultProps = {
|
|
12368
|
+
animationDelay: 700,
|
|
12369
|
+
maxSize: MAX_SIZE_DEFAULT,
|
|
12370
|
+
psButtonDisabled: false,
|
|
12371
|
+
size: 'md',
|
|
12372
|
+
usAccept: 'image/*',
|
|
12373
|
+
usDisabled: false,
|
|
12374
|
+
usLabel: ''
|
|
12375
|
+
};
|
|
12376
|
+
dragCounter = 0;
|
|
12377
|
+
timeouts = 0;
|
|
12557
12378
|
constructor(props) {
|
|
12558
12379
|
super(props);
|
|
12559
|
-
this.dragCounter = 0;
|
|
12560
|
-
this.timeouts = null;
|
|
12561
12380
|
this.state = {
|
|
12562
12381
|
fileName: '',
|
|
12382
|
+
isDroppable: false,
|
|
12563
12383
|
isComplete: false,
|
|
12564
12384
|
isError: false,
|
|
12565
12385
|
isImage: false,
|
|
12566
12386
|
isProcessing: false,
|
|
12567
12387
|
isSuccess: false,
|
|
12568
|
-
response:
|
|
12569
|
-
uploadedImage:
|
|
12388
|
+
response: undefined,
|
|
12389
|
+
uploadedImage: undefined
|
|
12570
12390
|
};
|
|
12571
12391
|
}
|
|
12572
12392
|
getErrorMessage(status) {
|
|
12393
|
+
const {
|
|
12394
|
+
csFailureText,
|
|
12395
|
+
csTooLargeMessage,
|
|
12396
|
+
csWrongTypeMessage,
|
|
12397
|
+
maxSize,
|
|
12398
|
+
intl
|
|
12399
|
+
} = this.props;
|
|
12573
12400
|
switch (status) {
|
|
12574
12401
|
case 413:
|
|
12575
|
-
return
|
|
12576
|
-
maxSize:
|
|
12402
|
+
return csTooLargeMessage || intl.formatMessage(messages.csTooLargeMessage, {
|
|
12403
|
+
maxSize: maxSize / 1000000
|
|
12577
12404
|
});
|
|
12578
12405
|
case 415:
|
|
12579
|
-
return
|
|
12406
|
+
return csWrongTypeMessage || intl.formatMessage(messages.csWrongTypeMessage);
|
|
12580
12407
|
default:
|
|
12581
|
-
return
|
|
12408
|
+
return csFailureText || intl.formatMessage(messages.csFailureText);
|
|
12582
12409
|
}
|
|
12583
12410
|
}
|
|
12584
12411
|
onDragLeave(event) {
|
|
@@ -12605,7 +12432,7 @@ class Upload extends React.Component {
|
|
|
12605
12432
|
});
|
|
12606
12433
|
}
|
|
12607
12434
|
}
|
|
12608
|
-
onDrop(event) {
|
|
12435
|
+
async onDrop(event) {
|
|
12609
12436
|
const {
|
|
12610
12437
|
isProcessing
|
|
12611
12438
|
} = this.state;
|
|
@@ -12613,8 +12440,8 @@ class Upload extends React.Component {
|
|
|
12613
12440
|
if (!isProcessing) {
|
|
12614
12441
|
this.reset();
|
|
12615
12442
|
}
|
|
12616
|
-
if (event.dataTransfer
|
|
12617
|
-
this.fileDropped(event.dataTransfer.files[0]);
|
|
12443
|
+
if (event.dataTransfer?.files?.[0]) {
|
|
12444
|
+
await this.fileDropped(event.dataTransfer.files[0]);
|
|
12618
12445
|
}
|
|
12619
12446
|
}
|
|
12620
12447
|
onAnimationCompleted = async status => {
|
|
@@ -12623,77 +12450,70 @@ class Upload extends React.Component {
|
|
|
12623
12450
|
isProcessing,
|
|
12624
12451
|
fileName
|
|
12625
12452
|
} = this.state;
|
|
12626
|
-
// Success.
|
|
12627
12453
|
const {
|
|
12628
12454
|
animationDelay
|
|
12629
12455
|
} = this.props;
|
|
12630
|
-
if (isProcessing && status ===
|
|
12456
|
+
if (isProcessing && status === 'succeeded') {
|
|
12631
12457
|
const {
|
|
12632
12458
|
onSuccess
|
|
12633
12459
|
} = this.props;
|
|
12634
|
-
this.timeouts = setTimeout(() => {
|
|
12460
|
+
this.timeouts = window.setTimeout(() => {
|
|
12635
12461
|
this.setState({
|
|
12636
12462
|
isProcessing: false,
|
|
12637
12463
|
isComplete: true
|
|
12638
|
-
}, () => onSuccess
|
|
12464
|
+
}, onSuccess ? () => onSuccess(response, fileName) : undefined);
|
|
12639
12465
|
}, animationDelay);
|
|
12640
12466
|
}
|
|
12641
|
-
|
|
12642
|
-
if (isProcessing && status === exports.Status.FAILED) {
|
|
12467
|
+
if (isProcessing && status === 'failed') {
|
|
12643
12468
|
const {
|
|
12644
12469
|
onFailure
|
|
12645
12470
|
} = this.props;
|
|
12646
|
-
this.timeouts = setTimeout(() => {
|
|
12471
|
+
this.timeouts = window.setTimeout(() => {
|
|
12647
12472
|
this.setState({
|
|
12648
12473
|
isProcessing: false,
|
|
12649
12474
|
isComplete: true
|
|
12650
|
-
}, () => onFailure
|
|
12475
|
+
}, onFailure ? () => onFailure(response) : undefined);
|
|
12651
12476
|
}, animationDelay);
|
|
12652
12477
|
}
|
|
12653
12478
|
};
|
|
12654
|
-
asyncPost = file => {
|
|
12479
|
+
asyncPost = async file => {
|
|
12655
12480
|
const {
|
|
12656
12481
|
httpOptions,
|
|
12657
12482
|
fetcher
|
|
12658
12483
|
} = this.props;
|
|
12484
|
+
if (httpOptions == null) {
|
|
12485
|
+
throw new Error('Cannot find HTTP options');
|
|
12486
|
+
}
|
|
12659
12487
|
const {
|
|
12660
12488
|
fileInputName = file.name,
|
|
12661
12489
|
data = {}
|
|
12662
|
-
} = httpOptions
|
|
12490
|
+
} = httpOptions;
|
|
12663
12491
|
const formData = new FormData();
|
|
12664
12492
|
formData.append(fileInputName, file);
|
|
12665
12493
|
Object.keys(data).forEach(key => formData.append(key, data[key]));
|
|
12666
|
-
return postData(
|
|
12494
|
+
return postData(httpOptions, formData, fetcher);
|
|
12667
12495
|
};
|
|
12668
12496
|
asyncResponse = (response, type) => {
|
|
12669
12497
|
// Gives time to the animation callback to fire.
|
|
12670
|
-
this.timeouts = setTimeout(() => {
|
|
12498
|
+
this.timeouts = window.setTimeout(() => {
|
|
12671
12499
|
this.setState({
|
|
12672
12500
|
response,
|
|
12673
|
-
isError: type ===
|
|
12674
|
-
isSuccess: type ===
|
|
12501
|
+
isError: type === 'error',
|
|
12502
|
+
isSuccess: type === 'success'
|
|
12675
12503
|
});
|
|
12676
12504
|
}, ANIMATION_FIX);
|
|
12677
12505
|
};
|
|
12678
|
-
prepareHttpOptions = httpOptions => {
|
|
12679
|
-
if (!httpOptions.url) {
|
|
12680
|
-
throw new Error('You must supply a URL to post image data asynchronously');
|
|
12681
|
-
}
|
|
12682
|
-
return httpOptions;
|
|
12683
|
-
};
|
|
12684
12506
|
handleOnClear = event => {
|
|
12685
12507
|
event.preventDefault();
|
|
12686
12508
|
const {
|
|
12687
12509
|
onCancel
|
|
12688
12510
|
} = this.props;
|
|
12689
|
-
|
|
12690
|
-
onCancel();
|
|
12691
|
-
}
|
|
12511
|
+
onCancel?.();
|
|
12692
12512
|
this.reset();
|
|
12693
12513
|
};
|
|
12694
12514
|
reset = () => {
|
|
12695
12515
|
this.dragCounter = 0;
|
|
12696
|
-
clearTimeout(this.timeouts);
|
|
12516
|
+
window.clearTimeout(this.timeouts);
|
|
12697
12517
|
this.setState({
|
|
12698
12518
|
isComplete: false,
|
|
12699
12519
|
isError: false,
|
|
@@ -12733,14 +12553,12 @@ class Upload extends React.Component {
|
|
|
12733
12553
|
isDroppable: false,
|
|
12734
12554
|
isProcessing: true
|
|
12735
12555
|
});
|
|
12736
|
-
|
|
12737
|
-
onStart(file);
|
|
12738
|
-
}
|
|
12556
|
+
onStart?.(file);
|
|
12739
12557
|
let file64 = null;
|
|
12740
12558
|
try {
|
|
12741
12559
|
file64 = await asyncFileRead(file);
|
|
12742
12560
|
} catch (error) {
|
|
12743
|
-
this.asyncResponse(error,
|
|
12561
|
+
this.asyncResponse(error, 'error');
|
|
12744
12562
|
}
|
|
12745
12563
|
if (!file64) {
|
|
12746
12564
|
return false;
|
|
@@ -12749,30 +12567,31 @@ class Upload extends React.Component {
|
|
|
12749
12567
|
isImage: getFileType(file, file64).includes('image')
|
|
12750
12568
|
});
|
|
12751
12569
|
if (!isTypeValid(file, usAccept, file64)) {
|
|
12752
|
-
|
|
12570
|
+
this.asyncResponse(new ResponseError(new Response(null, {
|
|
12753
12571
|
status: 415,
|
|
12754
12572
|
statusText: 'Unsupported Media Type'
|
|
12755
|
-
};
|
|
12756
|
-
this.asyncResponse(response, PROCESS_STATE[0]);
|
|
12573
|
+
})), 'error');
|
|
12757
12574
|
return false;
|
|
12758
12575
|
}
|
|
12759
12576
|
if (!isSizeValid(file, maxSize)) {
|
|
12760
|
-
|
|
12577
|
+
this.asyncResponse(new ResponseError(new Response(null, {
|
|
12761
12578
|
status: 413,
|
|
12762
12579
|
statusText: 'Request Entity Too Large'
|
|
12763
|
-
};
|
|
12764
|
-
this.asyncResponse(response, PROCESS_STATE[0]);
|
|
12580
|
+
})), 'error');
|
|
12765
12581
|
return false;
|
|
12766
12582
|
}
|
|
12767
12583
|
if (httpOptions) {
|
|
12768
12584
|
// Post the file to provided endpoint
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
}
|
|
12773
|
-
this.asyncResponse(error,
|
|
12585
|
+
let response;
|
|
12586
|
+
try {
|
|
12587
|
+
response = await this.asyncPost(file);
|
|
12588
|
+
} catch (error) {
|
|
12589
|
+
this.asyncResponse(error, 'error');
|
|
12774
12590
|
return false;
|
|
12775
|
-
}
|
|
12591
|
+
}
|
|
12592
|
+
this.asyncResponse(response, 'success');
|
|
12593
|
+
this.showDataImage(file64);
|
|
12594
|
+
return true;
|
|
12776
12595
|
}
|
|
12777
12596
|
// Post on form submit. And return the encoded image.
|
|
12778
12597
|
this.showDataImage(file64);
|
|
@@ -12781,6 +12600,7 @@ class Upload extends React.Component {
|
|
|
12781
12600
|
};
|
|
12782
12601
|
render() {
|
|
12783
12602
|
const {
|
|
12603
|
+
maxSize,
|
|
12784
12604
|
usDropMessage,
|
|
12785
12605
|
usAccept,
|
|
12786
12606
|
usButtonText,
|
|
@@ -12794,7 +12614,6 @@ class Upload extends React.Component {
|
|
|
12794
12614
|
csButtonText,
|
|
12795
12615
|
csSuccessText,
|
|
12796
12616
|
size,
|
|
12797
|
-
uploadStep,
|
|
12798
12617
|
intl
|
|
12799
12618
|
} = this.props;
|
|
12800
12619
|
const {
|
|
@@ -12808,7 +12627,6 @@ class Upload extends React.Component {
|
|
|
12808
12627
|
isSuccess,
|
|
12809
12628
|
uploadedImage
|
|
12810
12629
|
} = this.state;
|
|
12811
|
-
const UploadStepComponent = UPLOAD_STEP_COMPONENTS[uploadStep] || UploadImageStep;
|
|
12812
12630
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
12813
12631
|
className: classNames__default.default('droppable-area', {
|
|
12814
12632
|
droppable: true,
|
|
@@ -12822,10 +12640,10 @@ class Upload extends React.Component {
|
|
|
12822
12640
|
}),
|
|
12823
12641
|
onDragEnter: event => this.onDragEnter(event),
|
|
12824
12642
|
onDragLeave: event => this.onDragLeave(event),
|
|
12825
|
-
onDrop: event => this.onDrop(event),
|
|
12643
|
+
onDrop: async event => this.onDrop(event),
|
|
12826
12644
|
onDragOver: event => event.preventDefault(),
|
|
12827
|
-
children: [!isProcessing && !isComplete && /*#__PURE__*/jsxRuntime.jsx(
|
|
12828
|
-
fileDropped: file => this.fileDropped(file),
|
|
12645
|
+
children: [!isProcessing && !isComplete && /*#__PURE__*/jsxRuntime.jsx(UploadImageStep, {
|
|
12646
|
+
fileDropped: async file => this.fileDropped(file),
|
|
12829
12647
|
isComplete: isComplete,
|
|
12830
12648
|
usAccept: usAccept,
|
|
12831
12649
|
usButtonText: usButtonText || intl.formatMessage(messages.usButtonText),
|
|
@@ -12833,7 +12651,7 @@ class Upload extends React.Component {
|
|
|
12833
12651
|
usHelpImage: usHelpImage,
|
|
12834
12652
|
usLabel: usLabel,
|
|
12835
12653
|
usPlaceholder: usPlaceholder || intl.formatMessage(messages.usPlaceholder, {
|
|
12836
|
-
maxSize:
|
|
12654
|
+
maxSize: maxSize / 1000000
|
|
12837
12655
|
})
|
|
12838
12656
|
}), isProcessing && /*#__PURE__*/jsxRuntime.jsx(ProcessingStep, {
|
|
12839
12657
|
isComplete: isComplete,
|
|
@@ -12842,7 +12660,7 @@ class Upload extends React.Component {
|
|
|
12842
12660
|
psButtonText: psButtonText || intl.formatMessage(messages.psButtonText),
|
|
12843
12661
|
psProcessingText: psProcessingText || intl.formatMessage(messages.psProcessingText),
|
|
12844
12662
|
psButtonDisabled: psButtonDisabled,
|
|
12845
|
-
onAnimationCompleted: status => this.onAnimationCompleted(status),
|
|
12663
|
+
onAnimationCompleted: async status => this.onAnimationCompleted(status),
|
|
12846
12664
|
onClear: event => this.handleOnClear(event)
|
|
12847
12665
|
}), (isSuccess || isError || isComplete) && /*#__PURE__*/jsxRuntime.jsx(CompleteStep, {
|
|
12848
12666
|
fileName: fileName,
|
|
@@ -12850,7 +12668,7 @@ class Upload extends React.Component {
|
|
|
12850
12668
|
isError: isError,
|
|
12851
12669
|
isImage: isImage,
|
|
12852
12670
|
csButtonText: csButtonText || intl.formatMessage(messages.csButtonText),
|
|
12853
|
-
csFailureText: this.getErrorMessage(response
|
|
12671
|
+
csFailureText: this.getErrorMessage(response != null && typeof response === 'object' && 'status' in response && typeof response.status === 'number' ? response.status : undefined),
|
|
12854
12672
|
csSuccessText: csSuccessText || intl.formatMessage(messages.csSuccessText),
|
|
12855
12673
|
uploadedImage: uploadedImage,
|
|
12856
12674
|
onClear: event => this.handleOnClear(event)
|
|
@@ -12874,73 +12692,6 @@ class Upload extends React.Component {
|
|
|
12874
12692
|
});
|
|
12875
12693
|
}
|
|
12876
12694
|
}
|
|
12877
|
-
Upload.propTypes = {
|
|
12878
|
-
animationDelay: PropTypes__default.default.number,
|
|
12879
|
-
csButtonText: PropTypes__default.default.string,
|
|
12880
|
-
csFailureText: PropTypes__default.default.string,
|
|
12881
|
-
csSuccessText: PropTypes__default.default.string,
|
|
12882
|
-
csTooLargeMessage: PropTypes__default.default.string,
|
|
12883
|
-
csWrongTypeMessage: PropTypes__default.default.string,
|
|
12884
|
-
httpOptions: PropTypes__default.default.shape({
|
|
12885
|
-
url: PropTypes__default.default.string.isRequired,
|
|
12886
|
-
method: PropTypes__default.default.oneOf(['POST', 'PUT', 'PATCH']),
|
|
12887
|
-
fileInputName: PropTypes__default.default.string,
|
|
12888
|
-
data: PropTypes__default.default.object,
|
|
12889
|
-
headers: PropTypes__default.default.object
|
|
12890
|
-
}),
|
|
12891
|
-
/**
|
|
12892
|
-
* You can provide a fetcher function with the same interface as the global fetch function, which is used by default.
|
|
12893
|
-
* function fetcher(input: RequestInfo, init?: RequestInit): Promise<Response>
|
|
12894
|
-
*/
|
|
12895
|
-
fetcher: PropTypes__default.default.func,
|
|
12896
|
-
maxSize: PropTypes__default.default.number,
|
|
12897
|
-
onCancel: PropTypes__default.default.func,
|
|
12898
|
-
onFailure: PropTypes__default.default.func,
|
|
12899
|
-
onStart: PropTypes__default.default.func,
|
|
12900
|
-
onSuccess: PropTypes__default.default.func,
|
|
12901
|
-
psButtonText: PropTypes__default.default.string,
|
|
12902
|
-
psButtonDisabled: PropTypes__default.default.bool,
|
|
12903
|
-
psProcessingText: PropTypes__default.default.string,
|
|
12904
|
-
size: PropTypes__default.default.oneOf(['sm', 'md', 'lg']),
|
|
12905
|
-
/**
|
|
12906
|
-
* You can provide multiple rules separated by comma, e.g.: "application/pdf,image/*".
|
|
12907
|
-
* Using "*" will allow every file type to be uploaded.
|
|
12908
|
-
*/
|
|
12909
|
-
usAccept: PropTypes__default.default.string,
|
|
12910
|
-
usButtonText: PropTypes__default.default.string,
|
|
12911
|
-
usDisabled: PropTypes__default.default.bool,
|
|
12912
|
-
usDropMessage: PropTypes__default.default.string,
|
|
12913
|
-
usHelpImage: PropTypes__default.default.node,
|
|
12914
|
-
usLabel: PropTypes__default.default.string,
|
|
12915
|
-
usPlaceholder: PropTypes__default.default.string,
|
|
12916
|
-
uploadStep: PropTypes__default.default.oneOf(['uploadImageStep', 'mediaUploadStep'])
|
|
12917
|
-
};
|
|
12918
|
-
Upload.defaultProps = {
|
|
12919
|
-
animationDelay: 700,
|
|
12920
|
-
csButtonText: undefined,
|
|
12921
|
-
csFailureText: undefined,
|
|
12922
|
-
csSuccessText: undefined,
|
|
12923
|
-
csTooLargeMessage: undefined,
|
|
12924
|
-
csWrongTypeMessage: undefined,
|
|
12925
|
-
httpOptions: null,
|
|
12926
|
-
maxSize: MAX_SIZE_DEFAULT,
|
|
12927
|
-
onCancel: null,
|
|
12928
|
-
onFailure: null,
|
|
12929
|
-
onStart: null,
|
|
12930
|
-
onSuccess: null,
|
|
12931
|
-
psButtonText: undefined,
|
|
12932
|
-
psButtonDisabled: false,
|
|
12933
|
-
psProcessingText: undefined,
|
|
12934
|
-
size: 'md',
|
|
12935
|
-
usAccept: 'image/*',
|
|
12936
|
-
usButtonText: undefined,
|
|
12937
|
-
usDisabled: false,
|
|
12938
|
-
usDropMessage: undefined,
|
|
12939
|
-
usHelpImage: '',
|
|
12940
|
-
usLabel: '',
|
|
12941
|
-
usPlaceholder: undefined,
|
|
12942
|
-
uploadStep: exports.UploadStep.UPLOAD_IMAGE_STEP
|
|
12943
|
-
};
|
|
12944
12695
|
var Upload$1 = reactIntl.injectIntl(Upload);
|
|
12945
12696
|
|
|
12946
12697
|
var MESSAGES$2 = reactIntl.defineMessages({
|
|
@@ -13471,7 +13222,7 @@ const UploadInput = ({
|
|
|
13471
13222
|
name
|
|
13472
13223
|
} = file;
|
|
13473
13224
|
const id = generateFileId(file);
|
|
13474
|
-
const allowedFileTypes =
|
|
13225
|
+
const allowedFileTypes = typeof fileTypes === 'string' ? fileTypes : fileTypes.join(',');
|
|
13475
13226
|
// Check if file type is valid
|
|
13476
13227
|
if (!isTypeValid(file, allowedFileTypes)) {
|
|
13477
13228
|
handleFileUploadFailure(file, formatMessage(MESSAGES$2.fileTypeNotSupported));
|