@alaarab/ogrid-react-material 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useEffect, useState } from 'react';
|
|
3
3
|
import { Menu, MenuItem, Divider } from '@mui/material';
|
|
4
4
|
import { getColumnHeaderMenuItems } from '@alaarab/ogrid-react';
|
|
5
5
|
/**
|
|
@@ -46,8 +46,16 @@ export function ColumnHeaderMenu(props) {
|
|
|
46
46
|
minWidth: 140,
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
|
-
}, children: items.
|
|
49
|
+
}, children: items.flatMap((item, idx) => {
|
|
50
|
+
const elements = [
|
|
51
|
+
_jsx(MenuItem, { disabled: item.disabled, onClick: () => {
|
|
50
52
|
handlers[item.id]();
|
|
51
53
|
onClose();
|
|
52
|
-
}, children: item.label }
|
|
54
|
+
}, children: item.label }, item.id),
|
|
55
|
+
];
|
|
56
|
+
if (item.divider && idx < items.length - 1) {
|
|
57
|
+
elements.push(_jsx(Divider, {}, `${item.id}-divider`));
|
|
58
|
+
}
|
|
59
|
+
return elements;
|
|
60
|
+
}) }));
|
|
53
61
|
}
|
|
@@ -127,20 +127,16 @@ const CELL_TD_BASE_SX = { position: 'relative', p: 0, height: '1px' };
|
|
|
127
127
|
const CELL_TD_PINNED_LEFT_SX = {
|
|
128
128
|
...CELL_TD_BASE_SX, position: 'sticky', left: 0, zIndex: 6,
|
|
129
129
|
bgcolor: 'background.paper', willChange: 'transform',
|
|
130
|
-
'
|
|
131
|
-
|
|
132
|
-
width: '4px', background: 'linear-gradient(to right, rgba(0,0,0,0.12), transparent)', pointerEvents: 'none',
|
|
133
|
-
},
|
|
130
|
+
borderRight: '1px solid', borderRightColor: 'divider',
|
|
131
|
+
boxShadow: '2px 0 4px -1px rgba(0,0,0,0.1)',
|
|
134
132
|
};
|
|
135
133
|
const CELL_TD_PINNED_RIGHT_SX = {
|
|
136
134
|
...CELL_TD_BASE_SX, position: 'sticky', right: 0, zIndex: 6,
|
|
137
135
|
bgcolor: 'background.paper', willChange: 'transform',
|
|
138
|
-
'
|
|
139
|
-
|
|
140
|
-
width: '4px', background: 'linear-gradient(to left, rgba(0,0,0,0.12), transparent)', pointerEvents: 'none',
|
|
141
|
-
},
|
|
136
|
+
borderLeft: '1px solid', borderLeftColor: 'divider',
|
|
137
|
+
boxShadow: '-2px 0 4px -1px rgba(0,0,0,0.1)',
|
|
142
138
|
};
|
|
143
|
-
// Header cell positioning variants
|
|
139
|
+
// Header cell positioning variants (sticky)
|
|
144
140
|
const HEADER_BASE_SX = {
|
|
145
141
|
fontWeight: 600,
|
|
146
142
|
position: 'sticky', /* Enables vertical sticky for all headers */
|
|
@@ -151,18 +147,32 @@ const HEADER_BASE_SX = {
|
|
|
151
147
|
const HEADER_PINNED_LEFT_SX = {
|
|
152
148
|
...HEADER_BASE_SX, position: 'sticky', left: 0, top: 0,
|
|
153
149
|
zIndex: 10, bgcolor: 'action.hover', willChange: 'transform',
|
|
154
|
-
'
|
|
155
|
-
|
|
156
|
-
width: '4px', background: 'linear-gradient(to right, rgba(0,0,0,0.12), transparent)', pointerEvents: 'none',
|
|
157
|
-
},
|
|
150
|
+
borderRight: '1px solid', borderRightColor: 'divider',
|
|
151
|
+
boxShadow: '2px 0 4px -1px rgba(0,0,0,0.1)',
|
|
158
152
|
};
|
|
159
153
|
const HEADER_PINNED_RIGHT_SX = {
|
|
160
154
|
...HEADER_BASE_SX, position: 'sticky', right: 0, top: 0,
|
|
161
155
|
zIndex: 10, bgcolor: 'action.hover', willChange: 'transform',
|
|
162
|
-
'
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
156
|
+
borderLeft: '1px solid', borderLeftColor: 'divider',
|
|
157
|
+
boxShadow: '-2px 0 4px -1px rgba(0,0,0,0.1)',
|
|
158
|
+
};
|
|
159
|
+
// Header cell variants (non-sticky — stickyHeader=false)
|
|
160
|
+
const HEADER_BASE_NO_STICKY_SX = {
|
|
161
|
+
fontWeight: 600,
|
|
162
|
+
zIndex: 8,
|
|
163
|
+
bgcolor: 'action.hover',
|
|
164
|
+
};
|
|
165
|
+
const HEADER_PINNED_LEFT_NO_STICKY_SX = {
|
|
166
|
+
...HEADER_BASE_NO_STICKY_SX, position: 'sticky', left: 0,
|
|
167
|
+
zIndex: 10, willChange: 'transform',
|
|
168
|
+
borderRight: '1px solid', borderRightColor: 'divider',
|
|
169
|
+
boxShadow: '2px 0 4px -1px rgba(0,0,0,0.1)',
|
|
170
|
+
};
|
|
171
|
+
const HEADER_PINNED_RIGHT_NO_STICKY_SX = {
|
|
172
|
+
...HEADER_BASE_NO_STICKY_SX, position: 'sticky', right: 0,
|
|
173
|
+
zIndex: 10, willChange: 'transform',
|
|
174
|
+
borderLeft: '1px solid', borderLeftColor: 'divider',
|
|
175
|
+
boxShadow: '-2px 0 4px -1px rgba(0,0,0,0.1)',
|
|
166
176
|
};
|
|
167
177
|
// Resize handle
|
|
168
178
|
const RESIZE_HANDLE_SX = {
|
|
@@ -341,7 +351,9 @@ function DataGridTableInner(props) {
|
|
|
341
351
|
const col = cell.columnDef;
|
|
342
352
|
const isPinnedLeft = pinning.pinnedColumns[col.columnId] === 'left';
|
|
343
353
|
const isPinnedRight = pinning.pinnedColumns[col.columnId] === 'right';
|
|
344
|
-
const baseHeaderSx =
|
|
354
|
+
const baseHeaderSx = o.stickyHeader
|
|
355
|
+
? (isPinnedLeft ? HEADER_PINNED_LEFT_SX : isPinnedRight ? HEADER_PINNED_RIGHT_SX : HEADER_BASE_SX)
|
|
356
|
+
: (isPinnedLeft ? HEADER_PINNED_LEFT_NO_STICKY_SX : isPinnedRight ? HEADER_PINNED_RIGHT_NO_STICKY_SX : HEADER_BASE_NO_STICKY_SX);
|
|
345
357
|
// Override sticky offset for pinned columns (supports multiple pinned columns)
|
|
346
358
|
const headerSx = isPinnedLeft && pinning.leftOffsets[col.columnId] != null
|
|
347
359
|
? { ...baseHeaderSx, left: pinning.leftOffsets[col.columnId] }
|
|
@@ -14,5 +14,12 @@ export function GridContextMenu(props) {
|
|
|
14
14
|
return true;
|
|
15
15
|
return false;
|
|
16
16
|
}, [hasSelection, canUndo, canRedo]);
|
|
17
|
-
return (_jsx(Menu, { open: true, onClose: onClose, anchorReference: "anchorPosition", anchorPosition: { top: y, left: x }, MenuListProps: { dense: true, 'aria-label': 'Grid context menu' }, children: GRID_CONTEXT_MENU_ITEMS.
|
|
17
|
+
return (_jsx(Menu, { open: true, onClose: onClose, anchorReference: "anchorPosition", anchorPosition: { top: y, left: x }, MenuListProps: { dense: true, 'aria-label': 'Grid context menu' }, children: GRID_CONTEXT_MENU_ITEMS.flatMap((item) => {
|
|
18
|
+
const elements = [];
|
|
19
|
+
if (item.dividerBefore) {
|
|
20
|
+
elements.push(_jsx(Divider, {}, `${item.id}-divider`));
|
|
21
|
+
}
|
|
22
|
+
elements.push(_jsxs(MenuItem, { onClick: handlers[item.id], disabled: isDisabled(item), children: [_jsx("span", { style: { flex: 1 }, children: item.label }), item.shortcut && (_jsx("span", { style: { marginLeft: 24, color: 'var(--ogrid-fg-muted, rgba(0,0,0,0.4))', fontSize: '0.8em' }, children: formatShortcut(item.shortcut) }))] }, item.id));
|
|
23
|
+
return elements;
|
|
24
|
+
}) }));
|
|
18
25
|
}
|
package/dist/esm/OGrid/OGrid.js
CHANGED
|
@@ -20,7 +20,7 @@ const OGridInner = forwardRef(function OGridInner(props, ref) {
|
|
|
20
20
|
'--ogrid-fg-muted': theme.palette.text.disabled,
|
|
21
21
|
'--ogrid-hover-bg': theme.palette.action.hover,
|
|
22
22
|
}), [theme]);
|
|
23
|
-
return (_jsx(OGridLayout, { containerComponent: Box, containerProps: { sx: containerSx }, className: layout.className, sideBar: layout.sideBarProps, toolbar: layout.toolbar, toolbarBelow: layout.toolbarBelow, toolbarEnd: columnChooser.placement === 'toolbar' ? (_jsx(ColumnChooser, { columns: columnChooser.columns, visibleColumns: columnChooser.visibleColumns, onVisibilityChange: columnChooser.onVisibilityChange })) : undefined, pagination: _jsx(PaginationControls, { currentPage: pagination.page, pageSize: pagination.pageSize, totalCount: pagination.displayTotalCount, onPageChange: pagination.setPage, onPageSizeChange: (size) => {
|
|
23
|
+
return (_jsx(OGridLayout, { containerComponent: Box, containerProps: { sx: containerSx }, className: layout.className, sideBar: layout.sideBarProps, toolbar: layout.toolbar, toolbarBelow: layout.toolbarBelow, fullScreen: layout.fullScreen, toolbarEnd: columnChooser.placement === 'toolbar' ? (_jsx(ColumnChooser, { columns: columnChooser.columns, visibleColumns: columnChooser.visibleColumns, onVisibilityChange: columnChooser.onVisibilityChange })) : undefined, pagination: _jsx(PaginationControls, { currentPage: pagination.page, pageSize: pagination.pageSize, totalCount: pagination.displayTotalCount, onPageChange: pagination.setPage, onPageSizeChange: (size) => {
|
|
24
24
|
pagination.setPageSize(size);
|
|
25
25
|
}, pageSizeOptions: pagination.pageSizeOptions, entityLabelPlural: pagination.entityLabelPlural }), children: _jsx(DataGridTable, { ...dataGridProps }) }));
|
|
26
26
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alaarab/ogrid-react-material",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "OGrid React Material implementation – MUI Table–based data grid with sorting, filtering, pagination, column chooser, spreadsheet selection, and CSV export.",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": ">=18"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@alaarab/ogrid-react": "2.1.
|
|
42
|
+
"@alaarab/ogrid-react": "2.1.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@emotion/react": "^11.0.0",
|