@commercetools-frontend-extensions/import-resources-modal 1.7.6 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. package/dist/{active-drag-drop-area-a4fd91f7.cjs.dev.js → active-drag-drop-area-b84dd578.cjs.dev.js} +3 -3
  2. package/dist/{active-drag-drop-area-bfd1ac28.esm.js → active-drag-drop-area-b855fcf6.esm.js} +3 -3
  3. package/dist/{active-drag-drop-area-abe96e04.cjs.prod.js → active-drag-drop-area-c906211c.cjs.prod.js} +3 -3
  4. package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.dev.js +7 -7
  5. package/dist/commercetools-frontend-extensions-import-resources-modal.cjs.prod.js +7 -7
  6. package/dist/commercetools-frontend-extensions-import-resources-modal.esm.js +7 -7
  7. package/dist/declarations/src/@types/file-upload.d.ts +0 -4
  8. package/dist/{disabled-drop-area-c092ebd0.cjs.dev.js → disabled-drop-area-48c8a29e.cjs.dev.js} +7 -7
  9. package/dist/{disabled-drop-area-093742fc.esm.js → disabled-drop-area-d56b2ffb.esm.js} +7 -7
  10. package/dist/{disabled-drop-area-25e976d6.cjs.prod.js → disabled-drop-area-ead9d6e5.cjs.prod.js} +7 -7
  11. package/dist/{enabled-drop-area-db88a5da.esm.js → enabled-drop-area-4745c8da.esm.js} +7 -7
  12. package/dist/{enabled-drop-area-2e91435a.cjs.dev.js → enabled-drop-area-5c4ea376.cjs.dev.js} +7 -7
  13. package/dist/{enabled-drop-area-86aff122.cjs.prod.js → enabled-drop-area-e81190f8.cjs.prod.js} +7 -7
  14. package/dist/{file-dropped-area-88c05907.cjs.dev.js → file-dropped-area-2d51d63b.cjs.dev.js} +7 -7
  15. package/dist/{file-dropped-area-6279df47.cjs.prod.js → file-dropped-area-48990997.cjs.prod.js} +7 -7
  16. package/dist/{file-dropped-area-70be944b.esm.js → file-dropped-area-bf648f2e.esm.js} +7 -7
  17. package/dist/{index-6186162d.cjs.prod.js → index-762eed18.cjs.prod.js} +374 -110
  18. package/dist/{index-98c1d115.cjs.dev.js → index-a2c55a09.cjs.dev.js} +374 -110
  19. package/dist/{index-c388b02a.esm.js → index-d6f6d164.esm.js} +372 -108
  20. package/package.json +35 -34
@@ -25,15 +25,15 @@ import _wrapNativeSuper from '@babel/runtime-corejs3/helpers/esm/wrapNativeSuper
25
25
  import { plural } from 'pluralize';
26
26
  import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
27
27
  import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
28
+ import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
29
+ import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
28
30
  import _flatMapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat-map';
29
31
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
30
32
  import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
31
- import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
32
33
  import Papa from 'papaparse';
33
34
  import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
34
35
  import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
35
36
  import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
36
- import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
37
37
  import '@babel/runtime-corejs3/core-js-stable/instance/bind';
38
38
  import '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
39
39
  import '@babel/runtime-corejs3/core-js-stable/url-search-params';
@@ -269,7 +269,7 @@ const fetchUsingXhr = _ref2 => {
269
269
  return xhr;
270
270
  };
271
271
 
272
- const DEFAULT_DELIMITER = ',';
272
+ const ALLOWED_DELIMITERS = [',', ';', '|', '\t'];
273
273
  const INITIAL_COLUMN_DISPLAY_COUNT = 8;
