@etsoo/react 1.5.75 → 1.5.78
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 +9 -7
- package/lib/mu/ComboBox.d.ts +10 -8
- package/lib/mu/ComboBox.js +6 -6
- 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/ListMoreDisplay.d.ts +2 -2
- package/lib/mu/MUGlobal.d.ts +5 -5
- package/lib/mu/OptionGroup.d.ts +17 -14
- package/lib/mu/ResponsibleContainer.d.ts +5 -5
- package/lib/mu/ScrollerListEx.d.ts +11 -9
- package/lib/mu/ScrollerListEx.js +1 -1
- package/lib/mu/SearchOptionGroup.d.ts +1 -2
- package/lib/mu/SelectBool.d.ts +2 -2
- package/lib/mu/SelectBool.js +1 -1
- package/lib/mu/SelectEx.d.ts +16 -12
- package/lib/mu/SelectEx.js +2 -2
- package/lib/mu/TableEx.d.ts +10 -7
- package/lib/mu/TableEx.js +1 -2
- package/lib/mu/Tiplist.d.ts +4 -5
- package/lib/mu/Tiplist.js +4 -6
- package/lib/mu/pages/CommonPageProps.d.ts +1 -1
- package/lib/mu/pages/DataGridPage.d.ts +1 -1
- package/lib/mu/pages/DataGridPageProps.d.ts +2 -2
- package/lib/mu/pages/FixedListPage.d.ts +1 -1
- package/lib/mu/pages/ListPage.d.ts +1 -1
- package/lib/mu/pages/ListPageProps.d.ts +1 -2
- package/lib/mu/pages/ResponsivePage.d.ts +1 -1
- package/lib/mu/pages/ResponsivePageProps.d.ts +2 -2
- package/lib/mu/pages/SearchPageProps.d.ts +2 -2
- package/lib/mu/pages/TablePage.d.ts +1 -1
- 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 +15 -12
- package/src/mu/ComboBox.tsx +25 -21
- package/src/mu/DataGridEx.tsx +19 -18
- package/src/mu/DataGridRenderers.tsx +1 -1
- package/src/mu/DnDList.tsx +2 -2
- package/src/mu/ListMoreDisplay.tsx +2 -2
- package/src/mu/MUGlobal.ts +5 -5
- package/src/mu/OptionGroup.tsx +29 -27
- package/src/mu/ResponsibleContainer.tsx +18 -21
- package/src/mu/ScrollerListEx.tsx +24 -20
- package/src/mu/SearchOptionGroup.tsx +2 -3
- package/src/mu/SelectBool.tsx +13 -5
- package/src/mu/SelectEx.tsx +27 -20
- package/src/mu/TableEx.tsx +61 -59
- package/src/mu/Tiplist.tsx +20 -17
- package/src/mu/pages/CommonPageProps.ts +1 -1
- package/src/mu/pages/DataGridPage.tsx +14 -10
- package/src/mu/pages/DataGridPageProps.ts +16 -13
- package/src/mu/pages/FixedListPage.tsx +1 -1
- package/src/mu/pages/ListPage.tsx +1 -1
- package/src/mu/pages/ListPageProps.ts +4 -3
- package/src/mu/pages/ResponsivePage.tsx +5 -4
- package/src/mu/pages/ResponsivePageProps.ts +9 -6
- package/src/mu/pages/SearchPageProps.ts +5 -3
- package/src/mu/pages/TablePage.tsx +1 -1
- package/src/mu/pages/TablePageProps.ts +4 -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,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { IdLabelDto } from '@etsoo/appscript';
|
|
3
2
|
import { DataTypes } from '@etsoo/shared';
|
|
4
3
|
import { OptionGroupProps } from './OptionGroup';
|
|
5
4
|
/**
|
|
@@ -7,4 +6,4 @@ import { OptionGroupProps } from './OptionGroup';
|
|
|
7
6
|
* @param props Props
|
|
8
7
|
* @returns Component
|
|
9
8
|
*/
|
|
10
|
-
export declare function SearchOptionGroup<T extends
|
|
9
|
+
export declare function SearchOptionGroup<T extends object = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: OptionGroupProps<T, D>): JSX.Element;
|
package/lib/mu/SelectBool.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { DataTypes } from '@etsoo/shared';
|
|
3
3
|
import { SelectExProps } from './SelectEx';
|
|
4
4
|
/**
|
|
5
5
|
* SelectBool props
|
|
6
6
|
*/
|
|
7
|
-
export interface SelectBoolProps extends Omit<SelectExProps<
|
|
7
|
+
export interface SelectBoolProps extends Omit<SelectExProps<DataTypes.IdLabelItem<string>>, 'options' | 'loadData'> {
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* SelectBool (yes/no)
|
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 React.createElement(SelectEx, { options: options, search: search, ...rest });
|
|
21
|
+
return (React.createElement(SelectEx, { options: options, search: search, ...rest }));
|
|
22
22
|
}
|
package/lib/mu/SelectEx.d.ts
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import { SelectProps } from '@mui/material';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { DataTypes } 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> = DataTypes.Keys<T>> = Omit<SelectProps, 'labelId' | 'input' | 'native'> & {
|
|
8
8
|
/**
|
|
9
9
|
* Auto add blank item
|
|
10
10
|
*/
|
|
11
11
|
autoAddBlankItem?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Id field, default is id
|
|
14
|
-
*/
|
|
15
|
-
idField?: string & keyof T;
|
|
16
12
|
/**
|
|
17
13
|
* Item icon renderer
|
|
18
14
|
*/
|
|
19
15
|
itemIconRenderer?: (id: unknown) => React.ReactNode;
|
|
20
|
-
/**
|
|
21
|
-
* Label field, default is label
|
|
22
|
-
*/
|
|
23
|
-
labelField?: ((option: T) => string) | (string & keyof T);
|
|
24
16
|
/**
|
|
25
17
|
* Load data callback
|
|
26
18
|
*/
|
|
@@ -41,10 +33,22 @@ export interface SelectExProps<T extends {}> extends Omit<SelectProps, 'labelId'
|
|
|
41
33
|
* Is search case?
|
|
42
34
|
*/
|
|
43
35
|
search?: boolean;
|
|
44
|
-
}
|
|
36
|
+
} & (T extends {
|
|
37
|
+
id: DataTypes.IdType;
|
|
38
|
+
} ? {
|
|
39
|
+
idField?: D;
|
|
40
|
+
} : {
|
|
41
|
+
idField: D;
|
|
42
|
+
}) & (T extends {
|
|
43
|
+
label: string;
|
|
44
|
+
} ? {
|
|
45
|
+
labelField?: ((option: T) => string) | D;
|
|
46
|
+
} : {
|
|
47
|
+
labelField: ((option: T) => string) | D;
|
|
48
|
+
});
|
|
45
49
|
/**
|
|
46
50
|
* Extended select component
|
|
47
51
|
* @param props Props
|
|
48
52
|
* @returns Component
|
|
49
53
|
*/
|
|
50
|
-
export declare function SelectEx<T extends
|
|
54
|
+
export declare function SelectEx<T extends object = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: SelectExProps<T, D>): JSX.Element;
|
package/lib/mu/SelectEx.js
CHANGED
|
@@ -71,13 +71,13 @@ export function SelectEx(props) {
|
|
|
71
71
|
};
|
|
72
72
|
// Get option id
|
|
73
73
|
const getId = (option) => {
|
|
74
|
-
return
|
|
74
|
+
return option[idField];
|
|
75
75
|
};
|
|
76
76
|
// Get option label
|
|
77
77
|
const getLabel = (option) => {
|
|
78
78
|
return typeof labelField === 'function'
|
|
79
79
|
? labelField(option)
|
|
80
|
-
:
|
|
80
|
+
: new String(option[labelField]);
|
|
81
81
|
};
|
|
82
82
|
// Refs
|
|
83
83
|
const divRef = React.useRef();
|
package/lib/mu/TableEx.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataTypes } from '@etsoo/shared';
|
|
1
2
|
import { TableProps } from '@mui/material';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { GridColumn } from '../components/GridColumn';
|
|
@@ -19,7 +20,7 @@ export interface TableExMethodRef extends GridMethodRef {
|
|
|
19
20
|
/**
|
|
20
21
|
* Extended table props
|
|
21
22
|
*/
|
|
22
|
-
export
|
|
23
|
+
export declare type TableExProps<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> = TableProps & GridLoader<T> & {
|
|
23
24
|
/**
|
|
24
25
|
* Alternating colors for odd/even rows
|
|
25
26
|
*/
|
|
@@ -32,10 +33,6 @@ export interface TableExProps<T extends Record<string, any>> extends TableProps,
|
|
|
32
33
|
* Header cells background color and font color
|
|
33
34
|
*/
|
|
34
35
|
headerColors?: [string?, string?];
|
|
35
|
-
/**
|
|
36
|
-
* Id field
|
|
37
|
-
*/
|
|
38
|
-
idField?: string & keyof T;
|
|
39
36
|
/**
|
|
40
37
|
* Max height
|
|
41
38
|
*/
|
|
@@ -56,10 +53,16 @@ export interface TableExProps<T extends Record<string, any>> extends TableProps,
|
|
|
56
53
|
* Header and bottom height
|
|
57
54
|
*/
|
|
58
55
|
otherHeight?: number;
|
|
59
|
-
}
|
|
56
|
+
} & (T extends {
|
|
57
|
+
id: DataTypes.IdType;
|
|
58
|
+
} ? {
|
|
59
|
+
idField?: D;
|
|
60
|
+
} : {
|
|
61
|
+
idField: D;
|
|
62
|
+
});
|
|
60
63
|
/**
|
|
61
64
|
* Extended Table
|
|
62
65
|
* @param props Props
|
|
63
66
|
* @returns Component
|
|
64
67
|
*/
|
|
65
|
-
export declare function TableEx<T extends
|
|
68
|
+
export declare function TableEx<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: TableExProps<T, D>): JSX.Element;
|
package/lib/mu/TableEx.js
CHANGED
|
@@ -259,8 +259,7 @@ export function TableEx(props) {
|
|
|
259
259
|
columnIndex,
|
|
260
260
|
cellProps
|
|
261
261
|
})) : (React.createElement(React.Fragment, null, "\u00A0"));
|
|
262
|
-
return (React.createElement(TableCell, { key: rowId
|
|
263
|
-
columnIndex, ...cellProps }, child));
|
|
262
|
+
return (React.createElement(TableCell, { key: `${rowId}${columnIndex}`, ...cellProps }, child));
|
|
264
263
|
})));
|
|
265
264
|
})))),
|
|
266
265
|
React.createElement(TablePagination, { component: "div", showFirstButton: true, count: totalRows, rowsPerPage: batchSize, page: currentPage, onPageChange: handleChangePage, onRowsPerPageChange: handleChangeRowsPerPage, rowsPerPageOptions: [
|
package/lib/mu/Tiplist.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { IdLabelDto } from '@etsoo/appscript';
|
|
3
2
|
import { DataTypes } from '@etsoo/shared';
|
|
4
3
|
import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
|
|
5
4
|
/**
|
|
6
5
|
* Tiplist props
|
|
7
6
|
*/
|
|
8
|
-
export
|
|
7
|
+
export declare type TiplistProps<T extends object, D extends DataTypes.Keys<T>> = Omit<AutocompleteExtendedProps<T, D>, 'open'> & {
|
|
9
8
|
/**
|
|
10
9
|
* Load data callback
|
|
11
10
|
*/
|
|
12
|
-
loadData: (keyword?: string, id?:
|
|
13
|
-
}
|
|
11
|
+
loadData: (keyword?: string, id?: T[D]) => PromiseLike<T[] | null | undefined>;
|
|
12
|
+
};
|
|
14
13
|
/**
|
|
15
14
|
* Tiplist
|
|
16
15
|
* @param props Props
|
|
17
16
|
* @returns Component
|
|
18
17
|
*/
|
|
19
|
-
export declare function Tiplist<T extends
|
|
18
|
+
export declare function Tiplist<T extends object = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<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 :
|
|
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 };
|
|
@@ -31,7 +29,7 @@ export function Tiplist(props) {
|
|
|
31
29
|
value: null
|
|
32
30
|
});
|
|
33
31
|
// Input value
|
|
34
|
-
const inputValue = React.useMemo(() => states.value &&
|
|
32
|
+
const inputValue = React.useMemo(() => states.value && states.value[idField], [states.value]);
|
|
35
33
|
React.useEffect(() => {
|
|
36
34
|
if (localValue != null)
|
|
37
35
|
stateUpdate({ value: localValue });
|
|
@@ -128,7 +126,7 @@ export function Tiplist(props) {
|
|
|
128
126
|
}, []);
|
|
129
127
|
// Layout
|
|
130
128
|
return (React.createElement("div", null,
|
|
131
|
-
React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: inputValue !== null && inputValue !== void 0 ? inputValue : ''
|
|
129
|
+
React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: `${inputValue !== null && inputValue !== void 0 ? inputValue : ''}`, readOnly: true, onChange: inputOnChange }),
|
|
132
130
|
React.createElement(Autocomplete, { filterOptions: (options, _state) => options, value: states.value, options: states.options, onChange: (event, value, reason, details) => {
|
|
133
131
|
// Set value
|
|
134
132
|
setInputValue(value);
|
|
@@ -150,7 +148,7 @@ export function Tiplist(props) {
|
|
|
150
148
|
if (loading)
|
|
151
149
|
loadDataDirect(undefined, states.value == null
|
|
152
150
|
? undefined
|
|
153
|
-
:
|
|
151
|
+
: states.value[idField]);
|
|
154
152
|
}, onClose: () => {
|
|
155
153
|
stateUpdate({
|
|
156
154
|
open: false,
|
|
@@ -6,4 +6,4 @@ import { DataGridPageProps } from './DataGridPageProps';
|
|
|
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> = DataTypes.Keys<T>>(props: DataGridPageProps<T, F, D>): JSX.Element;
|
|
@@ -4,7 +4,7 @@ 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> = DataTypes.Keys<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
|
+
};
|
|
@@ -6,7 +6,7 @@ import { ListPageProps } from './ListPageProps';
|
|
|
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>(props: ListPageProps<T, F> & {
|
|
10
10
|
/**
|
|
11
11
|
* Height will be deducted
|
|
12
12
|
* @param height Current calcuated height
|
|
@@ -6,4 +6,4 @@ import { ListPageProps } from './ListPageProps';
|
|
|
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>(props: ListPageProps<T, F>): 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> = SearchPageProps<T, F> & Omit<ScrollerListExProps<T>, 'loadData'>;
|
|
@@ -6,4 +6,4 @@ import { ResponsePageProps } from './ResponsivePageProps';
|
|
|
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> = DataTypes.Keys<T>>(props: ResponsePageProps<T, F, D>): JSX.Element;
|
|
@@ -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> = DataTypes.Keys<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
|
+
};
|
|
@@ -6,4 +6,4 @@ import { TablePageProps } from './TablePageProps';
|
|
|
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>(props: TablePageProps<T, F>): 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> = SearchPageProps<T, F> & Omit<TableExProps<T>, '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.78",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -51,11 +51,11 @@
|
|
|
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.
|
|
57
|
-
"@mui/icons-material": "^5.
|
|
58
|
-
"@mui/material": "^5.10.
|
|
54
|
+
"@etsoo/appscript": "^1.2.82",
|
|
55
|
+
"@etsoo/notificationbase": "^1.1.7",
|
|
56
|
+
"@etsoo/shared": "^1.1.48",
|
|
57
|
+
"@mui/icons-material": "^5.10.2",
|
|
58
|
+
"@mui/material": "^5.10.2",
|
|
59
59
|
"@types/pica": "^9.0.1",
|
|
60
60
|
"@types/pulltorefreshjs": "^0.1.5",
|
|
61
61
|
"@types/react": "^18.0.17",
|
|
@@ -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
|
-
"@types/jest": "^28.1.
|
|
82
|
+
"@types/jest": "^28.1.8",
|
|
83
83
|
"@types/react-test-renderer": "^18.0.0",
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
85
|
-
"@typescript-eslint/parser": "^5.
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "^5.35.1",
|
|
85
|
+
"@typescript-eslint/parser": "^5.35.1",
|
|
86
86
|
"eslint": "^8.22.0",
|
|
87
87
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
88
88
|
"eslint-plugin-import": "^2.26.0",
|
|
89
|
-
"eslint-plugin-react": "^7.
|
|
89
|
+
"eslint-plugin-react": "^7.31.0",
|
|
90
90
|
"jest": "^28.1.3",
|
|
91
91
|
"jest-environment-jsdom": "^28.1.3",
|
|
92
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
|
+
};
|
|
@@ -48,12 +48,12 @@ export function GridDataGet<F extends DataTypes.BasicTemplate>(
|
|
|
48
48
|
/**
|
|
49
49
|
* Grid Json data
|
|
50
50
|
*/
|
|
51
|
-
export
|
|
51
|
+
export type GridJsonData = Omit<GridLoadDataProps, 'data'>;
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Grid data load props
|
|
55
55
|
*/
|
|
56
|
-
export
|
|
56
|
+
export type GridLoadDataProps = {
|
|
57
57
|
/**
|
|
58
58
|
* Current page
|
|
59
59
|
*/
|
|
@@ -78,12 +78,12 @@ export interface GridLoadDataProps {
|
|
|
78
78
|
* Data related
|
|
79
79
|
*/
|
|
80
80
|
data?: GridData;
|
|
81
|
-
}
|
|
81
|
+
};
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Grid data loader
|
|
85
85
|
*/
|
|
86
|
-
export
|
|
86
|
+
export type GridLoader<T extends object> = {
|
|
87
87
|
/**
|
|
88
88
|
* Auto load data, otherwise call reset
|
|
89
89
|
* @default true
|
|
@@ -109,12 +109,12 @@ export interface GridLoader<T> {
|
|
|
109
109
|
* Threshold at which to pre-fetch data; default is half of loadBatchSize
|
|
110
110
|
*/
|
|
111
111
|
threshold?: number | undefined;
|
|
112
|
-
}
|
|
112
|
+
};
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Grid loader states
|
|
116
116
|
*/
|
|
117
|
-
export
|
|
117
|
+
export type GridLoaderStates<T> = GridLoadDataProps & {
|
|
118
118
|
/**
|
|
119
119
|
* Auto load data, otherwise call reset
|
|
120
120
|
* @default true
|
|
@@ -150,4 +150,4 @@ export interface GridLoaderStates<T> extends GridLoadDataProps {
|
|
|
150
150
|
* Selected items of id
|
|
151
151
|
*/
|
|
152
152
|
selectedItems: T[];
|
|
153
|
-
}
|
|
153
|
+
};
|