@commercetools-frontend-extensions/export-resources-modal 5.15.0 → 5.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1603,7 +1603,10 @@ const updateFieldDependenciesStatus = formik => {
|
|
|
1603
1603
|
_forEachInstanceProperty__default["default"](fields).call(fields, (field, index) => {
|
|
1604
1604
|
const currentPath = `${path}.fields[${index}]`;
|
|
1605
1605
|
if (hasDependentFields(field)) {
|
|
1606
|
-
|
|
1606
|
+
const nextIsChecked = isAnyDependentChecked(_valuesInstanceProperty__default["default"](formik).groups, field.dependentGroupNames, field.dependentFieldNames);
|
|
1607
|
+
if (field.isChecked !== nextIsChecked) {
|
|
1608
|
+
formik.setFieldValue(`${currentPath}.isChecked`, nextIsChecked, false);
|
|
1609
|
+
}
|
|
1607
1610
|
}
|
|
1608
1611
|
if (field.fields) {
|
|
1609
1612
|
updateFields(field.fields, currentPath);
|
|
@@ -3255,23 +3258,18 @@ const ExportResourcesProvider = _ref => {
|
|
|
3255
3258
|
React__default["default"].useEffect(() => {
|
|
3256
3259
|
formik$1.validateForm();
|
|
3257
3260
|
}, [currentStep, fieldSelectionMode, importedHeaders, exportType]);
|
|
3258
|
-
|
|
3259
|
-
// The modal can be mounted before the data backing `fieldGroups` is ready
|
|
3260
|
-
// (the consumer opens it immediately and passes `isLoading`). Formik snapshots
|
|
3261
|
-
// the initial values once and does not reinitialize, so when the groups
|
|
3262
|
-
// arrive we set just the `groups` field — leaving any file settings the user
|
|
3263
|
-
// already changed on step 1 untouched. Guarded to run once, and only when the
|
|
3264
|
-
// form actually mounted without groups (a no-op for consumers that pass the
|
|
3265
|
-
// full `fieldGroups` upfront).
|
|
3261
|
+
const mountedWhileLoadingRef = React__default["default"].useRef(Boolean(props.isLoading));
|
|
3266
3262
|
const hasPopulatedFieldGroups = React__default["default"].useRef(false);
|
|
3267
3263
|
React__default["default"].useLayoutEffect(() => {
|
|
3268
|
-
if (hasPopulatedFieldGroups.current)
|
|
3269
|
-
|
|
3264
|
+
if (!mountedWhileLoadingRef.current || hasPopulatedFieldGroups.current) {
|
|
3265
|
+
return;
|
|
3266
|
+
}
|
|
3267
|
+
if (!props.isLoading && initialValues.groups.length > 0) {
|
|
3270
3268
|
formik$1.setFieldValue('groups', initialValues.groups);
|
|
3271
3269
|
hasPopulatedFieldGroups.current = true;
|
|
3272
3270
|
}
|
|
3273
3271
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3274
|
-
}, [initialValues.groups]);
|
|
3272
|
+
}, [props.isLoading, initialValues.groups]);
|
|
3275
3273
|
return jsxRuntime.jsx(ExportResourcesContext.Provider, {
|
|
3276
3274
|
value: {
|
|
3277
3275
|
formik: formik$1,
|
|
@@ -3346,7 +3344,7 @@ const FieldsPreview = _ref => {
|
|
|
3346
3344
|
};
|
|
3347
3345
|
|
|
3348
3346
|
function ownKeys$3(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; }
|
|
3349
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
3347
|
+
function _objectSpread$3(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$3(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$3(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
3350
3348
|
const ExportConfirmationStep = () => {
|
|
3351
3349
|
const intl = reactIntl.useIntl();
|
|
3352
3350
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
@@ -3360,10 +3358,16 @@ const ExportConfirmationStep = () => {
|
|
|
3360
3358
|
localeOption = _useExportResourcesMo.localeOption,
|
|
3361
3359
|
setCurrentStep = _useExportResourcesMo.setCurrentStep,
|
|
3362
3360
|
onClose = _useExportResourcesMo.onClose;
|
|
3363
|
-
const groupsWithSelectedFields = getGroupsWithSelectedFields(_valuesInstanceProperty__default["default"](formik).groups);
|
|
3364
3361
|
const isUsingImportedCsvTemplate = fieldSelectionMode === 'imported-csv-template';
|
|
3365
3362
|
const isUsingImportedCsvLocales = localeOption === 'onlyLocalesFoundInCsvFile';
|
|
3366
|
-
const
|
|
3363
|
+
const selectedFieldsByGroup = React.useMemo(() => {
|
|
3364
|
+
var _context;
|
|
3365
|
+
return _mapInstanceProperty__default["default"](_context = getGroupsWithSelectedFields(_valuesInstanceProperty__default["default"](formik).groups)).call(_context, group => ({
|
|
3366
|
+
group,
|
|
3367
|
+
fields: getSelectedFieldLabels(group)
|
|
3368
|
+
}));
|
|
3369
|
+
}, [_valuesInstanceProperty__default["default"](formik).groups]);
|
|
3370
|
+
const allSelectedFieldCount = React.useMemo(() => isUsingImportedCsvTemplate ? importedHeaders.length : getAllSelectedFieldCount(_valuesInstanceProperty__default["default"](formik).groups), [isUsingImportedCsvTemplate, importedHeaders, _valuesInstanceProperty__default["default"](formik).groups]);
|
|
3367
3371
|
const returnToFieldsSelection = () => setCurrentStep(Step.FieldsSelection);
|
|
3368
3372
|
return jsxRuntime.jsx(applicationComponents.FormDialog, {
|
|
3369
3373
|
isOpen: true,
|
|
@@ -3410,11 +3414,12 @@ const ExportConfirmationStep = () => {
|
|
|
3410
3414
|
})]
|
|
3411
3415
|
}), isUsingImportedCsvTemplate ? jsxRuntime.jsx(FieldsPreview, {
|
|
3412
3416
|
fields: importedHeaders
|
|
3413
|
-
}) : _mapInstanceProperty__default["default"](
|
|
3414
|
-
|
|
3417
|
+
}) : _mapInstanceProperty__default["default"](selectedFieldsByGroup).call(selectedFieldsByGroup, _ref => {
|
|
3418
|
+
let group = _ref.group,
|
|
3419
|
+
fields = _ref.fields;
|
|
3415
3420
|
return jsxRuntime.jsx(FieldsPreview, {
|
|
3416
3421
|
previewGroupLabel: group.previewGroupLabel,
|
|
3417
|
-
fields:
|
|
3422
|
+
fields: fields
|
|
3418
3423
|
}, group.groupName);
|
|
3419
3424
|
})]
|
|
3420
3425
|
})
|
|
@@ -1603,7 +1603,10 @@ const updateFieldDependenciesStatus = formik => {
|
|
|
1603
1603
|
_forEachInstanceProperty__default["default"](fields).call(fields, (field, index) => {
|
|
1604
1604
|
const currentPath = `${path}.fields[${index}]`;
|
|
1605
1605
|
if (hasDependentFields(field)) {
|
|
1606
|
-
|
|
1606
|
+
const nextIsChecked = isAnyDependentChecked(_valuesInstanceProperty__default["default"](formik).groups, field.dependentGroupNames, field.dependentFieldNames);
|
|
1607
|
+
if (field.isChecked !== nextIsChecked) {
|
|
1608
|
+
formik.setFieldValue(`${currentPath}.isChecked`, nextIsChecked, false);
|
|
1609
|
+
}
|
|
1607
1610
|
}
|
|
1608
1611
|
if (field.fields) {
|
|
1609
1612
|
updateFields(field.fields, currentPath);
|
|
@@ -3222,23 +3225,18 @@ const ExportResourcesProvider = _ref => {
|
|
|
3222
3225
|
React__default["default"].useEffect(() => {
|
|
3223
3226
|
formik$1.validateForm();
|
|
3224
3227
|
}, [currentStep, fieldSelectionMode, importedHeaders, exportType]);
|
|
3225
|
-
|
|
3226
|
-
// The modal can be mounted before the data backing `fieldGroups` is ready
|
|
3227
|
-
// (the consumer opens it immediately and passes `isLoading`). Formik snapshots
|
|
3228
|
-
// the initial values once and does not reinitialize, so when the groups
|
|
3229
|
-
// arrive we set just the `groups` field — leaving any file settings the user
|
|
3230
|
-
// already changed on step 1 untouched. Guarded to run once, and only when the
|
|
3231
|
-
// form actually mounted without groups (a no-op for consumers that pass the
|
|
3232
|
-
// full `fieldGroups` upfront).
|
|
3228
|
+
const mountedWhileLoadingRef = React__default["default"].useRef(Boolean(props.isLoading));
|
|
3233
3229
|
const hasPopulatedFieldGroups = React__default["default"].useRef(false);
|
|
3234
3230
|
React__default["default"].useLayoutEffect(() => {
|
|
3235
|
-
if (hasPopulatedFieldGroups.current)
|
|
3236
|
-
|
|
3231
|
+
if (!mountedWhileLoadingRef.current || hasPopulatedFieldGroups.current) {
|
|
3232
|
+
return;
|
|
3233
|
+
}
|
|
3234
|
+
if (!props.isLoading && initialValues.groups.length > 0) {
|
|
3237
3235
|
formik$1.setFieldValue('groups', initialValues.groups);
|
|
3238
3236
|
hasPopulatedFieldGroups.current = true;
|
|
3239
3237
|
}
|
|
3240
3238
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3241
|
-
}, [initialValues.groups]);
|
|
3239
|
+
}, [props.isLoading, initialValues.groups]);
|
|
3242
3240
|
return jsxRuntime.jsx(ExportResourcesContext.Provider, {
|
|
3243
3241
|
value: {
|
|
3244
3242
|
formik: formik$1,
|
|
@@ -3313,7 +3311,7 @@ const FieldsPreview = _ref => {
|
|
|
3313
3311
|
};
|
|
3314
3312
|
|
|
3315
3313
|
function ownKeys$3(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; }
|
|
3316
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
3314
|
+
function _objectSpread$3(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$3(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$3(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
3317
3315
|
const ExportConfirmationStep = () => {
|
|
3318
3316
|
const intl = reactIntl.useIntl();
|
|
3319
3317
|
const _useApplicationContex = applicationShellConnectors.useApplicationContext(applicationContext => ({
|
|
@@ -3327,10 +3325,16 @@ const ExportConfirmationStep = () => {
|
|
|
3327
3325
|
localeOption = _useExportResourcesMo.localeOption,
|
|
3328
3326
|
setCurrentStep = _useExportResourcesMo.setCurrentStep,
|
|
3329
3327
|
onClose = _useExportResourcesMo.onClose;
|
|
3330
|
-
const groupsWithSelectedFields = getGroupsWithSelectedFields(_valuesInstanceProperty__default["default"](formik).groups);
|
|
3331
3328
|
const isUsingImportedCsvTemplate = fieldSelectionMode === 'imported-csv-template';
|
|
3332
3329
|
const isUsingImportedCsvLocales = localeOption === 'onlyLocalesFoundInCsvFile';
|
|
3333
|
-
const
|
|
3330
|
+
const selectedFieldsByGroup = React.useMemo(() => {
|
|
3331
|
+
var _context;
|
|
3332
|
+
return _mapInstanceProperty__default["default"](_context = getGroupsWithSelectedFields(_valuesInstanceProperty__default["default"](formik).groups)).call(_context, group => ({
|
|
3333
|
+
group,
|
|
3334
|
+
fields: getSelectedFieldLabels(group)
|
|
3335
|
+
}));
|
|
3336
|
+
}, [_valuesInstanceProperty__default["default"](formik).groups]);
|
|
3337
|
+
const allSelectedFieldCount = React.useMemo(() => isUsingImportedCsvTemplate ? importedHeaders.length : getAllSelectedFieldCount(_valuesInstanceProperty__default["default"](formik).groups), [isUsingImportedCsvTemplate, importedHeaders, _valuesInstanceProperty__default["default"](formik).groups]);
|
|
3334
3338
|
const returnToFieldsSelection = () => setCurrentStep(Step.FieldsSelection);
|
|
3335
3339
|
return jsxRuntime.jsx(applicationComponents.FormDialog, {
|
|
3336
3340
|
isOpen: true,
|
|
@@ -3377,11 +3381,12 @@ const ExportConfirmationStep = () => {
|
|
|
3377
3381
|
})]
|
|
3378
3382
|
}), isUsingImportedCsvTemplate ? jsxRuntime.jsx(FieldsPreview, {
|
|
3379
3383
|
fields: importedHeaders
|
|
3380
|
-
}) : _mapInstanceProperty__default["default"](
|
|
3381
|
-
|
|
3384
|
+
}) : _mapInstanceProperty__default["default"](selectedFieldsByGroup).call(selectedFieldsByGroup, _ref => {
|
|
3385
|
+
let group = _ref.group,
|
|
3386
|
+
fields = _ref.fields;
|
|
3382
3387
|
return jsxRuntime.jsx(FieldsPreview, {
|
|
3383
3388
|
previewGroupLabel: group.previewGroupLabel,
|
|
3384
|
-
fields:
|
|
3389
|
+
fields: fields
|
|
3385
3390
|
}, group.groupName);
|
|
3386
3391
|
})]
|
|
3387
3392
|
})
|
|
@@ -1560,7 +1560,10 @@ const updateFieldDependenciesStatus = formik => {
|
|
|
1560
1560
|
_forEachInstanceProperty(fields).call(fields, (field, index) => {
|
|
1561
1561
|
const currentPath = `${path}.fields[${index}]`;
|
|
1562
1562
|
if (hasDependentFields(field)) {
|
|
1563
|
-
|
|
1563
|
+
const nextIsChecked = isAnyDependentChecked(_valuesInstanceProperty(formik).groups, field.dependentGroupNames, field.dependentFieldNames);
|
|
1564
|
+
if (field.isChecked !== nextIsChecked) {
|
|
1565
|
+
formik.setFieldValue(`${currentPath}.isChecked`, nextIsChecked, false);
|
|
1566
|
+
}
|
|
1564
1567
|
}
|
|
1565
1568
|
if (field.fields) {
|
|
1566
1569
|
updateFields(field.fields, currentPath);
|
|
@@ -3212,23 +3215,18 @@ const ExportResourcesProvider = _ref => {
|
|
|
3212
3215
|
React.useEffect(() => {
|
|
3213
3216
|
formik.validateForm();
|
|
3214
3217
|
}, [currentStep, fieldSelectionMode, importedHeaders, exportType]);
|
|
3215
|
-
|
|
3216
|
-
// The modal can be mounted before the data backing `fieldGroups` is ready
|
|
3217
|
-
// (the consumer opens it immediately and passes `isLoading`). Formik snapshots
|
|
3218
|
-
// the initial values once and does not reinitialize, so when the groups
|
|
3219
|
-
// arrive we set just the `groups` field — leaving any file settings the user
|
|
3220
|
-
// already changed on step 1 untouched. Guarded to run once, and only when the
|
|
3221
|
-
// form actually mounted without groups (a no-op for consumers that pass the
|
|
3222
|
-
// full `fieldGroups` upfront).
|
|
3218
|
+
const mountedWhileLoadingRef = React.useRef(Boolean(props.isLoading));
|
|
3223
3219
|
const hasPopulatedFieldGroups = React.useRef(false);
|
|
3224
3220
|
React.useLayoutEffect(() => {
|
|
3225
|
-
if (hasPopulatedFieldGroups.current)
|
|
3226
|
-
|
|
3221
|
+
if (!mountedWhileLoadingRef.current || hasPopulatedFieldGroups.current) {
|
|
3222
|
+
return;
|
|
3223
|
+
}
|
|
3224
|
+
if (!props.isLoading && initialValues.groups.length > 0) {
|
|
3227
3225
|
formik.setFieldValue('groups', initialValues.groups);
|
|
3228
3226
|
hasPopulatedFieldGroups.current = true;
|
|
3229
3227
|
}
|
|
3230
3228
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3231
|
-
}, [initialValues.groups]);
|
|
3229
|
+
}, [props.isLoading, initialValues.groups]);
|
|
3232
3230
|
return jsx(ExportResourcesContext.Provider, {
|
|
3233
3231
|
value: {
|
|
3234
3232
|
formik,
|
|
@@ -3303,7 +3301,7 @@ const FieldsPreview = _ref => {
|
|
|
3303
3301
|
};
|
|
3304
3302
|
|
|
3305
3303
|
function ownKeys$3(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; }
|
|
3306
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
3304
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$3(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$3(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3307
3305
|
const ExportConfirmationStep = () => {
|
|
3308
3306
|
const intl = useIntl();
|
|
3309
3307
|
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
@@ -3317,10 +3315,16 @@ const ExportConfirmationStep = () => {
|
|
|
3317
3315
|
localeOption = _useExportResourcesMo.localeOption,
|
|
3318
3316
|
setCurrentStep = _useExportResourcesMo.setCurrentStep,
|
|
3319
3317
|
onClose = _useExportResourcesMo.onClose;
|
|
3320
|
-
const groupsWithSelectedFields = getGroupsWithSelectedFields(_valuesInstanceProperty(formik).groups);
|
|
3321
3318
|
const isUsingImportedCsvTemplate = fieldSelectionMode === 'imported-csv-template';
|
|
3322
3319
|
const isUsingImportedCsvLocales = localeOption === 'onlyLocalesFoundInCsvFile';
|
|
3323
|
-
const
|
|
3320
|
+
const selectedFieldsByGroup = useMemo(() => {
|
|
3321
|
+
var _context;
|
|
3322
|
+
return _mapInstanceProperty(_context = getGroupsWithSelectedFields(_valuesInstanceProperty(formik).groups)).call(_context, group => ({
|
|
3323
|
+
group,
|
|
3324
|
+
fields: getSelectedFieldLabels(group)
|
|
3325
|
+
}));
|
|
3326
|
+
}, [_valuesInstanceProperty(formik).groups]);
|
|
3327
|
+
const allSelectedFieldCount = useMemo(() => isUsingImportedCsvTemplate ? importedHeaders.length : getAllSelectedFieldCount(_valuesInstanceProperty(formik).groups), [isUsingImportedCsvTemplate, importedHeaders, _valuesInstanceProperty(formik).groups]);
|
|
3324
3328
|
const returnToFieldsSelection = () => setCurrentStep(Step.FieldsSelection);
|
|
3325
3329
|
return jsx(FormDialog, {
|
|
3326
3330
|
isOpen: true,
|
|
@@ -3367,11 +3371,12 @@ const ExportConfirmationStep = () => {
|
|
|
3367
3371
|
})]
|
|
3368
3372
|
}), isUsingImportedCsvTemplate ? jsx(FieldsPreview, {
|
|
3369
3373
|
fields: importedHeaders
|
|
3370
|
-
}) : _mapInstanceProperty(
|
|
3371
|
-
|
|
3374
|
+
}) : _mapInstanceProperty(selectedFieldsByGroup).call(selectedFieldsByGroup, _ref => {
|
|
3375
|
+
let group = _ref.group,
|
|
3376
|
+
fields = _ref.fields;
|
|
3372
3377
|
return jsx(FieldsPreview, {
|
|
3373
3378
|
previewGroupLabel: group.previewGroupLabel,
|
|
3374
|
-
fields:
|
|
3379
|
+
fields: fields
|
|
3375
3380
|
}, group.groupName);
|
|
3376
3381
|
})]
|
|
3377
3382
|
})
|
package/package.json
CHANGED