@etsoo/materialui 1.4.46 → 1.4.48

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.
@@ -8,7 +8,7 @@ globalThis.ResizeObserver = vi.fn().mockImplementation(() => ({
8
8
  disconnect: vi.fn()
9
9
  }));
10
10
 
11
- type Data = { id: number; name: string };
11
+ type Data = { id: number; name: string; value?: string };
12
12
 
13
13
  // Timer mock
14
14
  // https://jestjs.io/docs/en/timer-mocks
@@ -28,7 +28,12 @@ it("Render ResponsePage", async () => {
28
28
  fields={[]}
29
29
  columns={[
30
30
  { field: "id", header: "ID" },
31
- { field: "name", header: "Name" }
31
+ { field: "name", header: "Name" },
32
+ {
33
+ field: "value",
34
+ header: "Value",
35
+ valueFormatter: ({ data }) => data?.value ?? data?.name
36
+ }
32
37
  ]}
33
38
  height={200}
34
39
  itemSize={[118, MUGlobal.pagePaddings]}
@@ -13,7 +13,7 @@ export declare namespace GridUtils {
13
13
  * @param keepSource Keep source or not
14
14
  * @returns Request data
15
15
  */
16
- function createLoader(props: GridLoadDataProps, template?: object, cacheKey?: string, keepSource?: boolean): {
16
+ function createLoader<const F>(props: GridLoadDataProps, template?: F, cacheKey?: string, keepSource?: boolean): DataTypes.BasicTemplateType<{ [k in keyof F]: F[k] extends "date" ? "string" | "date" : F[k] extends "string" | "number" | "bigint" | "boolean" | "date" | "number[]" | "bigint[]" | "date[]" | "boolean[]" | "string[]" | "unknown[]" ? F[k] : never; }> & {
17
17
  queryPaging: import("@etsoo/appscript").QueryPagingData;
18
18
  };
19
19
  /**
@@ -7,7 +7,7 @@ import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from "./
7
7
  /**
8
8
  * ResponsibleContainer props
9
9
  */
10
- export type ResponsibleContainerProps<T extends object> = Omit<DataGridExProps<T>, "height" | "itemKey" | "loadData" | "mRef" | "onScroll" | "onItemsRendered" | "onInitLoad" | "onUpdateRows"> & {
10
+ export type ResponsibleContainerProps<T extends object, F> = Omit<DataGridExProps<T>, "height" | "itemKey" | "loadData" | "mRef" | "onScroll" | "onItemsRendered" | "onInitLoad" | "onUpdateRows"> & {
11
11
  /**
12
12
  * Height will be deducted
13
13
  * @param height Current calcuated height
@@ -32,11 +32,11 @@ export type ResponsibleContainerProps<T extends object> = Omit<DataGridExProps<T
32
32
  /**
33
33
  * Search fields
34
34
  */
35
- fields?: React.ReactElement[] | ((data: GridTemplateType<ResponsibleContainerProps<T>["fieldTemplate"]>) => React.ReactElement[]);
35
+ fields?: React.ReactElement[] | ((data: GridTemplateType<F>) => React.ReactElement[]);
36
36
  /**
37
37
  * Search field template
38
38
  */
39
- fieldTemplate: object;
39
+ readonly fieldTemplate: F;
40
40
  /**
41
41
  * Grid height
42
42
  */
@@ -56,7 +56,7 @@ export type ResponsibleContainerProps<T extends object> = Omit<DataGridExProps<T
56
56
  /**
57
57
  * Load data callback
58
58
  */
59
- loadData: (data: GridJsonData & GridTemplateType<ResponsibleContainerProps<T>["fieldTemplate"]>, lastItem?: T) => PromiseLike<T[] | null | undefined>;
59
+ loadData: (data: GridJsonData & GridTemplateType<F>, lastItem?: T) => PromiseLike<T[] | null | undefined>;
60
60
  /**
61
61
  * Methods
62
62
  */
@@ -95,4 +95,4 @@ export type ResponsibleContainerProps<T extends object> = Omit<DataGridExProps<T
95
95
  * @param props Props
96
96
  * @returns Layout
97
97
  */
98
- export declare function ResponsibleContainer<T extends object>(props: ResponsibleContainerProps<T>): import("react/jsx-runtime").JSX.Element;
98
+ export declare function ResponsibleContainer<T extends object, F>(props: ResponsibleContainerProps<T, F>): import("react/jsx-runtime").JSX.Element;
@@ -4,4 +4,4 @@ import type { DataGridPageProps } from "./DataGridPageProps";
4
4
  * @param props Props
5
5
  * @returns Component
6
6
  */
7
- export declare function DataGridPage<T extends object>(props: DataGridPageProps<T>): import("react/jsx-runtime").JSX.Element;
7
+ export declare function DataGridPage<T extends object, F>(props: DataGridPageProps<T, F>): import("react/jsx-runtime").JSX.Element;
@@ -2,8 +2,9 @@ import type { DataGridExProps } from "../DataGridEx";
2
2
  import type { SearchPageProps } from "./SearchPageProps";
3
3
  /**
4
4
  * DataGrid page props
5
+ * Change it to interface extends can find the conflicts quickly
5
6
  */
6
- export type DataGridPageProps<T extends object> = SearchPageProps<T> & Omit<DataGridExProps<T>, "loadData"> & {
7
+ export type DataGridPageProps<T extends object, F> = SearchPageProps<T, F> & Omit<DataGridExProps<T>, "loadData" | "cacheKey" | "cacheMinutes" | "height"> & {
7
8
  /**
8
9
  * Height will be deducted
9
10
  * @param height Current calcuated height
@@ -4,7 +4,7 @@ import type { ListPageProps } from "./ListPage";
4
4
  * @param props Props
5
5
  * @returns Component
6
6
  */
7
- export declare function FixedListPage<T extends object>(props: ListPageProps<T> & {
7
+ export declare function FixedListPage<T extends object, F>(props: ListPageProps<T, F> & {
8
8
  /**
9
9
  * Height will be deducted
10
10
  * @param height Current calcuated height
@@ -3,10 +3,10 @@ import type { SearchPageProps } from "./SearchPageProps";
3
3
  /**
4
4
  * List page props
5
5
  */
6
- export type ListPageProps<T extends object> = SearchPageProps<T> & Omit<ScrollerListExProps<T>, "loadData">;
6
+ export type ListPageProps<T extends object, F> = SearchPageProps<T, F> & Omit<ScrollerListExProps<T>, "loadData">;
7
7
  /**
8
8
  * List page
9
9
  * @param props Props
10
10
  * @returns Component
11
11
  */
12
- export declare function ListPage<T extends object>(props: ListPageProps<T>): import("react/jsx-runtime").JSX.Element;
12
+ export declare function ListPage<T extends object, F>(props: ListPageProps<T, F>): import("react/jsx-runtime").JSX.Element;
@@ -7,7 +7,7 @@ import type { OperationMessageHandlerAll } from "../messages/OperationMessageHan
7
7
  /**
8
8
  * Response page props
9
9
  */
10
- export type ResponsePageProps<T extends object> = DataGridPageProps<T> & {
10
+ export type ResponsePageProps<T extends object, F> = DataGridPageProps<T, F> & {
11
11
  /**
12
12
  *
13
13
  * @param height Current height
@@ -53,4 +53,4 @@ export type ResponsePageProps<T extends object> = DataGridPageProps<T> & {
53
53
  * @param props Props
54
54
  * @returns Component
55
55
  */
56
- export declare function ResponsivePage<T extends object>(props: ResponsePageProps<T>): import("react/jsx-runtime").JSX.Element;
56
+ export declare function ResponsivePage<T extends object, F>(props: ResponsePageProps<T, F>): import("react/jsx-runtime").JSX.Element;
@@ -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> = Omit<GridLoader<T>, "loadData"> & {
6
+ export type SearchPageProps<T extends object, F> = Omit<GridLoader<T>, "loadData"> & {
7
7
  /**
8
8
  * Cache key
9
9
  */
@@ -15,15 +15,15 @@ export type SearchPageProps<T extends object> = Omit<GridLoader<T>, "loadData">
15
15
  /**
16
16
  * Search fields
17
17
  */
18
- fields: React.ReactElement[] | ((data: GridTemplateType<SearchPageProps<T>["fieldTemplate"]>) => React.ReactElement[]);
18
+ fields: React.ReactElement[] | ((data: GridTemplateType<F>) => React.ReactElement[]);
19
19
  /**
20
20
  * Search field template
21
21
  */
22
- readonly fieldTemplate: object;
22
+ readonly fieldTemplate: F;
23
23
  /**
24
24
  * Load data callback
25
25
  */
26
- loadData: (data: GridJsonData & GridTemplateType<SearchPageProps<T>["fieldTemplate"]>, lastItem?: T) => PromiseLike<T[] | null | undefined>;
26
+ loadData: (data: GridJsonData & GridTemplateType<F>, lastItem?: T) => PromiseLike<T[] | null | undefined>;
27
27
  /**
28
28
  * Page props
29
29
  */
@@ -4,10 +4,10 @@ import type { SearchPageProps } from "./SearchPageProps";
4
4
  /**
5
5
  * Table page props
6
6
  */
7
- export type TablePageProps<T extends object, D extends DataTypes.Keys<T>> = SearchPageProps<T> & Omit<TableExProps<T, D>, "loadData">;
7
+ export type TablePageProps<T extends object, F, D extends DataTypes.Keys<T>> = SearchPageProps<T, F> & Omit<TableExProps<T, D>, "loadData">;
8
8
  /**
9
9
  * Table page
10
10
  * @param props Props
11
11
  * @returns Component
12
12
  */
13
- export declare function TablePage<T extends object, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: TablePageProps<T, D>): import("react/jsx-runtime").JSX.Element;
13
+ export declare function TablePage<T extends object, F, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: TablePageProps<T, F, D>): import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.46",
3
+ "version": "1.4.48",
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.10",
40
+ "@etsoo/react": "^1.8.11",
41
41
  "@etsoo/shared": "^1.2.55",
42
42
  "@mui/icons-material": "^6.1.10",
43
43
  "@mui/material": "^6.1.10",
package/src/GridUtils.ts CHANGED
@@ -18,9 +18,9 @@ export namespace GridUtils {
18
18
  * @param keepSource Keep source or not
19
19
  * @returns Request data
20
20
  */
21
- export function createLoader(
21
+ export function createLoader<const F>(
22
22
  props: GridLoadDataProps,
23
- template?: object,
23
+ template?: F,
24
24
  cacheKey?: string,
25
25
  keepSource?: boolean
26
26
  ) {
@@ -33,7 +33,7 @@ import { GridUtils } from "./GridUtils";
33
33
  /**
34
34
  * ResponsibleContainer props
35
35
  */
36
- export type ResponsibleContainerProps<T extends object> = Omit<
36
+ export type ResponsibleContainerProps<T extends object, F> = Omit<
37
37
  DataGridExProps<T>,
38
38
  | "height"
39
39
  | "itemKey"
@@ -78,14 +78,12 @@ export type ResponsibleContainerProps<T extends object> = Omit<
78
78
  */
79
79
  fields?:
80
80
  | React.ReactElement[]
81
- | ((
82
- data: GridTemplateType<ResponsibleContainerProps<T>["fieldTemplate"]>
83
- ) => React.ReactElement[]);
81
+ | ((data: GridTemplateType<F>) => React.ReactElement[]);
84
82
 
85
83
  /**
86
84
  * Search field template
87
85
  */
88
- fieldTemplate: object;
86
+ readonly fieldTemplate: F;
89
87
 
90
88
  /**
91
89
  * Grid height
@@ -113,8 +111,7 @@ export type ResponsibleContainerProps<T extends object> = Omit<
113
111
  * Load data callback
114
112
  */
115
113
  loadData: (
116
- data: GridJsonData &
117
- GridTemplateType<ResponsibleContainerProps<T>["fieldTemplate"]>,
114
+ data: GridJsonData & GridTemplateType<F>,
118
115
  lastItem?: T
119
116
  ) => PromiseLike<T[] | null | undefined>;
120
117
 
@@ -185,8 +182,8 @@ function defaultContainerBoxSx(
185
182
  * @param props Props
186
183
  * @returns Layout
187
184
  */
188
- export function ResponsibleContainer<T extends object>(
189
- props: ResponsibleContainerProps<T>
185
+ export function ResponsibleContainer<T extends object, F>(
186
+ props: ResponsibleContainerProps<T, F>
190
187
  ) {
191
188
  // Destruct
192
189
  const {
@@ -28,7 +28,9 @@ interface LocalStates<T> {
28
28
  * @param props Props
29
29
  * @returns Component
30
30
  */
31
- export function DataGridPage<T extends object>(props: DataGridPageProps<T>) {
31
+ export function DataGridPage<T extends object, F>(
32
+ props: DataGridPageProps<T, F>
33
+ ) {
32
34
  // Destruct
33
35
  const {
34
36
  adjustHeight,
@@ -3,9 +3,13 @@ import type { SearchPageProps } from "./SearchPageProps";
3
3
 
4
4
  /**
5
5
  * DataGrid page props
6
+ * Change it to interface extends can find the conflicts quickly
6
7
  */
7
- export type DataGridPageProps<T extends object> = SearchPageProps<T> &
8
- Omit<DataGridExProps<T>, "loadData"> & {
8
+ export type DataGridPageProps<T extends object, F> = SearchPageProps<T, F> &
9
+ Omit<
10
+ DataGridExProps<T>,
11
+ "loadData" | "cacheKey" | "cacheMinutes" | "height"
12
+ > & {
9
13
  /**
10
14
  * Height will be deducted
11
15
  * @param height Current calcuated height
@@ -21,8 +21,8 @@ import type { ListPageProps } from "./ListPage";
21
21
  * @param props Props
22
22
  * @returns Component
23
23
  */
24
- export function FixedListPage<T extends object>(
25
- props: ListPageProps<T> & {
24
+ export function FixedListPage<T extends object, F>(
25
+ props: ListPageProps<T, F> & {
26
26
  /**
27
27
  * Height will be deducted
28
28
  * @param height Current calcuated height
@@ -18,7 +18,7 @@ import type { SearchPageProps } from "./SearchPageProps";
18
18
  /**
19
19
  * List page props
20
20
  */
21
- export type ListPageProps<T extends object> = SearchPageProps<T> &
21
+ export type ListPageProps<T extends object, F> = SearchPageProps<T, F> &
22
22
  Omit<ScrollerListExProps<T>, "loadData">;
23
23
 
24
24
  /**
@@ -26,7 +26,7 @@ export type ListPageProps<T extends object> = SearchPageProps<T> &
26
26
  * @param props Props
27
27
  * @returns Component
28
28
  */
29
- export function ListPage<T extends object>(props: ListPageProps<T>) {
29
+ export function ListPage<T extends object, F>(props: ListPageProps<T, F>) {
30
30
  // Destruct
31
31
  const {
32
32
  fields,
@@ -15,7 +15,7 @@ import type { OperationMessageHandlerAll } from "../messages/OperationMessageHan
15
15
  /**
16
16
  * Response page props
17
17
  */
18
- export type ResponsePageProps<T extends object> = DataGridPageProps<T> & {
18
+ export type ResponsePageProps<T extends object, F> = DataGridPageProps<T, F> & {
19
19
  /**
20
20
  *
21
21
  * @param height Current height
@@ -72,7 +72,9 @@ export type ResponsePageProps<T extends object> = DataGridPageProps<T> & {
72
72
  * @param props Props
73
73
  * @returns Component
74
74
  */
75
- export function ResponsivePage<T extends object>(props: ResponsePageProps<T>) {
75
+ export function ResponsivePage<T extends object, F>(
76
+ props: ResponsePageProps<T, F>
77
+ ) {
76
78
  // Destruct
77
79
  const { pageProps = {}, operationMessageHandler, ...rest } = props;
78
80
 
@@ -94,7 +96,7 @@ export function ResponsivePage<T extends object>(props: ResponsePageProps<T>) {
94
96
  {operationMessageHandler && (
95
97
  <OperationMessageContainer handler={operationMessageHandler} />
96
98
  )}
97
- <ResponsibleContainer<T>
99
+ <ResponsibleContainer<T, F>
98
100
  paddings={paddings}
99
101
  containerBoxSx={(paddings, hasField, _dataGrid) => {
100
102
  // Half
@@ -4,7 +4,7 @@ import type { CommonPageProps } from "./CommonPage";
4
4
  /**
5
5
  * Search page props
6
6
  */
7
- export type SearchPageProps<T extends object> = Omit<
7
+ export type SearchPageProps<T extends object, F> = Omit<
8
8
  GridLoader<T>,
9
9
  "loadData"
10
10
  > & {
@@ -23,20 +23,18 @@ export type SearchPageProps<T extends object> = Omit<
23
23
  */
24
24
  fields:
25
25
  | React.ReactElement[]
26
- | ((
27
- data: GridTemplateType<SearchPageProps<T>["fieldTemplate"]>
28
- ) => React.ReactElement[]);
26
+ | ((data: GridTemplateType<F>) => React.ReactElement[]);
29
27
 
30
28
  /**
31
29
  * Search field template
32
30
  */
33
- readonly fieldTemplate: object;
31
+ readonly fieldTemplate: F;
34
32
 
35
33
  /**
36
34
  * Load data callback
37
35
  */
38
36
  loadData: (
39
- data: GridJsonData & GridTemplateType<SearchPageProps<T>["fieldTemplate"]>,
37
+ data: GridJsonData & GridTemplateType<F>,
40
38
  lastItem?: T
41
39
  ) => PromiseLike<T[] | null | undefined>;
42
40
 
@@ -23,8 +23,9 @@ import type { SearchPageProps } from "./SearchPageProps";
23
23
  */
24
24
  export type TablePageProps<
25
25
  T extends object,
26
+ F,
26
27
  D extends DataTypes.Keys<T>
27
- > = SearchPageProps<T> & Omit<TableExProps<T, D>, "loadData">;
28
+ > = SearchPageProps<T, F> & Omit<TableExProps<T, D>, "loadData">;
28
29
 
29
30
  /**
30
31
  * Table page
@@ -33,8 +34,9 @@ export type TablePageProps<
33
34
  */
34
35
  export function TablePage<
35
36
  T extends object,
37
+ F,
36
38
  D extends DataTypes.Keys<T> = IdDefaultType<T>
37
- >(props: TablePageProps<T, D>) {
39
+ >(props: TablePageProps<T, F, D>) {
38
40
  // Destruct
39
41
  const {
40
42
  columns,