@etsoo/materialui 1.3.9 → 1.3.11
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.js +1 -1
- package/lib/MUUtils.d.ts +8 -0
- package/lib/MUUtils.js +23 -0
- package/package.json +5 -5
- package/src/DataGridEx.tsx +2 -1
- package/src/MUUtils.ts +29 -0
package/lib/DataGridEx.js
CHANGED
|
@@ -261,7 +261,7 @@ export function DataGridEx(props) {
|
|
|
261
261
|
rowIndex,
|
|
262
262
|
columnIndex,
|
|
263
263
|
cellProps,
|
|
264
|
-
renderProps,
|
|
264
|
+
renderProps: typeof renderProps === "function" ? renderProps(data) : renderProps,
|
|
265
265
|
setItems
|
|
266
266
|
});
|
|
267
267
|
return (React.createElement("div", { className: rowClass, style: style, "data-row": rowIndex, "data-column": columnIndex, onMouseDown: selectable && !checkable ? handleMouseDown : undefined, onMouseOver: selectable ? handleMouseOver : undefined, onMouseOut: selectable ? handleMouseOut : undefined, onClick: (event) => onClick && data != null && onClick(event, data), onDoubleClick: (event) => onDoubleClick && data != null && onDoubleClick(event, data) },
|
package/lib/MUUtils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ListType2 } from "@etsoo/shared";
|
|
2
|
+
import { GridApiCommunity } from "@mui/x-data-grid/models/api/gridApiCommunity";
|
|
2
3
|
/**
|
|
3
4
|
* MU utilities
|
|
4
5
|
*/
|
|
@@ -9,4 +10,11 @@ export declare namespace MUUtils {
|
|
|
9
10
|
* @returns Result
|
|
10
11
|
*/
|
|
11
12
|
function getListItemLabel(item: ListType2): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get grid data
|
|
15
|
+
* @param grid Grid
|
|
16
|
+
* @param checkField Check field or callback
|
|
17
|
+
* @returns Results
|
|
18
|
+
*/
|
|
19
|
+
function getGridData<T>(grid: GridApiCommunity, checkField: keyof T | ((item: T) => boolean)): T[];
|
|
12
20
|
}
|
package/lib/MUUtils.js
CHANGED
|
@@ -16,4 +16,27 @@ export var MUUtils;
|
|
|
16
16
|
: item.title;
|
|
17
17
|
}
|
|
18
18
|
MUUtils.getListItemLabel = getListItemLabel;
|
|
19
|
+
/**
|
|
20
|
+
* Get grid data
|
|
21
|
+
* @param grid Grid
|
|
22
|
+
* @param checkField Check field or callback
|
|
23
|
+
* @returns Results
|
|
24
|
+
*/
|
|
25
|
+
function getGridData(grid, checkField) {
|
|
26
|
+
const check = typeof checkField === "function"
|
|
27
|
+
? checkField
|
|
28
|
+
: (item) => {
|
|
29
|
+
const value = item[checkField];
|
|
30
|
+
return value == null || value === "" ? false : true;
|
|
31
|
+
};
|
|
32
|
+
const items = [];
|
|
33
|
+
for (const [_, value] of grid.getRowModels()) {
|
|
34
|
+
const item = value;
|
|
35
|
+
if (check(item)) {
|
|
36
|
+
items.push(item);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return items;
|
|
40
|
+
}
|
|
41
|
+
MUUtils.getGridData = getGridData;
|
|
19
42
|
})(MUUtils || (MUUtils = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.11",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"@emotion/css": "^11.11.2",
|
|
51
51
|
"@emotion/react": "^11.11.1",
|
|
52
52
|
"@emotion/styled": "^11.11.0",
|
|
53
|
-
"@etsoo/appscript": "^1.4.
|
|
53
|
+
"@etsoo/appscript": "^1.4.45",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.28",
|
|
55
|
-
"@etsoo/react": "^1.7.
|
|
55
|
+
"@etsoo/react": "^1.7.8",
|
|
56
56
|
"@etsoo/shared": "^1.2.12",
|
|
57
57
|
"@mui/icons-material": "^5.14.8",
|
|
58
58
|
"@mui/material": "^5.14.8",
|
|
59
|
-
"@mui/x-data-grid": "^6.
|
|
59
|
+
"@mui/x-data-grid": "^6.13.0",
|
|
60
60
|
"@types/pica": "^9.0.1",
|
|
61
61
|
"@types/pulltorefreshjs": "^0.1.5",
|
|
62
62
|
"@types/react": "^18.2.21",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@babel/cli": "^7.22.15",
|
|
79
|
-
"@babel/core": "^7.22.
|
|
79
|
+
"@babel/core": "^7.22.17",
|
|
80
80
|
"@babel/plugin-transform-runtime": "^7.22.15",
|
|
81
81
|
"@babel/preset-env": "^7.22.15",
|
|
82
82
|
"@babel/preset-react": "^7.22.15",
|
package/src/DataGridEx.tsx
CHANGED
package/src/MUUtils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ListType2 } from "@etsoo/shared";
|
|
2
|
+
import { GridApiCommunity } from "@mui/x-data-grid/models/api/gridApiCommunity";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* MU utilities
|
|
@@ -16,4 +17,32 @@ export namespace MUUtils {
|
|
|
16
17
|
? item.name
|
|
17
18
|
: item.title;
|
|
18
19
|
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get grid data
|
|
23
|
+
* @param grid Grid
|
|
24
|
+
* @param checkField Check field or callback
|
|
25
|
+
* @returns Results
|
|
26
|
+
*/
|
|
27
|
+
export function getGridData<T>(
|
|
28
|
+
grid: GridApiCommunity,
|
|
29
|
+
checkField: keyof T | ((item: T) => boolean)
|
|
30
|
+
) {
|
|
31
|
+
const check =
|
|
32
|
+
typeof checkField === "function"
|
|
33
|
+
? checkField
|
|
34
|
+
: (item: T) => {
|
|
35
|
+
const value = item[checkField];
|
|
36
|
+
return value == null || value === "" ? false : true;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const items: T[] = [];
|
|
40
|
+
for (const [_, value] of grid.getRowModels()) {
|
|
41
|
+
const item = value as T;
|
|
42
|
+
if (check(item)) {
|
|
43
|
+
items.push(item);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return items;
|
|
47
|
+
}
|
|
19
48
|
}
|