From 7b0659e820c27bfb9ac3db8c719a3206f0f9fce8 Mon Sep 17 00:00:00 2001 From: "pramod.mahajan" Date: Sun, 9 Nov 2025 22:39:30 +0530 Subject: [PATCH] upgrade pms action cell --- src/services/pmsGrid/PmsGrid.jsx | 237 ++++++++++++++++++------------ src/services/pmsGrid/pms-grid.css | 4 +- 2 files changed, 142 insertions(+), 99 deletions(-) diff --git a/src/services/pmsGrid/PmsGrid.jsx b/src/services/pmsGrid/PmsGrid.jsx index d734d12b..d554b4ad 100644 --- a/src/services/pmsGrid/PmsGrid.jsx +++ b/src/services/pmsGrid/PmsGrid.jsx @@ -234,6 +234,25 @@ export default function PmsGrid({ } /> + )} + {features.expand && ( + + 0 && + currentRows.every((r) => selected.has(r[rowKey])) + } + onChange={(e) => + e.target.checked + ? selectAllOnPage(currentRows) + : deselectAllOnPage(currentRows) + } + /> + )} {visibleColumns.map((col) => { const style = { @@ -303,7 +322,7 @@ export default function PmsGrid({ {features.actions && ( Actions @@ -387,104 +406,128 @@ export default function PmsGrid({ ); // render a single row (function hoisted so it can reference visibleColumns) - function renderRow(row) { - const isSelected = selected.has(row[rowKey]); + function renderRow(row) { + const isSelected = selected.has(row[rowKey]); + const isExpanded = expanded.has(row[rowKey]); - return ( - - - {features.selection && ( - - toggleSelect(row[rowKey])} - /> - - )} - - {visibleColumns.map((col) => { - const style = { - minWidth: col.width || 120, - width: col.width || undefined, - }; - - if (col.pinned) style.position = "sticky"; - if (col.pinned === "left") - style.left = `${getLeftOffset(colState, col.key)}px`; - if (col.pinned === "right") - style.right = `${getRightOffset(colState, col.key)}px`; - - return ( - - {col.render ? col.render(row) : row[col.key] ?? ""} - - ); - })} - - {features.actions && ( - -
- {Array.isArray(features.actions) - ? features.actions.map((act, i) => ( - - )) - : typeof features.actions === "function" - ? features.actions(row, toggleExpand) - : null} -
- - )} - - - {features.expand && expanded.has(row[rowKey]) && renderExpanded && ( - - - {renderExpanded(row)} - - + return ( + + + {/* Selection checkbox (always left) */} + {features.selection && ( + + toggleSelect(row[rowKey])} + /> + )} - - ); - } + + {/* Expand toggle next to selection */} + {features.expand && ( + + + + )} + + {/* Data columns */} + {visibleColumns.map((col) => { + const style = { + minWidth: col.width || 120, + width: col.width || undefined, + }; + + if (col.pinned) style.position = "sticky"; + if (col.pinned === "left") + style.left = `${getLeftOffset(colState, col.key)}px`; + if (col.pinned === "right") + style.right = `${getRightOffset(colState, col.key)}px`; + + return ( + + {col.render ? col.render(row) : row[col.key] ?? ""} + + ); + })} + + {/* Actions column (always right) */} + {features.actions && ( + +
+ {Array.isArray(features.actions) + ? features.actions.map((act, i) => ( + + )) + : typeof features.actions === "function" + ? features.actions(row, toggleExpand) + : null} +
+ + )} + + + {/* 🔹 5. Expanded row content (full width) */} + {isExpanded && renderExpanded && ( + + + {renderExpanded(row)} + + + )} +
+ ); +} + } // small helpers to compute sticky offsets diff --git a/src/services/pmsGrid/pms-grid.css b/src/services/pmsGrid/pms-grid.css index 53ced530..f918dada 100644 --- a/src/services/pmsGrid/pms-grid.css +++ b/src/services/pmsGrid/pms-grid.css @@ -102,8 +102,8 @@ } /* Always sticky last column (Actions) */ -.pms-grid th:last-child, -.pms-grid td:last-child { +.pms-grid .th-lastChild, +.pms-grid .td-lastChild { position: sticky; right: 0; z-index: 8;