@commercetools-frontend-extensions/export-resources-modal 0.0.0-canary-20240906151917 → 0.0.0-canary-20240912074653

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/README.md CHANGED
@@ -337,6 +337,7 @@ import ExportResourcesModal from '@commercetools-frontend-extensions/export-reso
337
337
  | `fieldGroups[].fields[].name` | `string` | ✅ | | A string that represents the unique identifier for each field. The leaf fields must align with the commercetools HTTP API fields, while parent fields can be developer-specific and created for grouping purposes. |
338
338
  | `fieldGroups[].fields[].label` | `string` | ✅ | | The label of the field to be shown in the export modal |
339
339
  | `fieldGroups[].fields[].isRequired` | `boolean` | | `false` | `isRequired` field indicates whether a field is required for the export process. If `true` the field will be selected by default and cannot be deselected by the user. This is useful for fields that are essential for the export process. Fields marked as required will have a `*` appended to their label in the UI |
340
+ | `fieldGroups[].fields[].extendedFieldNames` | `array` | | | An array of additional field names that should be included along with the main field name when exporting data. |
340
341
  | `fieldGroups[].fields[].dependentGroupNames` | `array` | | | The array of group names provided determines the state of the checkbox. If any of the groups mentioned in the `dependentGroupNames` has at least one checkbox selected, then the field is automatically selected. Optionally, `dependentFieldNames` can be used to specify particular fields within the group. <br>**Note:** The field will be readonly if it has dependencies. |
341
342
  | `fieldGroups[].fields[].dependentFieldNames` | `array` | | | The array of field names of specific fields within the group to determine the state of the checkbox. If any of the specified fields in the `dependentFieldNames` are checked, the field is automatically selected. |
342
343
  | `fieldGroups[].fields[].isSelectedByDefault` | `boolean` | | `false` | This field is a part of the `fields` array is used to control the default state of the corresponding checkbox in the UI. If `isSelectedByDefault` is set to true, the checkbox for that particular field will be checked by default when the component loads. |
