@etsoo/react 1.5.77 → 1.5.80
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__/mu/ComboBox.tsx +30 -0
- package/__tests__/mu/NotifierMUTests.tsx +1 -1
- package/__tests__/mu/SelectEx.tsx +26 -0
- 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 +6 -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/DataGridEx.d.ts +6 -6
- 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 +8 -8
- package/lib/mu/ResponsibleContainer.d.ts +6 -6
- package/lib/mu/ScrollerListEx.d.ts +11 -10
- package/lib/mu/SearchOptionGroup.d.ts +2 -2
- package/lib/mu/SelectBool.d.ts +2 -3
- package/lib/mu/SelectBool.js +1 -1
- package/lib/mu/SelectEx.d.ts +8 -8
- package/lib/mu/SelectEx.js +3 -3
- package/lib/mu/TableEx.d.ts +4 -4
- package/lib/mu/Tiplist.d.ts +4 -4
- package/lib/mu/Tiplist.js +1 -3
- 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 +12 -12
- 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 -62
- package/src/components/ScrollerList.tsx +2 -2
- package/src/mu/AutocompleteExtendedProps.ts +9 -9
- package/src/mu/ComboBox.tsx +20 -12
- package/src/mu/DataGridEx.tsx +15 -15
- 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 +22 -14
- package/src/mu/ResponsibleContainer.tsx +15 -20
- package/src/mu/ScrollerListEx.tsx +21 -20
- package/src/mu/SearchOptionGroup.tsx +11 -5
- package/src/mu/SelectBool.tsx +7 -14
- package/src/mu/SelectEx.tsx +25 -19
- package/src/mu/TableEx.tsx +53 -53
- package/src/mu/Tiplist.tsx +11 -10
- 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
|
@@ -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 { ListChildComponentProps } from 'react-window';
|
|
4
4
|
import { ScrollerListProps } from '../components/ScrollerList';
|
|
@@ -22,7 +22,7 @@ export interface ScrollerListExInnerItemRendererProps<T> extends ListChildCompon
|
|
|
22
22
|
/**
|
|
23
23
|
* Default margins
|
|
24
24
|
*/
|
|
25
|
-
margins:
|
|
25
|
+
margins: object;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Extended ScrollerList ItemSize type
|
|
@@ -30,19 +30,15 @@ export interface ScrollerListExInnerItemRendererProps<T> extends ListChildCompon
|
|
|
30
30
|
* 2. Static sets
|
|
31
31
|
* 3. Dynamic calculation
|
|
32
32
|
*/
|
|
33
|
-
export declare type ScrollerListExItemSize = ((index: number) => [number, number] | [number, number,
|
|
33
|
+
export declare type ScrollerListExItemSize = ((index: number) => [number, number] | [number, number, object]) | [number, number] | [number, object, boolean?];
|
|
34
34
|
/**
|
|
35
35
|
* Extended ScrollerList Props
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export declare type ScrollerListExProps<T extends object, D extends DataTypes.Keys<T>> = Omit<ScrollerListProps<T>, 'itemRenderer' | 'itemSize'> & {
|
|
38
38
|
/**
|
|
39
39
|
* Alternating colors for odd/even rows
|
|
40
40
|
*/
|
|
41
41
|
alternatingColors?: [string?, string?];
|
|
42
|
-
/**
|
|
43
|
-
* Id field
|
|
44
|
-
*/
|
|
45
|
-
idField?: D;
|
|
46
42
|
/**
|
|
47
43
|
* Inner item renderer
|
|
48
44
|
*/
|
|
@@ -51,6 +47,11 @@ export interface ScrollerListExProps<T extends {}, D extends DataTypes.Keys<T> =
|
|
|
51
47
|
* Item renderer
|
|
52
48
|
*/
|
|
53
49
|
itemRenderer?: (props: ListChildComponentProps<T>) => React.ReactElement;
|
|
50
|
+
/**
|
|
51
|
+
* Id field
|
|
52
|
+
* Failed: D extends { id: DataTypes.IdType } ? { idField?: D } : { idField: D }
|
|
53
|
+
*/
|
|
54
|
+
idField?: D;
|
|
54
55
|
/**
|
|
55
56
|
* Item size, a function indicates its a variable size list
|
|
56
57
|
*/
|
|
@@ -71,10 +72,10 @@ export interface ScrollerListExProps<T extends {}, D extends DataTypes.Keys<T> =
|
|
|
71
72
|
* Selected color
|
|
72
73
|
*/
|
|
73
74
|
selectedColor?: string;
|
|
74
|
-
}
|
|
75
|
+
};
|
|
75
76
|
/**
|
|
76
77
|
* Extended ScrollerList
|
|
77
78
|
* @param props Props
|
|
78
79
|
* @returns Component
|
|
79
80
|
*/
|
|
80
|
-
export declare function ScrollerListEx<T extends
|
|
81
|
+
export declare function ScrollerListEx<T extends object, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: ScrollerListExProps<T, D>): JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { DataTypes, IdDefaultType, LabelDefaultType, ListType } from '@etsoo/shared';
|
|
3
3
|
import { OptionGroupProps } from './OptionGroup';
|
|
4
4
|
/**
|
|
5
5
|
* Search OptionGroup
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export declare function SearchOptionGroup<T extends
|
|
9
|
+
export declare function SearchOptionGroup<T extends object = ListType, D extends DataTypes.Keys<T> = IdDefaultType<T>, L extends DataTypes.Keys<T, string> = LabelDefaultType<T>>(props: OptionGroupProps<T, D, L>): JSX.Element;
|
package/lib/mu/SelectBool.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { ListType1 } from '@etsoo/shared';
|
|
3
3
|
import { SelectExProps } from './SelectEx';
|
|
4
4
|
/**
|
|
5
5
|
* SelectBool props
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
}
|
|
7
|
+
export declare type SelectBoolProps = Omit<SelectExProps<ListType1>, 'options' | 'loadData'>;
|
|
9
8
|
/**
|
|
10
9
|
* SelectBool (yes/no)
|
|
11
10
|
* @param props Props
|
package/lib/mu/SelectBool.js
CHANGED
|
@@ -18,5 +18,5 @@ export function SelectBool(props) {
|
|
|
18
18
|
if (autoAddBlankItem)
|
|
19
19
|
Utils.addBlankItem(options);
|
|
20
20
|
// Layout
|
|
21
|
-
return
|
|
21
|
+
return React.createElement(SelectEx, { options: options, search: search, ...rest });
|
|
22
22
|
}
|
package/lib/mu/SelectEx.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SelectProps } from '@mui/material';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { DataTypes } from '@etsoo/shared';
|
|
3
|
+
import { DataTypes, IdDefaultType, LabelDefaultType, ListType } from '@etsoo/shared';
|
|
4
4
|
/**
|
|
5
5
|
* Extended select component props
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export declare type SelectExProps<T extends object, D extends DataTypes.Keys<T> = IdDefaultType<T>, L extends DataTypes.Keys<T, string> = LabelDefaultType<T>> = Omit<SelectProps, 'labelId' | 'input' | 'native'> & {
|
|
8
8
|
/**
|
|
9
9
|
* Auto add blank item
|
|
10
10
|
*/
|
|
@@ -12,15 +12,15 @@ export interface SelectExProps<T extends {}, D extends DataTypes.Keys<T> = DataT
|
|
|
12
12
|
/**
|
|
13
13
|
* Id field
|
|
14
14
|
*/
|
|
15
|
-
idField
|
|
15
|
+
idField?: D;
|
|
16
16
|
/**
|
|
17
17
|
* Item icon renderer
|
|
18
18
|
*/
|
|
19
|
-
itemIconRenderer?: (id:
|
|
19
|
+
itemIconRenderer?: (id: T[D]) => React.ReactNode;
|
|
20
20
|
/**
|
|
21
21
|
* Label field
|
|
22
22
|
*/
|
|
23
|
-
labelField
|
|
23
|
+
labelField?: L | ((option: T) => string);
|
|
24
24
|
/**
|
|
25
25
|
* Load data callback
|
|
26
26
|
*/
|
|
@@ -28,7 +28,7 @@ export interface SelectExProps<T extends {}, D extends DataTypes.Keys<T> = DataT
|
|
|
28
28
|
/**
|
|
29
29
|
* Item click handler
|
|
30
30
|
*/
|
|
31
|
-
onItemClick?: (event: React.MouseEvent,
|
|
31
|
+
onItemClick?: (event: React.MouseEvent, option: T) => void;
|
|
32
32
|
/**
|
|
33
33
|
* On load data handler
|
|
34
34
|
*/
|
|
@@ -41,10 +41,10 @@ export interface SelectExProps<T extends {}, D extends DataTypes.Keys<T> = DataT
|
|
|
41
41
|
* Is search case?
|
|
42
42
|
*/
|
|
43
43
|
search?: boolean;
|
|
44
|
-
}
|
|
44
|
+
};
|
|
45
45
|
/**
|
|
46
46
|
* Extended select component
|
|
47
47
|
* @param props Props
|
|
48
48
|
* @returns Component
|
|
49
49
|
*/
|
|
50
|
-
export declare function SelectEx<T extends
|
|
50
|
+
export declare function SelectEx<T extends object = ListType, D extends DataTypes.Keys<T> = IdDefaultType<T>, L extends DataTypes.Keys<T, string> = LabelDefaultType<T>>(props: SelectExProps<T, D, L>): JSX.Element;
|
package/lib/mu/SelectEx.js
CHANGED
|
@@ -77,7 +77,7 @@ export function SelectEx(props) {
|
|
|
77
77
|
const getLabel = (option) => {
|
|
78
78
|
return typeof labelField === 'function'
|
|
79
79
|
? labelField(option)
|
|
80
|
-
:
|
|
80
|
+
: option[labelField];
|
|
81
81
|
};
|
|
82
82
|
// Refs
|
|
83
83
|
const divRef = React.useRef();
|
|
@@ -142,7 +142,7 @@ export function SelectEx(props) {
|
|
|
142
142
|
// Option
|
|
143
143
|
return (React.createElement(MenuItem, { key: id, value: id, onClick: (event) => {
|
|
144
144
|
if (onItemClick) {
|
|
145
|
-
onItemClick(event,
|
|
145
|
+
onItemClick(event, option);
|
|
146
146
|
if (event.defaultPrevented)
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
@@ -151,6 +151,6 @@ export function SelectEx(props) {
|
|
|
151
151
|
} },
|
|
152
152
|
multiple && React.createElement(Checkbox, { checked: itemChecked(id) }),
|
|
153
153
|
React.createElement(ListItemText, { primary: label }),
|
|
154
|
-
itemIconRenderer && (React.createElement(ListItemRightIcon, null, itemIconRenderer(
|
|
154
|
+
itemIconRenderer && (React.createElement(ListItemRightIcon, null, itemIconRenderer(option[idField])))));
|
|
155
155
|
}))));
|
|
156
156
|
}
|
package/lib/mu/TableEx.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
2
|
import { TableProps } from '@mui/material';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { GridColumn } from '../components/GridColumn';
|
|
@@ -20,7 +20,7 @@ export interface TableExMethodRef extends GridMethodRef {
|
|
|
20
20
|
/**
|
|
21
21
|
* Extended table props
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export declare type TableExProps<T extends object, D extends DataTypes.Keys<T>> = TableProps & GridLoader<T> & {
|
|
24
24
|
/**
|
|
25
25
|
* Alternating colors for odd/even rows
|
|
26
26
|
*/
|
|
@@ -57,10 +57,10 @@ export interface TableExProps<T extends {}, D extends DataTypes.Keys<T> = DataTy
|
|
|
57
57
|
* Header and bottom height
|
|
58
58
|
*/
|
|
59
59
|
otherHeight?: number;
|
|
60
|
-
}
|
|
60
|
+
};
|
|
61
61
|
/**
|
|
62
62
|
* Extended Table
|
|
63
63
|
* @param props Props
|
|
64
64
|
* @returns Component
|
|
65
65
|
*/
|
|
66
|
-
export declare function TableEx<T extends
|
|
66
|
+
export declare function TableEx<T extends object, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: TableExProps<T, D>): JSX.Element;
|
package/lib/mu/Tiplist.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { DataTypes, IdDefaultType, ListType } from '@etsoo/shared';
|
|
3
3
|
import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
|
|
4
4
|
/**
|
|
5
5
|
* Tiplist props
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export declare type TiplistProps<T extends object, D extends DataTypes.Keys<T>> = Omit<AutocompleteExtendedProps<T, D>, 'open'> & {
|
|
8
8
|
/**
|
|
9
9
|
* Load data callback
|
|
10
10
|
*/
|
|
11
11
|
loadData: (keyword?: string, id?: T[D]) => PromiseLike<T[] | null | undefined>;
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
/**
|
|
14
14
|
* Tiplist
|
|
15
15
|
* @param props Props
|
|
16
16
|
* @returns Component
|
|
17
17
|
*/
|
|
18
|
-
export declare function Tiplist<T extends
|
|
18
|
+
export declare function Tiplist<T extends object = ListType, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: TiplistProps<T, D>): JSX.Element;
|
package/lib/mu/Tiplist.js
CHANGED
|
@@ -17,10 +17,8 @@ export function Tiplist(props) {
|
|
|
17
17
|
const inputRef = React.createRef();
|
|
18
18
|
// Local value
|
|
19
19
|
let localValue = value !== null && value !== void 0 ? value : defaultValue;
|
|
20
|
-
if (localValue === undefined)
|
|
21
|
-
localValue = null;
|
|
22
20
|
// One time calculation for input's default value (uncontrolled)
|
|
23
|
-
const localIdValue = idValue !== null && idValue !== void 0 ? idValue : DataTypes.getValue(localValue, idField
|
|
21
|
+
const localIdValue = idValue !== null && idValue !== void 0 ? idValue : DataTypes.getValue(localValue, idField);
|
|
24
22
|
// Changable states
|
|
25
23
|
const [states, stateUpdate] = React.useReducer((currentState, newState) => {
|
|
26
24
|
return { ...currentState, ...newState };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
3
3
|
import { DataGridPageProps } from './DataGridPageProps';
|
|
4
4
|
/**
|
|
5
5
|
* DataGrid page
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export declare function DataGridPage<T, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: DataGridPageProps<T, F>): JSX.Element;
|
|
9
|
+
export declare function DataGridPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: DataGridPageProps<T, F, D>): JSX.Element;
|
|
@@ -1,10 +1,10 @@
|
|
|
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
|
* DataGrid page props
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export declare type DataGridPageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>> = SearchPageProps<T, F> & Omit<DataGridExProps<T, D>, 'loadData' | 'height'> & {
|
|
8
8
|
/**
|
|
9
9
|
* Height will be deducted
|
|
10
10
|
* @param height Current calcuated height
|
|
@@ -14,4 +14,4 @@ export interface DataGridPageProps<T, F extends DataTypes.BasicTemplate> extends
|
|
|
14
14
|
* Grid height
|
|
15
15
|
*/
|
|
16
16
|
height?: number;
|
|
17
|
-
}
|
|
17
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
3
3
|
import { ListPageProps } from './ListPageProps';
|
|
4
4
|
/**
|
|
5
5
|
* Fixed height list page
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export declare function FixedListPage<T extends
|
|
9
|
+
export declare function FixedListPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: ListPageProps<T, F, D> & {
|
|
10
10
|
/**
|
|
11
11
|
* Height will be deducted
|
|
12
12
|
* @param height Current calcuated height
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
3
3
|
import { ListPageProps } from './ListPageProps';
|
|
4
4
|
/**
|
|
5
5
|
* List page
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export declare function ListPage<T extends
|
|
9
|
+
export declare function ListPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: ListPageProps<T, F, D>): JSX.Element;
|
|
@@ -4,5 +4,4 @@ import { SearchPageProps } from './SearchPageProps';
|
|
|
4
4
|
/**
|
|
5
5
|
* List page props
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
}
|
|
7
|
+
export declare type ListPageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T>> = SearchPageProps<T, F> & Omit<ScrollerListExProps<T, D>, 'loadData'>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
3
3
|
import { ResponsePageProps } from './ResponsivePageProps';
|
|
4
4
|
/**
|
|
5
5
|
* Fixed height list page
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export declare function ResponsivePage<T extends
|
|
9
|
+
export declare function ResponsivePage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: ResponsePageProps<T, F, D>): JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
3
3
|
import { ListChildComponentProps } from 'react-window';
|
|
4
4
|
import { GridMethodRef } from '../GridMethodRef';
|
|
5
5
|
import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from '../ScrollerListEx';
|
|
@@ -7,7 +7,7 @@ import { DataGridPageProps } from './DataGridPageProps';
|
|
|
7
7
|
/**
|
|
8
8
|
* Response page props
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export declare type ResponsePageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>> = Omit<DataGridPageProps<T, F, D>, 'mRef' | 'itemKey' | 'onScroll' | 'onItemsRendered'> & {
|
|
11
11
|
/**
|
|
12
12
|
* Min width to show Datagrid
|
|
13
13
|
*/
|
|
@@ -36,4 +36,4 @@ export interface ResponsePageProps<T, F extends DataTypes.BasicTemplate> extends
|
|
|
36
36
|
* Quick action for double click or click under mobile
|
|
37
37
|
*/
|
|
38
38
|
quickAction?: (data: T) => void;
|
|
39
|
-
}
|
|
39
|
+
};
|
|
@@ -5,7 +5,7 @@ import { CommonPageProps } from './CommonPageProps';
|
|
|
5
5
|
/**
|
|
6
6
|
* Search page props
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export declare type SearchPageProps<T extends object, F extends DataTypes.BasicTemplate> = Omit<GridLoader<T>, 'loadData'> & {
|
|
9
9
|
/**
|
|
10
10
|
* Search fields
|
|
11
11
|
*/
|
|
@@ -27,4 +27,4 @@ export interface SearchPageProps<T, F extends DataTypes.BasicTemplate> extends O
|
|
|
27
27
|
* @default 100
|
|
28
28
|
*/
|
|
29
29
|
sizeReadyMiliseconds?: number;
|
|
30
|
-
}
|
|
30
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
3
3
|
import { TablePageProps } from './TablePageProps';
|
|
4
4
|
/**
|
|
5
5
|
* Table page
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
|
-
export declare function TablePage<T extends
|
|
9
|
+
export declare function TablePage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: TablePageProps<T, F, D>): JSX.Element;
|
|
@@ -4,5 +4,4 @@ import { SearchPageProps } from './SearchPageProps';
|
|
|
4
4
|
/**
|
|
5
5
|
* Table page props
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
}
|
|
7
|
+
export declare type TablePageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T>> = SearchPageProps<T, F> & Omit<TableExProps<T, D>, 'loadData'>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataTypes } from '@etsoo/shared';
|
|
1
2
|
import { GridProps } from '@mui/material';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { GridColumnRenderProps, GridDataType } from '../../components/GridColumn';
|
|
@@ -5,7 +6,7 @@ import { CommonPageProps } from './CommonPageProps';
|
|
|
5
6
|
/**
|
|
6
7
|
* View page display field
|
|
7
8
|
*/
|
|
8
|
-
export interface ViewPageField<T extends
|
|
9
|
+
export interface ViewPageField<T extends object> extends GridProps {
|
|
9
10
|
/**
|
|
10
11
|
* Data field
|
|
11
12
|
*/
|
|
@@ -27,11 +28,11 @@ export interface ViewPageField<T extends {}> extends GridProps {
|
|
|
27
28
|
*/
|
|
28
29
|
renderProps?: GridColumnRenderProps;
|
|
29
30
|
}
|
|
30
|
-
declare type ViewPageFieldType<T> = (string & keyof T) | [string & keyof T, GridDataType, GridColumnRenderProps?] | ViewPageField<T>;
|
|
31
|
+
declare type ViewPageFieldType<T extends object> = (string & keyof T) | [string & keyof T, GridDataType, GridColumnRenderProps?] | ViewPageField<T>;
|
|
31
32
|
/**
|
|
32
33
|
* View page props
|
|
33
34
|
*/
|
|
34
|
-
export interface ViewPageProps<T extends
|
|
35
|
+
export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<CommonPageProps, 'children'> {
|
|
35
36
|
/**
|
|
36
37
|
* Actions
|
|
37
38
|
*/
|
|
@@ -61,5 +62,5 @@ export interface ViewPageProps<T extends {}> extends Omit<CommonPageProps, 'chil
|
|
|
61
62
|
* View page
|
|
62
63
|
* @param props Props
|
|
63
64
|
*/
|
|
64
|
-
export declare function ViewPage<T extends
|
|
65
|
+
export declare function ViewPage<T extends DataTypes.StringRecord>(props: ViewPageProps<T>): JSX.Element;
|
|
65
66
|
export {};
|
package/lib/states/IState.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
/**
|
|
4
4
|
* State UI creator
|
|
5
5
|
*/
|
|
6
|
-
export interface IUICreator<S extends IState, A extends IAction, P =
|
|
6
|
+
export interface IUICreator<S extends IState, A extends IAction, P = object> {
|
|
7
7
|
(state: S, dispatch: React.Dispatch<A>, props: P): React.ReactElement;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @param refs Refs
|
|
5
5
|
* @returns Callback
|
|
6
6
|
*/
|
|
7
|
-
export default function useCombinedRefs(...refs: (React.Ref<
|
|
7
|
+
export default function useCombinedRefs<T>(...refs: (React.Ref<T> | undefined)[]): (target: T | null) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.80",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"@emotion/css": "^11.10.0",
|
|
52
52
|
"@emotion/react": "^11.10.0",
|
|
53
53
|
"@emotion/styled": "^11.10.0",
|
|
54
|
-
"@etsoo/appscript": "^1.2.
|
|
55
|
-
"@etsoo/notificationbase": "^1.1.
|
|
56
|
-
"@etsoo/shared": "^1.1.
|
|
54
|
+
"@etsoo/appscript": "^1.2.85",
|
|
55
|
+
"@etsoo/notificationbase": "^1.1.7",
|
|
56
|
+
"@etsoo/shared": "^1.1.51",
|
|
57
57
|
"@mui/icons-material": "^5.10.2",
|
|
58
58
|
"@mui/material": "^5.10.2",
|
|
59
59
|
"@types/pica": "^9.0.1",
|
|
@@ -79,18 +79,18 @@
|
|
|
79
79
|
"@babel/plugin-transform-runtime": "^7.18.10",
|
|
80
80
|
"@babel/preset-env": "^7.18.10",
|
|
81
81
|
"@babel/runtime-corejs3": "^7.18.9",
|
|
82
|
-
"@
|
|
83
|
-
"@
|
|
84
|
-
"@
|
|
85
|
-
"@typescript-eslint/
|
|
86
|
-
"eslint": "^
|
|
82
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
83
|
+
"@testing-library/react": "^13.3.0",
|
|
84
|
+
"@types/jest": "^28.1.8",
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^5.35.1",
|
|
86
|
+
"@typescript-eslint/parser": "^5.35.1",
|
|
87
|
+
"eslint": "^8.23.0",
|
|
87
88
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
88
89
|
"eslint-plugin-import": "^2.26.0",
|
|
89
|
-
"eslint-plugin-react": "^7.
|
|
90
|
+
"eslint-plugin-react": "^7.31.1",
|
|
90
91
|
"jest": "^28.1.3",
|
|
91
92
|
"jest-environment-jsdom": "^28.1.3",
|
|
92
|
-
"react-test-renderer": "^18.2.0",
|
|
93
93
|
"ts-jest": "^28.0.8",
|
|
94
|
-
"typescript": "^4.
|
|
94
|
+
"typescript": "^4.8.2"
|
|
95
95
|
}
|
|
96
96
|
}
|
package/src/app/CommonApp.ts
CHANGED
|
@@ -57,7 +57,7 @@ export abstract class CommonApp<
|
|
|
57
57
|
* Refresh token
|
|
58
58
|
* @param props Props
|
|
59
59
|
*/
|
|
60
|
-
override async refreshToken<D = RefreshTokenRQ>(
|
|
60
|
+
override async refreshToken<D extends object = RefreshTokenRQ>(
|
|
61
61
|
props?: RefreshTokenProps<D>
|
|
62
62
|
) {
|
|
63
63
|
// Destruct
|
|
@@ -206,7 +206,7 @@ export abstract class CommonApp<
|
|
|
206
206
|
* @param showLoading Show loading bar or not
|
|
207
207
|
* @returns Result
|
|
208
208
|
*/
|
|
209
|
-
override async tryLogin<D = RefreshTokenRQ>(
|
|
209
|
+
override async tryLogin<D extends object = RefreshTokenRQ>(
|
|
210
210
|
data?: D,
|
|
211
211
|
showLoading?: boolean
|
|
212
212
|
) {
|
package/src/app/Labels.ts
CHANGED
package/src/app/ServiceApp.ts
CHANGED
|
@@ -101,7 +101,7 @@ export class ServiceApp<
|
|
|
101
101
|
* Refresh token
|
|
102
102
|
* @param props Props
|
|
103
103
|
*/
|
|
104
|
-
override async refreshToken<D = RefreshTokenRQ>(
|
|
104
|
+
override async refreshToken<D extends object = RefreshTokenRQ>(
|
|
105
105
|
props?: RefreshTokenProps<D>
|
|
106
106
|
) {
|
|
107
107
|
// Destruct
|
|
@@ -305,7 +305,7 @@ export class ServiceApp<
|
|
|
305
305
|
* @param showLoading Show loading bar or not
|
|
306
306
|
* @returns Result
|
|
307
307
|
*/
|
|
308
|
-
override async tryLogin<D extends
|
|
308
|
+
override async tryLogin<D extends object = {}>(
|
|
309
309
|
data?: D,
|
|
310
310
|
showLoading?: boolean
|
|
311
311
|
) {
|
|
@@ -40,7 +40,7 @@ export type GridCellValueType = string | number | Date | boolean | undefined;
|
|
|
40
40
|
/**
|
|
41
41
|
* Grid cell formatter props
|
|
42
42
|
*/
|
|
43
|
-
export
|
|
43
|
+
export type GridCellFormatterProps<T> = {
|
|
44
44
|
/**
|
|
45
45
|
* Current data
|
|
46
46
|
*/
|
|
@@ -60,13 +60,12 @@ export interface GridCellFormatterProps<T> {
|
|
|
60
60
|
* Column index
|
|
61
61
|
*/
|
|
62
62
|
columnIndex: number;
|
|
63
|
-
}
|
|
63
|
+
};
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Grid cell renderer props
|
|
67
67
|
*/
|
|
68
|
-
export
|
|
69
|
-
extends GridCellFormatterProps<T> {
|
|
68
|
+
export type GridCellRendererProps<T, P = any> = GridCellFormatterProps<T> & {
|
|
70
69
|
/**
|
|
71
70
|
* Cell props
|
|
72
71
|
*/
|
|
@@ -91,12 +90,12 @@ export interface GridCellRendererProps<T, P = any>
|
|
|
91
90
|
* Render props
|
|
92
91
|
*/
|
|
93
92
|
renderProps?: GridColumnRenderProps;
|
|
94
|
-
}
|
|
93
|
+
};
|
|
95
94
|
|
|
96
95
|
/**
|
|
97
96
|
* Grid header cell renderer props
|
|
98
97
|
*/
|
|
99
|
-
export
|
|
98
|
+
export type GridHeaderCellRendererProps<T, P = any> = {
|
|
100
99
|
/**
|
|
101
100
|
* Cell props
|
|
102
101
|
*/
|
|
@@ -116,12 +115,12 @@ export interface GridHeaderCellRendererProps<T, P = any> {
|
|
|
116
115
|
* States
|
|
117
116
|
*/
|
|
118
117
|
states: GridLoaderStates<T>;
|
|
119
|
-
}
|
|
118
|
+
};
|
|
120
119
|
|
|
121
120
|
/**
|
|
122
121
|
* Grid column render props
|
|
123
122
|
*/
|
|
124
|
-
export
|
|
123
|
+
export type GridColumnRenderProps = {
|
|
125
124
|
/**
|
|
126
125
|
* Culture, like zh-CN
|
|
127
126
|
*/
|
|
@@ -151,12 +150,12 @@ export interface GridColumnRenderProps {
|
|
|
151
150
|
* Additional data
|
|
152
151
|
*/
|
|
153
152
|
readonly data?: Readonly<Record<string, any>>;
|
|
154
|
-
}
|
|
153
|
+
};
|
|
155
154
|
|
|
156
155
|
/**
|
|
157
156
|
* Grid column
|
|
158
157
|
*/
|
|
159
|
-
export
|
|
158
|
+
export type GridColumn<T> = {
|
|
160
159
|
/**
|
|
161
160
|
* The column identifier. It's used to map with row data
|
|
162
161
|
*/
|
|
@@ -219,4 +218,4 @@ export interface GridColumn<T> {
|
|
|
219
218
|
headerCellRenderer?: (
|
|
220
219
|
props: GridHeaderCellRendererProps<T>
|
|
221
220
|
) => React.ReactNode;
|
|
222
|
-
}
|
|
221
|
+
};
|