@commercetools-frontend-extensions/import-resources-modal 1.7.5 → 1.8.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/dist/{active-drag-drop-area-bfd1ac28.esm.js → active-drag-drop-area-34cca429.esm.js} +3 -3
- package/dist/{active-drag-drop-area-a4fd91f7.cjs.dev.js → active-drag-drop-area-b645657a.cjs.dev.js} +3 -3
- package/dist/{active-drag-drop-area-abe96e04.cjs.prod.js → active-drag-drop-area-cf5791e7.cjs.prod.js} +3 -3
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.dev.js +7 -7
- package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.prod.js +7 -7
- package/dist/commercetools-frontend-extensions-import-resources-modal.esm.js +7 -7
- package/dist/declarations/src/@types/file-upload.d.ts +0 -4
- package/dist/{disabled-drop-area-093742fc.esm.js → disabled-drop-area-460a605b.esm.js} +7 -7
- package/dist/{disabled-drop-area-c092ebd0.cjs.dev.js → disabled-drop-area-9a4072d5.cjs.dev.js} +7 -7
- package/dist/{disabled-drop-area-25e976d6.cjs.prod.js → disabled-drop-area-c8e04dd6.cjs.prod.js} +7 -7
- package/dist/{enabled-drop-area-2e91435a.cjs.dev.js → enabled-drop-area-5d1a684a.cjs.dev.js} +7 -7
- package/dist/{enabled-drop-area-db88a5da.esm.js → enabled-drop-area-c2591e72.esm.js} +7 -7
- package/dist/{enabled-drop-area-86aff122.cjs.prod.js → enabled-drop-area-c30c7c5f.cjs.prod.js} +7 -7
- package/dist/{file-dropped-area-88c05907.cjs.dev.js → file-dropped-area-1c5c2843.cjs.dev.js} +7 -7
- package/dist/{file-dropped-area-6279df47.cjs.prod.js → file-dropped-area-27c8a11f.cjs.prod.js} +7 -7
- package/dist/{file-dropped-area-70be944b.esm.js → file-dropped-area-cf7278ba.esm.js} +7 -7
- package/dist/{index-c388b02a.esm.js → index-066e573b.esm.js} +152 -102
- package/dist/{index-6186162d.cjs.prod.js → index-757e3f18.cjs.prod.js} +154 -104
- package/dist/{index-98c1d115.cjs.dev.js → index-7e118bb3.cjs.dev.js} +154 -104
- package/package.json +35 -34
|
@@ -27,15 +27,15 @@ var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper')
|
|
|
27
27
|
var pluralize = require('pluralize');
|
|
28
28
|
var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
|
|
29
29
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
30
|
+
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
31
|
+
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
30
32
|
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
31
33
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
32
34
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
33
|
-
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
34
35
|
var Papa = require('papaparse');
|
|
35
36
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
36
37
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
37
38
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
38
|
-
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
39
39
|
require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
40
40
|
require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
41
41
|
require('@babel/runtime-corejs3/core-js-stable/url-search-params');
|
|
@@ -67,15 +67,15 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
67
67
|
var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
|
|
68
68
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
69
69
|
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
70
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
71
|
+
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
70
72
|
var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
|
|
71
73
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
72
74
|
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
73
|
-
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
74
75
|
var Papa__default = /*#__PURE__*/_interopDefault(Papa);
|
|
75
76
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
76
77
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
77
78
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
78
|
-
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
79
79
|
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
80
80
|
|
|
81
81
|
const EnabledResourceType = {
|
|
@@ -297,7 +297,7 @@ const fetchUsingXhr = _ref2 => {
|
|
|
297
297
|
return xhr;
|
|
298
298
|
};
|
|
299
299
|
|
|
300
|
-
const
|
|
300
|
+
const ALLOWED_DELIMITERS = [',', ';', '|', '\t'];
|
|
301
301
|
const INITIAL_COLUMN_DISPLAY_COUNT = 8;
|
|
302
302
|
const IMPORT_TAG_KEYS = {
|
|
303
303
|
source: 'source'
|
|
@@ -387,41 +387,113 @@ const DEFAULT_SHORT_LIVED_FLAGS = {};
|
|
|
387
387
|
const DEFAULT_LONG_LIVED_FLAGS = {};
|
|
388
388
|
_objectSpread$g(_objectSpread$g({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
|
|
389
389
|
|
|
390
|
+
var sharedMessages = reactIntl.defineMessages({
|
|
391
|
+
[`modalTitle.${IMPORTABLE_RESOURCES.CATEGORY}`]: {
|
|
392
|
+
id: 'ImportResourcesModal.modalTitle.category',
|
|
393
|
+
description: 'Label for the categories modal title',
|
|
394
|
+
defaultMessage: 'Import categories by CSV'
|
|
395
|
+
},
|
|
396
|
+
[`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT}`]: {
|
|
397
|
+
id: 'ImportResourcesModal.modalTitle.product',
|
|
398
|
+
description: 'Label for the products modal title',
|
|
399
|
+
defaultMessage: 'Import products by CSV'
|
|
400
|
+
},
|
|
401
|
+
[`modalTitle.${IMPORTABLE_RESOURCES.INVENTORY}`]: {
|
|
402
|
+
id: 'ImportResourcesModal.modalTitle.inventoryEntry',
|
|
403
|
+
description: 'Label for the inventories modal title',
|
|
404
|
+
defaultMessage: 'Import inventories by CSV'
|
|
405
|
+
},
|
|
406
|
+
[`modalTitle.${IMPORTABLE_RESOURCES.DISCOUNT_CODE}`]: {
|
|
407
|
+
id: 'ImportResourcesModal.modalTitle.discountCode',
|
|
408
|
+
description: 'Label for the inventories modal title',
|
|
409
|
+
defaultMessage: 'Import discount codes by CSV'
|
|
410
|
+
},
|
|
411
|
+
[`modalTitle.${IMPORTABLE_RESOURCES.CUSTOMER}`]: {
|
|
412
|
+
id: 'ImportResourcesModal.modalTitle.customer',
|
|
413
|
+
description: 'Label for the customers modal title',
|
|
414
|
+
defaultMessage: 'Import customers by CSV'
|
|
415
|
+
},
|
|
416
|
+
[`modalTitle.${IMPORTABLE_RESOURCES.ORDER}`]: {
|
|
417
|
+
id: 'ImportResourcesModal.modalTitle.order',
|
|
418
|
+
description: 'Label for the order modal title',
|
|
419
|
+
defaultMessage: 'Import orders by CSV'
|
|
420
|
+
},
|
|
421
|
+
[`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT_TYPE}`]: {
|
|
422
|
+
id: 'ImportResourcesModal.modalTitle.productType',
|
|
423
|
+
description: 'Label for the product type modal title',
|
|
424
|
+
defaultMessage: 'Import product types by CSV'
|
|
425
|
+
},
|
|
426
|
+
uploadButton: {
|
|
427
|
+
id: 'ImportResourcesModal.uploadButton',
|
|
428
|
+
description: 'Label for the upload button',
|
|
429
|
+
defaultMessage: 'Upload and preview'
|
|
430
|
+
},
|
|
431
|
+
cancel: {
|
|
432
|
+
id: 'ImportResourcesModal.cancel',
|
|
433
|
+
description: 'Label for the cancel button',
|
|
434
|
+
defaultMessage: 'Cancel'
|
|
435
|
+
},
|
|
436
|
+
close: {
|
|
437
|
+
id: 'ImportResourcesModal.close',
|
|
438
|
+
description: 'Label for the close button',
|
|
439
|
+
defaultMessage: 'Close'
|
|
440
|
+
},
|
|
441
|
+
listConjunctionOr: {
|
|
442
|
+
id: 'ImportResourcesModal.listConjunctionOr',
|
|
443
|
+
description: 'Label for the list conjunction or',
|
|
444
|
+
defaultMessage: 'or'
|
|
445
|
+
},
|
|
446
|
+
delimiterComma: {
|
|
447
|
+
id: 'ImportResourcesModal.delimiterComma',
|
|
448
|
+
description: 'Label for the delimiter name comma',
|
|
449
|
+
defaultMessage: 'comma'
|
|
450
|
+
},
|
|
451
|
+
delimiterSemicolon: {
|
|
452
|
+
id: 'ImportResourcesModal.delimiterSemicolon',
|
|
453
|
+
description: 'Label for the delimiter name semicolon',
|
|
454
|
+
defaultMessage: 'semicolon'
|
|
455
|
+
},
|
|
456
|
+
delimiterPipe: {
|
|
457
|
+
id: 'ImportResourcesModal.delimiterPipe',
|
|
458
|
+
description: 'Label for the delimiter name pipe',
|
|
459
|
+
defaultMessage: 'pipe'
|
|
460
|
+
},
|
|
461
|
+
delimiterTab: {
|
|
462
|
+
id: 'ImportResourcesModal.delimiterTab',
|
|
463
|
+
description: 'Label for the delimiter name tab',
|
|
464
|
+
defaultMessage: 'tab'
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
|
|
390
468
|
function ownKeys$f(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
391
|
-
function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
* @returns {Promise<DelimiterCheck>} A Promise that resolves to a DelimiterCheck object.
|
|
399
|
-
*/
|
|
400
|
-
const checkDelimiter = function (file) {
|
|
401
|
-
let expectedDelimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_DELIMITER;
|
|
469
|
+
function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$f(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$f(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
470
|
+
|
|
471
|
+
// Delimiters not included in this array may be treated as part of a column content
|
|
472
|
+
// potentially causing the file to be parsed as a single-column CSV and pass this validation
|
|
473
|
+
const NON_ALLOWED_DELIMITERS = ['%', '.', ' '];
|
|
474
|
+
const DELIMITERS_TO_GUESS = [...ALLOWED_DELIMITERS, ...NON_ALLOWED_DELIMITERS];
|
|
475
|
+
const validateDelimiter = file => {
|
|
402
476
|
return new _Promise__default["default"](resolve => {
|
|
403
|
-
let lineCount = 0;
|
|
404
|
-
let correctDelimiterCount = 0;
|
|
405
|
-
let detectedDelimiter = null;
|
|
406
477
|
Papa__default["default"].parse(file, {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
if (
|
|
413
|
-
|
|
478
|
+
delimitersToGuess: DELIMITERS_TO_GUESS,
|
|
479
|
+
preview: 10,
|
|
480
|
+
complete: result => {
|
|
481
|
+
const headerRow = result.data?.[0];
|
|
482
|
+
const isOnlyOneColumn = _Array$isArray__default["default"](headerRow) && headerRow.length === 1;
|
|
483
|
+
if (isOnlyOneColumn) {
|
|
484
|
+
resolve(true);
|
|
485
|
+
return;
|
|
414
486
|
}
|
|
415
|
-
|
|
416
|
-
|
|
487
|
+
const detectedDelimiter = result.meta.delimiter;
|
|
488
|
+
let isValid = false;
|
|
489
|
+
if (detectedDelimiter !== null && _includesInstanceProperty__default["default"](ALLOWED_DELIMITERS).call(ALLOWED_DELIMITERS, detectedDelimiter)) {
|
|
490
|
+
var _context;
|
|
491
|
+
const isUndetectableDelimiter = _someInstanceProperty__default["default"](_context = result.errors).call(_context, error => error.code === 'UndetectableDelimiter');
|
|
492
|
+
if (!isUndetectableDelimiter) {
|
|
493
|
+
isValid = true;
|
|
494
|
+
}
|
|
417
495
|
}
|
|
418
|
-
|
|
419
|
-
complete: () => {
|
|
420
|
-
const isValid = correctDelimiterCount === lineCount;
|
|
421
|
-
resolve({
|
|
422
|
-
isValid,
|
|
423
|
-
delimiter: detectedDelimiter
|
|
424
|
-
});
|
|
496
|
+
resolve(isValid);
|
|
425
497
|
}
|
|
426
498
|
});
|
|
427
499
|
});
|
|
@@ -430,8 +502,8 @@ const mapUploadFileErrorsResponseToUploadFileErrorRows = uploadFileErrorsRespons
|
|
|
430
502
|
if (!uploadFileErrorsResponse || !_Array$isArray__default["default"](uploadFileErrorsResponse)) return [];
|
|
431
503
|
let idCounter = 1;
|
|
432
504
|
return _flatMapInstanceProperty__default["default"](uploadFileErrorsResponse).call(uploadFileErrorsResponse, rowErrorsResponse => {
|
|
433
|
-
var
|
|
434
|
-
return _mapInstanceProperty__default["default"](
|
|
505
|
+
var _context2;
|
|
506
|
+
return _mapInstanceProperty__default["default"](_context2 = rowErrorsResponse.errors).call(_context2, rowError => ({
|
|
435
507
|
// DataTable component requires unique `id` field
|
|
436
508
|
id: String(idCounter++),
|
|
437
509
|
row: rowErrorsResponse.row,
|
|
@@ -481,6 +553,35 @@ const toBytes = megabytes => megabytes * 1024 * 1024;
|
|
|
481
553
|
const getValidatedColumns = (columns, ignoredColumns) => {
|
|
482
554
|
return _filterInstanceProperty__default["default"](columns).call(columns, column => !_includesInstanceProperty__default["default"](ignoredColumns).call(ignoredColumns, column));
|
|
483
555
|
};
|
|
556
|
+
const formatAllowedDelimitersForMessageDisplay = intl => {
|
|
557
|
+
const localizedOr = intl.formatMessage(sharedMessages.listConjunctionOr);
|
|
558
|
+
const descriptions = _mapInstanceProperty__default["default"](ALLOWED_DELIMITERS).call(ALLOWED_DELIMITERS, delimiter => {
|
|
559
|
+
let nameDescriptor;
|
|
560
|
+
switch (delimiter) {
|
|
561
|
+
case ',':
|
|
562
|
+
nameDescriptor = sharedMessages.delimiterComma;
|
|
563
|
+
break;
|
|
564
|
+
case ';':
|
|
565
|
+
nameDescriptor = sharedMessages.delimiterSemicolon;
|
|
566
|
+
break;
|
|
567
|
+
case '|':
|
|
568
|
+
nameDescriptor = sharedMessages.delimiterPipe;
|
|
569
|
+
break;
|
|
570
|
+
case '\t':
|
|
571
|
+
nameDescriptor = sharedMessages.delimiterTab;
|
|
572
|
+
break;
|
|
573
|
+
default:
|
|
574
|
+
nameDescriptor = undefined;
|
|
575
|
+
}
|
|
576
|
+
const name = nameDescriptor ? intl.formatMessage(nameDescriptor) : delimiter;
|
|
577
|
+
return delimiter === '\t' ? name : `${name} (${delimiter})`;
|
|
578
|
+
});
|
|
579
|
+
if (descriptions.length === 1) {
|
|
580
|
+
return descriptions[0];
|
|
581
|
+
}
|
|
582
|
+
const lastDescription = descriptions.pop();
|
|
583
|
+
return `${descriptions.join(', ')} ${localizedOr} ${lastDescription}`;
|
|
584
|
+
};
|
|
484
585
|
|
|
485
586
|
function getFileUploadErrorsCount(errors) {
|
|
486
587
|
if (!errors || !_Array$isArray__default["default"](errors)) return 0;
|
|
@@ -753,13 +854,13 @@ function getDefaultDropWrapperStyles(_dropAreaState) {
|
|
|
753
854
|
return /*#__PURE__*/react.css(process.env.NODE_ENV === "production" ? "" : ";label:getDefaultDropWrapperStyles;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImRyb3AtYXJlYS13cmFwcGVyLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUE0QlkiLCJmaWxlIjoiZHJvcC1hcmVhLXdyYXBwZXIudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgdHlwZSBEcm9wem9uZVJvb3RQcm9wcyB9IGZyb20gJ3JlYWN0LWRyb3B6b25lJ1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCdcbmltcG9ydCB7IHN0eWxlcyB9IGZyb20gJy4vc3R5bGVzJ1xuaW1wb3J0IHsgdHlwZSBEcm9wQXJlYVN0YXRlIH0gZnJvbSAnLi4vLi4vLi4vQHR5cGVzJ1xuXG5pbnRlcmZhY2UgRHJvcFdyYXBwZXJQcm9wcyBleHRlbmRzIERyb3B6b25lUm9vdFByb3BzIHtcbiAgZHJvcEFyZWFTdGF0ZTogRHJvcEFyZWFTdGF0ZVxufVxuZXhwb3J0IGNvbnN0IERyb3BXcmFwcGVyID0gc3R5bGVkLmRpdjxEcm9wV3JhcHBlclByb3BzPmBcbiAgJHtzdHlsZXMuYmFzZX1cbiAgJHsocHJvcHMpID0+IHtcbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2Rpc2FibGVkJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5kaXNhYmxlZFxuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ3JlYWR5LWZvci1kcm9wJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5yZWFkeUZvckRyb3BcbiAgICB9XG4gICAgaWYgKHByb3BzLmRyb3BBcmVhU3RhdGUgPT09ICdhY3RpdmUtZHJhZycpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuYWN0aXZlRHJhZ1xuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2ZpbGUtZHJvcHBlZCcpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuZmlsZURyb3BwZWRcbiAgICB9XG4gICAgcmV0dXJuIGdldERlZmF1bHREcm9wV3JhcHBlclN0eWxlcyhwcm9wcy5kcm9wQXJlYVN0YXRlKVxuICB9fVxuYFxuZnVuY3Rpb24gZ2V0RGVmYXVsdERyb3BXcmFwcGVyU3R5bGVzKF9kcm9wQXJlYVN0YXRlOiBuZXZlcikge1xuICByZXR1cm4gY3NzYGBcbn1cbiJdfQ== */");
|
|
754
855
|
}
|
|
755
856
|
|
|
756
|
-
var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-
|
|
857
|
+
var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-b645657a.cjs.dev.js' /* webpackChunkName: "active-drag-drop-area" */); }));
|
|
757
858
|
|
|
758
|
-
var DisabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./disabled-drop-area-
|
|
859
|
+
var DisabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./disabled-drop-area-9a4072d5.cjs.dev.js' /* webpackChunkName: "disabled-drop-area" */); }));
|
|
759
860
|
|
|
760
|
-
var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-
|
|
861
|
+
var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-5d1a684a.cjs.dev.js' /* webpackChunkName: "enabled-drop-area" */); }));
|
|
761
862
|
|
|
762
|
-
var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-
|
|
863
|
+
var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-1c5c2843.cjs.dev.js' /* webpackChunkName: "filed-dropped-area" */); }));
|
|
763
864
|
|
|
764
865
|
function getDropArea(_ref) {
|
|
765
866
|
let dropAreaState = _ref.dropAreaState,
|
|
@@ -881,14 +982,14 @@ var messages$6 = reactIntl.defineMessages({
|
|
|
881
982
|
description: 'Error description when the file contains more rows than the allowable maximum',
|
|
882
983
|
defaultMessage: 'The file contains more than the allowable maximum of {rowLimit} rows'
|
|
883
984
|
},
|
|
884
|
-
|
|
885
|
-
id: 'ImportResourcesModal.
|
|
886
|
-
defaultMessage: 'Wrong
|
|
985
|
+
wrongSeparatorTitle: {
|
|
986
|
+
id: 'ImportResourcesModal.wrongSeparatorTitle',
|
|
987
|
+
defaultMessage: 'Wrong separator'
|
|
887
988
|
},
|
|
888
|
-
|
|
889
|
-
id: 'ImportResourcesModal.
|
|
989
|
+
wrongSeparatorDescription: {
|
|
990
|
+
id: 'ImportResourcesModal.wrongSeparatorDescription',
|
|
890
991
|
description: 'Message within the drop area when a CSV file uses an unexpected delimiter',
|
|
891
|
-
defaultMessage: 'The file is using an
|
|
992
|
+
defaultMessage: 'The file is using an unsupported separator. Please use one of the allowed delimiters: {delimiterList}.'
|
|
892
993
|
},
|
|
893
994
|
dropAreaNotEnoughRowsTitle: {
|
|
894
995
|
id: 'ImportResourcesModal.dropAreaNotEnoughRowsTitle',
|
|
@@ -939,10 +1040,12 @@ const useUpload = () => {
|
|
|
939
1040
|
}, [state.abortController]);
|
|
940
1041
|
const isFileValid = async file => {
|
|
941
1042
|
const errors = [];
|
|
942
|
-
const
|
|
943
|
-
if (!
|
|
944
|
-
title: intl.formatMessage(messages$6.
|
|
945
|
-
description: intl.formatMessage(messages$6.
|
|
1043
|
+
const isDelimiterValid = await validateDelimiter(file);
|
|
1044
|
+
if (!isDelimiterValid) errors.push({
|
|
1045
|
+
title: intl.formatMessage(messages$6.wrongSeparatorTitle),
|
|
1046
|
+
description: intl.formatMessage(messages$6.wrongSeparatorDescription, {
|
|
1047
|
+
delimiterList: formatAllowedDelimitersForMessageDisplay(intl)
|
|
1048
|
+
})
|
|
946
1049
|
});
|
|
947
1050
|
const rowCount = await getRowCount(file);
|
|
948
1051
|
if (rowCount < 1) errors.push({
|
|
@@ -1212,59 +1315,6 @@ const UploadSettings = () => {
|
|
|
1212
1315
|
return null;
|
|
1213
1316
|
};
|
|
1214
1317
|
|
|
1215
|
-
var sharedMessages = reactIntl.defineMessages({
|
|
1216
|
-
[`modalTitle.${IMPORTABLE_RESOURCES.CATEGORY}`]: {
|
|
1217
|
-
id: 'ImportResourcesModal.modalTitle.category',
|
|
1218
|
-
description: 'Label for the categories modal title',
|
|
1219
|
-
defaultMessage: 'Import categories by CSV'
|
|
1220
|
-
},
|
|
1221
|
-
[`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT}`]: {
|
|
1222
|
-
id: 'ImportResourcesModal.modalTitle.product',
|
|
1223
|
-
description: 'Label for the products modal title',
|
|
1224
|
-
defaultMessage: 'Import products by CSV'
|
|
1225
|
-
},
|
|
1226
|
-
[`modalTitle.${IMPORTABLE_RESOURCES.INVENTORY}`]: {
|
|
1227
|
-
id: 'ImportResourcesModal.modalTitle.inventoryEntry',
|
|
1228
|
-
description: 'Label for the inventories modal title',
|
|
1229
|
-
defaultMessage: 'Import inventories by CSV'
|
|
1230
|
-
},
|
|
1231
|
-
[`modalTitle.${IMPORTABLE_RESOURCES.DISCOUNT_CODE}`]: {
|
|
1232
|
-
id: 'ImportResourcesModal.modalTitle.discountCode',
|
|
1233
|
-
description: 'Label for the inventories modal title',
|
|
1234
|
-
defaultMessage: 'Import discount codes by CSV'
|
|
1235
|
-
},
|
|
1236
|
-
[`modalTitle.${IMPORTABLE_RESOURCES.CUSTOMER}`]: {
|
|
1237
|
-
id: 'ImportResourcesModal.modalTitle.customer',
|
|
1238
|
-
description: 'Label for the customers modal title',
|
|
1239
|
-
defaultMessage: 'Import customers by CSV'
|
|
1240
|
-
},
|
|
1241
|
-
[`modalTitle.${IMPORTABLE_RESOURCES.ORDER}`]: {
|
|
1242
|
-
id: 'ImportResourcesModal.modalTitle.order',
|
|
1243
|
-
description: 'Label for the order modal title',
|
|
1244
|
-
defaultMessage: 'Import orders by CSV'
|
|
1245
|
-
},
|
|
1246
|
-
[`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT_TYPE}`]: {
|
|
1247
|
-
id: 'ImportResourcesModal.modalTitle.productType',
|
|
1248
|
-
description: 'Label for the product type modal title',
|
|
1249
|
-
defaultMessage: 'Import product types by CSV'
|
|
1250
|
-
},
|
|
1251
|
-
uploadButton: {
|
|
1252
|
-
id: 'ImportResourcesModal.uploadButton',
|
|
1253
|
-
description: 'Label for the upload button',
|
|
1254
|
-
defaultMessage: 'Upload and preview'
|
|
1255
|
-
},
|
|
1256
|
-
cancel: {
|
|
1257
|
-
id: 'ImportResourcesModal.cancel',
|
|
1258
|
-
description: 'Label for the cancel button',
|
|
1259
|
-
defaultMessage: 'Cancel'
|
|
1260
|
-
},
|
|
1261
|
-
close: {
|
|
1262
|
-
id: 'ImportResourcesModal.close',
|
|
1263
|
-
description: 'Label for the close button',
|
|
1264
|
-
defaultMessage: 'Close'
|
|
1265
|
-
}
|
|
1266
|
-
});
|
|
1267
|
-
|
|
1268
1318
|
const Upload = () => {
|
|
1269
1319
|
const _useImportResourcesCo = useImportResourcesContext(),
|
|
1270
1320
|
state = _useImportResourcesCo.state,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend-extensions/import-resources-modal",
|
|
3
3
|
"description": "Shared import modal for importing resources",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"README.md"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@babel/runtime": "7.27.
|
|
19
|
-
"@babel/runtime-corejs3": "7.27.
|
|
18
|
+
"@babel/runtime": "7.27.4",
|
|
19
|
+
"@babel/runtime-corejs3": "7.27.4",
|
|
20
20
|
"@commercetools/importapi-sdk": "5.20.0",
|
|
21
21
|
"@emotion/react": "11.14.0",
|
|
22
22
|
"@emotion/styled": "11.14.0",
|
|
@@ -27,32 +27,33 @@
|
|
|
27
27
|
"lodash.truncate": "4.4.2",
|
|
28
28
|
"moment": "2.30.1",
|
|
29
29
|
"omit-empty-es": "^1.1.3",
|
|
30
|
-
"papaparse": "5.5.
|
|
30
|
+
"papaparse": "5.5.3",
|
|
31
31
|
"pluralize": "8.0.0",
|
|
32
32
|
"prop-types": "15.8.1",
|
|
33
33
|
"ramda": "^0.30.0",
|
|
34
34
|
"react-dropzone": "14.3.8"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@commercetools-frontend/actions-global": "
|
|
38
|
-
"@commercetools-frontend/application-components": "
|
|
39
|
-
"@commercetools-frontend/application-shell": "
|
|
40
|
-
"@commercetools-frontend/application-shell-connectors": "
|
|
41
|
-
"@commercetools-frontend/constants": "
|
|
42
|
-
"@commercetools-frontend/fullstory": "
|
|
43
|
-
"@commercetools-frontend/i18n": "
|
|
44
|
-
"@commercetools-frontend/jest-preset-mc-app": "
|
|
45
|
-
"@commercetools-frontend/permissions": "
|
|
46
|
-
"@commercetools-frontend/sdk": "
|
|
47
|
-
"@commercetools-frontend/sentry": "
|
|
48
|
-
"@commercetools-frontend/ui-kit": "
|
|
49
|
-
"@commercetools-uikit/data-table": "
|
|
50
|
-
"@commercetools-uikit/design-system": "
|
|
51
|
-
"@commercetools-uikit/icons": "
|
|
52
|
-
"@commercetools-uikit/select-field": "
|
|
37
|
+
"@commercetools-frontend/actions-global": "24.0.0",
|
|
38
|
+
"@commercetools-frontend/application-components": "24.0.0",
|
|
39
|
+
"@commercetools-frontend/application-shell": "24.0.0",
|
|
40
|
+
"@commercetools-frontend/application-shell-connectors": "24.0.0",
|
|
41
|
+
"@commercetools-frontend/constants": "24.0.0",
|
|
42
|
+
"@commercetools-frontend/fullstory": "4.0.0",
|
|
43
|
+
"@commercetools-frontend/i18n": "24.0.0",
|
|
44
|
+
"@commercetools-frontend/jest-preset-mc-app": "24.0.0",
|
|
45
|
+
"@commercetools-frontend/permissions": "24.0.0",
|
|
46
|
+
"@commercetools-frontend/sdk": "24.0.0",
|
|
47
|
+
"@commercetools-frontend/sentry": "24.0.0",
|
|
48
|
+
"@commercetools-frontend/ui-kit": "20.0.0",
|
|
49
|
+
"@commercetools-uikit/data-table": "20.0.0",
|
|
50
|
+
"@commercetools-uikit/design-system": "20.0.0",
|
|
51
|
+
"@commercetools-uikit/icons": "20.0.0",
|
|
52
|
+
"@commercetools-uikit/select-field": "20.0.0",
|
|
53
53
|
"@preconstruct/cli": "2.8.12",
|
|
54
54
|
"@types/jest": "29.5.14",
|
|
55
55
|
"@types/lodash.truncate": "^4.4.7",
|
|
56
|
+
"@types/papaparse": "5.3.16",
|
|
56
57
|
"@types/testing-library__jest-dom": "^5.14.5",
|
|
57
58
|
"msw": "1.3.5",
|
|
58
59
|
"react": "19.0.0",
|
|
@@ -62,20 +63,20 @@
|
|
|
62
63
|
"rimraf": "6.0.1"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
|
-
"@commercetools-frontend/actions-global": "23.x || 24.x
|
|
66
|
-
"@commercetools-frontend/application-components": "23.x || 24.x
|
|
67
|
-
"@commercetools-frontend/application-shell": "23.x || 24.x
|
|
68
|
-
"@commercetools-frontend/application-shell-connectors": "23.x || 24.x
|
|
69
|
-
"@commercetools-frontend/constants": "23.x || 24.x
|
|
70
|
-
"@commercetools-frontend/fullstory": "2.x || 3.x || 4.x
|
|
71
|
-
"@commercetools-frontend/i18n": "23.x || 24.x
|
|
72
|
-
"@commercetools-frontend/jest-preset-mc-app": "23.x || 24.x
|
|
73
|
-
"@commercetools-frontend/permissions": "23.x || 24.x
|
|
74
|
-
"@commercetools-frontend/sdk": "23.x || 24.x
|
|
75
|
-
"@commercetools-frontend/sentry": "23.x || 24.x
|
|
76
|
-
"@commercetools-frontend/ui-kit": "19.x || 20.x
|
|
77
|
-
"@commercetools-uikit/design-system": "19.x || 20.x
|
|
78
|
-
"@commercetools-uikit/icons": "19.x || 20.x
|
|
66
|
+
"@commercetools-frontend/actions-global": "23.x || 24.x",
|
|
67
|
+
"@commercetools-frontend/application-components": "23.x || 24.x",
|
|
68
|
+
"@commercetools-frontend/application-shell": "23.x || 24.x",
|
|
69
|
+
"@commercetools-frontend/application-shell-connectors": "23.x || 24.x",
|
|
70
|
+
"@commercetools-frontend/constants": "23.x || 24.x",
|
|
71
|
+
"@commercetools-frontend/fullstory": "2.x || 3.x || 4.x",
|
|
72
|
+
"@commercetools-frontend/i18n": "23.x || 24.x",
|
|
73
|
+
"@commercetools-frontend/jest-preset-mc-app": "23.x || 24.x",
|
|
74
|
+
"@commercetools-frontend/permissions": "23.x || 24.x",
|
|
75
|
+
"@commercetools-frontend/sdk": "23.x || 24.x",
|
|
76
|
+
"@commercetools-frontend/sentry": "23.x || 24.x",
|
|
77
|
+
"@commercetools-frontend/ui-kit": "19.x || 20.x",
|
|
78
|
+
"@commercetools-uikit/design-system": "19.x || 20.x",
|
|
79
|
+
"@commercetools-uikit/icons": "19.x || 20.x",
|
|
79
80
|
"react": "17.x || 19.x",
|
|
80
81
|
"react-intl": "6.x || 7.x",
|
|
81
82
|
"react-redux": "7.x",
|