274
274
  const IMPORT_TAG_KEYS = {
275
275
  source: 'source'
@@ -359,41 +359,270 @@ const DEFAULT_SHORT_LIVED_FLAGS = {};
359
359
  const DEFAULT_LONG_LIVED_FLAGS = {};
360
360
  _objectSpread$g(_objectSpread$g({}, DEFAULT_SHORT_LIVED_FLAGS), DEFAULT_LONG_LIVED_FLAGS);
361
361
 
362
+ var sharedMessages = defineMessages({
363
+ [`modalTitle.${IMPORTABLE_RESOURCES.CATEGORY}`]: {
364
+ id: 'ImportResourcesModal.modalTitle.category',
365
+ description: 'Label for the categories modal title',
366
+ defaultMessage: 'Import categories by CSV'
367
+ },
368
+ [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT}`]: {
369
+ id: 'ImportResourcesModal.modalTitle.product',
370
+ description: 'Label for the products modal title',
371
+ defaultMessage: 'Import products by CSV'
372
+ },
373
+ [`modalTitle.${IMPORTABLE_RESOURCES.INVENTORY}`]: {
374
+ id: 'ImportResourcesModal.modalTitle.inventoryEntry',
375
+ description: 'Label for the inventories modal title',
376
+ defaultMessage: 'Import inventories by CSV'
377
+ },
378
+ [`modalTitle.${IMPORTABLE_RESOURCES.DISCOUNT_CODE}`]: {
379
+ id: 'ImportResourcesModal.modalTitle.discountCode',
380
+ description: 'Label for the inventories modal title',
381
+ defaultMessage: 'Import discount codes by CSV'
382
+ },
383
+ [`modalTitle.${IMPORTABLE_RESOURCES.CUSTOMER}`]: {
384
+ id: 'ImportResourcesModal.modalTitle.customer',
385
+ description: 'Label for the customers modal title',
386
+ defaultMessage: 'Import customers by CSV'
387
+ },
388
+ [`modalTitle.${IMPORTABLE_RESOURCES.ORDER}`]: {
389
+ id: 'ImportResourcesModal.modalTitle.order',
390
+ description: 'Label for the order modal title',
391
+ defaultMessage: 'Import orders by CSV'
392
+ },
393
+ [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT_TYPE}`]: {
394
+ id: 'ImportResourcesModal.modalTitle.productType',
395
+ description: 'Label for the product type modal title',
396
+ defaultMessage: 'Import product types by CSV'
397
+ },
398
+ uploadButton: {
399
+ id: 'ImportResourcesModal.uploadButton',
400
+ description: 'Label for the upload button',
401
+ defaultMessage: 'Upload and preview'
402
+ },
403
+ cancel: {
404
+ id: 'ImportResourcesModal.cancel',
405
+ description: 'Label for the cancel button',
406
+ defaultMessage: 'Cancel'
407
+ },
408
+ close: {
409
+ id: 'ImportResourcesModal.close',
410
+ description: 'Label for the close button',
411
+ defaultMessage: 'Close'
412
+ },
413
+ listConjunctionOr: {
414
+ id: 'ImportResourcesModal.listConjunctionOr',
415
+ description: 'Label for the list conjunction or',
416
+ defaultMessage: 'or'
417
+ },
418
+ delimiterComma: {
419
+ id: 'ImportResourcesModal.delimiterComma',
420
+ description: 'Label for the delimiter name comma',
421
+ defaultMessage: 'comma'
422
+ },
423
+ delimiterSemicolon: {
424
+ id: 'ImportResourcesModal.delimiterSemicolon',
425
+ description: 'Label for the delimiter name semicolon',
426
+ defaultMessage: 'semicolon'
427
+ },
428
+ delimiterPipe: {
429
+ id: 'ImportResourcesModal.delimiterPipe',
430
+ description: 'Label for the delimiter name pipe',
431
+ defaultMessage: 'pipe'
432
+ },
433
+ delimiterTab: {
434
+ id: 'ImportResourcesModal.delimiterTab',
435
+ description: 'Label for the delimiter name tab',
436
+ defaultMessage: 'tab'
437
+ },
438
+ // Resource types
439
+ product: {
440
+ id: 'ImportResourcesModal.product',
441
+ description: 'Label for the product resource type',
442
+ defaultMessage: 'Product'
443
+ },
444
+ products: {
445
+ id: 'ImportResourcesModal.products',
446
+ description: 'Label for the products resource type',
447
+ defaultMessage: 'Products'
448
+ },
449
+ inventory: {
450
+ id: 'ImportResourcesModal.inventory',
451
+ description: 'Label for the inventory entry resource type',
452
+ defaultMessage: 'Inventory'
453
+ },
454
+ inventories: {
455
+ id: 'ImportResourcesModal.inventories',
456
+ description: 'Label for the inventories entry resource type',
457
+ defaultMessage: 'Inventories'
458
+ },
459
+ category: {
460
+ id: 'ImportResourcesModal.category',
461
+ description: 'Label for the category resource type',
462
+ defaultMessage: 'Category'
463
+ },
464
+ categories: {
465
+ id: 'ImportResourcesModal.categories',
466
+ description: 'Label for the categories resource type',
467
+ defaultMessage: 'Categories'
468
+ },
469
+ 'custom-object': {
470
+ id: 'ImportResourcesModal.custom-object',
471
+ description: 'Label for the custom-object resource type',
472
+ defaultMessage: 'Custom object'
473
+ },
474
+ 'custom-objects': {
475
+ id: 'ImportResourcesModal.custom-objects',
476
+ description: 'Label for the custom-objects resource type',
477
+ defaultMessage: 'Custom objects'
478
+ },
479
+ customer: {
480
+ id: 'ImportResourcesModal.customer',
481
+ description: 'Label for the customer resource type',
482
+ defaultMessage: 'Customer'
483
+ },
484
+ customers: {
485
+ id: 'ImportResourcesModal.customers',
486
+ description: 'Label for the customers resource type',
487
+ defaultMessage: 'Customers'
488
+ },
489
+ order: {
490
+ id: 'ImportResourcesModal.order',
491
+ description: 'Label for the order resource type',
492
+ defaultMessage: 'Order'
493
+ },
494
+ orders: {
495
+ id: 'ImportResourcesModal.orders',
496
+ description: 'Label for the orders resource type',
497
+ defaultMessage: 'Orders'
498
+ },
499
+ 'order-patch': {
500
+ id: 'ImportResourcesModal.order-patch',
501
+ description: 'Label for the order-patch resource type',
502
+ defaultMessage: 'Order patch'
503
+ },
504
+ 'order-patches': {
505
+ id: 'ImportResourcesModal.order-patches',
506
+ description: 'Label for the order-patches resource type',
507
+ defaultMessage: 'Order patches'
508
+ },
509
+ price: {
510
+ id: 'ImportResourcesModal.price',
511
+ description: 'Label for the price resource type',
512
+ defaultMessage: 'Price'
513
+ },
514
+ prices: {
515
+ id: 'ImportResourcesModal.prices',
516
+ description: 'Label for the prices resource type',
517
+ defaultMessage: 'Prices'
518
+ },
519
+ 'product-draft': {
520
+ id: 'ImportResourcesModal.product-draft',
521
+ description: 'Label for the product-draft resource type',
522
+ defaultMessage: 'Product draft'
523
+ },
524
+ 'product-drafts': {
525
+ id: 'ImportResourcesModal.product-drafts',
526
+ description: 'Label for the product-drafts resource type',
527
+ defaultMessage: 'Product drafts'
528
+ },
529
+ 'product-type': {
530
+ id: 'ImportResourcesModal.product-type',
531
+ description: 'Label for the product-type resource type',
532
+ defaultMessage: 'Product type'
533
+ },
534
+ 'product-types': {
535
+ id: 'ImportResourcesModal.product-types',
536
+ description: 'Label for the product-types resource type',
537
+ defaultMessage: 'Product types'
538
+ },
539
+ 'product-variant': {
540
+ id: 'ImportResourcesModal.product-variant',
541
+ description: 'Label for the product-variant resource type',
542
+ defaultMessage: 'Product variant'
543
+ },
544
+ 'product-variants': {
545
+ id: 'ImportResourcesModal.product-variants',
546
+ description: 'Label for the product-variants resource type',
547
+ defaultMessage: 'Product variants'
548
+ },
549
+ 'product-variant-patch': {
550
+ id: 'ImportResourcesModal.product-variant-patch',
551
+ description: 'Label for the product-variant-patch resource type',
552
+ defaultMessage: 'Product variant patch'
553
+ },
554
+ 'product-variant-patches': {
555
+ id: 'ImportResourcesModal.product-variant-patches',
556
+ description: 'Label for the product-variant-patches resource type',
557
+ defaultMessage: 'Product variant patches'
558
+ },
559
+ 'standalone-price': {
560
+ id: 'ImportResourcesModal.standalone-price',
561
+ description: 'Label for the standalone-price resource type',
562
+ defaultMessage: 'Standalone price'
563
+ },
564
+ 'standalone-prices': {
565
+ id: 'ImportResourcesModal.standalone-prices',
566
+ description: 'Label for the standalone-prices resource type',
567
+ defaultMessage: 'Standalone prices'
568
+ },
569
+ type: {
570
+ id: 'ImportResourcesModal.type',
571
+ description: 'Label for the type resource type',
572
+ defaultMessage: 'Type'
573
+ },
574
+ types: {
575
+ id: 'ImportResourcesModal.types',
576
+ description: 'Label for the types resource type',
577
+ defaultMessage: 'Types'
578
+ },
579
+ 'discount-code': {
580
+ id: 'ImportResourcesModal.discount-code',
581
+ description: 'Label for the discount-code resource type',
582
+ defaultMessage: 'Discount code'
583
+ },
584
+ 'discount-codes': {
585
+ id: 'ImportResourcesModal.discount-codes',
586
+ description: 'Label for the discount-codes resource type',
587
+ defaultMessage: 'Discount codes'
588
+ },
589
+ unknownResourceType: {
590
+ id: 'ImportResourcesModal.unknown-resource-type',
591
+ description: 'Label for the unknown resource type',
592
+ defaultMessage: 'Unknown resource type'
593
+ }
594
+ //
595
+ });
596
+
362
597
  function ownKeys$f(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
363
- function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$f(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$f(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
364
- /**
365
- * This function checks if the provided `expectedDelimiter` is used consistently in the first 10 lines of a CSV file.
366
- * Returns a Promise that resolves to an object containing a boolean `isValid` property and the detected delimiter `delimiter`.
367
- *
368
- * @param {File} file - The CSV file to check.
369
- * @param {string} [expectedDelimiter=DEFAULT_DELIMITER] - The expected delimiter to check for in the file.
370
- * @returns {Promise<DelimiterCheck>} A Promise that resolves to a DelimiterCheck object.
371
- */
372
- const checkDelimiter = function (file) {
373
- let expectedDelimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_DELIMITER;
598
+ 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(_context3 = ownKeys$f(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$f(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
599
+
600
+ // Delimiters not included in this array may be treated as part of a column content
601
+ // potentially causing the file to be parsed as a single-column CSV and pass this validation
602
+ const NON_ALLOWED_DELIMITERS = ['%', '.', ' '];
603
+ const DELIMITERS_TO_GUESS = [...ALLOWED_DELIMITERS, ...NON_ALLOWED_DELIMITERS];
604
+ const validateDelimiter = file => {
374
605
  return new _Promise(resolve => {
375
- let lineCount = 0;
376
- let correctDelimiterCount = 0;
377
- let detectedDelimiter = null;
378
606
  Papa.parse(file, {
379
- step: (results, parser) => {
380
- lineCount++;
381
- if (detectedDelimiter === null) {
382
- detectedDelimiter = results.meta.delimiter;
383
- }
384
- if (results.meta.delimiter === expectedDelimiter) {
385
- correctDelimiterCount++;
607
+ delimitersToGuess: DELIMITERS_TO_GUESS,
608
+ preview: 10,
609
+ complete: result => {
610
+ const headerRow = result.data?.[0];
611
+ const isOnlyOneColumn = _Array$isArray(headerRow) && headerRow.length === 1;
612
+ if (isOnlyOneColumn) {
613
+ resolve(true);
614
+ return;
386
615
  }
387
- if (lineCount >= 10) {
388
- parser.abort();
616
+ const detectedDelimiter = result.meta.delimiter;
617
+ let isValid = false;
618
+ if (detectedDelimiter !== null && _includesInstanceProperty(ALLOWED_DELIMITERS).call(ALLOWED_DELIMITERS, detectedDelimiter)) {
619
+ var _context;
620
+ const isUndetectableDelimiter = _someInstanceProperty(_context = result.errors).call(_context, error => error.code === 'UndetectableDelimiter');
621
+ if (!isUndetectableDelimiter) {
622
+ isValid = true;
623
+ }
389
624
  }
390
- },
391
- complete: () => {
392
- const isValid = correctDelimiterCount === lineCount;
393
- resolve({
394
- isValid,
395
- delimiter: detectedDelimiter
396
- });
625
+ resolve(isValid);
397
626
  }
398
627
  });
399
628
  });
@@ -402,8 +631,8 @@ const mapUploadFileErrorsResponseToUploadFileErrorRows = uploadFileErrorsRespons
402
631
  if (!uploadFileErrorsResponse || !_Array$isArray(uploadFileErrorsResponse)) return [];
403
632
  let idCounter = 1;
404
633
  return _flatMapInstanceProperty(uploadFileErrorsResponse).call(uploadFileErrorsResponse, rowErrorsResponse => {
405
- var _context;
406
- return _mapInstanceProperty(_context = rowErrorsResponse.errors).call(_context, rowError => ({
634
+ var _context2;
635
+ return _mapInstanceProperty(_context2 = rowErrorsResponse.errors).call(_context2, rowError => ({
407
636
  // DataTable component requires unique `id` field
408
637
  id: String(idCounter++),
409
638
  row: rowErrorsResponse.row,
@@ -453,6 +682,35 @@ const toBytes = megabytes => megabytes * 1024 * 1024;
453
682
  const getValidatedColumns = (columns, ignoredColumns) => {
454
683
  return _filterInstanceProperty(columns).call(columns, column => !_includesInstanceProperty(ignoredColumns).call(ignoredColumns, column));
455
684
  };
685
+ const formatAllowedDelimitersForMessageDisplay = intl => {
686
+ const localizedOr = intl.formatMessage(sharedMessages.listConjunctionOr);
687
+ const descriptions = _mapInstanceProperty(ALLOWED_DELIMITERS).call(ALLOWED_DELIMITERS, delimiter => {
688
+ let nameDescriptor;
689
+ switch (delimiter) {
690
+ case ',':
691
+ nameDescriptor = sharedMessages.delimiterComma;
692
+ break;
693
+ case ';':
694
+ nameDescriptor = sharedMessages.delimiterSemicolon;
695
+ break;
696
+ case '|':
697
+ nameDescriptor = sharedMessages.delimiterPipe;
698
+ break;
699
+ case '\t':
700
+ nameDescriptor = sharedMessages.delimiterTab;
701
+ break;
702
+ default:
703
+ nameDescriptor = undefined;
704
+ }
705
+ const name = nameDescriptor ? intl.formatMessage(nameDescriptor) : delimiter;
706
+ return delimiter === '\t' ? name : `${name} (${delimiter})`;
707
+ });
708
+ if (descriptions.length === 1) {
709
+ return descriptions[0];
710
+ }
711
+ const lastDescription = descriptions.pop();
712
+ return `${descriptions.join(', ')} ${localizedOr} ${lastDescription}`;
713
+ };
456
714
 
457
715
  function getFileUploadErrorsCount(errors) {
458
716
  if (!errors || !_Array$isArray(errors)) return 0;
@@ -481,6 +739,57 @@ function formatErrorCode(code) {
481
739
  return code;
482
740
  }
483
741
  }
742
+ function resourceTypeToMessage(resourceType) {
743
+ const resourceTypeMap = {
744
+ category: sharedMessages.category,
745
+ product: sharedMessages.product,
746
+ 'product-type': sharedMessages['product-type'],
747
+ order: sharedMessages.order,
748
+ customer: sharedMessages.customer,
749
+ 'discount-code': sharedMessages['discount-code'],
750
+ inventory: sharedMessages.inventory,
751
+ // TODO: remove `inventory` after aligning the resource type names in the file upload API
752
+ 'inventory-entry': sharedMessages.inventory,
753
+ 'order-patch': sharedMessages['order-patch'],
754
+ price: sharedMessages.price,
755
+ 'product-draft': sharedMessages['product-draft'],
756
+ 'product-variant': sharedMessages['product-variant'],
757
+ 'product-variant-patch': sharedMessages['product-variant-patch'],
758
+ 'standalone-price': sharedMessages['standalone-price'],
759
+ 'custom-object': sharedMessages['custom-object'],
760
+ type: sharedMessages.type
761
+ };
762
+ const message = resourceTypeMap[resourceType];
763
+ if (!message) {
764
+ return sharedMessages.unknownResourceType;
765
+ }
766
+ return message;
767
+ }
768
+ function resourceTypeToPluralMessage(resourceType) {
769
+ const resourceTypePluralMap = {
770
+ category: sharedMessages.categories,
771
+ 'custom-object': sharedMessages['custom-objects'],
772
+ product: sharedMessages.products,
773
+ 'product-type': sharedMessages['product-types'],
774
+ order: sharedMessages.orders,
775
+ customer: sharedMessages.customers,
776
+ 'discount-code': sharedMessages['discount-codes'],
777
+ inventory: sharedMessages.inventories,
778
+ // TODO: remove `inventory` after aligning the resource type names in the file upload API
779
+ 'inventory-entry': sharedMessages.inventories,
780
+ 'order-patch': sharedMessages['order-patches'],
781
+ price: sharedMessages.prices,
782
+ 'product-draft': sharedMessages['product-drafts'],
783
+ 'product-variant': sharedMessages['product-variants'],
784
+ 'product-variant-patch': sharedMessages['product-variant-patches'],
785
+ 'standalone-price': sharedMessages['standalone-prices']
786
+ };
787
+ const message = resourceTypePluralMap[resourceType];
788
+ if (!message) {
789
+ return sharedMessages.unknownResourceType;
790
+ }
791
+ return message;
792
+ }
484
793
 
485
794
  const encodeFileNameWithTimestampToContainerKey = fileName => {
486
795
  return btoa(_JSON$stringify({
@@ -725,13 +1034,13 @@ function getDefaultDropWrapperStyles(_dropAreaState) {
725
1034
  return /*#__PURE__*/css(process.env.NODE_ENV === "production" ? "" : ";label:getDefaultDropWrapperStyles;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImRyb3AtYXJlYS13cmFwcGVyLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUE0QlkiLCJmaWxlIjoiZHJvcC1hcmVhLXdyYXBwZXIudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgdHlwZSBEcm9wem9uZVJvb3RQcm9wcyB9IGZyb20gJ3JlYWN0LWRyb3B6b25lJ1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCdcbmltcG9ydCB7IHN0eWxlcyB9IGZyb20gJy4vc3R5bGVzJ1xuaW1wb3J0IHsgdHlwZSBEcm9wQXJlYVN0YXRlIH0gZnJvbSAnLi4vLi4vLi4vQHR5cGVzJ1xuXG5pbnRlcmZhY2UgRHJvcFdyYXBwZXJQcm9wcyBleHRlbmRzIERyb3B6b25lUm9vdFByb3BzIHtcbiAgZHJvcEFyZWFTdGF0ZTogRHJvcEFyZWFTdGF0ZVxufVxuZXhwb3J0IGNvbnN0IERyb3BXcmFwcGVyID0gc3R5bGVkLmRpdjxEcm9wV3JhcHBlclByb3BzPmBcbiAgJHtzdHlsZXMuYmFzZX1cbiAgJHsocHJvcHMpID0+IHtcbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2Rpc2FibGVkJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5kaXNhYmxlZFxuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ3JlYWR5LWZvci1kcm9wJykge1xuICAgICAgcmV0dXJuIHN0eWxlcy5yZWFkeUZvckRyb3BcbiAgICB9XG4gICAgaWYgKHByb3BzLmRyb3BBcmVhU3RhdGUgPT09ICdhY3RpdmUtZHJhZycpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuYWN0aXZlRHJhZ1xuICAgIH1cbiAgICBpZiAocHJvcHMuZHJvcEFyZWFTdGF0ZSA9PT0gJ2ZpbGUtZHJvcHBlZCcpIHtcbiAgICAgIHJldHVybiBzdHlsZXMuZmlsZURyb3BwZWRcbiAgICB9XG4gICAgcmV0dXJuIGdldERlZmF1bHREcm9wV3JhcHBlclN0eWxlcyhwcm9wcy5kcm9wQXJlYVN0YXRlKVxuICB9fVxuYFxuZnVuY3Rpb24gZ2V0RGVmYXVsdERyb3BXcmFwcGVyU3R5bGVzKF9kcm9wQXJlYVN0YXRlOiBuZXZlcikge1xuICByZXR1cm4gY3NzYGBcbn1cbiJdfQ== */");
726
1035
  }
727
1036
 
728
- var ActiveDragDropArea = /*#__PURE__*/lazy(() => import('./active-drag-drop-area-bfd1ac28.esm.js' /* webpackChunkName: "active-drag-drop-area" */));
1037
+ var ActiveDragDropArea = /*#__PURE__*/lazy(() => import('./active-drag-drop-area-b855fcf6.esm.js' /* webpackChunkName: "active-drag-drop-area" */));
729
1038
 
730
- var DisabledDropArea = /*#__PURE__*/lazy(() => import('./disabled-drop-area-093742fc.esm.js' /* webpackChunkName: "disabled-drop-area" */));
1039
+ var DisabledDropArea = /*#__PURE__*/lazy(() => import('./disabled-drop-area-d56b2ffb.esm.js' /* webpackChunkName: "disabled-drop-area" */));
731
1040
 
732
- var EnabledDropArea = /*#__PURE__*/lazy(() => import('./enabled-drop-area-db88a5da.esm.js' /* webpackChunkName: "enabled-drop-area" */));
1041
+ var EnabledDropArea = /*#__PURE__*/lazy(() => import('./enabled-drop-area-4745c8da.esm.js' /* webpackChunkName: "enabled-drop-area" */));
733
1042
 
734
- var FileDropped = /*#__PURE__*/lazy(() => import('./file-dropped-area-70be944b.esm.js' /* webpackChunkName: "filed-dropped-area" */));
1043
+ var FileDropped = /*#__PURE__*/lazy(() => import('./file-dropped-area-bf648f2e.esm.js' /* webpackChunkName: "filed-dropped-area" */));
735
1044
 
736
1045
  function getDropArea(_ref) {
737
1046
  let dropAreaState = _ref.dropAreaState,
@@ -853,14 +1162,14 @@ var messages$6 = defineMessages({
853
1162
  description: 'Error description when the file contains more rows than the allowable maximum',
854
1163
  defaultMessage: 'The file contains more than the allowable maximum of {rowLimit} rows'
855
1164
  },
856
- dropAreaWrongDelimiterTitle: {
857
- id: 'ImportResourcesModal.wrongDelimiterTitle',
858
- defaultMessage: 'Wrong delimiter'
1165
+ wrongSeparatorTitle: {
1166
+ id: 'ImportResourcesModal.wrongSeparatorTitle',
1167
+ defaultMessage: 'Wrong separator'
859
1168
  },
860
- dropAreaWrongDelimiterDescription: {
861
- id: 'ImportResourcesModal.wrongDelimiterDescription',
1169
+ wrongSeparatorDescription: {
1170
+ id: 'ImportResourcesModal.wrongSeparatorDescription',
862
1171
  description: 'Message within the drop area when a CSV file uses an unexpected delimiter',
863
- defaultMessage: 'The file is using an incorrect delimiter. Please use comma (,) instead.'
1172
+ defaultMessage: 'The file is using an unsupported separator. Please use one of the allowed delimiters: {delimiterList}.'
864
1173
  },
865
1174
  dropAreaNotEnoughRowsTitle: {
866
1175
  id: 'ImportResourcesModal.dropAreaNotEnoughRowsTitle',
@@ -911,10 +1220,12 @@ const useUpload = () => {
911
1220
  }, [state.abortController]);
912
1221
  const isFileValid = async file => {
913
1222
  const errors = [];
914
- const delimiterCheck = await checkDelimiter(file);
915
- if (!delimiterCheck.isValid) errors.push({
916
- title: intl.formatMessage(messages$6.dropAreaWrongDelimiterTitle),
917
- description: intl.formatMessage(messages$6.dropAreaWrongDelimiterDescription)
1223
+ const isDelimiterValid = await validateDelimiter(file);
1224
+ if (!isDelimiterValid) errors.push({
1225
+ title: intl.formatMessage(messages$6.wrongSeparatorTitle),
1226
+ description: intl.formatMessage(messages$6.wrongSeparatorDescription, {
1227
+ delimiterList: formatAllowedDelimitersForMessageDisplay(intl)
1228
+ })
918
1229
  });
919
1230
  const rowCount = await getRowCount(file);
920
1231
  if (rowCount < 1) errors.push({
@@ -1184,59 +1495,6 @@ const UploadSettings = () => {
1184
1495
  return null;
1185
1496
  };
1186
1497
 
1187
- var sharedMessages = defineMessages({
1188
- [`modalTitle.${IMPORTABLE_RESOURCES.CATEGORY}`]: {
1189
- id: 'ImportResourcesModal.modalTitle.category',
1190
- description: 'Label for the categories modal title',
1191
- defaultMessage: 'Import categories by CSV'
1192
- },
1193
- [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT}`]: {
1194
- id: 'ImportResourcesModal.modalTitle.product',
1195
- description: 'Label for the products modal title',
1196
- defaultMessage: 'Import products by CSV'
1197
- },
1198
- [`modalTitle.${IMPORTABLE_RESOURCES.INVENTORY}`]: {
1199
- id: 'ImportResourcesModal.modalTitle.inventoryEntry',
1200
- description: 'Label for the inventories modal title',
1201
- defaultMessage: 'Import inventories by CSV'
1202
- },
1203
- [`modalTitle.${IMPORTABLE_RESOURCES.DISCOUNT_CODE}`]: {
1204
- id: 'ImportResourcesModal.modalTitle.discountCode',
1205
- description: 'Label for the inventories modal title',
1206
- defaultMessage: 'Import discount codes by CSV'
1207
- },
1208
- [`modalTitle.${IMPORTABLE_RESOURCES.CUSTOMER}`]: {
1209
- id: 'ImportResourcesModal.modalTitle.customer',
1210
- description: 'Label for the customers modal title',
1211
- defaultMessage: 'Import customers by CSV'
1212
- },
1213
- [`modalTitle.${IMPORTABLE_RESOURCES.ORDER}`]: {
1214
- id: 'ImportResourcesModal.modalTitle.order',
1215
- description: 'Label for the order modal title',
1216
- defaultMessage: 'Import orders by CSV'
1217
- },
1218
- [`modalTitle.${IMPORTABLE_RESOURCES.PRODUCT_TYPE}`]: {
1219
- id: 'ImportResourcesModal.modalTitle.productType',
1220
- description: 'Label for the product type modal title',
1221
- defaultMessage: 'Import product types by CSV'
1222
- },
1223
- uploadButton: {
1224
- id: 'ImportResourcesModal.uploadButton',
1225
- description: 'Label for the upload button',
1226
- defaultMessage: 'Upload and preview'
1227
- },
1228
- cancel: {
1229
- id: 'ImportResourcesModal.cancel',
1230
- description: 'Label for the cancel button',
1231
- defaultMessage: 'Cancel'
1232
- },
1233
- close: {
1234
- id: 'ImportResourcesModal.close',
1235
- description: 'Label for the close button',
1236
- defaultMessage: 'Close'
1237
- }
1238
- });
1239
-
1240
1498
  const Upload = () => {
1241
1499
  const _useImportResourcesCo = useImportResourcesContext(),
1242
1500
  state = _useImportResourcesCo.state,
@@ -1582,10 +1840,10 @@ var messages$3 = defineMessages({
1582
1840
  description: 'Label for modal path',
1583
1841
  defaultMessage: "Here's a preview of your import"
1584
1842
  },
1585
- rowsToBeImported: {
1586
- id: 'ImportResourcesModal.rowsToBeImported',
1587
- description: 'This message indicates the number of rows that are ready to be imported into the system.',
1588
- defaultMessage: '{rowCount, plural, one {<b>1</b> row to be imported} other {<b>{rowCount}</b> rows to be imported}}{publish, select, true { and published} other {}}'
1843
+ itemsToBeImported: {
1844
+ id: 'ImportResourcesModal.itemsToBeImported',
1845
+ description: 'This message indicates the number of items that are ready to be imported into the project.',
1846
+ defaultMessage: '{itemCount, plural, one {<b>1</b> {resourceType} to be imported{publish, select, true { and published} other {}}} other {<b>{itemCount}</b> {resourceTypePlural} to be imported{publish, select, true { and published} other {}}}}'
1589
1847
  },
1590
1848
  columnsToBeImported: {
1591
1849
  id: 'ImportResourcesModal.columnsToBeImported',
@@ -1694,6 +1952,10 @@ function UploadPreviewModal() {
1694
1952
  actions = _useImportResourcesCo2.actions,
1695
1953
  onClose = _useImportResourcesCo2.onClose;
1696
1954
  if (!state.resourceType || !state.uploadFileResponse) return null;
1955
+ const resourceTypeMessage = resourceTypeToMessage(state.resourceType);
1956
+ const resourceType = intl.formatMessage(resourceTypeMessage).toLowerCase();
1957
+ const resourceTypePluralMessage = resourceTypeToPluralMessage(state.resourceType);
1958
+ const resourceTypePlural = intl.formatMessage(resourceTypePluralMessage).toLowerCase();
1697
1959
  const ignoredColumns = state.uploadFileResponse.ignoredColumns;
1698
1960
  const validatedColumns = getValidatedColumns(state.uploadFileResponse.columns, ignoredColumns);
1699
1961
  return jsx(FormDialog, {
@@ -1731,9 +1993,11 @@ function UploadPreviewModal() {
1731
1993
  children: [jsx(CheckBoldIcon, {
1732
1994
  color: "success"
1733
1995
  }), jsx(Text.Body, {
1734
- intlMessage: _objectSpread$5(_objectSpread$5({}, messages$3.rowsToBeImported), {}, {
1996
+ intlMessage: _objectSpread$5(_objectSpread$5({}, messages$3.itemsToBeImported), {}, {
1735
1997
  values: {
1736
- rowCount: intl.formatNumber(state.uploadFileResponse.rowsCount),
1998
+ resourceType,
1999
+ resourceTypePlural,
2000
+ itemCount: intl.formatNumber(state.uploadFileResponse.itemsCount),
1737
2001
  publish: state.resourceType === 'product' && state.settings?.publish,
1738
2002
  b: getBold$1
1739
2003
  }