@alaarab/ogrid-react-material 2.4.0 → 2.4.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.
- package/dist/esm/index.js +91 -61
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React4 from 'react';
|
|
2
2
|
import { useMemo, useCallback, useState, useRef, useEffect } from 'react';
|
|
3
3
|
import { Box, Tooltip, Typography, IconButton, Popover, useTheme, TextField, InputAdornment, Button, CircularProgress, FormControlLabel, Checkbox, Avatar, Table, TableHead, TableRow, TableCell, Select, MenuItem, Menu, Divider } from '@mui/material';
|
|
4
|
-
import { createBaseFilterRenderers, useColumnHeaderFilterState, getColumnHeaderFilterStateParams, renderFilterContent, areGridRowPropsEqual, PaginationControlsBase, createOGrid, useListVirtualizer, CHECKBOX_COLUMN_WIDTH, STOP_PROPAGATION, ROW_NUMBER_COLUMN_WIDTH, useDataGridTableOrchestration, useColumnMeta, getCellRenderDescriptor, buildInlineEditorProps, buildPopoverEditorProps, resolveCellDisplayContent, resolveCellStyle, getCellInteractionProps, CellErrorBoundary, PREVENT_DEFAULT, indexToColumnLetter, getHeaderFilterConfig, MarchingAntsOverlay, FormulaRefOverlay, NOOP, getColumnHeaderMenuProps, useColumnChooserState, ColumnChooserContent, BaseInlineCellEditor, partitionColumnsForVirtualization, getContextMenuHandlers, GRID_CONTEXT_MENU_ITEMS, formatShortcut, getColumnHeaderMenuItems, getStatusBarParts } from '@alaarab/ogrid-react';
|
|
4
|
+
import { createBaseFilterRenderers, useColumnHeaderFilterState, getColumnHeaderFilterStateParams, renderFilterContent, areGridRowPropsEqual, PaginationControlsBase, createOGrid, useListVirtualizer, CHECKBOX_COLUMN_WIDTH, STOP_PROPAGATION, ROW_NUMBER_COLUMN_WIDTH, useDataGridTableOrchestration, useColumnMeta, getCellRenderDescriptor, buildInlineEditorProps, buildPopoverEditorProps, resolveCellDisplayContent, resolveCellStyle, getCellInteractionProps, CellErrorBoundary, PREVENT_DEFAULT, indexToColumnLetter, ROW_NUMBER_COLUMN_ID, getHeaderFilterConfig, MarchingAntsOverlay, FormulaRefOverlay, NOOP, getColumnHeaderMenuProps, useColumnChooserState, ColumnChooserContent, BaseInlineCellEditor, partitionColumnsForVirtualization, getContextMenuHandlers, GRID_CONTEXT_MENU_ITEMS, formatShortcut, getColumnHeaderMenuItems, getStatusBarParts } from '@alaarab/ogrid-react';
|
|
5
5
|
export { BaseColumnHeaderMenu, BaseDropIndicator, BaseEmptyState, BaseInlineCellEditor, BaseLoadingOverlay, CELL_PADDING, CHECKBOX_COLUMN_WIDTH, COLUMN_HEADER_MENU_ITEMS, CURSOR_CELL_STYLE, CellErrorBoundary, DEFAULT_MIN_COLUMN_WIDTH, DateFilterContent, EmptyState, GRID_BORDER_RADIUS, GRID_CONTEXT_MENU_ITEMS, GRID_ROOT_STYLE, GridContextMenu, MAX_PAGE_BUTTONS, MarchingAntsOverlay, NOOP, OGridLayout, PAGE_SIZE_OPTIONS, POPOVER_ANCHOR_STYLE, PREVENT_DEFAULT, ROW_NUMBER_COLUMN_WIDTH, STOP_PROPAGATION, SideBar, StatusBar, UndoRedoStack, areGridRowPropsEqual, booleanParser, buildCsvHeader, buildCsvRows, buildHeaderRows, buildInlineEditorProps, buildPopoverEditorProps, clampSelectionToBounds, computeAggregations, computeAutoScrollSpeed, computeTabNavigation, createOGrid, currencyParser, dateParser, deriveFilterOptionsFromData, editorInputStyle, editorWrapperStyle, emailParser, escapeCsvValue, exportToCsv, findCtrlArrowTarget, flattenColumns, formatCellValueForTsv, formatSelectionAsTsv, formatShortcut, getCellInteractionProps, getCellRenderDescriptor, getCellValue, getColumnHeaderFilterStateParams, getColumnHeaderMenuItems, getContextMenuHandlers, getDataGridStatusBarConfig, getDateFilterContentProps, getFilterField, getHeaderFilterConfig, getMultiSelectFilterFields, getPaginationViewModel, getStatusBarParts, isInSelectionRange, isRowInRange, mergeFilter, normalizeSelectionRange, numberParser, parseTsvClipboard, parseValue, processClientSideData, rangesEqual, renderFilterContent, resolveCellDisplayContent, resolveCellStyle, richSelectDropdownStyle, richSelectNoMatchesStyle, richSelectOptionHighlightedStyle, richSelectOptionStyle, richSelectWrapperStyle, selectChevronStyle, selectDisplayStyle, selectEditorStyle, toUserLike, triggerCsvDownload, useActiveCell, useCellEditing, useCellSelection, useClipboard, useColumnChooserState, useColumnHeaderFilterState, useColumnMeta, useColumnReorder, useColumnResize, useContextMenu, useDataGridState, useDataGridTableOrchestration, useDateFilterState, useDebounce, useFillHandle, useFilterOptions, useInlineCellEditorState, useKeyboardNavigation, useLatestRef, useListVirtualizer, useMultiSelectFilterState, useOGrid, usePaginationControls, usePeopleFilterState, useRichSelectState, useRowSelection, useSelectState, useSideBarState, useTableLayout, useTextFilterState, useUndoRedo, useVirtualScroll } from '@alaarab/ogrid-react';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
import { FilterList, Search, Clear, ExpandLess, ExpandMore, ViewColumn, LastPage, ChevronRight, ChevronLeft, FirstPage } from '@mui/icons-material';
|
|
@@ -725,7 +725,8 @@ function GridRowInner(props) {
|
|
|
725
725
|
rowHeight,
|
|
726
726
|
leftSpacerWidth,
|
|
727
727
|
rightSpacerWidth,
|
|
728
|
-
globalColIndexMap
|
|
728
|
+
globalColIndexMap,
|
|
729
|
+
rowNumWidth
|
|
729
730
|
} = props;
|
|
730
731
|
return /* @__PURE__ */ jsxs(
|
|
731
732
|
"tr",
|
|
@@ -754,20 +755,23 @@ function GridRowInner(props) {
|
|
|
754
755
|
)
|
|
755
756
|
}
|
|
756
757
|
) }),
|
|
757
|
-
hasRowNumbersCol &&
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
758
|
+
hasRowNumbersCol && (() => {
|
|
759
|
+
const rnw = rowNumWidth ?? ROW_NUMBER_COLUMN_WIDTH;
|
|
760
|
+
return /* @__PURE__ */ jsx(
|
|
761
|
+
"td",
|
|
762
|
+
{
|
|
763
|
+
className: "ogrid-mat-td ogrid-mat-row-number",
|
|
764
|
+
style: {
|
|
765
|
+
width: rnw,
|
|
766
|
+
minWidth: rnw,
|
|
767
|
+
maxWidth: rnw,
|
|
768
|
+
left: hasCheckboxCol ? CHECKBOX_COLUMN_WIDTH : 0,
|
|
769
|
+
borderBottom: "1px solid var(--ogrid-border, rgba(224,224,224,1))"
|
|
770
|
+
},
|
|
771
|
+
children: rowNumberOffset + rowIndex + 1
|
|
772
|
+
}
|
|
773
|
+
);
|
|
774
|
+
})(),
|
|
771
775
|
leftSpacerWidth != null && leftSpacerWidth > 0 && /* @__PURE__ */ jsx("td", { style: { ...SPACER_TD_STYLE, width: leftSpacerWidth, minWidth: leftSpacerWidth }, "aria-hidden": true }),
|
|
772
776
|
columnLayouts.map((cl, colIdx) => {
|
|
773
777
|
const globalIdx = globalColIndexMap ? globalColIndexMap[colIdx] : colIdx;
|
|
@@ -813,7 +817,8 @@ function MaterialTableBody(props) {
|
|
|
813
817
|
copyRange,
|
|
814
818
|
isDragging,
|
|
815
819
|
editingCell,
|
|
816
|
-
pinnedColumns
|
|
820
|
+
pinnedColumns,
|
|
821
|
+
rowNumWidth
|
|
817
822
|
} = props;
|
|
818
823
|
const { rowLayouts, globalColIndexMap, leftSpacerWidth, rightSpacerWidth } = React4.useMemo(() => {
|
|
819
824
|
if (!columnRange) {
|
|
@@ -868,7 +873,8 @@ function MaterialTableBody(props) {
|
|
|
868
873
|
editingRowId: editingCell?.rowId ?? null,
|
|
869
874
|
leftSpacerWidth,
|
|
870
875
|
rightSpacerWidth,
|
|
871
|
-
globalColIndexMap
|
|
876
|
+
globalColIndexMap,
|
|
877
|
+
rowNumWidth
|
|
872
878
|
},
|
|
873
879
|
rowIdStr
|
|
874
880
|
);
|
|
@@ -1037,9 +1043,14 @@ function DataGridTableInner(props) {
|
|
|
1037
1043
|
)
|
|
1038
1044
|
] });
|
|
1039
1045
|
} else {
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1046
|
+
let displayNode;
|
|
1047
|
+
if (descriptor.columnType === "boolean") {
|
|
1048
|
+
displayNode = /* @__PURE__ */ jsx("input", { type: "checkbox", checked: !!descriptor.displayValue, disabled: true, style: { margin: 0, pointerEvents: "none" }, "aria-label": descriptor.displayValue ? "True" : "False" });
|
|
1049
|
+
} else {
|
|
1050
|
+
const content = resolveCellDisplayContent(col, item, descriptor.displayValue);
|
|
1051
|
+
const cellStyle = resolveCellStyle(col, item, descriptor.displayValue);
|
|
1052
|
+
displayNode = cellStyle ? /* @__PURE__ */ jsx("span", { style: cellStyle, children: content }) : content;
|
|
1053
|
+
}
|
|
1043
1054
|
let cls = "ogrid-mat-cell";
|
|
1044
1055
|
if (col.type === "numeric") cls += " ogrid-mat-cell--numeric";
|
|
1045
1056
|
else if (col.type === "boolean") cls += " ogrid-mat-cell--boolean";
|
|
@@ -1056,7 +1067,7 @@ function DataGridTableInner(props) {
|
|
|
1056
1067
|
...interactionProps,
|
|
1057
1068
|
style: cellDensityStyle,
|
|
1058
1069
|
children: [
|
|
1059
|
-
|
|
1070
|
+
displayNode,
|
|
1060
1071
|
descriptor.canEditAny && descriptor.isSelectionEndCell && /* @__PURE__ */ jsx("div", { className: "ogrid-mat-fill-handle", onMouseDown: handleFillHandleMouseDown, "aria-label": "Fill handle" })
|
|
1061
1072
|
]
|
|
1062
1073
|
}
|
|
@@ -1137,45 +1148,59 @@ function DataGridTableInner(props) {
|
|
|
1137
1148
|
}
|
|
1138
1149
|
),
|
|
1139
1150
|
rowIdx === 0 && rowIdx < headerRows.length - 1 && hasCheckboxCol && /* @__PURE__ */ jsx(TableCell, { ...{ rowSpan: headerRows.length - 1, sx: CHECKBOX_PLACEHOLDER_SX } }),
|
|
1140
|
-
rowIdx === headerRows.length - 1 && hasRowNumbersCol &&
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1151
|
+
rowIdx === headerRows.length - 1 && hasRowNumbersCol && (() => {
|
|
1152
|
+
const rnw = columnSizingOverrides?.[ROW_NUMBER_COLUMN_ID]?.widthPx ?? ROW_NUMBER_COLUMN_WIDTH;
|
|
1153
|
+
return /* @__PURE__ */ jsxs(
|
|
1154
|
+
TableCell,
|
|
1155
|
+
{
|
|
1156
|
+
...{
|
|
1157
|
+
component: "th",
|
|
1158
|
+
scope: "col",
|
|
1159
|
+
rowSpan: headerRows.length > 1 ? 1 : void 0,
|
|
1160
|
+
sx: {
|
|
1161
|
+
width: rnw,
|
|
1162
|
+
minWidth: rnw,
|
|
1163
|
+
maxWidth: rnw,
|
|
1164
|
+
textAlign: "center",
|
|
1165
|
+
fontWeight: 600,
|
|
1166
|
+
backgroundColor: HEADER_BG,
|
|
1167
|
+
position: "sticky",
|
|
1168
|
+
left: hasCheckboxCol ? CHECKBOX_COLUMN_WIDTH : 0,
|
|
1169
|
+
zIndex: 4,
|
|
1170
|
+
...headerCellSx
|
|
1171
|
+
}
|
|
1172
|
+
},
|
|
1173
|
+
children: [
|
|
1174
|
+
"#",
|
|
1175
|
+
/* @__PURE__ */ jsx(Box, { onMouseDown: (e) => {
|
|
1176
|
+
setActiveCell(null);
|
|
1177
|
+
interaction.setSelectionRange(null);
|
|
1178
|
+
wrapperRef.current?.focus({ preventScroll: true });
|
|
1179
|
+
handleResizeStart(e, { columnId: ROW_NUMBER_COLUMN_ID, name: "#" });
|
|
1180
|
+
}, sx: RESIZE_HANDLE_SX })
|
|
1181
|
+
]
|
|
1182
|
+
}
|
|
1183
|
+
);
|
|
1184
|
+
})(),
|
|
1185
|
+
rowIdx === 0 && rowIdx < headerRows.length - 1 && hasRowNumbersCol && (() => {
|
|
1186
|
+
const spacerRnw = columnSizingOverrides?.[ROW_NUMBER_COLUMN_ID]?.widthPx ?? ROW_NUMBER_COLUMN_WIDTH;
|
|
1187
|
+
return /* @__PURE__ */ jsx(
|
|
1188
|
+
TableCell,
|
|
1189
|
+
{
|
|
1190
|
+
...{
|
|
1191
|
+
rowSpan: headerRows.length - 1,
|
|
1192
|
+
sx: {
|
|
1193
|
+
width: spacerRnw,
|
|
1194
|
+
minWidth: spacerRnw,
|
|
1195
|
+
position: "sticky",
|
|
1196
|
+
left: hasCheckboxCol ? CHECKBOX_COLUMN_WIDTH : 0,
|
|
1197
|
+
zIndex: 4,
|
|
1198
|
+
backgroundColor: "background.paper"
|
|
1199
|
+
}
|
|
1175
1200
|
}
|
|
1176
1201
|
}
|
|
1177
|
-
|
|
1178
|
-
),
|
|
1202
|
+
);
|
|
1203
|
+
})(),
|
|
1179
1204
|
row.map((cell, cellIdx) => {
|
|
1180
1205
|
if (cell.isGroup) {
|
|
1181
1206
|
return /* @__PURE__ */ jsx(
|
|
@@ -1235,7 +1260,11 @@ function DataGridTableInner(props) {
|
|
|
1235
1260
|
component: "button",
|
|
1236
1261
|
onClick: (e) => {
|
|
1237
1262
|
e.stopPropagation();
|
|
1238
|
-
headerMenu.
|
|
1263
|
+
if (headerMenu.isOpen && headerMenu.openForColumn === col.columnId) {
|
|
1264
|
+
headerMenu.close();
|
|
1265
|
+
} else {
|
|
1266
|
+
headerMenu.open(col.columnId, e.currentTarget);
|
|
1267
|
+
}
|
|
1239
1268
|
},
|
|
1240
1269
|
"aria-label": "Column options",
|
|
1241
1270
|
title: "Column options",
|
|
@@ -1282,7 +1311,8 @@ function DataGridTableInner(props) {
|
|
|
1282
1311
|
copyRange,
|
|
1283
1312
|
isDragging,
|
|
1284
1313
|
editingCell,
|
|
1285
|
-
pinnedColumns: pinning.pinnedColumns
|
|
1314
|
+
pinnedColumns: pinning.pinnedColumns,
|
|
1315
|
+
rowNumWidth: hasRowNumbersCol ? columnSizingOverrides?.[ROW_NUMBER_COLUMN_ID]?.widthPx ?? ROW_NUMBER_COLUMN_WIDTH : void 0
|
|
1286
1316
|
}
|
|
1287
1317
|
)
|
|
1288
1318
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alaarab/ogrid-react-material",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.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.4.
|
|
42
|
+
"@alaarab/ogrid-react": "2.4.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@emotion/react": "^11.0.0",
|