@commercetools-frontend-extensions/export-resources-modal 0.0.0-canary-20240906151917 → 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 +49 -51
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +49 -51
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +49 -51
- 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 +1 -1
- package/dist/declarations/src/@hooks/use-convert-type-definitions-for-export.d.ts +0 -8
- package/dist/declarations/src/@types/type-definition.d.ts +0 -22
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,9 +1031,9 @@ 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
|
|
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
1037
|
const getFieldFullName = _ref => {
|
|
1038
1038
|
var _context;
|
|
1039
1039
|
let fieldPrefix = _ref.fieldPrefix,
|
|
@@ -1041,76 +1041,74 @@ const getFieldFullName = _ref => {
|
|
|
1041
1041
|
return _filterInstanceProperty__default["default"](_context = [fieldPrefix, fieldName]).call(_context, Boolean).join('.');
|
|
1042
1042
|
};
|
|
1043
1043
|
const localizeTypeDefinitionLabels = function () {
|
|
1044
|
-
let
|
|
1045
|
-
return _mapInstanceProperty__default["default"](
|
|
1046
|
-
let
|
|
1047
|
-
|
|
1048
|
-
const
|
|
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
|
-
|
|
1050
|
+
name: fieldsType.name,
|
|
1051
|
+
label: isFieldTypeLabelLocalized ? l10n.applyTransformedLocalizedFields(fieldsType, [{
|
|
1051
1052
|
from: 'label',
|
|
1052
1053
|
to: 'label'
|
|
1053
|
-
}]) :
|
|
1054
|
-
fields:
|
|
1055
|
-
const isFieldLabelLocalized = _Array$isArray__default["default"](
|
|
1054
|
+
}]).label : fieldsType.label,
|
|
1055
|
+
fields: fields?.map(field => {
|
|
1056
|
+
const isFieldLabelLocalized = _Array$isArray__default["default"](field.label);
|
|
1056
1057
|
if (!isFieldLabelLocalized) {
|
|
1057
|
-
return
|
|
1058
|
+
return field;
|
|
1058
1059
|
}
|
|
1059
|
-
return _objectSpread$5({}, l10n.applyTransformedLocalizedFields(
|
|
1060
|
+
return _objectSpread$5({}, l10n.applyTransformedLocalizedFields(field, [{
|
|
1060
1061
|
from: 'label',
|
|
1061
1062
|
to: 'label'
|
|
1062
1063
|
}]));
|
|
1063
|
-
})
|
|
1064
|
+
}) || []
|
|
1064
1065
|
};
|
|
1065
1066
|
});
|
|
1066
1067
|
};
|
|
1067
|
-
const
|
|
1068
|
+
const useConvertFieldDefinitionsForExport = () => {
|
|
1068
1069
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
1069
1070
|
language: applicationContext.dataLocale,
|
|
1070
1071
|
languages: applicationContext.project?.languages
|
|
1071
1072
|
})),
|
|
1072
1073
|
language = _useApplicationContex.language,
|
|
1073
1074
|
languages = _useApplicationContex.languages;
|
|
1074
|
-
const
|
|
1075
|
-
let
|
|
1075
|
+
const convertFieldDefinitionsForExport = _ref3 => {
|
|
1076
|
+
let fieldDefinitions = _ref3.fieldDefinitions,
|
|
1076
1077
|
fieldPrefix = _ref3.fieldPrefix,
|
|
1077
1078
|
_ref3$expandAll = _ref3.expandAll,
|
|
1078
1079
|
expandAll = _ref3$expandAll === void 0 ? false : _ref3$expandAll;
|
|
1079
|
-
if (!
|
|
1080
|
-
const
|
|
1081
|
-
return _mapInstanceProperty__default["default"](
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
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
|
+
}),
|
|
1087
1099
|
label: l10n.formatLocalizedString({
|
|
1088
|
-
label:
|
|
1100
|
+
label: fieldDefinition.label
|
|
1089
1101
|
}, {
|
|
1090
1102
|
key: 'label',
|
|
1091
1103
|
locale: language,
|
|
1092
1104
|
fallbackOrder: languages,
|
|
1093
|
-
fallback:
|
|
1094
|
-
})
|
|
1095
|
-
|
|
1096
|
-
|
|
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
|
-
});
|
|
1105
|
+
fallback: fieldDefinition.name
|
|
1106
|
+
})
|
|
1107
|
+
}))
|
|
1108
|
+
}));
|
|
1111
1109
|
};
|
|
1112
1110
|
return {
|
|
1113
|
-
|
|
1111
|
+
convertFieldDefinitionsForExport
|
|
1114
1112
|
};
|
|
1115
1113
|
};
|
|
1116
1114
|
|
|
@@ -1946,4 +1944,4 @@ ExportResourcesModal.defaultProps = {
|
|
|
1946
1944
|
exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
|
|
1947
1945
|
exports.EXPORT_TYPES = EXPORT_TYPES;
|
|
1948
1946
|
exports["default"] = ExportResourcesModal;
|
|
1949
|
-
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,9 +1031,9 @@ 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
|
|
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
1037
|
const getFieldFullName = _ref => {
|
|
1038
1038
|
var _context;
|
|
1039
1039
|
let fieldPrefix = _ref.fieldPrefix,
|
|
@@ -1041,76 +1041,74 @@ const getFieldFullName = _ref => {
|
|
|
1041
1041
|
return _filterInstanceProperty__default["default"](_context = [fieldPrefix, fieldName]).call(_context, Boolean).join('.');
|
|
1042
1042
|
};
|
|
1043
1043
|
const localizeTypeDefinitionLabels = function () {
|
|
1044
|
-
let
|
|
1045
|
-
return _mapInstanceProperty__default["default"](
|
|
1046
|
-
let
|
|
1047
|
-
|
|
1048
|
-
const
|
|
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
|
-
|
|
1050
|
+
name: fieldsType.name,
|
|
1051
|
+
label: isFieldTypeLabelLocalized ? l10n.applyTransformedLocalizedFields(fieldsType, [{
|
|
1051
1052
|
from: 'label',
|
|
1052
1053
|
to: 'label'
|
|
1053
|
-
}]) :
|
|
1054
|
-
fields:
|
|
1055
|
-
const isFieldLabelLocalized = _Array$isArray__default["default"](
|
|
1054
|
+
}]).label : fieldsType.label,
|
|
1055
|
+
fields: fields?.map(field => {
|
|
1056
|
+
const isFieldLabelLocalized = _Array$isArray__default["default"](field.label);
|
|
1056
1057
|
if (!isFieldLabelLocalized) {
|
|
1057
|
-
return
|
|
1058
|
+
return field;
|
|
1058
1059
|
}
|
|
1059
|
-
return _objectSpread$5({}, l10n.applyTransformedLocalizedFields(
|
|
1060
|
+
return _objectSpread$5({}, l10n.applyTransformedLocalizedFields(field, [{
|
|
1060
1061
|
from: 'label',
|
|
1061
1062
|
to: 'label'
|
|
1062
1063
|
}]));
|
|
1063
|
-
})
|
|
1064
|
+
}) || []
|
|
1064
1065
|
};
|
|
1065
1066
|
});
|
|
1066
1067
|
};
|
|
1067
|
-
const
|
|
1068
|
+
const useConvertFieldDefinitionsForExport = () => {
|
|
1068
1069
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
1069
1070
|
language: applicationContext.dataLocale,
|
|
1070
1071
|
languages: applicationContext.project?.languages
|
|
1071
1072
|
})),
|
|
1072
1073
|
language = _useApplicationContex.language,
|
|
1073
1074
|
languages = _useApplicationContex.languages;
|
|
1074
|
-
const
|
|
1075
|
-
let
|
|
1075
|
+
const convertFieldDefinitionsForExport = _ref3 => {
|
|
1076
|
+
let fieldDefinitions = _ref3.fieldDefinitions,
|
|
1076
1077
|
fieldPrefix = _ref3.fieldPrefix,
|
|
1077
1078
|
_ref3$expandAll = _ref3.expandAll,
|
|
1078
1079
|
expandAll = _ref3$expandAll === void 0 ? false : _ref3$expandAll;
|
|
1079
|
-
if (!
|
|
1080
|
-
const
|
|
1081
|
-
return _mapInstanceProperty__default["default"](
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
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
|
+
}),
|
|
1087
1099
|
label: l10n.formatLocalizedString({
|
|
1088
|
-
label:
|
|
1100
|
+
label: fieldDefinition.label
|
|
1089
1101
|
}, {
|
|
1090
1102
|
key: 'label',
|
|
1091
1103
|
locale: language,
|
|
1092
1104
|
fallbackOrder: languages,
|
|
1093
|
-
fallback:
|
|
1094
|
-
})
|
|
1095
|
-
|
|
1096
|
-
|
|
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
|
-
});
|
|
1105
|
+
fallback: fieldDefinition.name
|
|
1106
|
+
})
|
|
1107
|
+
}))
|
|
1108
|
+
}));
|
|
1111
1109
|
};
|
|
1112
1110
|
return {
|
|
1113
|
-
|
|
1111
|
+
convertFieldDefinitionsForExport
|
|
1114
1112
|
};
|
|
1115
1113
|
};
|
|
1116
1114
|
|
|
@@ -1913,4 +1911,4 @@ ExportResourcesModal.defaultProps = {
|
|
|
1913
1911
|
exports.EXPORTABLE_RESOURCES = EXPORTABLE_RESOURCES;
|
|
1914
1912
|
exports.EXPORT_TYPES = EXPORT_TYPES;
|
|
1915
1913
|
exports["default"] = ExportResourcesModal;
|
|
1916
|
-
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,9 +997,9 @@ 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
|
|
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
1003
|
const getFieldFullName = _ref => {
|
|
1004
1004
|
var _context;
|
|
1005
1005
|
let fieldPrefix = _ref.fieldPrefix,
|
|
@@ -1007,76 +1007,74 @@ const getFieldFullName = _ref => {
|
|
|
1007
1007
|
return _filterInstanceProperty(_context = [fieldPrefix, fieldName]).call(_context, Boolean).join('.');
|
|
1008
1008
|
};
|
|
1009
1009
|
const localizeTypeDefinitionLabels = function () {
|
|
1010
|
-
let
|
|
1011
|
-
return _mapInstanceProperty(
|
|
1012
|
-
let
|
|
1013
|
-
|
|
1014
|
-
const
|
|
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
|
-
|
|
1016
|
+
name: fieldsType.name,
|
|
1017
|
+
label: isFieldTypeLabelLocalized ? applyTransformedLocalizedFields(fieldsType, [{
|
|
1017
1018
|
from: 'label',
|
|
1018
1019
|
to: 'label'
|
|
1019
|
-
}]) :
|
|
1020
|
-
fields:
|
|
1021
|
-
const isFieldLabelLocalized = _Array$isArray(
|
|
1020
|
+
}]).label : fieldsType.label,
|
|
1021
|
+
fields: fields?.map(field => {
|
|
1022
|
+
const isFieldLabelLocalized = _Array$isArray(field.label);
|
|
1022
1023
|
if (!isFieldLabelLocalized) {
|
|
1023
|
-
return
|
|
1024
|
+
return field;
|
|
1024
1025
|
}
|
|
1025
|
-
return _objectSpread$5({}, applyTransformedLocalizedFields(
|
|
1026
|
+
return _objectSpread$5({}, applyTransformedLocalizedFields(field, [{
|
|
1026
1027
|
from: 'label',
|
|
1027
1028
|
to: 'label'
|
|
1028
1029
|
}]));
|
|
1029
|
-
})
|
|
1030
|
+
}) || []
|
|
1030
1031
|
};
|
|
1031
1032
|
});
|
|
1032
1033
|
};
|
|
1033
|
-
const
|
|
1034
|
+
const useConvertFieldDefinitionsForExport = () => {
|
|
1034
1035
|
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
1035
1036
|
language: applicationContext.dataLocale,
|
|
1036
1037
|
languages: applicationContext.project?.languages
|
|
1037
1038
|
})),
|
|
1038
1039
|
language = _useApplicationContex.language,
|
|
1039
1040
|
languages = _useApplicationContex.languages;
|
|
1040
|
-
const
|
|
1041
|
-
let
|
|
1041
|
+
const convertFieldDefinitionsForExport = _ref3 => {
|
|
1042
|
+
let fieldDefinitions = _ref3.fieldDefinitions,
|
|
1042
1043
|
fieldPrefix = _ref3.fieldPrefix,
|
|
1043
1044
|
_ref3$expandAll = _ref3.expandAll,
|
|
1044
1045
|
expandAll = _ref3$expandAll === void 0 ? false : _ref3$expandAll;
|
|
1045
|
-
if (!
|
|
1046
|
-
const
|
|
1047
|
-
return _mapInstanceProperty(
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
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
|
+
}),
|
|
1053
1065
|
label: formatLocalizedString({
|
|
1054
|
-
label:
|
|
1066
|
+
label: fieldDefinition.label
|
|
1055
1067
|
}, {
|
|
1056
1068
|
key: 'label',
|
|
1057
1069
|
locale: language,
|
|
1058
1070
|
fallbackOrder: languages,
|
|
1059
|
-
fallback:
|
|
1060
|
-
})
|
|
1061
|
-
|
|
1062
|
-
|
|
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
|
-
});
|
|
1071
|
+
fallback: fieldDefinition.name
|
|
1072
|
+
})
|
|
1073
|
+
}))
|
|
1074
|
+
}));
|
|
1077
1075
|
};
|
|
1078
1076
|
return {
|
|
1079
|
-
|
|
1077
|
+
convertFieldDefinitionsForExport
|
|
1080
1078
|
};
|
|
1081
1079
|
};
|
|
1082
1080
|
|
|
@@ -1909,4 +1907,4 @@ ExportResourcesModal.defaultProps = {
|
|
|
1909
1907
|
fieldOrder: []
|
|
1910
1908
|
};
|
|
1911
1909
|
|
|
1912
|
-
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"
|
|
@@ -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 {};
|