@commercetools-frontend-extensions/export-resources-modal 0.0.0-canary-20240904091928 → 0.0.0-canary-20240909093252
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 +1 -0
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +64 -59
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +64 -59
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +64 -59
- package/dist/declarations/src/@hooks/index.d.ts +1 -1
- package/dist/declarations/src/@hooks/use-convert-field-definitions-for-export.d.ts +8 -0
- package/dist/declarations/src/@types/export-resources-modal-types.d.ts +1 -1
- package/dist/declarations/src/@types/field-definition.d.ts +6 -0
- package/dist/declarations/src/@types/form.d.ts +0 -2
- package/dist/declarations/src/@types/index.d.ts +1 -1
- package/dist/declarations/src/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/declarations/src/@hooks/use-convert-custom-type-definitions-for-export.d.ts +0 -8
- package/dist/declarations/src/@types/custom-type-definition.d.ts +0 -38
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. |
|
|
@@ -694,8 +694,8 @@ function getExportLogsLink(projectKey, msg) {
|
|
|
694
694
|
}
|
|
695
695
|
const extractFieldNamesAndAdditionalFieldExtensions = fields => {
|
|
696
696
|
const result = _reduceInstanceProperty__default["default"](fields).call(fields, (acc, field) => {
|
|
697
|
-
if (field.
|
|
698
|
-
return [...acc,
|
|
697
|
+
if (field.extendedFieldNames) {
|
|
698
|
+
return [...acc, field.name, ...field.extendedFieldNames];
|
|
699
699
|
}
|
|
700
700
|
return [...acc, field.name];
|
|
701
701
|
}, []);
|
|
@@ -784,14 +784,14 @@ const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
|
|
|
784
784
|
});
|
|
785
785
|
};
|
|
786
786
|
const updateFieldGroupWithAdditionalFieldExtensions = groups => {
|
|
787
|
-
function updateAdditionalFieldExtensions(fields,
|
|
787
|
+
function updateAdditionalFieldExtensions(fields, extendedFieldNames) {
|
|
788
788
|
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
789
|
-
const updatedAdditionalFieldExtensions = [...
|
|
789
|
+
const updatedAdditionalFieldExtensions = [...extendedFieldNames, ...(field.extendedFieldNames || [])];
|
|
790
790
|
if (field.fields) {
|
|
791
791
|
field.fields = updateAdditionalFieldExtensions(field.fields, updatedAdditionalFieldExtensions);
|
|
792
792
|
}
|
|
793
793
|
return _objectSpread$6(_objectSpread$6({}, field), {}, {
|
|
794
|
-
|
|
794
|
+
extendedFieldNames: updatedAdditionalFieldExtensions
|
|
795
795
|
});
|
|
796
796
|
});
|
|
797
797
|
}
|
|
@@ -1031,79 +1031,84 @@ const useStartExportOperation = props => {
|
|
|
1031
1031
|
};
|
|
1032
1032
|
};
|
|
1033
1033
|
|
|
1034
|
-
const _excluded$1 = ["
|
|
1034
|
+
const _excluded$1 = ["fields"];
|
|
1035
1035
|
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
|
|
1037
|
-
const
|
|
1038
|
-
const getCustomFieldFullName = _ref => {
|
|
1036
|
+
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
|
+
const getFieldFullName = _ref => {
|
|
1039
1038
|
var _context;
|
|
1040
|
-
let
|
|
1041
|
-
|
|
1042
|
-
return _filterInstanceProperty__default["default"](_context = [
|
|
1039
|
+
let fieldPrefix = _ref.fieldPrefix,
|
|
1040
|
+
fieldName = _ref.fieldName;
|
|
1041
|
+
return _filterInstanceProperty__default["default"](_context = [fieldPrefix, fieldName]).call(_context, Boolean).join('.');
|
|
1043
1042
|
};
|
|
1044
|
-
const
|
|
1045
|
-
let
|
|
1046
|
-
return _mapInstanceProperty__default["default"](
|
|
1047
|
-
let
|
|
1048
|
-
|
|
1043
|
+
const localizeTypeDefinitionLabels = function () {
|
|
1044
|
+
let fieldDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1045
|
+
return _mapInstanceProperty__default["default"](fieldDefinitions).call(fieldDefinitions, _ref2 => {
|
|
1046
|
+
let fields = _ref2.fields,
|
|
1047
|
+
fieldsType = _objectWithoutProperties(_ref2, _excluded$1);
|
|
1048
|
+
const isFieldTypeLabelLocalized = _Array$isArray__default["default"](fieldsType.label);
|
|
1049
1049
|
return {
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
}]),
|
|
1054
|
-
fields: _mapInstanceProperty__default["default"](fieldDefinitions).call(fieldDefinitions, fieldDefinition => _objectSpread$5({}, l10n.applyTransformedLocalizedFields(fieldDefinition, [{
|
|
1055
|
-
from: 'labelAllLocales',
|
|
1050
|
+
name: fieldsType.name,
|
|
1051
|
+
label: isFieldTypeLabelLocalized ? l10n.applyTransformedLocalizedFields(fieldsType, [{
|
|
1052
|
+
from: 'label',
|
|
1056
1053
|
to: 'label'
|
|
1057
|
-
}])
|
|
1054
|
+
}]).label : fieldsType.label,
|
|
1055
|
+
fields: fields?.map(field => {
|
|
1056
|
+
const isFieldLabelLocalized = _Array$isArray__default["default"](field.label);
|
|
1057
|
+
if (!isFieldLabelLocalized) {
|
|
1058
|
+
return field;
|
|
1059
|
+
}
|
|
1060
|
+
return _objectSpread$5({}, l10n.applyTransformedLocalizedFields(field, [{
|
|
1061
|
+
from: 'label',
|
|
1062
|
+
to: 'label'
|
|
1063
|
+
}]));
|
|
1064
|
+
}) || []
|
|
1058
1065
|
};
|
|
1059
1066
|
});
|
|
1060
1067
|
};
|
|
1061
|
-
const
|
|
1068
|
+
const useConvertFieldDefinitionsForExport = () => {
|
|
1062
1069
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
1063
1070
|
language: applicationContext.dataLocale,
|
|
1064
1071
|
languages: applicationContext.project?.languages
|
|
1065
1072
|
})),
|
|
1066
1073
|
language = _useApplicationContex.language,
|
|
1067
1074
|
languages = _useApplicationContex.languages;
|
|
1068
|
-
const
|
|
1069
|
-
let
|
|
1070
|
-
|
|
1071
|
-
expandAll = _ref3.expandAll
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1075
|
+
const convertFieldDefinitionsForExport = _ref3 => {
|
|
1076
|
+
let fieldDefinitions = _ref3.fieldDefinitions,
|
|
1077
|
+
fieldPrefix = _ref3.fieldPrefix,
|
|
1078
|
+
_ref3$expandAll = _ref3.expandAll,
|
|
1079
|
+
expandAll = _ref3$expandAll === void 0 ? false : _ref3$expandAll;
|
|
1080
|
+
if (!fieldDefinitions) return [];
|
|
1081
|
+
const localizedTypeDefinitions = localizeTypeDefinitionLabels(fieldDefinitions);
|
|
1082
|
+
return _mapInstanceProperty__default["default"](localizedTypeDefinitions).call(localizedTypeDefinitions, transformedType => ({
|
|
1083
|
+
isExpandable: true,
|
|
1084
|
+
isExpanded: expandAll,
|
|
1085
|
+
name: transformedType.name,
|
|
1086
|
+
label: l10n.formatLocalizedString({
|
|
1087
|
+
label: transformedType.label
|
|
1088
|
+
}, {
|
|
1089
|
+
key: 'label',
|
|
1090
|
+
locale: language,
|
|
1091
|
+
fallbackOrder: languages,
|
|
1092
|
+
fallback: transformedType.name
|
|
1093
|
+
}),
|
|
1094
|
+
fields: transformedType.fields?.map(fieldDefinition => ({
|
|
1095
|
+
name: getFieldFullName({
|
|
1096
|
+
fieldPrefix: fieldPrefix,
|
|
1097
|
+
fieldName: fieldDefinition.name
|
|
1098
|
+
}),
|
|
1080
1099
|
label: l10n.formatLocalizedString({
|
|
1081
|
-
|
|
1100
|
+
label: fieldDefinition.label
|
|
1082
1101
|
}, {
|
|
1083
|
-
key: '
|
|
1102
|
+
key: 'label',
|
|
1084
1103
|
locale: language,
|
|
1085
1104
|
fallbackOrder: languages,
|
|
1086
|
-
fallback:
|
|
1087
|
-
})
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
customFieldPrefix: customFieldPrefix,
|
|
1091
|
-
key: fieldDefinition.name
|
|
1092
|
-
}),
|
|
1093
|
-
label: l10n.formatLocalizedString({
|
|
1094
|
-
labelAllLocales: fieldDefinition.label
|
|
1095
|
-
}, {
|
|
1096
|
-
key: 'labelAllLocales',
|
|
1097
|
-
locale: language,
|
|
1098
|
-
fallbackOrder: languages,
|
|
1099
|
-
fallback: fieldDefinition.name
|
|
1100
|
-
})
|
|
1101
|
-
}))
|
|
1102
|
-
};
|
|
1103
|
-
});
|
|
1105
|
+
fallback: fieldDefinition.name
|
|
1106
|
+
})
|
|
1107
|
+
}))
|
|
1108
|
+
}));
|
|
1104
1109
|
};
|
|
1105
1110
|
return {
|
|
1106
|
-
|
|
1111
|
+
convertFieldDefinitionsForExport
|
|
1107
1112
|
};
|
|
1108
1113
|
};
|
|
1109
1114
|
|
|
@@ -1939,4 +1944,4 @@ ExportResourcesModal.defaultProps = {
|
|
|
1939
1944
|
exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
|
|
1940
1945
|
exports.EXPORT_TYPES = EXPORT_TYPES;
|
|
1941
1946
|
exports["default"] = ExportResourcesModal;
|
|
1942
|
-
exports.
|
|
1947
|
+
exports.useConvertFieldDefinitionsForExport = useConvertFieldDefinitionsForExport;
|
|
@@ -694,8 +694,8 @@ function getExportLogsLink(projectKey, msg) {
|
|
|
694
694
|
}
|
|
695
695
|
const extractFieldNamesAndAdditionalFieldExtensions = fields => {
|
|
696
696
|
const result = _reduceInstanceProperty__default["default"](fields).call(fields, (acc, field) => {
|
|
697
|
-
if (field.
|
|
698
|
-
return [...acc,
|
|
697
|
+
if (field.extendedFieldNames) {
|
|
698
|
+
return [...acc, field.name, ...field.extendedFieldNames];
|
|
699
699
|
}
|
|
700
700
|
return [...acc, field.name];
|
|
701
701
|
}, []);
|
|
@@ -784,14 +784,14 @@ const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
|
|
|
784
784
|
});
|
|
785
785
|
};
|
|
786
786
|
const updateFieldGroupWithAdditionalFieldExtensions = groups => {
|
|
787
|
-
function updateAdditionalFieldExtensions(fields,
|
|
787
|
+
function updateAdditionalFieldExtensions(fields, extendedFieldNames) {
|
|
788
788
|
return _mapInstanceProperty__default["default"](fields).call(fields, field => {
|
|
789
|
-
const updatedAdditionalFieldExtensions = [...
|
|
789
|
+
const updatedAdditionalFieldExtensions = [...extendedFieldNames, ...(field.extendedFieldNames || [])];
|
|
790
790
|
if (field.fields) {
|
|
791
791
|
field.fields = updateAdditionalFieldExtensions(field.fields, updatedAdditionalFieldExtensions);
|
|
792
792
|
}
|
|
793
793
|
return _objectSpread$6(_objectSpread$6({}, field), {}, {
|
|
794
|
-
|
|
794
|
+
extendedFieldNames: updatedAdditionalFieldExtensions
|
|
795
795
|
});
|
|
796
796
|
});
|
|
797
797
|
}
|
|
@@ -1031,79 +1031,84 @@ const useStartExportOperation = props => {
|
|
|
1031
1031
|
};
|
|
1032
1032
|
};
|
|
1033
1033
|
|
|
1034
|
-
const _excluded$1 = ["
|
|
1034
|
+
const _excluded$1 = ["fields"];
|
|
1035
1035
|
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
|
|
1037
|
-
const
|
|
1038
|
-
const getCustomFieldFullName = _ref => {
|
|
1036
|
+
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
|
+
const getFieldFullName = _ref => {
|
|
1039
1038
|
var _context;
|
|
1040
|
-
let
|
|
1041
|
-
|
|
1042
|
-
return _filterInstanceProperty__default["default"](_context = [
|
|
1039
|
+
let fieldPrefix = _ref.fieldPrefix,
|
|
1040
|
+
fieldName = _ref.fieldName;
|
|
1041
|
+
return _filterInstanceProperty__default["default"](_context = [fieldPrefix, fieldName]).call(_context, Boolean).join('.');
|
|
1043
1042
|
};
|
|
1044
|
-
const
|
|
1045
|
-
let
|
|
1046
|
-
return _mapInstanceProperty__default["default"](
|
|
1047
|
-
let
|
|
1048
|
-
|
|
1043
|
+
const localizeTypeDefinitionLabels = function () {
|
|
1044
|
+
let fieldDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1045
|
+
return _mapInstanceProperty__default["default"](fieldDefinitions).call(fieldDefinitions, _ref2 => {
|
|
1046
|
+
let fields = _ref2.fields,
|
|
1047
|
+
fieldsType = _objectWithoutProperties(_ref2, _excluded$1);
|
|
1048
|
+
const isFieldTypeLabelLocalized = _Array$isArray__default["default"](fieldsType.label);
|
|
1049
1049
|
return {
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
}]),
|
|
1054
|
-
fields: _mapInstanceProperty__default["default"](fieldDefinitions).call(fieldDefinitions, fieldDefinition => _objectSpread$5({}, l10n.applyTransformedLocalizedFields(fieldDefinition, [{
|
|
1055
|
-
from: 'labelAllLocales',
|
|
1050
|
+
name: fieldsType.name,
|
|
1051
|
+
label: isFieldTypeLabelLocalized ? l10n.applyTransformedLocalizedFields(fieldsType, [{
|
|
1052
|
+
from: 'label',
|
|
1056
1053
|
to: 'label'
|
|
1057
|
-
}])
|
|
1054
|
+
}]).label : fieldsType.label,
|
|
1055
|
+
fields: fields?.map(field => {
|
|
1056
|
+
const isFieldLabelLocalized = _Array$isArray__default["default"](field.label);
|
|
1057
|
+
if (!isFieldLabelLocalized) {
|
|
1058
|
+
return field;
|
|
1059
|
+
}
|
|
1060
|
+
return _objectSpread$5({}, l10n.applyTransformedLocalizedFields(field, [{
|
|
1061
|
+
from: 'label',
|
|
1062
|
+
to: 'label'
|
|
1063
|
+
}]));
|
|
1064
|
+
}) || []
|
|
1058
1065
|
};
|
|
1059
1066
|
});
|
|
1060
1067
|
};
|
|
1061
|
-
const
|
|
1068
|
+
const useConvertFieldDefinitionsForExport = () => {
|
|
1062
1069
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
1063
1070
|
language: applicationContext.dataLocale,
|
|
1064
1071
|
languages: applicationContext.project?.languages
|
|
1065
1072
|
})),
|
|
1066
1073
|
language = _useApplicationContex.language,
|
|
1067
1074
|
languages = _useApplicationContex.languages;
|
|
1068
|
-
const
|
|
1069
|
-
let
|
|
1070
|
-
|
|
1071
|
-
expandAll = _ref3.expandAll
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1075
|
+
const convertFieldDefinitionsForExport = _ref3 => {
|
|
1076
|
+
let fieldDefinitions = _ref3.fieldDefinitions,
|
|
1077
|
+
fieldPrefix = _ref3.fieldPrefix,
|
|
1078
|
+
_ref3$expandAll = _ref3.expandAll,
|
|
1079
|
+
expandAll = _ref3$expandAll === void 0 ? false : _ref3$expandAll;
|
|
1080
|
+
if (!fieldDefinitions) return [];
|
|
1081
|
+
const localizedTypeDefinitions = localizeTypeDefinitionLabels(fieldDefinitions);
|
|
1082
|
+
return _mapInstanceProperty__default["default"](localizedTypeDefinitions).call(localizedTypeDefinitions, transformedType => ({
|
|
1083
|
+
isExpandable: true,
|
|
1084
|
+
isExpanded: expandAll,
|
|
1085
|
+
name: transformedType.name,
|
|
1086
|
+
label: l10n.formatLocalizedString({
|
|
1087
|
+
label: transformedType.label
|
|
1088
|
+
}, {
|
|
1089
|
+
key: 'label',
|
|
1090
|
+
locale: language,
|
|
1091
|
+
fallbackOrder: languages,
|
|
1092
|
+
fallback: transformedType.name
|
|
1093
|
+
}),
|
|
1094
|
+
fields: transformedType.fields?.map(fieldDefinition => ({
|
|
1095
|
+
name: getFieldFullName({
|
|
1096
|
+
fieldPrefix: fieldPrefix,
|
|
1097
|
+
fieldName: fieldDefinition.name
|
|
1098
|
+
}),
|
|
1080
1099
|
label: l10n.formatLocalizedString({
|
|
1081
|
-
|
|
1100
|
+
label: fieldDefinition.label
|
|
1082
1101
|
}, {
|
|
1083
|
-
key: '
|
|
1102
|
+
key: 'label',
|
|
1084
1103
|
locale: language,
|
|
1085
1104
|
fallbackOrder: languages,
|
|
1086
|
-
fallback:
|
|
1087
|
-
})
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
customFieldPrefix: customFieldPrefix,
|
|
1091
|
-
key: fieldDefinition.name
|
|
1092
|
-
}),
|
|
1093
|
-
label: l10n.formatLocalizedString({
|
|
1094
|
-
labelAllLocales: fieldDefinition.label
|
|
1095
|
-
}, {
|
|
1096
|
-
key: 'labelAllLocales',
|
|
1097
|
-
locale: language,
|
|
1098
|
-
fallbackOrder: languages,
|
|
1099
|
-
fallback: fieldDefinition.name
|
|
1100
|
-
})
|
|
1101
|
-
}))
|
|
1102
|
-
};
|
|
1103
|
-
});
|
|
1105
|
+
fallback: fieldDefinition.name
|
|
1106
|
+
})
|
|
1107
|
+
}))
|
|
1108
|
+
}));
|
|
1104
1109
|
};
|
|
1105
1110
|
return {
|
|
1106
|
-
|
|
1111
|
+
convertFieldDefinitionsForExport
|
|
1107
1112
|
};
|
|
1108
1113
|
};
|
|
1109
1114
|
|
|
@@ -1906,4 +1911,4 @@ ExportResourcesModal.defaultProps = {
|
|
|
1906
1911
|
exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
|
|
1907
1912
|
exports.EXPORT_TYPES = EXPORT_TYPES;
|
|
1908
1913
|
exports["default"] = ExportResourcesModal;
|
|
1909
|
-
exports.
|
|
1914
|
+
exports.useConvertFieldDefinitionsForExport = useConvertFieldDefinitionsForExport;
|
|
@@ -660,8 +660,8 @@ function getExportLogsLink(projectKey, msg) {
|
|
|
660
660
|
}
|
|
661
661
|
const extractFieldNamesAndAdditionalFieldExtensions = fields => {
|
|
662
662
|
const result = _reduceInstanceProperty(fields).call(fields, (acc, field) => {
|
|
663
|
-
if (field.
|
|
664
|
-
return [...acc,
|
|
663
|
+
if (field.extendedFieldNames) {
|
|
664
|
+
return [...acc, field.name, ...field.extendedFieldNames];
|
|
665
665
|
}
|
|
666
666
|
return [...acc, field.name];
|
|
667
667
|
}, []);
|
|
@@ -750,14 +750,14 @@ const updateFieldGroupsWithIsCheckedValue = (groups, cachedSelectedGroups) => {
|
|
|
750
750
|
});
|
|
751
751
|
};
|
|
752
752
|
const updateFieldGroupWithAdditionalFieldExtensions = groups => {
|
|
753
|
-
function updateAdditionalFieldExtensions(fields,
|
|
753
|
+
function updateAdditionalFieldExtensions(fields, extendedFieldNames) {
|
|
754
754
|
return _mapInstanceProperty(fields).call(fields, field => {
|
|
755
|
-
const updatedAdditionalFieldExtensions = [...
|
|
755
|
+
const updatedAdditionalFieldExtensions = [...extendedFieldNames, ...(field.extendedFieldNames || [])];
|
|
756
756
|
if (field.fields) {
|
|
757
757
|
field.fields = updateAdditionalFieldExtensions(field.fields, updatedAdditionalFieldExtensions);
|
|
758
758
|
}
|
|
759
759
|
return _objectSpread$6(_objectSpread$6({}, field), {}, {
|
|
760
|
-
|
|
760
|
+
extendedFieldNames: updatedAdditionalFieldExtensions
|
|
761
761
|
});
|
|
762
762
|
});
|
|
763
763
|
}
|
|
@@ -997,79 +997,84 @@ const useStartExportOperation = props => {
|
|
|
997
997
|
};
|
|
998
998
|
};
|
|
999
999
|
|
|
1000
|
-
const _excluded$1 = ["
|
|
1000
|
+
const _excluded$1 = ["fields"];
|
|
1001
1001
|
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
|
|
1003
|
-
const
|
|
1004
|
-
const getCustomFieldFullName = _ref => {
|
|
1002
|
+
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
|
+
const getFieldFullName = _ref => {
|
|
1005
1004
|
var _context;
|
|
1006
|
-
let
|
|
1007
|
-
|
|
1008
|
-
return _filterInstanceProperty(_context = [
|
|
1005
|
+
let fieldPrefix = _ref.fieldPrefix,
|
|
1006
|
+
fieldName = _ref.fieldName;
|
|
1007
|
+
return _filterInstanceProperty(_context = [fieldPrefix, fieldName]).call(_context, Boolean).join('.');
|
|
1009
1008
|
};
|
|
1010
|
-
const
|
|
1011
|
-
let
|
|
1012
|
-
return _mapInstanceProperty(
|
|
1013
|
-
let
|
|
1014
|
-
|
|
1009
|
+
const localizeTypeDefinitionLabels = function () {
|
|
1010
|
+
let fieldDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1011
|
+
return _mapInstanceProperty(fieldDefinitions).call(fieldDefinitions, _ref2 => {
|
|
1012
|
+
let fields = _ref2.fields,
|
|
1013
|
+
fieldsType = _objectWithoutProperties(_ref2, _excluded$1);
|
|
1014
|
+
const isFieldTypeLabelLocalized = _Array$isArray(fieldsType.label);
|
|
1015
1015
|
return {
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
}]),
|
|
1020
|
-
fields: _mapInstanceProperty(fieldDefinitions).call(fieldDefinitions, fieldDefinition => _objectSpread$5({}, applyTransformedLocalizedFields(fieldDefinition, [{
|
|
1021
|
-
from: 'labelAllLocales',
|
|
1016
|
+
name: fieldsType.name,
|
|
1017
|
+
label: isFieldTypeLabelLocalized ? applyTransformedLocalizedFields(fieldsType, [{
|
|
1018
|
+
from: 'label',
|
|
1022
1019
|
to: 'label'
|
|
1023
|
-
}])
|
|
1020
|
+
}]).label : fieldsType.label,
|
|
1021
|
+
fields: fields?.map(field => {
|
|
1022
|
+
const isFieldLabelLocalized = _Array$isArray(field.label);
|
|
1023
|
+
if (!isFieldLabelLocalized) {
|
|
1024
|
+
return field;
|
|
1025
|
+
}
|
|
1026
|
+
return _objectSpread$5({}, applyTransformedLocalizedFields(field, [{
|
|
1027
|
+
from: 'label',
|
|
1028
|
+
to: 'label'
|
|
1029
|
+
}]));
|
|
1030
|
+
}) || []
|
|
1024
1031
|
};
|
|
1025
1032
|
});
|
|
1026
1033
|
};
|
|
1027
|
-
const
|
|
1034
|
+
const useConvertFieldDefinitionsForExport = () => {
|
|
1028
1035
|
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
1029
1036
|
language: applicationContext.dataLocale,
|
|
1030
1037
|
languages: applicationContext.project?.languages
|
|
1031
1038
|
})),
|
|
1032
1039
|
language = _useApplicationContex.language,
|
|
1033
1040
|
languages = _useApplicationContex.languages;
|
|
1034
|
-
const
|
|
1035
|
-
let
|
|
1036
|
-
|
|
1037
|
-
expandAll = _ref3.expandAll
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1041
|
+
const convertFieldDefinitionsForExport = _ref3 => {
|
|
1042
|
+
let fieldDefinitions = _ref3.fieldDefinitions,
|
|
1043
|
+
fieldPrefix = _ref3.fieldPrefix,
|
|
1044
|
+
_ref3$expandAll = _ref3.expandAll,
|
|
1045
|
+
expandAll = _ref3$expandAll === void 0 ? false : _ref3$expandAll;
|
|
1046
|
+
if (!fieldDefinitions) return [];
|
|
1047
|
+
const localizedTypeDefinitions = localizeTypeDefinitionLabels(fieldDefinitions);
|
|
1048
|
+
return _mapInstanceProperty(localizedTypeDefinitions).call(localizedTypeDefinitions, transformedType => ({
|
|
1049
|
+
isExpandable: true,
|
|
1050
|
+
isExpanded: expandAll,
|
|
1051
|
+
name: transformedType.name,
|
|
1052
|
+
label: formatLocalizedString({
|
|
1053
|
+
label: transformedType.label
|
|
1054
|
+
}, {
|
|
1055
|
+
key: 'label',
|
|
1056
|
+
locale: language,
|
|
1057
|
+
fallbackOrder: languages,
|
|
1058
|
+
fallback: transformedType.name
|
|
1059
|
+
}),
|
|
1060
|
+
fields: transformedType.fields?.map(fieldDefinition => ({
|
|
1061
|
+
name: getFieldFullName({
|
|
1062
|
+
fieldPrefix: fieldPrefix,
|
|
1063
|
+
fieldName: fieldDefinition.name
|
|
1064
|
+
}),
|
|
1046
1065
|
label: formatLocalizedString({
|
|
1047
|
-
|
|
1066
|
+
label: fieldDefinition.label
|
|
1048
1067
|
}, {
|
|
1049
|
-
key: '
|
|
1068
|
+
key: 'label',
|
|
1050
1069
|
locale: language,
|
|
1051
1070
|
fallbackOrder: languages,
|
|
1052
|
-
fallback:
|
|
1053
|
-
})
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
customFieldPrefix: customFieldPrefix,
|
|
1057
|
-
key: fieldDefinition.name
|
|
1058
|
-
}),
|
|
1059
|
-
label: formatLocalizedString({
|
|
1060
|
-
labelAllLocales: fieldDefinition.label
|
|
1061
|
-
}, {
|
|
1062
|
-
key: 'labelAllLocales',
|
|
1063
|
-
locale: language,
|
|
1064
|
-
fallbackOrder: languages,
|
|
1065
|
-
fallback: fieldDefinition.name
|
|
1066
|
-
})
|
|
1067
|
-
}))
|
|
1068
|
-
};
|
|
1069
|
-
});
|
|
1071
|
+
fallback: fieldDefinition.name
|
|
1072
|
+
})
|
|
1073
|
+
}))
|
|
1074
|
+
}));
|
|
1070
1075
|
};
|
|
1071
1076
|
return {
|
|
1072
|
-
|
|
1077
|
+
convertFieldDefinitionsForExport
|
|
1073
1078
|
};
|
|
1074
1079
|
};
|
|
1075
1080
|
|
|
@@ -1902,4 +1907,4 @@ ExportResourcesModal.defaultProps = {
|
|
|
1902
1907
|
fieldOrder: []
|
|
1903
1908
|
};
|
|
1904
1909
|
|
|
1905
|
-
export { EXPORTABLE_RESOURCES, EXPORT_TYPES, ExportResourcesModal as default,
|
|
1910
|
+
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-
|
|
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
|
-
|
|
9
|
+
extendedFieldNames?: string[];
|
|
10
10
|
dependentGroupNames?: string[];
|
|
11
11
|
dependentFieldNames?: string[];
|
|
12
12
|
isExpanded?: boolean;
|
|
@@ -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 {
|
|
@@ -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 {
|
|
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-
|
|
4
|
+
"version": "0.0.0-canary-20240909093252",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@commercetools-frontend/constants": "22.32.0",
|
|
39
39
|
"@commercetools-frontend/i18n": "22.32.0",
|
|
40
40
|
"@commercetools-frontend/jest-preset-mc-app": "22.32.0",
|
|
41
|
-
"@commercetools-frontend/l10n": "22.
|
|
41
|
+
"@commercetools-frontend/l10n": "22.x",
|
|
42
42
|
"@commercetools-frontend/sdk": "22.32.0",
|
|
43
43
|
"@commercetools-frontend/sentry": "22.32.0",
|
|
44
44
|
"@commercetools-frontend/ui-kit": "19.11.0",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Field, CustomTypeDefinition } from "../@types/index.js";
|
|
2
|
-
export declare const useConvertCustomTypeDefinitionsForExport: () => {
|
|
3
|
-
convertCustomTypeDefinitionsForExport: ({ customTypeDefinitions, customFieldPrefix, expandAll, }: {
|
|
4
|
-
customTypeDefinitions?: CustomTypeDefinition[] | undefined;
|
|
5
|
-
customFieldPrefix?: string | undefined;
|
|
6
|
-
expandAll?: boolean | undefined;
|
|
7
|
-
}) => Field[];
|
|
8
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
type LocalizedString = {
|
|
2
|
-
value: string;
|
|
3
|
-
locale: string;
|
|
4
|
-
};
|
|
5
|
-
type FieldType = {
|
|
6
|
-
name: string;
|
|
7
|
-
};
|
|
8
|
-
export type FieldDefinition = {
|
|
9
|
-
type: FieldType;
|
|
10
|
-
name: string;
|
|
11
|
-
labelAllLocales: LocalizedString[];
|
|
12
|
-
};
|
|
13
|
-
export type CustomTypeDefinition = {
|
|
14
|
-
key: string;
|
|
15
|
-
nameAllLocales: LocalizedString[];
|
|
16
|
-
fieldDefinitions: FieldDefinition[];
|
|
17
|
-
};
|
|
18
|
-
type TransformedFieldDefinition = {
|
|
19
|
-
type: {
|
|
20
|
-
name: string;
|
|
21
|
-
};
|
|
22
|
-
name: string;
|
|
23
|
-
label: {
|
|
24
|
-
value: string;
|
|
25
|
-
locale: string;
|
|
26
|
-
}[];
|
|
27
|
-
};
|
|
28
|
-
export type TransformedCustomTypeDefinition = {
|
|
29
|
-
type: {
|
|
30
|
-
key: string;
|
|
31
|
-
name: {
|
|
32
|
-
value: string;
|
|
33
|
-
locale: string;
|
|
34
|
-
}[];
|
|
35
|
-
};
|
|
36
|
-
fields: TransformedFieldDefinition[];
|
|
37
|
-
};
|
|
38
|
-
export {};
|