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
1 line
2.2 KiB
Plaintext
1 line
2.2 KiB
Plaintext
{"version":3,"file":"reduceFieldsToValuesWithValidation.js","names":["unflatten","flatleyUnflatten","reduceFieldsToValuesWithValidation","fields","ignoreDisableFormData","state","data","valid","Object","keys","forEach","key","disableFormData","value"],"sources":["../../src/utilities/reduceFieldsToValuesWithValidation.ts"],"sourcesContent":["import type { Data, FormState } from 'payload'\n\nimport { unflatten as flatleyUnflatten } from 'payload/shared'\n\ntype ReturnType = {\n data: Data\n valid: boolean\n}\n\n/**\n * Reduce flattened form fields (Fields) to just map to the respective values instead of the full FormField object\n *\n * @param unflatten This also unflattens the data if `unflatten` is true. The unflattened data should match the original data structure\n * @param ignoreDisableFormData - if true, will include fields that have `disableFormData` set to true, for example, blocks or arrays fields.\n *\n */\nexport const reduceFieldsToValuesWithValidation = (\n fields: FormState,\n unflatten?: boolean,\n ignoreDisableFormData?: boolean,\n): ReturnType => {\n const state: ReturnType = {\n data: {},\n valid: true,\n }\n\n if (!fields) {\n return state\n }\n\n Object.keys(fields).forEach((key) => {\n if (ignoreDisableFormData === true || !fields[key]?.disableFormData) {\n state.data[key] = fields[key]?.value\n if (!fields[key].valid) {\n state.valid = false\n }\n }\n })\n\n if (unflatten) {\n state.data = flatleyUnflatten(state.data)\n }\n\n return state\n}\n"],"mappings":"AAEA,SAASA,SAAA,IAAaC,gBAAgB,QAAQ;AAO9C;;;;;;;AAOA,OAAO,MAAMC,kCAAA,GAAqCA,CAChDC,MAAA,EACAH,SAAA,EACAI,qBAAA;EAEA,MAAMC,KAAA,GAAoB;IACxBC,IAAA,EAAM,CAAC;IACPC,KAAA,EAAO;EACT;EAEA,IAAI,CAACJ,MAAA,EAAQ;IACX,OAAOE,KAAA;EACT;EAEAG,MAAA,CAAOC,IAAI,CAACN,MAAA,EAAQO,OAAO,CAAEC,GAAA;IAC3B,IAAIP,qBAAA,KAA0B,QAAQ,CAACD,MAAM,CAACQ,GAAA,CAAI,EAAEC,eAAA,EAAiB;MACnEP,KAAA,CAAMC,IAAI,CAACK,GAAA,CAAI,GAAGR,MAAM,CAACQ,GAAA,CAAI,EAAEE,KAAA;MAC/B,IAAI,CAACV,MAAM,CAACQ,GAAA,CAAI,CAACJ,KAAK,EAAE;QACtBF,KAAA,CAAME,KAAK,GAAG;MAChB;IACF;EACF;EAEA,IAAIP,SAAA,EAAW;IACbK,KAAA,CAAMC,IAAI,GAAGL,gBAAA,CAAiBI,KAAA,CAAMC,IAAI;EAC1C;EAEA,OAAOD,KAAA;AACT","ignoreList":[]} |