@etsoo/react 1.5.76 → 1.5.79
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/app/CommonApp.d.ts +2 -2
- package/lib/app/Labels.d.ts +1 -1
- package/lib/app/ServiceApp.d.ts +2 -2
- package/lib/components/GridColumn.d.ts +10 -10
- package/lib/components/GridLoader.d.ts +7 -8
- package/lib/components/ScrollerGrid.d.ts +7 -7
- package/lib/components/ScrollerList.d.ts +2 -2
- package/lib/mu/AutocompleteExtendedProps.d.ts +4 -4
- package/lib/mu/ComboBox.d.ts +5 -5
- package/lib/mu/ComboBox.js +1 -1
- package/lib/mu/DataGridEx.d.ts +6 -5
- package/lib/mu/DataGridRenderers.d.ts +1 -1
- package/lib/mu/DnDList.d.ts +2 -2
- package/lib/mu/ItemList.d.ts +6 -5
- package/lib/mu/ItemList.js +4 -12
- package/lib/mu/ListMoreDisplay.d.ts +2 -2
- package/lib/mu/MUGlobal.d.ts +5 -5
- package/lib/mu/OptionGroup.d.ts +10 -11
- package/lib/mu/ResponsibleContainer.d.ts +6 -6
- package/lib/mu/ScrollerListEx.d.ts +11 -9
- package/lib/mu/ScrollerListEx.js +1 -1
- package/lib/mu/SearchOptionGroup.d.ts +2 -3
- package/lib/mu/SelectBool.d.ts +2 -3
- package/lib/mu/SelectBool.js +1 -1
- package/lib/mu/SelectEx.d.ts +6 -6
- package/lib/mu/SelectEx.js +1 -1
- package/lib/mu/TableEx.d.ts +5 -4
- package/lib/mu/TableEx.js +1 -2
- package/lib/mu/Tiplist.d.ts +4 -4
- package/lib/mu/Tiplist.js +2 -4
- package/lib/mu/pages/CommonPageProps.d.ts +1 -1
- package/lib/mu/pages/DataGridPage.d.ts +2 -2
- package/lib/mu/pages/DataGridPageProps.d.ts +3 -3
- package/lib/mu/pages/FixedListPage.d.ts +2 -2
- package/lib/mu/pages/ListPage.d.ts +2 -2
- package/lib/mu/pages/ListPageProps.d.ts +1 -2
- package/lib/mu/pages/ResponsivePage.d.ts +2 -2
- package/lib/mu/pages/ResponsivePageProps.d.ts +3 -3
- package/lib/mu/pages/SearchPageProps.d.ts +2 -2
- package/lib/mu/pages/TablePage.d.ts +2 -2
- package/lib/mu/pages/TablePageProps.d.ts +1 -2
- package/lib/mu/pages/ViewPage.d.ts +5 -4
- package/lib/states/IState.d.ts +1 -1
- package/lib/uses/useCombinedRefs.d.ts +1 -1
- package/package.json +11 -11
- package/src/app/CommonApp.ts +2 -2
- package/src/app/Labels.ts +1 -1
- package/src/app/ServiceApp.ts +2 -2
- package/src/components/GridColumn.ts +10 -11
- package/src/components/GridLoader.ts +7 -7
- package/src/components/ScrollerGrid.tsx +66 -59
- package/src/components/ScrollerList.tsx +2 -4
- package/src/mu/AutocompleteExtendedProps.ts +9 -9
- package/src/mu/ComboBox.tsx +21 -13
- package/src/mu/DataGridEx.tsx +19 -18
- package/src/mu/DataGridRenderers.tsx +1 -1
- package/src/mu/DnDList.tsx +2 -2
- package/src/mu/ItemList.tsx +28 -25
- package/src/mu/ListMoreDisplay.tsx +2 -2
- package/src/mu/MUGlobal.ts +5 -5
- package/src/mu/OptionGroup.tsx +30 -23
- package/src/mu/ResponsibleContainer.tsx +19 -22
- package/src/mu/ScrollerListEx.tsx +25 -21
- package/src/mu/SearchOptionGroup.tsx +11 -6
- package/src/mu/SelectBool.tsx +7 -12
- package/src/mu/SelectEx.tsx +21 -13
- package/src/mu/TableEx.tsx +61 -60
- package/src/mu/Tiplist.tsx +15 -12
- package/src/mu/pages/CommonPageProps.ts +1 -1
- package/src/mu/pages/DataGridPage.tsx +15 -11
- package/src/mu/pages/DataGridPageProps.ts +17 -14
- package/src/mu/pages/FixedListPage.tsx +6 -5
- package/src/mu/pages/ListPage.tsx +6 -5
- package/src/mu/pages/ListPageProps.ts +5 -3
- package/src/mu/pages/ResponsivePage.tsx +6 -5
- package/src/mu/pages/ResponsivePageProps.ts +10 -7
- package/src/mu/pages/SearchPageProps.ts +5 -3
- package/src/mu/pages/TablePage.tsx +6 -5
- package/src/mu/pages/TablePageProps.ts +5 -3
- package/src/mu/pages/ViewPage.tsx +8 -6
- package/src/states/IState.ts +1 -1
- package/src/states/UserState.ts +1 -1
- package/src/uses/useCombinedRefs.ts +3 -3
package/src/mu/Tiplist.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType, ListType } from '@etsoo/shared';
|
|
2
2
|
import { Autocomplete, AutocompleteRenderInputParams } from '@mui/material';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { ReactUtils } from '../app/ReactUtils';
|
|
@@ -10,8 +10,10 @@ import { SearchField } from './SearchField';
|
|
|
10
10
|
/**
|
|
11
11
|
* Tiplist props
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
14
|
-
|
|
13
|
+
export type TiplistProps<T extends object, D extends DataTypes.Keys<T>> = Omit<
|
|
14
|
+
AutocompleteExtendedProps<T, D>,
|
|
15
|
+
'open'
|
|
16
|
+
> & {
|
|
15
17
|
/**
|
|
16
18
|
* Load data callback
|
|
17
19
|
*/
|
|
@@ -19,10 +21,10 @@ export interface TiplistProps<T extends {}, D extends DataTypes.Keys<T>>
|
|
|
19
21
|
keyword?: string,
|
|
20
22
|
id?: T[D]
|
|
21
23
|
) => PromiseLike<T[] | null | undefined>;
|
|
22
|
-
}
|
|
24
|
+
};
|
|
23
25
|
|
|
24
26
|
// Multiple states
|
|
25
|
-
interface States<T extends
|
|
27
|
+
interface States<T extends object> {
|
|
26
28
|
open: boolean;
|
|
27
29
|
options: T[];
|
|
28
30
|
value?: T | null;
|
|
@@ -34,13 +36,14 @@ interface States<T extends {}> {
|
|
|
34
36
|
* @param props Props
|
|
35
37
|
* @returns Component
|
|
36
38
|
*/
|
|
37
|
-
export function Tiplist<
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
export function Tiplist<
|
|
40
|
+
T extends object = ListType,
|
|
41
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
42
|
+
>(props: TiplistProps<T, D>) {
|
|
40
43
|
// Destruct
|
|
41
44
|
const {
|
|
42
45
|
search = false,
|
|
43
|
-
idField,
|
|
46
|
+
idField = 'id' as D,
|
|
44
47
|
idValue,
|
|
45
48
|
inputAutoComplete = 'off',
|
|
46
49
|
inputError,
|
|
@@ -66,10 +69,10 @@ export function Tiplist<T extends {}, D extends DataTypes.Keys<T>>(
|
|
|
66
69
|
|
|
67
70
|
// Local value
|
|
68
71
|
let localValue = value ?? defaultValue;
|
|
69
|
-
if (localValue === undefined) localValue = null;
|
|
70
72
|
|
|
71
73
|
// One time calculation for input's default value (uncontrolled)
|
|
72
|
-
const localIdValue =
|
|
74
|
+
const localIdValue =
|
|
75
|
+
idValue ?? DataTypes.getValue(localValue, idField as any);
|
|
73
76
|
|
|
74
77
|
// Changable states
|
|
75
78
|
const [states, stateUpdate] = React.useReducer(
|
|
@@ -216,7 +219,7 @@ export function Tiplist<T extends {}, D extends DataTypes.Keys<T>>(
|
|
|
216
219
|
onChange={inputOnChange}
|
|
217
220
|
/>
|
|
218
221
|
{/* Previous input will reset first with "disableClearable = false", next input trigger change works */}
|
|
219
|
-
<Autocomplete
|
|
222
|
+
<Autocomplete<T, undefined, false, false>
|
|
220
223
|
filterOptions={(options, _state) => options}
|
|
221
224
|
value={states.value}
|
|
222
225
|
options={states.options}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
2
|
import { Box, Stack } from '@mui/material';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { GridDataGet, GridLoadDataProps } from '../../components/GridLoader';
|
|
5
5
|
import { ScrollerGridForwardRef } from '../../components/ScrollerGrid';
|
|
6
6
|
import useCombinedRefs from '../../uses/useCombinedRefs';
|
|
7
7
|
import { useDimensions } from '../../uses/useDimensions';
|
|
8
|
-
import { DataGridEx } from '../DataGridEx';
|
|
8
|
+
import { DataGridEx, DataGridExProps } from '../DataGridEx';
|
|
9
9
|
import { MUGlobal } from '../MUGlobal';
|
|
10
10
|
import { SearchBar } from '../SearchBar';
|
|
11
11
|
import { CommonPage } from './CommonPage';
|
|
@@ -24,9 +24,10 @@ interface LocalStates {
|
|
|
24
24
|
* @returns Component
|
|
25
25
|
*/
|
|
26
26
|
export function DataGridPage<
|
|
27
|
-
T,
|
|
28
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
29
|
-
>
|
|
27
|
+
T extends object,
|
|
28
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
|
|
29
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
30
|
+
>(props: DataGridPageProps<T, F, D>) {
|
|
30
31
|
// Destruct
|
|
31
32
|
const {
|
|
32
33
|
adjustHeight,
|
|
@@ -52,11 +53,14 @@ export function DataGridPage<
|
|
|
52
53
|
}
|
|
53
54
|
);
|
|
54
55
|
|
|
55
|
-
const refs = useCombinedRefs(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
const refs = useCombinedRefs<ScrollerGridForwardRef>(
|
|
57
|
+
mRef,
|
|
58
|
+
(ref: ScrollerGridForwardRef | null) => {
|
|
59
|
+
if (ref == null) return;
|
|
60
|
+
states.ref = ref;
|
|
61
|
+
//setStates({ ref });
|
|
62
|
+
}
|
|
63
|
+
);
|
|
60
64
|
|
|
61
65
|
// On submit callback
|
|
62
66
|
const onSubmit = (data: FormData, _reset: boolean) => {
|
|
@@ -95,7 +99,7 @@ export function DataGridPage<
|
|
|
95
99
|
if (gridHeight == null) return;
|
|
96
100
|
|
|
97
101
|
return (
|
|
98
|
-
<DataGridEx<T>
|
|
102
|
+
<DataGridEx<T, D>
|
|
99
103
|
autoLoad={false}
|
|
100
104
|
height={gridHeight}
|
|
101
105
|
loadData={localLoadData}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
2
|
import { DataGridExProps } from '../DataGridEx';
|
|
3
3
|
import { SearchPageProps } from './SearchPageProps';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* DataGrid page props
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
9
|
-
extends
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
export type DataGridPageProps<
|
|
9
|
+
T extends object,
|
|
10
|
+
F extends DataTypes.BasicTemplate,
|
|
11
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
12
|
+
> = SearchPageProps<T, F> &
|
|
13
|
+
Omit<DataGridExProps<T, D>, 'loadData' | 'height'> & {
|
|
14
|
+
/**
|
|
15
|
+
* Height will be deducted
|
|
16
|
+
* @param height Current calcuated height
|
|
17
|
+
*/
|
|
18
|
+
adjustHeight?: (height: number) => number;
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
20
|
+
/**
|
|
21
|
+
* Grid height
|
|
22
|
+
*/
|
|
23
|
+
height?: number;
|
|
24
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
2
|
import { Box, Stack } from '@mui/material';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { GridDataGet, GridLoadDataProps } from '../../components/GridLoader';
|
|
@@ -17,10 +17,11 @@ import { ListPageProps } from './ListPageProps';
|
|
|
17
17
|
* @returns Component
|
|
18
18
|
*/
|
|
19
19
|
export function FixedListPage<
|
|
20
|
-
T extends
|
|
21
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
20
|
+
T extends object,
|
|
21
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
|
|
22
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
22
23
|
>(
|
|
23
|
-
props: ListPageProps<T, F> & {
|
|
24
|
+
props: ListPageProps<T, F, D> & {
|
|
24
25
|
/**
|
|
25
26
|
* Height will be deducted
|
|
26
27
|
* @param height Current calcuated height
|
|
@@ -99,7 +100,7 @@ export function FixedListPage<
|
|
|
99
100
|
height: height + 'px'
|
|
100
101
|
}}
|
|
101
102
|
>
|
|
102
|
-
<ScrollerListEx<T>
|
|
103
|
+
<ScrollerListEx<T, D>
|
|
103
104
|
autoLoad={false}
|
|
104
105
|
height={height}
|
|
105
106
|
loadData={localLoadData}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
2
|
import { Box, Stack } from '@mui/material';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { GridDataGet, GridLoadDataProps } from '../../components/GridLoader';
|
|
@@ -16,9 +16,10 @@ import { ListPageProps } from './ListPageProps';
|
|
|
16
16
|
* @returns Component
|
|
17
17
|
*/
|
|
18
18
|
export function ListPage<
|
|
19
|
-
T extends
|
|
20
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
21
|
-
>
|
|
19
|
+
T extends object,
|
|
20
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
|
|
21
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
22
|
+
>(props: ListPageProps<T, F, D>) {
|
|
22
23
|
// Destruct
|
|
23
24
|
const {
|
|
24
25
|
fields,
|
|
@@ -74,7 +75,7 @@ export function ListPage<
|
|
|
74
75
|
>
|
|
75
76
|
<SearchBar fields={fields} onSubmit={onSubmit} />
|
|
76
77
|
</Box>
|
|
77
|
-
<ScrollerListEx<T>
|
|
78
|
+
<ScrollerListEx<T, D>
|
|
78
79
|
autoLoad={false}
|
|
79
80
|
loadData={localLoadData}
|
|
80
81
|
mRef={refs}
|
|
@@ -5,6 +5,8 @@ import { SearchPageProps } from './SearchPageProps';
|
|
|
5
5
|
/**
|
|
6
6
|
* List page props
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
9
|
-
extends
|
|
10
|
-
|
|
8
|
+
export type ListPageProps<
|
|
9
|
+
T extends object,
|
|
10
|
+
F extends DataTypes.BasicTemplate,
|
|
11
|
+
D extends DataTypes.Keys<T>
|
|
12
|
+
> = SearchPageProps<T, F> & Omit<ScrollerListExProps<T, D>, 'loadData'>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { MUGlobal } from '../MUGlobal';
|
|
4
4
|
import { ResponsibleContainer } from '../ResponsibleContainer';
|
|
@@ -11,9 +11,10 @@ import { ResponsePageProps } from './ResponsivePageProps';
|
|
|
11
11
|
* @returns Component
|
|
12
12
|
*/
|
|
13
13
|
export function ResponsivePage<
|
|
14
|
-
T extends
|
|
15
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
16
|
-
>
|
|
14
|
+
T extends object,
|
|
15
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
|
|
16
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
17
|
+
>(props: ResponsePageProps<T, F, D>) {
|
|
17
18
|
// Destruct
|
|
18
19
|
const { pageProps = {}, ...rest } = props;
|
|
19
20
|
|
|
@@ -32,7 +33,7 @@ export function ResponsivePage<
|
|
|
32
33
|
scrollContainer={scrollContainer}
|
|
33
34
|
fabColumnDirection={direction}
|
|
34
35
|
>
|
|
35
|
-
<ResponsibleContainer<T, F>
|
|
36
|
+
<ResponsibleContainer<T, F, D>
|
|
36
37
|
paddings={paddings}
|
|
37
38
|
containerBoxSx={(paddings, hasField, _dataGrid) => {
|
|
38
39
|
// Half
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
2
|
import { ListChildComponentProps } from 'react-window';
|
|
3
3
|
import { GridMethodRef } from '../GridMethodRef';
|
|
4
4
|
import {
|
|
@@ -10,11 +10,14 @@ import { DataGridPageProps } from './DataGridPageProps';
|
|
|
10
10
|
/**
|
|
11
11
|
* Response page props
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
14
|
-
extends
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
export type ResponsePageProps<
|
|
14
|
+
T extends object,
|
|
15
|
+
F extends DataTypes.BasicTemplate,
|
|
16
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
17
|
+
> = Omit<
|
|
18
|
+
DataGridPageProps<T, F, D>,
|
|
19
|
+
'mRef' | 'itemKey' | 'onScroll' | 'onItemsRendered'
|
|
20
|
+
> & {
|
|
18
21
|
/**
|
|
19
22
|
* Min width to show Datagrid
|
|
20
23
|
*/
|
|
@@ -51,4 +54,4 @@ export interface ResponsePageProps<T, F extends DataTypes.BasicTemplate>
|
|
|
51
54
|
* Quick action for double click or click under mobile
|
|
52
55
|
*/
|
|
53
56
|
quickAction?: (data: T) => void;
|
|
54
|
-
}
|
|
57
|
+
};
|
|
@@ -5,8 +5,10 @@ import { CommonPageProps } from './CommonPageProps';
|
|
|
5
5
|
/**
|
|
6
6
|
* Search page props
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
9
|
-
|
|
8
|
+
export type SearchPageProps<
|
|
9
|
+
T extends object,
|
|
10
|
+
F extends DataTypes.BasicTemplate
|
|
11
|
+
> = Omit<GridLoader<T>, 'loadData'> & {
|
|
10
12
|
/**
|
|
11
13
|
* Search fields
|
|
12
14
|
*/
|
|
@@ -34,4 +36,4 @@ export interface SearchPageProps<T, F extends DataTypes.BasicTemplate>
|
|
|
34
36
|
* @default 100
|
|
35
37
|
*/
|
|
36
38
|
sizeReadyMiliseconds?: number;
|
|
37
|
-
}
|
|
39
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
2
|
import { Box, Stack } from '@mui/material';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { GridDataGet, GridLoadDataProps } from '../../components/GridLoader';
|
|
@@ -16,9 +16,10 @@ import { TablePageProps } from './TablePageProps';
|
|
|
16
16
|
* @returns Component
|
|
17
17
|
*/
|
|
18
18
|
export function TablePage<
|
|
19
|
-
T extends
|
|
20
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
21
|
-
>
|
|
19
|
+
T extends object,
|
|
20
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
|
|
21
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
22
|
+
>(props: TablePageProps<T, F, D>) {
|
|
22
23
|
// Destruct
|
|
23
24
|
const {
|
|
24
25
|
columns,
|
|
@@ -88,7 +89,7 @@ export function TablePage<
|
|
|
88
89
|
if (!isNaN(paddingBottom)) maxHeight -= paddingBottom;
|
|
89
90
|
|
|
90
91
|
return (
|
|
91
|
-
<TableEx<T>
|
|
92
|
+
<TableEx<T, D>
|
|
92
93
|
autoLoad={false}
|
|
93
94
|
columns={columns}
|
|
94
95
|
loadData={localLoadData}
|
|
@@ -5,6 +5,8 @@ import { SearchPageProps } from './SearchPageProps';
|
|
|
5
5
|
/**
|
|
6
6
|
* Table page props
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
9
|
-
extends
|
|
10
|
-
|
|
8
|
+
export type TablePageProps<
|
|
9
|
+
T extends object,
|
|
10
|
+
F extends DataTypes.BasicTemplate,
|
|
11
|
+
D extends DataTypes.Keys<T>
|
|
12
|
+
> = SearchPageProps<T, F> & Omit<TableExProps<T, D>, 'loadData'>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Utils } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, Utils } from '@etsoo/shared';
|
|
2
2
|
import {
|
|
3
3
|
Grid,
|
|
4
4
|
GridProps,
|
|
@@ -22,7 +22,7 @@ import { CommonPageProps } from './CommonPageProps';
|
|
|
22
22
|
/**
|
|
23
23
|
* View page display field
|
|
24
24
|
*/
|
|
25
|
-
export interface ViewPageField<T extends
|
|
25
|
+
export interface ViewPageField<T extends object> extends GridProps {
|
|
26
26
|
/**
|
|
27
27
|
* Data field
|
|
28
28
|
*/
|
|
@@ -49,7 +49,7 @@ export interface ViewPageField<T extends {}> extends GridProps {
|
|
|
49
49
|
renderProps?: GridColumnRenderProps;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
type ViewPageFieldType<T> =
|
|
52
|
+
type ViewPageFieldType<T extends object> =
|
|
53
53
|
| (string & keyof T)
|
|
54
54
|
| [string & keyof T, GridDataType, GridColumnRenderProps?]
|
|
55
55
|
| ViewPageField<T>;
|
|
@@ -57,7 +57,7 @@ type ViewPageFieldType<T> =
|
|
|
57
57
|
/**
|
|
58
58
|
* View page props
|
|
59
59
|
*/
|
|
60
|
-
export interface ViewPageProps<T extends
|
|
60
|
+
export interface ViewPageProps<T extends DataTypes.StringRecord>
|
|
61
61
|
extends Omit<CommonPageProps, 'children'> {
|
|
62
62
|
/**
|
|
63
63
|
* Actions
|
|
@@ -101,7 +101,7 @@ function formatItemData(fieldData: unknown): string | undefined {
|
|
|
101
101
|
return `${fieldData}`;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
function getItemField<T>(
|
|
104
|
+
function getItemField<T extends object>(
|
|
105
105
|
field: ViewPageFieldType<T>,
|
|
106
106
|
data: T
|
|
107
107
|
): [React.ReactNode, React.ReactNode, GridProps] {
|
|
@@ -163,7 +163,9 @@ function getItemField<T>(
|
|
|
163
163
|
* View page
|
|
164
164
|
* @param props Props
|
|
165
165
|
*/
|
|
166
|
-
export function ViewPage<T extends
|
|
166
|
+
export function ViewPage<T extends DataTypes.StringRecord>(
|
|
167
|
+
props: ViewPageProps<T>
|
|
168
|
+
) {
|
|
167
169
|
// Destruct
|
|
168
170
|
const {
|
|
169
171
|
actions,
|
package/src/states/IState.ts
CHANGED
|
@@ -4,7 +4,7 @@ import React, { ReactNode } from 'react';
|
|
|
4
4
|
/**
|
|
5
5
|
* State UI creator
|
|
6
6
|
*/
|
|
7
|
-
export interface IUICreator<S extends IState, A extends IAction, P =
|
|
7
|
+
export interface IUICreator<S extends IState, A extends IAction, P = object> {
|
|
8
8
|
(state: S, dispatch: React.Dispatch<A>, props: P): React.ReactElement;
|
|
9
9
|
}
|
|
10
10
|
|
package/src/states/UserState.ts
CHANGED
|
@@ -122,7 +122,7 @@ export class UserState<D extends IUser> {
|
|
|
122
122
|
this.provider = provider;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
private getChangedFields(input:
|
|
125
|
+
private getChangedFields(input: object, init: object) {
|
|
126
126
|
return Utils.objectUpdated(input, init, [
|
|
127
127
|
'authorized',
|
|
128
128
|
'seconds',
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* @param refs Refs
|
|
4
4
|
* @returns Callback
|
|
5
5
|
*/
|
|
6
|
-
export default function useCombinedRefs(
|
|
7
|
-
...refs: (React.Ref<
|
|
6
|
+
export default function useCombinedRefs<T>(
|
|
7
|
+
...refs: (React.Ref<T> | undefined)[]
|
|
8
8
|
) {
|
|
9
|
-
return (target:
|
|
9
|
+
return (target: T | null) => {
|
|
10
10
|
// Ignore null reference
|
|
11
11
|
if (target == null) return;
|
|
12
12
|
|