@etsoo/materialui 1.1.67 → 1.1.68
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/lib/DataGridEx.d.ts +5 -5
- package/lib/DataGridEx.js +59 -57
- package/lib/MUGlobal.d.ts +1 -1
- package/lib/MUGlobal.js +2 -1
- package/package.json +4 -4
- package/src/DataGridEx.tsx +610 -625
package/lib/DataGridEx.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { GridColumn, GridLoaderStates, ScrollerGridProps } from
|
|
2
|
-
import { DataTypes, IdDefaultType } from
|
|
3
|
-
import React from
|
|
4
|
-
import { MouseEventWithDataHandler } from
|
|
1
|
+
import { GridColumn, GridLoaderStates, ScrollerGridProps } from "@etsoo/react";
|
|
2
|
+
import { DataTypes, IdDefaultType } from "@etsoo/shared";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { MouseEventWithDataHandler } from "./MUGlobal";
|
|
5
5
|
/**
|
|
6
6
|
* Footer item renderer props
|
|
7
7
|
*/
|
|
@@ -15,7 +15,7 @@ export type DataGridExFooterItemRendererProps<T extends object> = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Extended DataGrid with VariableSizeGrid props
|
|
17
17
|
*/
|
|
18
|
-
export type DataGridExProps<T extends object, D extends DataTypes.Keys<T>> = Omit<ScrollerGridProps<T, D>,
|
|
18
|
+
export type DataGridExProps<T extends object, D extends DataTypes.Keys<T>> = Omit<ScrollerGridProps<T, D>, "itemRenderer" | "columnCount" | "columnWidth" | "width"> & {
|
|
19
19
|
/**
|
|
20
20
|
* Alternating colors for odd/even rows
|
|
21
21
|
*/
|
package/lib/DataGridEx.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { css } from
|
|
2
|
-
import { GridAlignGet, ScrollerGrid, useCombinedRefs } from
|
|
3
|
-
import { Utils } from
|
|
4
|
-
import { Box, Checkbox, Paper, TableSortLabel, useTheme } from
|
|
5
|
-
import React from
|
|
6
|
-
import { DataGridRenderers } from
|
|
1
|
+
import { css } from "@emotion/css";
|
|
2
|
+
import { GridAlignGet, ScrollerGrid, useCombinedRefs } from "@etsoo/react";
|
|
3
|
+
import { Utils } from "@etsoo/shared";
|
|
4
|
+
import { Box, Checkbox, Paper, TableSortLabel, useTheme } from "@mui/material";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { DataGridRenderers } from "./DataGridRenderers";
|
|
7
7
|
// Borders
|
|
8
|
-
const boldBorder =
|
|
9
|
-
const thinBorder =
|
|
8
|
+
const boldBorder = "2px solid rgba(224, 224, 224, 1)";
|
|
9
|
+
const thinBorder = "1px solid rgba(224, 224, 224, 1)";
|
|
10
10
|
// Scroll bar size
|
|
11
11
|
const scrollbarSize = 16;
|
|
12
12
|
// Minimum width
|
|
13
13
|
const minWidth = 120;
|
|
14
14
|
const createGridStyle = (alternatingColors, selectedColor, hoverColor) => {
|
|
15
15
|
return css({
|
|
16
|
-
|
|
16
|
+
".DataGridEx-Selected": {
|
|
17
17
|
backgroundColor: selectedColor
|
|
18
18
|
},
|
|
19
|
-
|
|
19
|
+
".DataGridEx-Hover:not(.DataGridEx-Selected)": {
|
|
20
20
|
backgroundColor: hoverColor
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
"& .DataGridEx-Cell0:not(.DataGridEx-Hover):not(.DataGridEx-Selected)": {
|
|
23
23
|
backgroundColor: alternatingColors[0]
|
|
24
24
|
},
|
|
25
|
-
|
|
25
|
+
"& .DataGridEx-Cell1:not(.DataGridEx-Hover):not(.DataGridEx-Selected)": {
|
|
26
26
|
backgroundColor: alternatingColors[1]
|
|
27
27
|
},
|
|
28
|
-
|
|
28
|
+
"& .DataGridEx-Cell-Border": {
|
|
29
29
|
borderBottom: thinBorder
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
33
|
const rowItems = (div, callback) => {
|
|
34
|
-
const row = div.dataset[
|
|
34
|
+
const row = div.dataset["row"];
|
|
35
35
|
if (div.parentElement == null || row == null)
|
|
36
36
|
return;
|
|
37
37
|
doRowItems(div.parentElement, parseFloat(row), callback);
|
|
@@ -90,7 +90,7 @@ export function DataGridEx(props) {
|
|
|
90
90
|
}
|
|
91
91
|
else if (sortable && field != null) {
|
|
92
92
|
const active = orderBy === field;
|
|
93
|
-
sortLabel = (React.createElement(TableSortLabel, { active: active, direction: sortAsc ?
|
|
93
|
+
sortLabel = (React.createElement(TableSortLabel, { active: active, direction: sortAsc ? "asc" : "desc", onClick: (_event) => {
|
|
94
94
|
if (active)
|
|
95
95
|
column.sortAsc = !sortAsc;
|
|
96
96
|
handleSort(field, column.sortAsc);
|
|
@@ -119,21 +119,21 @@ export function DataGridEx(props) {
|
|
|
119
119
|
checkable
|
|
120
120
|
})
|
|
121
121
|
: undefined;
|
|
122
|
-
return (React.createElement(Box, { key:
|
|
122
|
+
return (React.createElement(Box, { key: "bottom-" + (field !== null && field !== void 0 ? field : index.toString()), textAlign: GridAlignGet(align, type), width: columnWidth(index) },
|
|
123
123
|
React.createElement(Box, { className: "DataGridEx-Cell", onMouseEnter: handleMouseEnter, ...cellProps }, cell)));
|
|
124
124
|
})));
|
|
125
125
|
}
|
|
126
126
|
// Destruct
|
|
127
|
-
const { alternatingColors = [theme.palette.grey[100], undefined], borderRowsCount, bottomHeight = 53, checkable = false, className, columns, defaultOrderBy, height, headerHeight = 56, headerRenderer = defaultHeaderRenderer, footerRenderer = defaultFooterRenderer, footerItemRenderer = DataGridRenderers.defaultFooterItemRenderer, hideFooter = false, hoverColor =
|
|
127
|
+
const { alternatingColors = [theme.palette.grey[100], undefined], borderRowsCount, bottomHeight = 53, checkable = false, className, columns, defaultOrderBy, height, headerHeight = 56, headerRenderer = defaultHeaderRenderer, footerRenderer = defaultFooterRenderer, footerItemRenderer = DataGridRenderers.defaultFooterItemRenderer, hideFooter = false, hoverColor = "#f6f9fb", idField = "id", mRef = React.createRef(), onClick, onDoubleClick, selectable = true, selectedColor = "#edf4fb", width, ...rest } = props;
|
|
128
128
|
if (checkable) {
|
|
129
129
|
const cbColumn = {
|
|
130
|
-
field:
|
|
131
|
-
header:
|
|
130
|
+
field: "selected",
|
|
131
|
+
header: "",
|
|
132
132
|
sortable: false,
|
|
133
133
|
width: 50,
|
|
134
134
|
cellRenderer: ({ cellProps, data, selected }) => {
|
|
135
135
|
cellProps.sx = {
|
|
136
|
-
padding:
|
|
136
|
+
padding: "4px!important"
|
|
137
137
|
};
|
|
138
138
|
return (React.createElement(Checkbox, { color: "primary", checked: selected, onChange: (_event, checked) => {
|
|
139
139
|
var _a;
|
|
@@ -151,7 +151,7 @@ export function DataGridEx(props) {
|
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
153
|
// Update to the latest version
|
|
154
|
-
if (columns[0].field ===
|
|
154
|
+
if (columns[0].field === "selected") {
|
|
155
155
|
columns[0] = cbColumn;
|
|
156
156
|
}
|
|
157
157
|
else {
|
|
@@ -181,14 +181,14 @@ export function DataGridEx(props) {
|
|
|
181
181
|
div.title = innerText;
|
|
182
182
|
}
|
|
183
183
|
else {
|
|
184
|
-
div.title =
|
|
184
|
+
div.title = "";
|
|
185
185
|
}
|
|
186
186
|
};
|
|
187
187
|
// selectedRowIndex state
|
|
188
188
|
const selectedRowIndex = React.useRef(-1);
|
|
189
189
|
const handleMouseDown = (event) => {
|
|
190
190
|
const div = event.currentTarget;
|
|
191
|
-
const row = div.dataset[
|
|
191
|
+
const row = div.dataset["row"];
|
|
192
192
|
if (div.parentElement == null || row == null)
|
|
193
193
|
return;
|
|
194
194
|
const rowIndex = parseFloat(row);
|
|
@@ -197,22 +197,22 @@ export function DataGridEx(props) {
|
|
|
197
197
|
return;
|
|
198
198
|
if (selectedRowIndex.current != -1) {
|
|
199
199
|
doRowItems(div.parentElement, selectedRowIndex.current, (preDiv) => {
|
|
200
|
-
preDiv.classList.remove(
|
|
200
|
+
preDiv.classList.remove("DataGridEx-Selected");
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
rowItems(div, (currentDiv) => {
|
|
204
|
-
currentDiv.classList.add(
|
|
204
|
+
currentDiv.classList.add("DataGridEx-Selected");
|
|
205
205
|
});
|
|
206
206
|
selectedRowIndex.current = rowIndex;
|
|
207
207
|
};
|
|
208
208
|
const handleMouseOver = (event) => {
|
|
209
209
|
rowItems(event.currentTarget, (div) => {
|
|
210
|
-
div.classList.add(
|
|
210
|
+
div.classList.add("DataGridEx-Hover");
|
|
211
211
|
});
|
|
212
212
|
};
|
|
213
213
|
const handleMouseOut = (event) => {
|
|
214
214
|
rowItems(event.currentTarget, (div) => {
|
|
215
|
-
div.classList.remove(
|
|
215
|
+
div.classList.remove("DataGridEx-Hover");
|
|
216
216
|
});
|
|
217
217
|
};
|
|
218
218
|
/**
|
|
@@ -220,7 +220,7 @@ export function DataGridEx(props) {
|
|
|
220
220
|
*/
|
|
221
221
|
const itemRenderer = ({ columnIndex, rowIndex, style, data, selectedItems }) => {
|
|
222
222
|
// Column
|
|
223
|
-
const { align, cellRenderer = DataGridRenderers.defaultCellRenderer, field, type, valueFormatter, renderProps } = columns[columnIndex];
|
|
223
|
+
const { align, cellRenderer = DataGridRenderers.defaultCellRenderer, cellBoxStyle, field, type, valueFormatter, renderProps } = columns[columnIndex];
|
|
224
224
|
// Props
|
|
225
225
|
const formatProps = {
|
|
226
226
|
data,
|
|
@@ -237,21 +237,25 @@ export function DataGridEx(props) {
|
|
|
237
237
|
// Selected
|
|
238
238
|
const selected = data != null &&
|
|
239
239
|
(selectedRowIndex.current === rowIndex ||
|
|
240
|
-
selectedItems.some((selectedItem) => selectedItem != null &&
|
|
241
|
-
selectedItem[idField] === data[idField]));
|
|
240
|
+
selectedItems.some((selectedItem) => selectedItem != null && selectedItem[idField] === data[idField]));
|
|
242
241
|
if (selected) {
|
|
243
242
|
rowClass += ` DataGridEx-Selected`;
|
|
244
243
|
}
|
|
244
|
+
// Box style
|
|
245
|
+
const boxStyle = data == null || cellBoxStyle == null
|
|
246
|
+
? undefined
|
|
247
|
+
: typeof cellBoxStyle === "function"
|
|
248
|
+
? cellBoxStyle(data)
|
|
249
|
+
: cellBoxStyle;
|
|
245
250
|
const cellProps = {
|
|
246
|
-
className:
|
|
247
|
-
textAlign: GridAlignGet(align, type)
|
|
251
|
+
className: "DataGridEx-Cell",
|
|
252
|
+
textAlign: GridAlignGet(align, type),
|
|
253
|
+
sx: { ...boxStyle }
|
|
248
254
|
};
|
|
249
255
|
const child = cellRenderer({
|
|
250
256
|
data,
|
|
251
257
|
field,
|
|
252
|
-
formattedValue: valueFormatter
|
|
253
|
-
? valueFormatter(formatProps)
|
|
254
|
-
: undefined,
|
|
258
|
+
formattedValue: valueFormatter ? valueFormatter(formatProps) : undefined,
|
|
255
259
|
selected,
|
|
256
260
|
type,
|
|
257
261
|
rowIndex,
|
|
@@ -274,9 +278,7 @@ export function DataGridEx(props) {
|
|
|
274
278
|
if (column.width != null)
|
|
275
279
|
return column.width;
|
|
276
280
|
// More space
|
|
277
|
-
const leftWidth = width -
|
|
278
|
-
widthCalculator.total -
|
|
279
|
-
(width < 800 ? 0 : scrollbarSize);
|
|
281
|
+
const leftWidth = width - widthCalculator.total - (width < 800 ? 0 : scrollbarSize);
|
|
280
282
|
// Shared width
|
|
281
283
|
const sharedWidth = leftWidth > 0 ? leftWidth / widthCalculator.unset : 0;
|
|
282
284
|
return (column.minWidth || minWidth) + sharedWidth;
|
|
@@ -287,43 +289,43 @@ export function DataGridEx(props) {
|
|
|
287
289
|
const defaultOrderByAsc = defaultOrderBy
|
|
288
290
|
? (_a = columns.find((column) => column.field === defaultOrderBy)) === null || _a === void 0 ? void 0 : _a.sortAsc
|
|
289
291
|
: undefined;
|
|
290
|
-
return (React.createElement(ScrollerGrid, { className: Utils.mergeClasses(
|
|
292
|
+
return (React.createElement(ScrollerGrid, { className: Utils.mergeClasses("DataGridEx-Body", "DataGridEx-CustomBar", className, createGridStyle(alternatingColors, selectedColor, hoverColor)), columnCount: columns.length, columnWidth: columnWidth, defaultOrderBy: defaultOrderBy, defaultOrderByAsc: defaultOrderByAsc, height: height -
|
|
291
293
|
headerHeight -
|
|
292
294
|
(hideFooter ? 0 : bottomHeight + 1) -
|
|
293
295
|
scrollbarSize, headerRenderer: headerRenderer, idField: idField, itemRenderer: itemRenderer, footerRenderer: hideFooter ? undefined : footerRenderer, width: Math.max(width !== null && width !== void 0 ? width : 0, widthCalculator.total), mRef: mRefLocal, ...rest }));
|
|
294
296
|
}, [width]);
|
|
295
297
|
return (React.createElement(Paper, { sx: {
|
|
296
|
-
fontSize:
|
|
298
|
+
fontSize: "0.875rem",
|
|
297
299
|
height,
|
|
298
|
-
|
|
300
|
+
"& .DataGridEx-Cell": {
|
|
299
301
|
padding: 2,
|
|
300
|
-
whiteSpace:
|
|
301
|
-
overflow:
|
|
302
|
-
textOverflow:
|
|
302
|
+
whiteSpace: "nowrap",
|
|
303
|
+
overflow: "hidden",
|
|
304
|
+
textOverflow: "ellipsis"
|
|
303
305
|
},
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
306
|
+
"& .DataGridEx-CustomBar": {
|
|
307
|
+
"@media (min-width: 800px)": {
|
|
308
|
+
"::-webkit-scrollbar": {
|
|
307
309
|
width: scrollbarSize,
|
|
308
310
|
height: scrollbarSize,
|
|
309
|
-
backgroundColor:
|
|
311
|
+
backgroundColor: "#f6f6f6"
|
|
310
312
|
},
|
|
311
|
-
|
|
312
|
-
backgroundColor:
|
|
313
|
-
borderRadius:
|
|
313
|
+
"::-webkit-scrollbar-thumb": {
|
|
314
|
+
backgroundColor: "rgba(0,0,0,0.4)",
|
|
315
|
+
borderRadius: "2px"
|
|
314
316
|
},
|
|
315
|
-
|
|
316
|
-
background:
|
|
317
|
+
"::-webkit-scrollbar-track-piece:start": {
|
|
318
|
+
background: "transparent"
|
|
317
319
|
},
|
|
318
|
-
|
|
319
|
-
background:
|
|
320
|
+
"::-webkit-scrollbar-track-piece:end": {
|
|
321
|
+
background: "transparent"
|
|
320
322
|
}
|
|
321
323
|
}
|
|
322
324
|
}
|
|
323
325
|
} },
|
|
324
326
|
React.createElement("div", { className: "DataGridEx-CustomBar", style: {
|
|
325
327
|
width,
|
|
326
|
-
overflowX:
|
|
327
|
-
overflowY:
|
|
328
|
+
overflowX: "auto",
|
|
329
|
+
overflowY: "hidden"
|
|
328
330
|
} }, table)));
|
|
329
331
|
}
|
package/lib/MUGlobal.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export declare class MUGlobal {
|
|
|
49
49
|
* @param href Item's href
|
|
50
50
|
* @returns Props
|
|
51
51
|
*/
|
|
52
|
-
static getMenuItem(path: string, href: string): ListItemButtonProps
|
|
52
|
+
static getMenuItem(path: string, href: string): ListItemButtonProps;
|
|
53
53
|
/**
|
|
54
54
|
* Update object number properties with half of it
|
|
55
55
|
* @param input Input object
|
package/lib/MUGlobal.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Link } from 'react-router-dom';
|
|
|
3
3
|
/**
|
|
4
4
|
* MUGlobal for global configurations
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
class MUGlobal {
|
|
7
7
|
/**
|
|
8
8
|
* Get menu item props
|
|
9
9
|
* @param path Current path
|
|
@@ -182,3 +182,4 @@ MUGlobal.pagePaddings = { xs: 2, sm: 3 };
|
|
|
182
182
|
* Break points defined
|
|
183
183
|
*/
|
|
184
184
|
MUGlobal.breakpoints = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
185
|
+
export { MUGlobal };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.68",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"@emotion/styled": "^11.10.6",
|
|
53
53
|
"@etsoo/appscript": "^1.3.82",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.24",
|
|
55
|
-
"@etsoo/react": "^1.6.
|
|
55
|
+
"@etsoo/react": "^1.6.54",
|
|
56
56
|
"@etsoo/shared": "^1.1.92",
|
|
57
57
|
"@mui/icons-material": "^5.11.11",
|
|
58
58
|
"@mui/material": "^5.11.14",
|
|
59
59
|
"@mui/x-data-grid": "^6.0.3",
|
|
60
60
|
"@types/pica": "^9.0.1",
|
|
61
61
|
"@types/pulltorefreshjs": "^0.1.5",
|
|
62
|
-
"@types/react": "^18.0.
|
|
62
|
+
"@types/react": "^18.0.29",
|
|
63
63
|
"@types/react-avatar-editor": "^13.0.0",
|
|
64
64
|
"@types/react-dom": "^18.0.11",
|
|
65
65
|
"@types/react-input-mask": "^3.0.2",
|
|
@@ -89,6 +89,6 @@
|
|
|
89
89
|
"@typescript-eslint/parser": "^5.56.0",
|
|
90
90
|
"jest": "^29.5.0",
|
|
91
91
|
"jest-environment-jsdom": "^29.5.0",
|
|
92
|
-
"typescript": "^
|
|
92
|
+
"typescript": "^5.0.2"
|
|
93
93
|
}
|
|
94
94
|
}
|