@etsoo/materialui 1.4.48 → 1.4.50
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/__tests__/ResponsePage.tsx +23 -12
- package/__tests__/tsconfig.json +2 -2
- package/lib/DataGridEx.d.ts +2 -2
- package/lib/pages/DataGridPageProps.d.ts +2 -2
- package/lib/pages/SearchPageProps.d.ts +1 -5
- package/package.json +2 -2
- package/src/DataGridEx.tsx +7 -2
- package/src/pages/DataGridPageProps.ts +6 -6
- package/src/pages/SearchPageProps.ts +3 -11
- package/tsconfig.json +1 -1
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { act, render } from "@testing-library/react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
MUGlobal,
|
|
4
|
+
MobileListItemRenderer,
|
|
5
|
+
ResponsivePage,
|
|
6
|
+
SearchField
|
|
7
|
+
} from "../src";
|
|
3
8
|
import React from "react";
|
|
4
9
|
|
|
5
10
|
globalThis.ResizeObserver = vi.fn().mockImplementation(() => ({
|
|
@@ -8,7 +13,13 @@ globalThis.ResizeObserver = vi.fn().mockImplementation(() => ({
|
|
|
8
13
|
disconnect: vi.fn()
|
|
9
14
|
}));
|
|
10
15
|
|
|
11
|
-
type Data = {
|
|
16
|
+
type Data = {
|
|
17
|
+
id: number;
|
|
18
|
+
name: string;
|
|
19
|
+
deviceName?: string;
|
|
20
|
+
data?: string;
|
|
21
|
+
creation?: Date;
|
|
22
|
+
};
|
|
12
23
|
|
|
13
24
|
// Timer mock
|
|
14
25
|
// https://jestjs.io/docs/en/timer-mocks
|
|
@@ -25,16 +36,7 @@ it("Render ResponsePage", async () => {
|
|
|
25
36
|
// Act
|
|
26
37
|
render(
|
|
27
38
|
<ResponsivePage<Data, typeof fieldTemplate>
|
|
28
|
-
fields={[]}
|
|
29
|
-
columns={[
|
|
30
|
-
{ field: "id", header: "ID" },
|
|
31
|
-
{ field: "name", header: "Name" },
|
|
32
|
-
{
|
|
33
|
-
field: "value",
|
|
34
|
-
header: "Value",
|
|
35
|
-
valueFormatter: ({ data }) => data?.value ?? data?.name
|
|
36
|
-
}
|
|
37
|
-
]}
|
|
39
|
+
fields={[<SearchField label="Keyword" name="keyword" minChars={2} />]}
|
|
38
40
|
height={200}
|
|
39
41
|
itemSize={[118, MUGlobal.pagePaddings]}
|
|
40
42
|
fieldTemplate={fieldTemplate}
|
|
@@ -45,6 +47,15 @@ it("Render ResponsePage", async () => {
|
|
|
45
47
|
{ id: id ?? 0, name: "auto" }
|
|
46
48
|
])
|
|
47
49
|
}
|
|
50
|
+
columns={[
|
|
51
|
+
{ field: "id", header: "ID" },
|
|
52
|
+
{ field: "name", header: "Name" },
|
|
53
|
+
{
|
|
54
|
+
field: "deviceName",
|
|
55
|
+
header: "Value",
|
|
56
|
+
valueFormatter: ({ data }) => data?.deviceName ?? data?.name
|
|
57
|
+
}
|
|
58
|
+
]}
|
|
48
59
|
innerItemRenderer={(props) =>
|
|
49
60
|
MobileListItemRenderer(props, (data) => {
|
|
50
61
|
return [
|
package/__tests__/tsconfig.json
CHANGED
package/lib/DataGridEx.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GridColumn, GridLoaderStates, ScrollerGridProps } from "@etsoo/react";
|
|
1
|
+
import { GridColumn, GridJsonData, GridLoadDataProps, GridLoaderStates, ScrollerGridProps } from "@etsoo/react";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { MouseEventWithDataHandler } from "./MUGlobal";
|
|
4
4
|
/**
|
|
@@ -14,7 +14,7 @@ export type DataGridExFooterItemRendererProps<T extends object> = {
|
|
|
14
14
|
/**
|
|
15
15
|
* Extended DataGrid with VariableSizeGrid props
|
|
16
16
|
*/
|
|
17
|
-
export type DataGridExProps<T extends object> = Omit<ScrollerGridProps<T>, "itemRenderer" | "columnCount" | "columnWidth" | "width"> & {
|
|
17
|
+
export type DataGridExProps<T extends object, P extends GridJsonData = GridLoadDataProps> = Omit<ScrollerGridProps<T, P>, "itemRenderer" | "columnCount" | "columnWidth" | "width"> & {
|
|
18
18
|
/**
|
|
19
19
|
* Alternating colors for odd/even rows
|
|
20
20
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { GridJsonData, GridTemplateType } from "@etsoo/react";
|
|
1
2
|
import type { DataGridExProps } from "../DataGridEx";
|
|
2
3
|
import type { SearchPageProps } from "./SearchPageProps";
|
|
3
4
|
/**
|
|
4
5
|
* DataGrid page props
|
|
5
|
-
* Change it to interface extends can find the conflicts quickly
|
|
6
6
|
*/
|
|
7
|
-
export type DataGridPageProps<T extends object, F> =
|
|
7
|
+
export type DataGridPageProps<T extends object, F> = DataGridExProps<T, GridJsonData & GridTemplateType<F>> & SearchPageProps<T, F> & {
|
|
8
8
|
/**
|
|
9
9
|
* Height will be deducted
|
|
10
10
|
* @param height Current calcuated height
|
|
@@ -3,7 +3,7 @@ import type { CommonPageProps } from "./CommonPage";
|
|
|
3
3
|
/**
|
|
4
4
|
* Search page props
|
|
5
5
|
*/
|
|
6
|
-
export type SearchPageProps<T extends object, F> =
|
|
6
|
+
export type SearchPageProps<T extends object, F> = GridLoader<T, GridJsonData & GridTemplateType<F>> & {
|
|
7
7
|
/**
|
|
8
8
|
* Cache key
|
|
9
9
|
*/
|
|
@@ -20,10 +20,6 @@ export type SearchPageProps<T extends object, F> = Omit<GridLoader<T>, "loadData
|
|
|
20
20
|
* Search field template
|
|
21
21
|
*/
|
|
22
22
|
readonly fieldTemplate: F;
|
|
23
|
-
/**
|
|
24
|
-
* Load data callback
|
|
25
|
-
*/
|
|
26
|
-
loadData: (data: GridJsonData & GridTemplateType<F>, lastItem?: T) => PromiseLike<T[] | null | undefined>;
|
|
27
23
|
/**
|
|
28
24
|
* Page props
|
|
29
25
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/materialui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.50",
|
|
4
4
|
"description": "TypeScript Material-UI Implementation",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@emotion/styled": "^11.13.5",
|
|
38
38
|
"@etsoo/appscript": "^1.5.78",
|
|
39
39
|
"@etsoo/notificationbase": "^1.1.54",
|
|
40
|
-
"@etsoo/react": "^1.8.
|
|
40
|
+
"@etsoo/react": "^1.8.14",
|
|
41
41
|
"@etsoo/shared": "^1.2.55",
|
|
42
42
|
"@mui/icons-material": "^6.1.10",
|
|
43
43
|
"@mui/material": "^6.1.10",
|
package/src/DataGridEx.tsx
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
GridCellRendererProps,
|
|
6
6
|
GridColumn,
|
|
7
7
|
GridHeaderCellRendererProps,
|
|
8
|
+
GridJsonData,
|
|
9
|
+
GridLoadDataProps,
|
|
8
10
|
GridLoaderPartialStates,
|
|
9
11
|
GridLoaderStates,
|
|
10
12
|
ScrollerGrid,
|
|
@@ -40,8 +42,11 @@ export type DataGridExFooterItemRendererProps<T extends object> = {
|
|
|
40
42
|
/**
|
|
41
43
|
* Extended DataGrid with VariableSizeGrid props
|
|
42
44
|
*/
|
|
43
|
-
export type DataGridExProps<
|
|
44
|
-
|
|
45
|
+
export type DataGridExProps<
|
|
46
|
+
T extends object,
|
|
47
|
+
P extends GridJsonData = GridLoadDataProps
|
|
48
|
+
> = Omit<
|
|
49
|
+
ScrollerGridProps<T, P>,
|
|
45
50
|
"itemRenderer" | "columnCount" | "columnWidth" | "width"
|
|
46
51
|
> & {
|
|
47
52
|
/**
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { GridJsonData, GridTemplateType } from "@etsoo/react";
|
|
1
2
|
import type { DataGridExProps } from "../DataGridEx";
|
|
2
3
|
import type { SearchPageProps } from "./SearchPageProps";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* DataGrid page props
|
|
6
|
-
* Change it to interface extends can find the conflicts quickly
|
|
7
7
|
*/
|
|
8
|
-
export type DataGridPageProps<T extends object, F> =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
> & {
|
|
8
|
+
export type DataGridPageProps<T extends object, F> = DataGridExProps<
|
|
9
|
+
T,
|
|
10
|
+
GridJsonData & GridTemplateType<F>
|
|
11
|
+
> &
|
|
12
|
+
SearchPageProps<T, F> & {
|
|
13
13
|
/**
|
|
14
14
|
* Height will be deducted
|
|
15
15
|
* @param height Current calcuated height
|
|
@@ -4,9 +4,9 @@ import type { CommonPageProps } from "./CommonPage";
|
|
|
4
4
|
/**
|
|
5
5
|
* Search page props
|
|
6
6
|
*/
|
|
7
|
-
export type SearchPageProps<T extends object, F> =
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export type SearchPageProps<T extends object, F> = GridLoader<
|
|
8
|
+
T,
|
|
9
|
+
GridJsonData & GridTemplateType<F>
|
|
10
10
|
> & {
|
|
11
11
|
/**
|
|
12
12
|
* Cache key
|
|
@@ -30,14 +30,6 @@ export type SearchPageProps<T extends object, F> = Omit<
|
|
|
30
30
|
*/
|
|
31
31
|
readonly fieldTemplate: F;
|
|
32
32
|
|
|
33
|
-
/**
|
|
34
|
-
* Load data callback
|
|
35
|
-
*/
|
|
36
|
-
loadData: (
|
|
37
|
-
data: GridJsonData & GridTemplateType<F>,
|
|
38
|
-
lastItem?: T
|
|
39
|
-
) => PromiseLike<T[] | null | undefined>;
|
|
40
|
-
|
|
41
33
|
/**
|
|
42
34
|
* Page props
|
|
43
35
|
*/
|
package/tsconfig.json
CHANGED