diff --git a/src/services/pmsGrid/GridPinnedCalculator.js b/src/services/pmsGrid/GridPinnedCalculator.js new file mode 100644 index 00000000..729f2768 --- /dev/null +++ b/src/services/pmsGrid/GridPinnedCalculator.js @@ -0,0 +1,40 @@ +// GridPinnedCalculator.js +export function computeLeftOffsets(colState) { + const ordered = colState + .filter((c) => c.visible) + .sort((a, b) => a.order - b.order); + + let offset = 0; + const map = {}; + + for (const col of ordered) { + if (col.pinned === "left") { + map[col.key] = offset; + offset += col.width || 120; + } else { + map[col.key] = null; // not pinned-left + } + } + + return map; +} + +export function computeRightOffsets(colState) { + const ordered = colState + .filter((c) => c.visible) + .sort((a, b) => b.order - a.order); + + let offset = 0; + const map = {}; + + for (const col of ordered) { + if (col.pinned === "right") { + map[col.key] = offset; + offset += col.width || 120; + } else { + map[col.key] = null; // not pinned-right + } + } + + return map; +}