@alaarab/ogrid-react-material 2.0.14 → 2.0.16
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,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React, { useMemo, useEffect, useState } from 'react';
|
|
3
3
|
import { Menu, MenuItem, Divider } from '@mui/material';
|
|
4
|
-
import { getColumnHeaderMenuItems } from '@alaarab/ogrid-
|
|
4
|
+
import { getColumnHeaderMenuItems } from '@alaarab/ogrid-react';
|
|
5
5
|
/**
|
|
6
6
|
* Column header dropdown menu for pin/sort/autosize actions.
|
|
7
7
|
* Uses Material UI Menu component with anchor position.
|
|
@@ -14,6 +14,21 @@ import { DropIndicator } from './DropIndicator';
|
|
|
14
14
|
import { useDataGridTableOrchestration, getHeaderFilterConfig, getCellRenderDescriptor, MarchingAntsOverlay, resolveCellDisplayContent, resolveCellStyle, buildInlineEditorProps, buildPopoverEditorProps, getCellInteractionProps, areGridRowPropsEqual, CellErrorBoundary, CHECKBOX_COLUMN_WIDTH, ROW_NUMBER_COLUMN_WIDTH, DEFAULT_MIN_COLUMN_WIDTH, PREVENT_DEFAULT, NOOP, STOP_PROPAGATION, } from '@alaarab/ogrid-react';
|
|
15
15
|
// ── Module-scope stable styles (avoid per-render Emotion resolutions) ──
|
|
16
16
|
const gridRootSx = { position: 'relative', flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' };
|
|
17
|
+
// Editing cell wrapper (plain div, not MUI)
|
|
18
|
+
const EDITING_CELL_STYLE = {
|
|
19
|
+
width: '100%',
|
|
20
|
+
height: '100%',
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
boxSizing: 'border-box',
|
|
24
|
+
outline: '2px solid var(--ogrid-selection-color, #217346)',
|
|
25
|
+
outlineOffset: '-1px',
|
|
26
|
+
zIndex: 2,
|
|
27
|
+
position: 'relative',
|
|
28
|
+
background: 'var(--ogrid-bg, #fff)',
|
|
29
|
+
overflow: 'visible',
|
|
30
|
+
padding: 0,
|
|
31
|
+
};
|
|
17
32
|
// Row
|
|
18
33
|
const ROW_HOVER_SX = { '&:hover': { bgcolor: 'action.hover' } };
|
|
19
34
|
// Checkbox column
|
|
@@ -187,7 +202,7 @@ function GridRowInner(props) {
|
|
|
187
202
|
const GridRow = React.memo(GridRowInner, areGridRowPropsEqual);
|
|
188
203
|
function DataGridTableInner(props) {
|
|
189
204
|
const o = useDataGridTableOrchestration({ props });
|
|
190
|
-
const { wrapperRef, tableContainerRef, lastMouseShiftRef, interaction, pinning, handleResizeStart, getColumnWidth, isReorderDragging, dropIndicatorX, handleHeaderMouseDown, virtualScrollEnabled, visibleRange, items, getRowId, emptyState, freezeRows, freezeCols, suppressHorizontalScroll, isLoading, loadingMessage, ariaLabel, ariaLabelledBy, columnReorder, density, rowNumberOffset, headerRows, allowOverflowX, fitToContent, editCallbacks, interactionHandlers, cellDescriptorInputRef, pendingEditorValueRef, popoverAnchorElRef, handleSingleRowClick, handlePasteVoid, visibleCols, hasCheckboxCol, hasRowNumbersCol, colOffset, minTableWidth, columnSizingOverrides, selectedRowIds, handleRowCheckboxChange, handleSelectAll, allSelected, someSelected, editingCell, setPopoverAnchorEl, cancelPopoverEdit, setActiveCell, selectionRange, hasCellSelection, handleGridKeyDown, handleFillHandleMouseDown, handleCopy, handleCut, cutRange, copyRange, canUndo, canRedo, onUndo, onRedo, isDragging, menuPosition, closeContextMenu, headerFilterInput, statusBarConfig, showEmptyInGrid, onCellError, } = o;
|
|
205
|
+
const { wrapperRef, tableContainerRef, lastMouseShiftRef, interaction, pinning, handleResizeStart, getColumnWidth, isReorderDragging, dropIndicatorX, handleHeaderMouseDown, virtualScrollEnabled, visibleRange, items, getRowId, emptyState, freezeRows, freezeCols, suppressHorizontalScroll, isLoading, loadingMessage, ariaLabel, ariaLabelledBy, columnReorder, density, rowNumberOffset, headerRows, allowOverflowX, fitToContent, editCallbacks, interactionHandlers, cellDescriptorInputRef, pendingEditorValueRef, popoverAnchorElRef, handleSingleRowClick, handlePasteVoid, visibleCols, hasCheckboxCol, hasRowNumbersCol, colOffset, minTableWidth, columnSizingOverrides, measuredColumnWidths, selectedRowIds, handleRowCheckboxChange, handleSelectAll, allSelected, someSelected, editingCell, setPopoverAnchorEl, cancelPopoverEdit, setActiveCell, selectionRange, hasCellSelection, handleGridKeyDown, handleFillHandleMouseDown, handleCopy, handleCut, cutRange, copyRange, canUndo, canRedo, onUndo, onRedo, isDragging, menuPosition, closeContextMenu, headerFilterInput, statusBarConfig, showEmptyInGrid, onCellError, } = o;
|
|
191
206
|
// Density-aware cell padding
|
|
192
207
|
const densityPadding = useMemo(() => getDensityPadding(density), [density]);
|
|
193
208
|
const _cellSx = useMemo(() => ({ ...CELL_CONTENT_BASE_SX, ...densityPadding }), [densityPadding]);
|
|
@@ -206,8 +221,13 @@ function DataGridTableInner(props) {
|
|
|
206
221
|
? { ...baseTdSx, right: pinning.rightOffsets[col.columnId] }
|
|
207
222
|
: baseTdSx;
|
|
208
223
|
const hasResizeOverride = !!columnSizingOverrides[col.columnId];
|
|
209
|
-
|
|
210
|
-
|
|
224
|
+
// Use previously-measured DOM width as a minWidth floor to prevent columns
|
|
225
|
+
// from shrinking when new data loads (e.g. server-side pagination).
|
|
226
|
+
const measuredW = measuredColumnWidths[col.columnId];
|
|
227
|
+
const baseMinWidth = col.minWidth ?? DEFAULT_MIN_COLUMN_WIDTH;
|
|
228
|
+
const effectiveMinWidth = hasResizeOverride ? columnWidth : Math.max(baseMinWidth, measuredW ?? 0);
|
|
229
|
+
return { col, tdSx, minWidth: effectiveMinWidth, width: columnWidth, maxWidth: columnWidth };
|
|
230
|
+
}), [visibleCols, freezeCols, getColumnWidth, columnSizingOverrides, measuredColumnWidths, pinning.pinnedColumns, pinning.leftOffsets, pinning.rightOffsets]);
|
|
211
231
|
// Wrapper sx (depends on dynamic values — memoize to avoid recreation)
|
|
212
232
|
const wrapperSx = useMemo(() => ({
|
|
213
233
|
position: 'relative',
|
|
@@ -227,7 +247,7 @@ function DataGridTableInner(props) {
|
|
|
227
247
|
const rowId = getRowId(item);
|
|
228
248
|
let cellContent;
|
|
229
249
|
if (descriptor.mode === 'editing-inline') {
|
|
230
|
-
cellContent = _jsx(InlineCellEditor, { ...buildInlineEditorProps(item, col, descriptor, editCallbacks) });
|
|
250
|
+
cellContent = (_jsx("div", { style: EDITING_CELL_STYLE, children: _jsx(InlineCellEditor, { ...buildInlineEditorProps(item, col, descriptor, editCallbacks) }) }));
|
|
231
251
|
}
|
|
232
252
|
else if (descriptor.mode === 'editing-popover' && typeof col.cellEditor === 'function') {
|
|
233
253
|
const editorProps = buildPopoverEditorProps(item, col, descriptor, pendingEditorValueRef.current, editCallbacks);
|
|
@@ -313,7 +333,7 @@ function DataGridTableInner(props) {
|
|
|
313
333
|
sx: {
|
|
314
334
|
...headerSx,
|
|
315
335
|
...headerCellSx,
|
|
316
|
-
minWidth: col.minWidth ?? DEFAULT_MIN_COLUMN_WIDTH,
|
|
336
|
+
minWidth: Math.max(col.minWidth ?? DEFAULT_MIN_COLUMN_WIDTH, measuredColumnWidths[col.columnId] ?? 0),
|
|
317
337
|
width: columnWidth,
|
|
318
338
|
maxWidth: columnWidth,
|
|
319
339
|
...(columnReorder ? { cursor: isReorderDragging ? 'grabbing' : 'grab' } : {}),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Checkbox
|
|
3
|
-
import { BaseInlineCellEditor
|
|
2
|
+
import { Checkbox } from '@mui/material';
|
|
3
|
+
import { BaseInlineCellEditor } from '@alaarab/ogrid-react';
|
|
4
4
|
export function InlineCellEditor(props) {
|
|
5
|
-
return (_jsx(BaseInlineCellEditor, { ...props, renderCheckbox: (checked, onCommit, onCancel) => (_jsx(Checkbox, { checked: checked, onChange: (_, c) => onCommit(c), onKeyDown: (e) => e.key === 'Escape' && (e.preventDefault(), onCancel()), size: "small" }))
|
|
5
|
+
return (_jsx(BaseInlineCellEditor, { ...props, renderCheckbox: (checked, onCommit, onCancel) => (_jsx(Checkbox, { checked: checked, onChange: (_, c) => onCommit(c), onKeyDown: (e) => e.key === 'Escape' && (e.preventDefault(), onCancel()), size: "small" })) }));
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alaarab/ogrid-react-material",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.16",
|
|
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.0.
|
|
42
|
+
"@alaarab/ogrid-react": "2.0.15"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@emotion/react": "^11.0.0",
|