Files
klz-cables.com/.pnpm-store/v10/files/fd/2ebda604bcd419a9d5ed67df595c5f3e39bdc8e07d1414f6c13f248b570a18735fea86426a30e560e9b7d66b07c909df0a99915bdc8cac6852acd347b5a984
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

85 lines
2.0 KiB
Plaintext

import { calculateDefaultValues } from './calculateDefaultValues/index.js';
import { iterateFields } from './iterateFields.js';
export const fieldSchemasToFormState = async ({
id,
clientFieldSchemaMap,
collectionSlug,
data = {},
documentData,
fields,
fieldSchemaMap,
initialBlockData,
mockRSCs,
operation,
permissions,
preferences,
previousFormState,
readOnly,
renderAllFields,
renderFieldFn,
req,
schemaPath,
select,
selectMode,
skipValidation
}) => {
if (!clientFieldSchemaMap && renderFieldFn) {
// eslint-disable-next-line no-console
console.warn('clientFieldSchemaMap is not passed to fieldSchemasToFormState - this will reduce performance');
}
if (fields && fields.length) {
const state = {};
const dataWithDefaultValues = {
...data
};
await calculateDefaultValues({
id,
data: dataWithDefaultValues,
fields,
locale: req.locale,
req,
select,
selectMode,
siblingData: dataWithDefaultValues,
user: req.user
});
let fullData = dataWithDefaultValues;
if (documentData) {
// By the time this function is used to get form state for nested forms, their default values should have already been calculated
// => no need to run calculateDefaultValues here
fullData = documentData;
}
await iterateFields({
id,
addErrorPathToParent: null,
blockData: initialBlockData,
clientFieldSchemaMap,
collectionSlug,
data: dataWithDefaultValues,
fields,
fieldSchemaMap,
fullData,
mockRSCs,
operation,
parentIndexPath: '',
parentPassesCondition: true,
parentPath: '',
parentSchemaPath: schemaPath,
permissions,
preferences,
previousFormState,
readOnly,
renderAllFields,
renderFieldFn,
req,
select,
selectMode,
skipValidation,
state
});
return state;
}
return {};
};
export { iterateFields };
//# sourceMappingURL=index.js.map