@@ -122,6 +122,11 @@ var messages = reactIntl.defineMessages({
122
122
  description: 'Label for the customers modal title',
123
123
  defaultMessage: 'Export customers'
124
124
  },
125
+ 'modalTitle.order': {
126
+ id: 'ExportResourcesModal.modalTitle.order',
127
+ description: 'Label for the orders modal title',
128
+ defaultMessage: 'Export orders'
129
+ },
125
130
  outputFormat: {
126
131
  id: 'ExportResourcesModal.outputFormat',
127
132
  description: 'File format like (csv, xls, ...etc)',
@@ -694,8 +699,8 @@ function getExportLogsLink(projectKey, msg) {
694
699
  }
695
700
  const extractFieldNamesAndAdditionalFieldExtensions = fields => {
696
701
  const result = _reduceInstanceProperty__default["default"](fields).call(fields, (acc, field) => {
697
- if (field.additionalFieldExtensions) {
698
- return [...acc, ...field.additionalFieldExtensions, field.name];
702
+ if (field.extendedFieldNames) {
703
+ return [...acc, field.name, ...field.extendedFieldNames];
699
704
  }
700
705
  return [...acc, field.name];
701
706
  }, []);
@@ -784,14 +789,14 @@ const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
784
789
  });
785
790
  };
786
791
  const updateFieldGroupWithAdditionalFieldExtensions = groups => {
787
- function updateAdditionalFieldExtensions(fields, additionalFieldExtensions) {
792
+ function updateAdditionalFieldExtensions(fields, extendedFieldNames) {
788
793
  return _mapInstanceProperty__default["default"](fields).call(fields, field => {
789
- const updatedAdditionalFieldExtensions = [...additionalFieldExtensions, ...(field.additionalFieldExtensions || [])];
794
+ const updatedAdditionalFieldExtensions = [...extendedFieldNames, ...(field.extendedFieldNames || [])];
790
795
  if (field.fields) {
791
796
  field.fields = updateAdditionalFieldExtensions(field.fields, updatedAdditionalFieldExtensions);
792
797
  }
793
798
  return _objectSpread$6(_objectSpread$6({}, field), {}, {
794
- additionalFieldExtensions: updatedAdditionalFieldExtensions
799
+ extendedFieldNames: updatedAdditionalFieldExtensions
795
800
  });
796
801
  });
797
802
  }
@@ -1031,9 +1036,9 @@ const useStartExportOperation = props => {
1031
1036
  };
1032
1037
  };
1033
1038
 
1034
- const _excluded$1 = ["fieldDefinitions"];
1039
+ const _excluded$1 = ["fields"];
1035
1040
  function ownKeys$5(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; }
1036
- function _objectSpread$5(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$5(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$5(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1041
+ function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$5(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$5(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1037
1042
  const getFieldFullName = _ref => {
1038
1043
  var _context;
1039
1044
  let fieldPrefix = _ref.fieldPrefix,
@@ -1041,76 +1046,74 @@ const getFieldFullName = _ref => {
1041
1046
  return _filterInstanceProperty__default["default"](_context = [fieldPrefix, fieldName]).call(_context, Boolean).join('.');
1042
1047
  };
1043
1048
  const localizeTypeDefinitionLabels = function () {
1044
- let typeDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1045
- return _mapInstanceProperty__default["default"](typeDefinitions).call(typeDefinitions, _ref2 => {
1046
- let fieldDefinitions = _ref2.fieldDefinitions,
1047
- typeDefinition = _objectWithoutProperties(_ref2, _excluded$1);
1048
- const isTypeLabelLocalized = _Array$isArray__default["default"](typeDefinition.label);
1049
+ let fieldDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1050
+ return _mapInstanceProperty__default["default"](fieldDefinitions).call(fieldDefinitions, _ref2 => {
1051
+ let fields = _ref2.fields,
1052
+ fieldsType = _objectWithoutProperties(_ref2, _excluded$1);
1053
+ const isFieldTypeLabelLocalized = _Array$isArray__default["default"](fieldsType.label);
1049
1054
  return {
1050
- type: isTypeLabelLocalized ? l10n.applyTransformedLocalizedFields(typeDefinition, [{
1055
+ name: fieldsType.name,
1056
+ label: isFieldTypeLabelLocalized ? l10n.applyTransformedLocalizedFields(fieldsType, [{
1051
1057
  from: 'label',
1052
1058
  to: 'label'
1053
- }]) : typeDefinition,
1054
- fields: _mapInstanceProperty__default["default"](fieldDefinitions).call(fieldDefinitions, fieldDefinition => {
1055
- const isFieldLabelLocalized = _Array$isArray__default["default"](fieldDefinition.label);
1059
+ }]).label : fieldsType.label,
1060
+ fields: fields?.map(field => {
1061
+ const isFieldLabelLocalized = _Array$isArray__default["default"](field.label);
1056
1062
  if (!isFieldLabelLocalized) {
1057
- return fieldDefinition;
1063
+ return field;
1058
1064
  }
1059
- return _objectSpread$5({}, l10n.applyTransformedLocalizedFields(fieldDefinition, [{
1065
+ return _objectSpread$5({}, l10n.applyTransformedLocalizedFields(field, [{
1060
1066
  from: 'label',
1061
1067
  to: 'label'
1062
1068
  }]));
1063
- })
1069
+ }) || []
1064
1070
  };
1065
1071
  });
1066
1072
  };
1067
- const useConvertTypeDefinitionsForExport = () => {
1073
+ const useConvertFieldDefinitionsForExport = () => {
1068
1074
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
1069
1075
  language: applicationContext.dataLocale,
1070
1076
  languages: applicationContext.project?.languages
1071
1077
  })),
1072
1078
  language = _useApplicationContex.language,
1073
1079
  languages = _useApplicationContex.languages;
1074
- const convertTypeDefinitionsForExport = _ref3 => {
1075
- let typeDefinitions = _ref3.typeDefinitions,
1080
+ const convertFieldDefinitionsForExport = _ref3 => {
1081
+ let fieldDefinitions = _ref3.fieldDefinitions,
1076
1082
  fieldPrefix = _ref3.fieldPrefix,
1077
1083
  _ref3$expandAll = _ref3.expandAll,
1078
1084
  expandAll = _ref3$expandAll === void 0 ? false : _ref3$expandAll;
1079
- if (!typeDefinitions) return [];
1080
- const transformedTypeDefinitions = localizeTypeDefinitionLabels(typeDefinitions);
1081
- return _mapInstanceProperty__default["default"](transformedTypeDefinitions).call(transformedTypeDefinitions, transformedType => {
1082
- var _context2;
1083
- return {
1084
- isExpandable: true,
1085
- isExpanded: expandAll,
1086
- name: transformedType.type.name,
1085
+ if (!fieldDefinitions) return [];
1086
+ const localizedTypeDefinitions = localizeTypeDefinitionLabels(fieldDefinitions);
1087
+ return _mapInstanceProperty__default["default"](localizedTypeDefinitions).call(localizedTypeDefinitions, transformedType => ({
1088
+ isExpandable: true,
1089
+ isExpanded: expandAll,
1090
+ name: transformedType.name,
1091
+ label: l10n.formatLocalizedString({
1092
+ label: transformedType.label
1093
+ }, {
1094
+ key: 'label',
1095
+ locale: language,
1096
+ fallbackOrder: languages,
1097
+ fallback: transformedType.name
1098
+ }),
1099
+ fields: transformedType.fields?.map(fieldDefinition => ({
1100
+ name: getFieldFullName({
1101
+ fieldPrefix: fieldPrefix,
1102
+ fieldName: fieldDefinition.name
1103
+ }),
1087
1104
  label: l10n.formatLocalizedString({
1088
- label: transformedType.type.label
1105
+ label: fieldDefinition.label
1089
1106
  }, {
1090
1107
  key: 'label',
1091
1108
  locale: language,
1092
1109
  fallbackOrder: languages,
1093
- fallback: transformedType.type.name
1094
- }),
1095
- fields: _mapInstanceProperty__default["default"](_context2 = transformedType.fields).call(_context2, fieldDefinition => ({
1096
- name: getFieldFullName({
1097
- fieldPrefix: fieldPrefix,
1098
- fieldName: fieldDefinition.name
1099
- }),
1100
- label: l10n.formatLocalizedString({
1101
- label: fieldDefinition.label
1102
- }, {
1103
- key: 'label',
1104
- locale: language,
1105
- fallbackOrder: languages,
1106
- fallback: fieldDefinition.name
1107
- })
1108
- }))
1109
- };
1110
- });
1110
+ fallback: fieldDefinition.name
1111
+ })
1112
+ }))
1113
+ }));
1111
1114
  };
1112
1115
  return {
1113
- convertTypeDefinitionsForExport
1116
+ convertFieldDefinitionsForExport
1114
1117
  };
1115
1118
  };
1116
1119
 
@@ -1946,4 +1949,4 @@ ExportResourcesModal.defaultProps = {
1946
1949
  exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
1947
1950
  exports.EXPORT_TYPES = EXPORT_TYPES;
1948
1951
  exports["default"] = ExportResourcesModal;
1949
- exports.useConvertTypeDefinitionsForExport = useConvertTypeDefinitionsForExport;
1952
+ exports.useConvertFieldDefinitionsForExport = useConvertFieldDefinitionsForExport;
@@ -122,6 +122,11 @@ var messages = reactIntl.defineMessages({
122
122
  description: 'Label for the customers modal title',
123
123
  defaultMessage: 'Export customers'
124
124
  },
125
+ 'modalTitle.order': {
126
+ id: 'ExportResourcesModal.modalTitle.order',
127
+ description: 'Label for the orders modal title',
128
+ defaultMessage: 'Export orders'
129
+ },
125
130
  outputFormat: {
126
131
  id: 'ExportResourcesModal.outputFormat',
127
132
  description: 'File format like (csv, xls, ...etc)',
@@ -694,8 +699,8 @@ function getExportLogsLink(projectKey, msg) {
694
699
  }
695
700
  const extractFieldNamesAndAdditionalFieldExtensions = fields => {
696
701
  const result = _reduceInstanceProperty__default["default"](fields).call(fields, (acc, field) => {
697
- if (field.additionalFieldExtensions) {
698
- return [...acc, ...field.additionalFieldExtensions, field.name];
702
+ if (field.extendedFieldNames) {
703
+ return [...acc, field.name, ...field.extendedFieldNames];
699
704
  }
700
705
  return [...acc, field.name];
701
706
  }, []);
@@ -784,14 +789,14 @@ const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
784
789
  });
785
790
  };
786
791
  const updateFieldGroupWithAdditionalFieldExtensions = groups => {
787
- function updateAdditionalFieldExtensions(fields, additionalFieldExtensions) {
792
+ function updateAdditionalFieldExtensions(fields, extendedFieldNames) {
788
793
  return _mapInstanceProperty__default["default"](fields).call(fields, field => {
789
- const updatedAdditionalFieldExtensions = [...additionalFieldExtensions, ...(field.additionalFieldExtensions || [])];
794
+ const updatedAdditionalFieldExtensions = [...extendedFieldNames, ...(field.extendedFieldNames || [])];
790
795
  if (field.fields) {
791
796
  field.fields = updateAdditionalFieldExtensions(field.fields, updatedAdditionalFieldExtensions);
792
797
  }
793
798
  return _objectSpread$6(_objectSpread$6({}, field), {}, {
794
- additionalFieldExtensions: updatedAdditionalFieldExtensions
799
+ extendedFieldNames: updatedAdditionalFieldExtensions
795
800
  });
796
801
  });
797
802
  }
@@ -1031,9 +1036,9 @@ const useStartExportOperation = props => {
1031
1036
  };
1032
1037
  };
1033
1038
 
1034
- const _excluded$1 = ["fieldDefinitions"];
1039
+ const _excluded$1 = ["fields"];
1035
1040
  function ownKeys$5(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; }
1036
- function _objectSpread$5(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$5(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$5(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1041
+ function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$5(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$5(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1037
1042
  const getFieldFullName = _ref => {
1038
1043
  var _context;
1039
1044
  let fieldPrefix = _ref.fieldPrefix,
@@ -1041,76 +1046,74 @@ const getFieldFullName = _ref => {
1041
1046
  return _filterInstanceProperty__default["default"](_context = [fieldPrefix, fieldName]).call(_context, Boolean).join('.');
1042
1047
  };
1043
1048
  const localizeTypeDefinitionLabels = function () {
1044
- let typeDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1045
- return _mapInstanceProperty__default["default"](typeDefinitions).call(typeDefinitions, _ref2 => {
1046
- let fieldDefinitions = _ref2.fieldDefinitions,
1047
- typeDefinition = _objectWithoutProperties(_ref2, _excluded$1);
1048
- const isTypeLabelLocalized = _Array$isArray__default["default"](typeDefinition.label);
1049
+ let fieldDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1050
+ return _mapInstanceProperty__default["default"](fieldDefinitions).call(fieldDefinitions, _ref2 => {
1051
+ let fields = _ref2.fields,
1052
+ fieldsType = _objectWithoutProperties(_ref2, _excluded$1);
1053
+ const isFieldTypeLabelLocalized = _Array$isArray__default["default"](fieldsType.label);
1049
1054
  return {
1050
- type: isTypeLabelLocalized ? l10n.applyTransformedLocalizedFields(typeDefinition, [{
1055
+ name: fieldsType.name,
1056
+ label: isFieldTypeLabelLocalized ? l10n.applyTransformedLocalizedFields(fieldsType, [{
1051
1057
  from: 'label',
1052
1058
  to: 'label'
1053
- }]) : typeDefinition,
1054
- fields: _mapInstanceProperty__default["default"](fieldDefinitions).call(fieldDefinitions, fieldDefinition => {
1055
- const isFieldLabelLocalized = _Array$isArray__default["default"](fieldDefinition.label);
1059
+ }]).label : fieldsType.label,
1060
+ fields: fields?.map(field => {
1061
+ const isFieldLabelLocalized = _Array$isArray__default["default"](field.label);
1056
1062
  if (!isFieldLabelLocalized) {
1057
- return fieldDefinition;
1063
+ return field;
1058
1064
  }
1059
- return _objectSpread$5({}, l10n.applyTransformedLocalizedFields(fieldDefinition, [{
1065
+ return _objectSpread$5({}, l10n.applyTransformedLocalizedFields(field, [{
1060
1066
  from: 'label',
1061
1067
  to: 'label'
1062
1068
  }]));
1063
- })
1069
+ }) || []
1064
1070
  };
1065
1071
  });
1066
1072
  };
1067
- const useConvertTypeDefinitionsForExport = () => {
1073
+ const useConvertFieldDefinitionsForExport = () => {
1068
1074
  const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
1069
1075
  language: applicationContext.dataLocale,
1070
1076
  languages: applicationContext.project?.languages
1071
1077
  })),
1072
1078
  language = _useApplicationContex.language,
1073
1079
  languages = _useApplicationContex.languages;
1074
- const convertTypeDefinitionsForExport = _ref3 => {
1075
- let typeDefinitions = _ref3.typeDefinitions,
1080
+ const convertFieldDefinitionsForExport = _ref3 => {
1081
+ let fieldDefinitions = _ref3.fieldDefinitions,
1076
1082
  fieldPrefix = _ref3.fieldPrefix,
1077
1083
  _ref3$expandAll = _ref3.expandAll,
1078
1084
  expandAll = _ref3$expandAll === void 0 ? false : _ref3$expandAll;
1079
- if (!typeDefinitions) return [];
1080
- const transformedTypeDefinitions = localizeTypeDefinitionLabels(typeDefinitions);
1081
- return _mapInstanceProperty__default["default"](transformedTypeDefinitions).call(transformedTypeDefinitions, transformedType => {
1082
- var _context2;
1083
- return {
1084
- isExpandable: true,
1085
- isExpanded: expandAll,
1086
- name: transformedType.type.name,
1085
+ if (!fieldDefinitions) return [];
1086
+ const localizedTypeDefinitions = localizeTypeDefinitionLabels(fieldDefinitions);
1087
+ return _mapInstanceProperty__default["default"](localizedTypeDefinitions).call(localizedTypeDefinitions, transformedType => ({
1088
+ isExpandable: true,
1089
+ isExpanded: expandAll,
1090
+ name: transformedType.name,
1091
+ label: l10n.formatLocalizedString({
1092
+ label: transformedType.label
1093
+ }, {
1094
+ key: 'label',
1095
+ locale: language,
1096
+ fallbackOrder: languages,
1097
+ fallback: transformedType.name
1098
+ }),
1099
+ fields: transformedType.fields?.map(fieldDefinition => ({
1100
+ name: getFieldFullName({
1101
+ fieldPrefix: fieldPrefix,
1102
+ fieldName: fieldDefinition.name
1103
+ }),
1087
1104
  label: l10n.formatLocalizedString({
1088
- label: transformedType.type.label
1105
+ label: fieldDefinition.label
1089
1106
  }, {
1090
1107
  key: 'label',
1091
1108
  locale: language,
1092
1109
  fallbackOrder: languages,
1093
- fallback: transformedType.type.name
1094
- }),
1095
- fields: _mapInstanceProperty__default["default"](_context2 = transformedType.fields).call(_context2, fieldDefinition => ({
1096
- name: getFieldFullName({
1097
- fieldPrefix: fieldPrefix,
1098
- fieldName: fieldDefinition.name
1099
- }),
1100
- label: l10n.formatLocalizedString({
1101
- label: fieldDefinition.label
1102
- }, {
1103
- key: 'label',
1104
- locale: language,
1105
- fallbackOrder: languages,
1106
- fallback: fieldDefinition.name
1107
- })
1108
- }))
1109
- };
1110
- });
1110
+ fallback: fieldDefinition.name
1111
+ })
1112
+ }))
1113
+ }));
1111
1114
  };
1112
1115
  return {
1113
- convertTypeDefinitionsForExport
1116
+ convertFieldDefinitionsForExport
1114
1117
  };
1115
1118
  };
1116
1119
 
@@ -1913,4 +1916,4 @@ ExportResourcesModal.defaultProps = {
1913
1916
  exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
1914
1917
  exports.EXPORT_TYPES = EXPORT_TYPES;
1915
1918
  exports["default"] = ExportResourcesModal;
1916
- exports.useConvertTypeDefinitionsForExport = useConvertTypeDefinitionsForExport;
1919
+ exports.useConvertFieldDefinitionsForExport = useConvertFieldDefinitionsForExport;
@@ -88,6 +88,11 @@ var messages = defineMessages({
88
88
  description: 'Label for the customers modal title',
89
89
  defaultMessage: 'Export customers'
90
90
  },
91
+ 'modalTitle.order': {
92
+ id: 'ExportResourcesModal.modalTitle.order',
93
+ description: 'Label for the orders modal title',
94
+ defaultMessage: 'Export orders'
95
+ },
91
96
  outputFormat: {
92
97
  id: 'ExportResourcesModal.outputFormat',
93
98
  description: 'File format like (csv, xls, ...etc)',
@@ -660,8 +665,8 @@ function getExportLogsLink(projectKey, msg) {
660
665
  }
661
666
  const extractFieldNamesAndAdditionalFieldExtensions = fields => {
662
667
  const result = _reduceInstanceProperty(fields).call(fields, (acc, field) => {
663
- if (field.additionalFieldExtensions) {
664
- return [...acc, ...field.additionalFieldExtensions, field.name];
668
+ if (field.extendedFieldNames) {
669
+ return [...acc, field.name, ...field.extendedFieldNames];
665
670
  }
666
671
  return [...acc, field.name];
667
672
  }, []);
@@ -750,14 +755,14 @@ const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
750
755
  });
751
756
  };
752
757
  const updateFieldGroupWithAdditionalFieldExtensions = groups => {
753
- function updateAdditionalFieldExtensions(fields, additionalFieldExtensions) {
758
+ function updateAdditionalFieldExtensions(fields, extendedFieldNames) {
754
759
  return _mapInstanceProperty(fields).call(fields, field => {
755
- const updatedAdditionalFieldExtensions = [...additionalFieldExtensions, ...(field.additionalFieldExtensions || [])];
760
+ const updatedAdditionalFieldExtensions = [...extendedFieldNames, ...(field.extendedFieldNames || [])];
756
761
  if (field.fields) {
757
762
  field.fields = updateAdditionalFieldExtensions(field.fields, updatedAdditionalFieldExtensions);
758
763
  }
759
764
  return _objectSpread$6(_objectSpread$6({}, field), {}, {
760
- additionalFieldExtensions: updatedAdditionalFieldExtensions
765
+ extendedFieldNames: updatedAdditionalFieldExtensions
761
766
  });
762
767
  });
763
768
  }
@@ -997,9 +1002,9 @@ const useStartExportOperation = props => {
997
1002
  };
998
1003
  };
999
1004
 
1000
- const _excluded$1 = ["fieldDefinitions"];
1005
+ const _excluded$1 = ["fields"];
1001
1006
  function ownKeys$5(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; }
1002
- function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys$5(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$5(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1007
+ function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$5(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$5(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
1003
1008
  const getFieldFullName = _ref => {
1004
1009
  var _context;
1005
1010
  let fieldPrefix = _ref.fieldPrefix,
@@ -1007,76 +1012,74 @@ const getFieldFullName = _ref => {
1007
1012
  return _filterInstanceProperty(_context = [fieldPrefix, fieldName]).call(_context, Boolean).join('.');
1008
1013
  };
1009
1014
  const localizeTypeDefinitionLabels = function () {
1010
- let typeDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1011
- return _mapInstanceProperty(typeDefinitions).call(typeDefinitions, _ref2 => {
1012
- let fieldDefinitions = _ref2.fieldDefinitions,
1013
- typeDefinition = _objectWithoutProperties(_ref2, _excluded$1);
1014
- const isTypeLabelLocalized = _Array$isArray(typeDefinition.label);
1015
+ let fieldDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1016
+ return _mapInstanceProperty(fieldDefinitions).call(fieldDefinitions, _ref2 => {
1017
+ let fields = _ref2.fields,
1018
+ fieldsType = _objectWithoutProperties(_ref2, _excluded$1);
1019
+ const isFieldTypeLabelLocalized = _Array$isArray(fieldsType.label);
1015
1020
  return {
1016
- type: isTypeLabelLocalized ? applyTransformedLocalizedFields(typeDefinition, [{
1021
+ name: fieldsType.name,
1022
+ label: isFieldTypeLabelLocalized ? applyTransformedLocalizedFields(fieldsType, [{
1017
1023
  from: 'label',
1018
1024
  to: 'label'
1019
- }]) : typeDefinition,
1020
- fields: _mapInstanceProperty(fieldDefinitions).call(fieldDefinitions, fieldDefinition => {
1021
- const isFieldLabelLocalized = _Array$isArray(fieldDefinition.label);
1025
+ }]).label : fieldsType.label,
1026
+ fields: fields?.map(field => {
1027
+ const isFieldLabelLocalized = _Array$isArray(field.label);
1022
1028
  if (!isFieldLabelLocalized) {
1023
- return fieldDefinition;
1029
+ return field;
1024
1030
  }
1025
- return _objectSpread$5({}, applyTransformedLocalizedFields(fieldDefinition, [{
1031
+ return _objectSpread$5({}, applyTransformedLocalizedFields(field, [{
1026
1032
  from: 'label',
1027
1033
  to: 'label'
1028
1034
  }]));
1029
- })
1035
+ }) || []
1030
1036
  };
1031
1037
  });
1032
1038
  };
1033
- const useConvertTypeDefinitionsForExport = () => {
1039
+ const useConvertFieldDefinitionsForExport = () => {
1034
1040
  const _useApplicationContex = useApplicationContext(applicationContext => ({
1035
1041
  language: applicationContext.dataLocale,
1036
1042
  languages: applicationContext.project?.languages
1037
1043
  })),
1038
1044
  language = _useApplicationContex.language,
1039
1045
  languages = _useApplicationContex.languages;
1040
- const convertTypeDefinitionsForExport = _ref3 => {
1041
- let typeDefinitions = _ref3.typeDefinitions,
1046
+ const convertFieldDefinitionsForExport = _ref3 => {
1047
+ let fieldDefinitions = _ref3.fieldDefinitions,
1042
1048
  fieldPrefix = _ref3.fieldPrefix,
1043
1049
  _ref3$expandAll = _ref3.expandAll,
1044
1050
  expandAll = _ref3$expandAll === void 0 ? false : _ref3$expandAll;
1045
- if (!typeDefinitions) return [];
1046
- const transformedTypeDefinitions = localizeTypeDefinitionLabels(typeDefinitions);
1047
- return _mapInstanceProperty(transformedTypeDefinitions).call(transformedTypeDefinitions, transformedType => {
1048
- var _context2;
1049
- return {
1050
- isExpandable: true,
1051
- isExpanded: expandAll,
1052
- name: transformedType.type.name,
1051
+ if (!fieldDefinitions) return [];
1052
+ const localizedTypeDefinitions = localizeTypeDefinitionLabels(fieldDefinitions);
1053
+ return _mapInstanceProperty(localizedTypeDefinitions).call(localizedTypeDefinitions, transformedType => ({
1054
+ isExpandable: true,
1055
+ isExpanded: expandAll,
1056
+ name: transformedType.name,
1057
+ label: formatLocalizedString({
1058
+ label: transformedType.label
1059
+ }, {
1060
+ key: 'label',
1061
+ locale: language,
1062
+ fallbackOrder: languages,
1063
+ fallback: transformedType.name
1064
+ }),
1065
+ fields: transformedType.fields?.map(fieldDefinition => ({
1066
+ name: getFieldFullName({
1067
+ fieldPrefix: fieldPrefix,
1068
+ fieldName: fieldDefinition.name
1069
+ }),
1053
1070
  label: formatLocalizedString({
1054
- label: transformedType.type.label
1071
+ label: fieldDefinition.label
1055
1072
  }, {
1056
1073
  key: 'label',
1057
1074
  locale: language,
1058
1075
  fallbackOrder: languages,
1059
- fallback: transformedType.type.name
1060
- }),
1061
- fields: _mapInstanceProperty(_context2 = transformedType.fields).call(_context2, fieldDefinition => ({
1062
- name: getFieldFullName({
1063
- fieldPrefix: fieldPrefix,
1064
- fieldName: fieldDefinition.name
1065
- }),
1066
- label: formatLocalizedString({
1067
- label: fieldDefinition.label
1068
- }, {
1069
- key: 'label',
1070
- locale: language,
1071
- fallbackOrder: languages,
1072
- fallback: fieldDefinition.name
1073
- })
1074
- }))
1075
- };
1076
- });
1076
+ fallback: fieldDefinition.name
1077
+ })
1078
+ }))
1079
+ }));
1077
1080
  };
1078
1081
  return {
1079
- convertTypeDefinitionsForExport
1082
+ convertFieldDefinitionsForExport
1080
1083
  };
1081
1084
  };
1082
1085
 
@@ -1909,4 +1912,4 @@ ExportResourcesModal.defaultProps = {
1909
1912
  fieldOrder: []
1910
1913
  };
1911
1914
 
1912
- export { EXPORTABLE_RESOURCES, EXPORT_TYPES, ExportResourcesModal as default, useConvertTypeDefinitionsForExport };
1915
+ export { EXPORTABLE_RESOURCES, EXPORT_TYPES, ExportResourcesModal as default, useConvertFieldDefinitionsForExport };
@@ -1,4 +1,4 @@
1
1
  export * from "./use-export-resources-modal-context.js";
2
2
  export * from "./use-initial-values.js";
3
3
  export * from "./use-start-export-operation.js";
4
- export * from "./use-convert-type-definitions-for-export.js";
4
+ export * from "./use-convert-field-definitions-for-export.js";
@@ -0,0 +1,8 @@
1
+ import type { Field, FieldDefinition } from "../@types/index.js";
2
+ export declare const useConvertFieldDefinitionsForExport: () => {
3
+ convertFieldDefinitionsForExport: ({ fieldDefinitions, fieldPrefix, expandAll, }: {
4
+ fieldDefinitions?: FieldDefinition[] | undefined;
5
+ fieldPrefix?: string | undefined;
6
+ expandAll?: boolean | undefined;
7
+ }) => Field[];
8
+ };
@@ -6,7 +6,7 @@ export interface Field {
6
6
  isSelectedByDefault?: boolean;
7
7
  isRequired?: boolean;
8
8
  fields?: Field[];
9
- additionalFieldExtensions?: string[];
9
+ extendedFieldNames?: string[];
10
10
  dependentGroupNames?: string[];
11
11
  dependentFieldNames?: string[];
12
12
  isExpanded?: boolean;
@@ -0,0 +1,6 @@
1
+ import type { LocalizedField } from '@commercetools-frontend/l10n/dist/declarations/src/types';
2
+ export type FieldDefinition = {
3
+ name: string;
4
+ label: LocalizedField[] | string;
5
+ fields?: FieldDefinition[];
6
+ };
@@ -3,11 +3,9 @@ import type { OutputFormat } from "./output-format.js";
3
3
  export interface FormField extends Field {
4
4
  isChecked?: boolean;
5
5
  fields?: FormField[];
6
- additionalFieldExtensions?: string[];
7
6
  }
8
7
  export interface FormGroup extends FieldGroup {
9
8
  isChecked?: boolean;
10
- isExpanded?: boolean;
11
9
  fields: FormField[];
12
10
  }
13
11
  export interface FilteredField extends FormField {
@@ -4,4 +4,4 @@ export * from "./form.js";
4
4
  export * from "./resource-type.js";
5
5
  export * from "./output-format.js";
6
6
  export * from "./export-api.js";
7
- export * from "./type-definition.js";
7
+ export * from "./field-definition.js";
@@ -1,5 +1,5 @@
1
1
  import ExportResourcesModal from "./export-resources-modal.js";
2
2
  export { EXPORT_TYPES, EXPORTABLE_RESOURCES } from "./@constants/index.js";
3
3
  export * from "./@types/index.js";
4
- export { useConvertTypeDefinitionsForExport } from "./@hooks/index.js";
4
+ export { useConvertFieldDefinitionsForExport } from "./@hooks/index.js";
5
5
  export default ExportResourcesModal;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-frontend-extensions/export-resources-modal",
3
3
  "description": "Shared export modal for exporting resources",
4
- "version": "0.0.0-canary-20240906151917",
4
+ "version": "0.0.0-canary-20240912074653",
5
5
  "license": "BSD-3-Clause",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -50,7 +50,7 @@
50
50
  "react-intl": "6.6.8",
51
51
  "react-redux": "7.2.9",
52
52
  "redux": "4.2.1",
53
- "rimraf": "5.0.10"
53
+ "rimraf": "6.0.1"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@commercetools-frontend/actions-global": "22.x",
@@ -1,8 +0,0 @@
1
- import type { Field, TypeDefinition } from "../@types/index.js";
2
- export declare const useConvertTypeDefinitionsForExport: () => {
3
- convertTypeDefinitionsForExport: ({ typeDefinitions, fieldPrefix, expandAll, }: {
4
- typeDefinitions?: TypeDefinition[] | undefined;
5
- fieldPrefix?: string | undefined;
6
- expandAll?: boolean | undefined;
7
- }) => Field[];
8
- };
@@ -1,22 +0,0 @@
1
- type LocalizedField = {
2
- value: string;
3
- locale: string;
4
- };
5
- export type FieldDefinition = {
6
- name: string;
7
- label: LocalizedField[];
8
- };
9
- export type TypeDefinition = {
10
- name: string;
11
- label: LocalizedField[];
12
- fieldDefinitions: FieldDefinition[];
13
- };
14
- type TransformedFieldDefinition = {
15
- name: string;
16
- label: LocalizedField[];
17
- };
18
- export type TransformedTypeDefinition = {
19
- type: FieldDefinition;
20
- fields: TransformedFieldDefinition[];
21
- };
22
- export {};