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.6 KiB
Plaintext
1 line
2.6 KiB
Plaintext
{"version":3,"file":"rows.js","names":["separateRows","path","fields","remainingFields","rows","Object","entries","reduce","incomingRows","fieldPath","field","newRows","indexOf","rowIndex","replace","split","String","flattenRows","row","i","subFields","subPath","subField"],"sources":["../../../src/forms/Form/rows.ts"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\ntype Result = {\n remainingFields: FormState\n rows: FormState[]\n}\n\nexport const separateRows = (path: string, fields: FormState): Result => {\n const remainingFields: FormState = {}\n\n const rows = Object.entries(fields).reduce((incomingRows, [fieldPath, field]) => {\n const newRows = incomingRows\n\n if (fieldPath.indexOf(`${path}.`) === 0) {\n const [rowIndex] = fieldPath.replace(`${path}.`, '').split('.')\n if (!newRows[rowIndex]) {\n newRows[rowIndex] = {}\n }\n newRows[rowIndex][fieldPath.replace(`${path}.${String(rowIndex)}.`, '')] = { ...field }\n } else {\n remainingFields[fieldPath] = field\n }\n\n return newRows\n }, [])\n\n return {\n remainingFields,\n rows,\n }\n}\n\nexport const flattenRows = (path: string, rows: FormState[]): FormState => {\n return rows.reduce(\n (fields, row, i) => ({\n ...fields,\n ...Object.entries(row).reduce((subFields, [subPath, subField]) => {\n return {\n ...subFields,\n [`${path}.${i}.${subPath}`]: { ...subField },\n }\n }, {}),\n }),\n {},\n )\n}\n"],"mappings":"AAAA;;AAQA,OAAO,MAAMA,YAAA,GAAeA,CAACC,IAAA,EAAcC,MAAA;EACzC,MAAMC,eAAA,GAA6B,CAAC;EAEpC,MAAMC,IAAA,GAAOC,MAAA,CAAOC,OAAO,CAACJ,MAAA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