Files
klz-cables.com/.pnpm-store/v10/files/70/ac4fec94fe27d855be870f46dca69bd3e33e8743d2c60975aa0c12db6a3dd5b6a3373bd4652f474aca0736ca4bfd501e89a32734d8fe3f3cbe11838a3138d8
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

35 lines
1.4 KiB
Plaintext

import { reduceFieldsToValues } from './reduceFieldsToValues.js';
import { unflatten } from './unflatten.js';
export const getSiblingData = (fields, path)=>{
if (!fields) {
return null;
}
if (path.indexOf('.') === -1) {
return reduceFieldsToValues(fields, true);
}
const siblingFields = {};
// Determine if the last segment of the path is an array-based row
const pathSegments = path.split('.');
const lastSegment = pathSegments[pathSegments.length - 1];
const lastSegmentIsRowIndex = !Number.isNaN(Number(lastSegment));
let parentFieldPath;
if (lastSegmentIsRowIndex) {
// If the last segment is a row index,
// the sibling data is that row's contents
// so create a parent field path that will
// retrieve all contents of that row index only
parentFieldPath = `${path}.`;
} else {
// Otherwise, the last path segment is a field name
// and it should be removed
parentFieldPath = path.substring(0, path.lastIndexOf('.') + 1);
}
Object.keys(fields).forEach((fieldKey)=>{
if (!fields[fieldKey]?.disableFormData && fieldKey.indexOf(parentFieldPath) === 0) {
siblingFields[fieldKey.replace(parentFieldPath, '')] = fields[fieldKey]?.value;
}
});
return unflatten(siblingFields);
};
//# sourceMappingURL=getSiblingData.js.map