@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
|
@@ -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
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import {
|
|
3
4
|
Align,
|
|
@@ -9,8 +10,10 @@ import {
|
|
|
9
10
|
import { GridMethodRef } from '../mu/GridMethodRef';
|
|
10
11
|
import { GridLoadDataProps, GridLoader, GridLoaderStates } from './GridLoader';
|
|
11
12
|
|
|
12
|
-
export
|
|
13
|
-
|
|
13
|
+
export type ScrollerGridItemRendererProps<T> = Omit<
|
|
14
|
+
GridChildComponentProps<T>,
|
|
15
|
+
'data'
|
|
16
|
+
> & {
|
|
14
17
|
/**
|
|
15
18
|
* Selected items
|
|
16
19
|
*/
|
|
@@ -20,64 +23,65 @@ export interface ScrollerGridItemRendererProps<T>
|
|
|
20
23
|
* Data
|
|
21
24
|
*/
|
|
22
25
|
data?: T;
|
|
23
|
-
}
|
|
26
|
+
};
|
|
24
27
|
|
|
25
28
|
/**
|
|
26
29
|
* Scroller vertical grid props
|
|
27
30
|
*/
|
|
28
|
-
export
|
|
29
|
-
extends
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
31
|
+
export type ScrollerGridProps<
|
|
32
|
+
T extends object,
|
|
33
|
+
D extends DataTypes.Keys<T>
|
|
34
|
+
> = GridLoader<T> &
|
|
35
|
+
Omit<
|
|
36
|
+
VariableSizeGridProps<T>,
|
|
37
|
+
'children' | 'rowCount' | 'rowHeight' | 'ref'
|
|
38
|
+
> & {
|
|
39
|
+
/**
|
|
40
|
+
* Default order by asc
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
defaultOrderByAsc?: boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Footer renderer
|
|
47
|
+
*/
|
|
48
|
+
footerRenderer?: (
|
|
49
|
+
rows: T[],
|
|
50
|
+
states: GridLoaderStates<T>
|
|
51
|
+
) => React.ReactNode;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Header renderer
|
|
55
|
+
*/
|
|
56
|
+
headerRenderer?: (states: GridLoaderStates<T>) => React.ReactNode;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Id field
|
|
60
|
+
*/
|
|
61
|
+
idField?: D;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Item renderer
|
|
65
|
+
*/
|
|
66
|
+
itemRenderer: (
|
|
67
|
+
props: ScrollerGridItemRendererProps<T>
|
|
68
|
+
) => React.ReactElement;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Methods
|
|
72
|
+
*/
|
|
73
|
+
mRef?: React.Ref<ScrollerGridForwardRef>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* On items select change
|
|
77
|
+
*/
|
|
78
|
+
onSelectChange?: (selectedItems: T[]) => void;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Returns the height of the specified row.
|
|
82
|
+
*/
|
|
83
|
+
rowHeight?: ((index: number) => number) | number;
|
|
84
|
+
};
|
|
81
85
|
|
|
82
86
|
/**
|
|
83
87
|
* Scroller grid forward ref
|
|
@@ -143,8 +147,11 @@ export interface ScrollerGridForwardRef extends GridMethodRef {
|
|
|
143
147
|
* @param props Props
|
|
144
148
|
* @returns Component
|
|
145
149
|
*/
|
|
146
|
-
export const ScrollerGrid = <
|
|
147
|
-
|
|
150
|
+
export const ScrollerGrid = <
|
|
151
|
+
T extends object,
|
|
152
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
153
|
+
>(
|
|
154
|
+
props: ScrollerGridProps<T, D>
|
|
148
155
|
) => {
|
|
149
156
|
// Destruct
|
|
150
157
|
const {
|
|
@@ -154,7 +161,7 @@ export const ScrollerGrid = <T extends Record<string, unknown>>(
|
|
|
154
161
|
footerRenderer,
|
|
155
162
|
headerRenderer,
|
|
156
163
|
itemRenderer,
|
|
157
|
-
idField = 'id',
|
|
164
|
+
idField = 'id' as D,
|
|
158
165
|
loadBatchSize,
|
|
159
166
|
loadData,
|
|
160
167
|
mRef,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
/**
|
|
21
21
|
* Scroller vertical list props
|
|
22
22
|
*/
|
|
23
|
-
export interface ScrollerListProps<T>
|
|
23
|
+
export interface ScrollerListProps<T extends object>
|
|
24
24
|
extends GridLoader<T>,
|
|
25
25
|
Omit<
|
|
26
26
|
ListProps<T>,
|
|
@@ -98,9 +98,7 @@ const calculateBatchSize = (
|
|
|
98
98
|
* @param props Props
|
|
99
99
|
* @returns Component
|
|
100
100
|
*/
|
|
101
|
-
export const ScrollerList = <T extends
|
|
102
|
-
props: ScrollerListProps<T>
|
|
103
|
-
) => {
|
|
101
|
+
export const ScrollerList = <T extends object>(props: ScrollerListProps<T>) => {
|
|
104
102
|
// Destruct
|
|
105
103
|
const {
|
|
106
104
|
autoLoad = true,
|
|
@@ -5,17 +5,17 @@ import { ChangeEventHandler } from 'react';
|
|
|
5
5
|
/**
|
|
6
6
|
* Autocomplete extended props
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
9
|
-
T extends
|
|
8
|
+
export type AutocompleteExtendedProps<
|
|
9
|
+
T extends object,
|
|
10
10
|
D extends DataTypes.Keys<T>
|
|
11
|
-
>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
> = Omit<
|
|
12
|
+
AutocompleteProps<T, undefined, false, false>,
|
|
13
|
+
'renderInput' | 'options'
|
|
14
|
+
> & {
|
|
15
15
|
/**
|
|
16
|
-
* Id field
|
|
16
|
+
* Id field
|
|
17
17
|
*/
|
|
18
|
-
idField
|
|
18
|
+
idField?: D;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Id value
|
|
@@ -80,4 +80,4 @@ export interface AutocompleteExtendedProps<
|
|
|
80
80
|
* Is search field?
|
|
81
81
|
*/
|
|
82
82
|
search?: boolean;
|
|
83
|
-
}
|
|
83
|
+
};
|
package/src/mu/ComboBox.tsx
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DataTypes,
|
|
3
|
+
IdDefaultType,
|
|
4
|
+
Keyboard,
|
|
5
|
+
LabelDefaultType,
|
|
6
|
+
ListType
|
|
7
|
+
} from '@etsoo/shared';
|
|
2
8
|
import { Autocomplete, AutocompleteRenderInputParams } from '@mui/material';
|
|
3
9
|
import React from 'react';
|
|
4
10
|
import { Utils as SharedUtils } from '@etsoo/shared';
|
|
@@ -10,10 +16,11 @@ import { ReactUtils } from '../app/ReactUtils';
|
|
|
10
16
|
/**
|
|
11
17
|
* ComboBox props
|
|
12
18
|
*/
|
|
13
|
-
export
|
|
14
|
-
T extends
|
|
15
|
-
D extends DataTypes.Keys<T
|
|
16
|
-
|
|
19
|
+
export type ComboBoxProps<
|
|
20
|
+
T extends object,
|
|
21
|
+
D extends DataTypes.Keys<T>,
|
|
22
|
+
L extends DataTypes.Keys<T, string>
|
|
23
|
+
> = AutocompleteExtendedProps<T, D> & {
|
|
17
24
|
/**
|
|
18
25
|
* Auto add blank item
|
|
19
26
|
*/
|
|
@@ -27,7 +34,7 @@ export interface ComboBoxProps<
|
|
|
27
34
|
/**
|
|
28
35
|
* Label field
|
|
29
36
|
*/
|
|
30
|
-
labelField
|
|
37
|
+
labelField?: L;
|
|
31
38
|
|
|
32
39
|
/**
|
|
33
40
|
* Load data callback
|
|
@@ -43,7 +50,7 @@ export interface ComboBoxProps<
|
|
|
43
50
|
* Array of options.
|
|
44
51
|
*/
|
|
45
52
|
options?: ReadonlyArray<T>;
|
|
46
|
-
}
|
|
53
|
+
};
|
|
47
54
|
|
|
48
55
|
/**
|
|
49
56
|
* ComboBox
|
|
@@ -51,14 +58,15 @@ export interface ComboBoxProps<
|
|
|
51
58
|
* @returns Component
|
|
52
59
|
*/
|
|
53
60
|
export function ComboBox<
|
|
54
|
-
T extends
|
|
55
|
-
D extends DataTypes.Keys<T> =
|
|
56
|
-
|
|
61
|
+
T extends object = ListType,
|
|
62
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>,
|
|
63
|
+
L extends DataTypes.Keys<T, string> = LabelDefaultType<T>
|
|
64
|
+
>(props: ComboBoxProps<T, D, L>) {
|
|
57
65
|
// Destruct
|
|
58
66
|
const {
|
|
59
67
|
search = false,
|
|
60
68
|
autoAddBlankItem = search,
|
|
61
|
-
idField,
|
|
69
|
+
idField = 'id' as D,
|
|
62
70
|
idValue,
|
|
63
71
|
inputError,
|
|
64
72
|
inputHelperText,
|
|
@@ -68,7 +76,7 @@ export function ComboBox<
|
|
|
68
76
|
inputVariant,
|
|
69
77
|
defaultValue,
|
|
70
78
|
label,
|
|
71
|
-
labelField,
|
|
79
|
+
labelField = 'label' as L,
|
|
72
80
|
loadData,
|
|
73
81
|
onLoadData,
|
|
74
82
|
name,
|
|
@@ -194,7 +202,7 @@ export function ComboBox<
|
|
|
194
202
|
onChange={inputOnChange}
|
|
195
203
|
/>
|
|
196
204
|
{/* Previous input will reset first with "disableClearable = false", next input trigger change works */}
|
|
197
|
-
<Autocomplete
|
|
205
|
+
<Autocomplete<T, undefined, false, false>
|
|
198
206
|
value={stateValue}
|
|
199
207
|
getOptionLabel={getOptionLabel}
|
|
200
208
|
isOptionEqualToValue={(option: T, value: T) =>
|
package/src/mu/DataGridEx.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { css } from '@emotion/css';
|
|
2
|
-
import { Utils } from '@etsoo/shared';
|
|
2
|
+
import { DataTypes, IdDefaultType, Utils } from '@etsoo/shared';
|
|
3
3
|
import {
|
|
4
4
|
Box,
|
|
5
5
|
BoxProps,
|
|
@@ -30,24 +30,24 @@ import { MouseEventWithDataHandler } from './MUGlobal';
|
|
|
30
30
|
/**
|
|
31
31
|
* Footer item renderer props
|
|
32
32
|
*/
|
|
33
|
-
export
|
|
34
|
-
T extends Record<string, any>
|
|
35
|
-
> {
|
|
33
|
+
export type DataGridExFooterItemRendererProps<T extends object> = {
|
|
36
34
|
column: GridColumn<T>;
|
|
37
35
|
index: number;
|
|
38
36
|
states: GridLoaderStates<T>;
|
|
39
37
|
cellProps: any;
|
|
40
38
|
checkable: boolean;
|
|
41
|
-
}
|
|
39
|
+
};
|
|
42
40
|
|
|
43
41
|
/**
|
|
44
42
|
* Extended DataGrid with VariableSizeGrid props
|
|
45
43
|
*/
|
|
46
|
-
export
|
|
47
|
-
extends
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
export type DataGridExProps<
|
|
45
|
+
T extends object,
|
|
46
|
+
D extends DataTypes.Keys<T>
|
|
47
|
+
> = Omit<
|
|
48
|
+
ScrollerGridProps<T, D>,
|
|
49
|
+
'itemRenderer' | 'columnCount' | 'columnWidth' | 'width'
|
|
50
|
+
> & {
|
|
51
51
|
/**
|
|
52
52
|
* Alternating colors for odd/even rows
|
|
53
53
|
*/
|
|
@@ -124,7 +124,7 @@ export interface DataGridExProps<T extends Record<string, any>>
|
|
|
124
124
|
* Width
|
|
125
125
|
*/
|
|
126
126
|
width?: number;
|
|
127
|
-
}
|
|
127
|
+
};
|
|
128
128
|
|
|
129
129
|
// Borders
|
|
130
130
|
const boldBorder = '2px solid rgba(224, 224, 224, 1)';
|
|
@@ -210,9 +210,10 @@ export function DataGridExCalColumns<T>(columns: GridColumn<T>[]) {
|
|
|
210
210
|
* @param props Props
|
|
211
211
|
* @returns Component
|
|
212
212
|
*/
|
|
213
|
-
export function DataGridEx<
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
export function DataGridEx<
|
|
214
|
+
T extends object,
|
|
215
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>
|
|
216
|
+
>(props: DataGridExProps<T, D>) {
|
|
216
217
|
// Theme
|
|
217
218
|
const theme = useTheme();
|
|
218
219
|
|
|
@@ -360,7 +361,7 @@ export function DataGridEx<T extends Record<string, any>>(
|
|
|
360
361
|
footerItemRenderer = DataGridRenderers.defaultFooterItemRenderer,
|
|
361
362
|
hideFooter = false,
|
|
362
363
|
hoverColor = '#f6f9fb',
|
|
363
|
-
idField = 'id',
|
|
364
|
+
idField = 'id' as D,
|
|
364
365
|
mRef = React.createRef(),
|
|
365
366
|
onClick,
|
|
366
367
|
onDoubleClick,
|
|
@@ -372,7 +373,7 @@ export function DataGridEx<T extends Record<string, any>>(
|
|
|
372
373
|
|
|
373
374
|
if (checkable) {
|
|
374
375
|
const cbColumn: GridColumn<T> = {
|
|
375
|
-
field: 'selected',
|
|
376
|
+
field: 'selected' as any, // Avoid validation from data model
|
|
376
377
|
header: '',
|
|
377
378
|
sortable: false,
|
|
378
379
|
width: 50,
|
|
@@ -442,7 +443,7 @@ export function DataGridEx<T extends Record<string, any>>(
|
|
|
442
443
|
};
|
|
443
444
|
|
|
444
445
|
// Reset
|
|
445
|
-
const reset = (add:
|
|
446
|
+
const reset = (add: object) => {
|
|
446
447
|
refs.current.ref?.reset(add);
|
|
447
448
|
};
|
|
448
449
|
|
|
@@ -632,7 +633,7 @@ export function DataGridEx<T extends Record<string, any>>(
|
|
|
632
633
|
: undefined;
|
|
633
634
|
|
|
634
635
|
return (
|
|
635
|
-
<ScrollerGrid<T>
|
|
636
|
+
<ScrollerGrid<T, D>
|
|
636
637
|
className={Utils.mergeClasses(
|
|
637
638
|
'DataGridEx-Body',
|
|
638
639
|
'DataGridEx-CustomBar',
|
|
@@ -117,7 +117,7 @@ export namespace DataGridRenderers {
|
|
|
117
117
|
* @param location Renderer location (column index)
|
|
118
118
|
* @returns Component
|
|
119
119
|
*/
|
|
120
|
-
export function defaultFooterItemRenderer<T>(
|
|
120
|
+
export function defaultFooterItemRenderer<T extends object>(
|
|
121
121
|
_rows: T[],
|
|
122
122
|
{ index, states, checkable }: DataGridExFooterItemRendererProps<T>,
|
|
123
123
|
location: number = 0
|
package/src/mu/DnDList.tsx
CHANGED
|
@@ -79,7 +79,7 @@ export const DnDItemStyle = (
|
|
|
79
79
|
/**
|
|
80
80
|
* DnD list forward ref
|
|
81
81
|
*/
|
|
82
|
-
export interface DnDListRef<D extends
|
|
82
|
+
export interface DnDListRef<D extends object> {
|
|
83
83
|
/**
|
|
84
84
|
* Add item
|
|
85
85
|
* @param item New item
|
|
@@ -109,7 +109,7 @@ export interface DnDListRef<D extends {}> {
|
|
|
109
109
|
/**
|
|
110
110
|
* DnD sortable list properties
|
|
111
111
|
*/
|
|
112
|
-
export interface DnDListPros<D extends
|
|
112
|
+
export interface DnDListPros<D extends object, K extends DataTypes.Keys<D>> {
|
|
113
113
|
/**
|
|
114
114
|
* Get list item style callback
|
|
115
115
|
*/
|
package/src/mu/ItemList.tsx
CHANGED
|
@@ -3,17 +3,26 @@ import {
|
|
|
3
3
|
Dialog,
|
|
4
4
|
DialogTitle,
|
|
5
5
|
List,
|
|
6
|
-
ListItem,
|
|
7
6
|
ListItemText,
|
|
8
7
|
DialogContent,
|
|
9
|
-
Button
|
|
8
|
+
Button,
|
|
9
|
+
ListItemButton
|
|
10
10
|
} from '@mui/material';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
DataTypes,
|
|
13
|
+
IdDefaultType,
|
|
14
|
+
LabelDefaultType,
|
|
15
|
+
ListType
|
|
16
|
+
} from '@etsoo/shared';
|
|
12
17
|
|
|
13
18
|
/**
|
|
14
19
|
* Item list properties
|
|
15
20
|
*/
|
|
16
|
-
export interface ItemListProps<
|
|
21
|
+
export interface ItemListProps<
|
|
22
|
+
T extends object,
|
|
23
|
+
D extends DataTypes.Keys<T>,
|
|
24
|
+
L extends DataTypes.Keys<T, string>
|
|
25
|
+
> {
|
|
17
26
|
/**
|
|
18
27
|
* Style class name
|
|
19
28
|
*/
|
|
@@ -22,12 +31,12 @@ export interface ItemListProps<T extends Record<string, unknown>> {
|
|
|
22
31
|
/**
|
|
23
32
|
* Id field name
|
|
24
33
|
*/
|
|
25
|
-
idField?:
|
|
34
|
+
idField?: D;
|
|
26
35
|
|
|
27
36
|
/**
|
|
28
37
|
* Label field name or callback
|
|
29
38
|
*/
|
|
30
|
-
labelField?:
|
|
39
|
+
labelField?: L | ((item: T) => string);
|
|
31
40
|
|
|
32
41
|
/**
|
|
33
42
|
* Button icon
|
|
@@ -47,7 +56,7 @@ export interface ItemListProps<T extends Record<string, unknown>> {
|
|
|
47
56
|
/**
|
|
48
57
|
* Current selected language
|
|
49
58
|
*/
|
|
50
|
-
selectedValue?:
|
|
59
|
+
selectedValue?: T[D];
|
|
51
60
|
|
|
52
61
|
/**
|
|
53
62
|
* Button size
|
|
@@ -75,15 +84,17 @@ export interface ItemListProps<T extends Record<string, unknown>> {
|
|
|
75
84
|
* @param props Properties
|
|
76
85
|
*/
|
|
77
86
|
export function ItemList<
|
|
78
|
-
T extends
|
|
79
|
-
|
|
87
|
+
T extends object = ListType,
|
|
88
|
+
D extends DataTypes.Keys<T> = IdDefaultType<T>,
|
|
89
|
+
L extends DataTypes.Keys<T, string> = LabelDefaultType<T>
|
|
90
|
+
>(props: ItemListProps<T, D, L>) {
|
|
80
91
|
// properties destructure
|
|
81
92
|
const {
|
|
82
93
|
className,
|
|
83
94
|
color = 'primary',
|
|
84
95
|
items,
|
|
85
|
-
idField = 'id',
|
|
86
|
-
labelField = 'label',
|
|
96
|
+
idField = 'id' as D,
|
|
97
|
+
labelField = 'label' as L,
|
|
87
98
|
icon,
|
|
88
99
|
onClose,
|
|
89
100
|
selectedValue,
|
|
@@ -92,13 +103,6 @@ export function ItemList<
|
|
|
92
103
|
variant = 'outlined'
|
|
93
104
|
} = props;
|
|
94
105
|
|
|
95
|
-
// Get id
|
|
96
|
-
const getId = (item: T): string | number => {
|
|
97
|
-
const id = item[idField];
|
|
98
|
-
if (typeof id === 'number') return id;
|
|
99
|
-
return DataTypes.convert(id, 'string') ?? '';
|
|
100
|
-
};
|
|
101
|
-
|
|
102
106
|
// Get label
|
|
103
107
|
const getLabel = (item: T): string => {
|
|
104
108
|
if (typeof labelField === 'function') {
|
|
@@ -113,7 +117,7 @@ export function ItemList<
|
|
|
113
117
|
|
|
114
118
|
// Default state
|
|
115
119
|
const defaultItem =
|
|
116
|
-
items.find((item) =>
|
|
120
|
+
items.find((item) => item[idField] === selectedValue) ?? items[0];
|
|
117
121
|
|
|
118
122
|
// Current item
|
|
119
123
|
const [currentItem, setCurrentItem] = React.useState(defaultItem);
|
|
@@ -179,18 +183,17 @@ export function ItemList<
|
|
|
179
183
|
<DialogContent>
|
|
180
184
|
<List>
|
|
181
185
|
{items.map((item) => {
|
|
182
|
-
const id =
|
|
186
|
+
const id = item[idField];
|
|
183
187
|
return (
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
disabled={id === getId(currentItem)}
|
|
188
|
+
<ListItemButton
|
|
189
|
+
key={id as unknown as React.Key}
|
|
190
|
+
disabled={id === currentItem[idField]}
|
|
188
191
|
onClick={() => closeItemHandler(item)}
|
|
189
192
|
>
|
|
190
193
|
<ListItemText>
|
|
191
194
|
{getLabel(item)}
|
|
192
195
|
</ListItemText>
|
|
193
|
-
</
|
|
196
|
+
</ListItemButton>
|
|
194
197
|
);
|
|
195
198
|
})}
|
|
196
199
|
</List>
|
|
@@ -22,7 +22,7 @@ import { LoadingButton } from './LoadingButton';
|
|
|
22
22
|
* ListMoreDisplay props
|
|
23
23
|
*/
|
|
24
24
|
export interface ListMoreDisplayProps<
|
|
25
|
-
T,
|
|
25
|
+
T extends object,
|
|
26
26
|
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
27
27
|
> extends Omit<CardProps, 'children'>,
|
|
28
28
|
GridLoader<T> {
|
|
@@ -63,7 +63,7 @@ type states<T> = {
|
|
|
63
63
|
* @returns Component
|
|
64
64
|
*/
|
|
65
65
|
export function ListMoreDisplay<
|
|
66
|
-
T extends
|
|
66
|
+
T extends object,
|
|
67
67
|
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
68
68
|
>(props: ListMoreDisplayProps<T, F>) {
|
|
69
69
|
// Destruct
|
package/src/mu/MUGlobal.ts
CHANGED
|
@@ -92,7 +92,7 @@ export class MUGlobal {
|
|
|
92
92
|
* @param input Input object
|
|
93
93
|
* @returns Updated object
|
|
94
94
|
*/
|
|
95
|
-
static half(input:
|
|
95
|
+
static half(input: object) {
|
|
96
96
|
const newObj = { ...input };
|
|
97
97
|
Object.entries(newObj).forEach(([key, value]) => {
|
|
98
98
|
if (typeof value === 'number') {
|
|
@@ -107,7 +107,7 @@ export class MUGlobal {
|
|
|
107
107
|
* @param input Input object
|
|
108
108
|
* @returns Updated object
|
|
109
109
|
*/
|
|
110
|
-
static reverse(input:
|
|
110
|
+
static reverse(input: object) {
|
|
111
111
|
const newObj = { ...input };
|
|
112
112
|
Object.entries(newObj).forEach(([key, value]) => {
|
|
113
113
|
if (typeof value === 'number') {
|
|
@@ -124,7 +124,7 @@ export class MUGlobal {
|
|
|
124
124
|
* @param field Specific field
|
|
125
125
|
* @returns Updated object
|
|
126
126
|
*/
|
|
127
|
-
static increase(input:
|
|
127
|
+
static increase(input: object, adjust: number | object, field?: string) {
|
|
128
128
|
const newObj = { ...input };
|
|
129
129
|
Object.entries(newObj).forEach(([key, value]) => {
|
|
130
130
|
if (typeof value === 'number') {
|
|
@@ -152,7 +152,7 @@ export class MUGlobal {
|
|
|
152
152
|
*/
|
|
153
153
|
static adjustWithTheme(
|
|
154
154
|
size: number,
|
|
155
|
-
adjust:
|
|
155
|
+
adjust: object,
|
|
156
156
|
updateFunc: (value: number) => string
|
|
157
157
|
) {
|
|
158
158
|
const newObj = { ...adjust };
|
|
@@ -185,7 +185,7 @@ export class MUGlobal {
|
|
|
185
185
|
* @param theme Theme
|
|
186
186
|
* @returns Result
|
|
187
187
|
*/
|
|
188
|
-
static getSpace(spaces:
|
|
188
|
+
static getSpace(spaces: object, theme: Theme) {
|
|
189
189
|
const start = this.breakpoints.length - 1;
|
|
190
190
|
for (let i = start; i >= 0; i--) {
|
|
191
191
|
const key = this.breakpoints[i];
|