@etsoo/react 1.5.76 → 1.5.77
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/components/ScrollerGrid.d.ts +4 -3
- package/lib/components/ScrollerList.d.ts +1 -1
- package/lib/mu/AutocompleteExtendedProps.d.ts +1 -1
- package/lib/mu/ComboBox.d.ts +1 -1
- package/lib/mu/ComboBox.js +1 -1
- package/lib/mu/DataGridEx.d.ts +4 -3
- package/lib/mu/OptionGroup.d.ts +6 -7
- package/lib/mu/ResponsibleContainer.d.ts +2 -2
- package/lib/mu/ScrollerListEx.d.ts +4 -3
- 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/SelectEx.d.ts +2 -2
- package/lib/mu/SelectEx.js +1 -1
- package/lib/mu/TableEx.d.ts +4 -3
- package/lib/mu/TableEx.js +1 -2
- package/lib/mu/Tiplist.d.ts +1 -1
- package/lib/mu/Tiplist.js +2 -2
- package/package.json +5 -5
- package/src/components/ScrollerGrid.tsx +6 -3
- package/src/components/ScrollerList.tsx +1 -3
- package/src/mu/AutocompleteExtendedProps.ts +1 -1
- package/src/mu/ComboBox.tsx +3 -3
- package/src/mu/DataGridEx.tsx +13 -12
- package/src/mu/OptionGroup.tsx +15 -16
- package/src/mu/ResponsibleContainer.tsx +7 -5
- package/src/mu/ScrollerListEx.tsx +11 -8
- package/src/mu/SearchOptionGroup.tsx +2 -3
- package/src/mu/SelectBool.tsx +7 -5
- package/src/mu/SelectEx.tsx +6 -4
- package/src/mu/TableEx.tsx +15 -14
- package/src/mu/Tiplist.tsx +7 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataTypes } from '@etsoo/shared';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { Align, GridChildComponentProps, VariableSizeGridProps } from 'react-window';
|
|
3
4
|
import { GridMethodRef } from '../mu/GridMethodRef';
|
|
@@ -15,7 +16,7 @@ export interface ScrollerGridItemRendererProps<T> extends Omit<GridChildComponen
|
|
|
15
16
|
/**
|
|
16
17
|
* Scroller vertical grid props
|
|
17
18
|
*/
|
|
18
|
-
export interface ScrollerGridProps<T> extends GridLoader<T>, Omit<VariableSizeGridProps<T>, 'children' | 'rowCount' | 'rowHeight' | 'ref'> {
|
|
19
|
+
export interface ScrollerGridProps<T extends {}, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> extends GridLoader<T>, Omit<VariableSizeGridProps<T>, 'children' | 'rowCount' | 'rowHeight' | 'ref'> {
|
|
19
20
|
/**
|
|
20
21
|
* Default order by asc
|
|
21
22
|
* @default true
|
|
@@ -33,7 +34,7 @@ export interface ScrollerGridProps<T> extends GridLoader<T>, Omit<VariableSizeGr
|
|
|
33
34
|
* Id field
|
|
34
35
|
* @default id
|
|
35
36
|
*/
|
|
36
|
-
idField?:
|
|
37
|
+
idField?: D;
|
|
37
38
|
/**
|
|
38
39
|
* Item renderer
|
|
39
40
|
*/
|
|
@@ -109,4 +110,4 @@ export interface ScrollerGridForwardRef extends GridMethodRef {
|
|
|
109
110
|
* @param props Props
|
|
110
111
|
* @returns Component
|
|
111
112
|
*/
|
|
112
|
-
export declare const ScrollerGrid: <T extends Record<string, unknown>>(props: ScrollerGridProps<T
|
|
113
|
+
export declare const ScrollerGrid: <T extends Record<string, unknown>>(props: ScrollerGridProps<T, DataTypes.Keys<T, string | number>>) => JSX.Element;
|
|
@@ -59,5 +59,5 @@ export interface ScrollerListForwardRef extends GridMethodRef, ScrollerListRef {
|
|
|
59
59
|
* @param props Props
|
|
60
60
|
* @returns Component
|
|
61
61
|
*/
|
|
62
|
-
export declare const ScrollerList: <T extends
|
|
62
|
+
export declare const ScrollerList: <T extends {}>(props: ScrollerListProps<T>) => JSX.Element;
|
|
63
63
|
export {};
|
package/lib/mu/ComboBox.d.ts
CHANGED
package/lib/mu/ComboBox.js
CHANGED
|
@@ -12,7 +12,7 @@ import { ReactUtils } from '../app/ReactUtils';
|
|
|
12
12
|
*/
|
|
13
13
|
export function ComboBox(props) {
|
|
14
14
|
// Destruct
|
|
15
|
-
const { search = false, autoAddBlankItem = search, idField, idValue, inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, defaultValue, label, labelField, loadData, onLoadData, name, inputAutoComplete = 'off', options, dataReadonly = true, readOnly, onChange, openOnFocus = true, value, getOptionLabel = (option) => `${option[labelField]}`, sx = { minWidth: '150px' }, ...rest } = props;
|
|
15
|
+
const { search = false, autoAddBlankItem = search, idField = 'id', idValue, inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, defaultValue, label, labelField = 'label', loadData, onLoadData, name, inputAutoComplete = 'off', options, dataReadonly = true, readOnly, onChange, openOnFocus = true, value, getOptionLabel = (option) => `${option[labelField]}`, sx = { minWidth: '150px' }, ...rest } = props;
|
|
16
16
|
// Value input ref
|
|
17
17
|
const inputRef = React.createRef();
|
|
18
18
|
// Options state
|
package/lib/mu/DataGridEx.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataTypes } from '@etsoo/shared';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { GridColumn } from '../components/GridColumn';
|
|
3
4
|
import { GridLoaderStates } from '../components/GridLoader';
|
|
@@ -6,7 +7,7 @@ import { MouseEventWithDataHandler } from './MUGlobal';
|
|
|
6
7
|
/**
|
|
7
8
|
* Footer item renderer props
|
|
8
9
|
*/
|
|
9
|
-
export interface DataGridExFooterItemRendererProps<T extends
|
|
10
|
+
export interface DataGridExFooterItemRendererProps<T extends {}> {
|
|
10
11
|
column: GridColumn<T>;
|
|
11
12
|
index: number;
|
|
12
13
|
states: GridLoaderStates<T>;
|
|
@@ -16,7 +17,7 @@ export interface DataGridExFooterItemRendererProps<T extends Record<string, any>
|
|
|
16
17
|
/**
|
|
17
18
|
* Extended DataGrid with VariableSizeGrid props
|
|
18
19
|
*/
|
|
19
|
-
export interface DataGridExProps<T extends
|
|
20
|
+
export interface DataGridExProps<T extends {}, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> extends Omit<ScrollerGridProps<T, D>, 'itemRenderer' | 'columnCount' | 'columnWidth' | 'width'> {
|
|
20
21
|
/**
|
|
21
22
|
* Alternating colors for odd/even rows
|
|
22
23
|
*/
|
|
@@ -92,4 +93,4 @@ export declare function DataGridExCalColumns<T>(columns: GridColumn<T>[]): {
|
|
|
92
93
|
* @param props Props
|
|
93
94
|
* @returns Component
|
|
94
95
|
*/
|
|
95
|
-
export declare function DataGridEx<T extends
|
|
96
|
+
export declare function DataGridEx<T extends {}, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: DataGridExProps<T, D>): JSX.Element;
|
package/lib/mu/OptionGroup.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { IdLabelDto } from '@etsoo/appscript';
|
|
3
2
|
import { DataTypes } from '@etsoo/shared';
|
|
4
3
|
import { FormControlProps } from '@mui/material';
|
|
5
4
|
/**
|
|
6
5
|
* OptionGroup props
|
|
7
6
|
*/
|
|
8
|
-
export interface OptionGroupProps<T extends
|
|
7
|
+
export interface OptionGroupProps<T extends {} = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> extends Omit<FormControlProps<'fieldset'>, 'defaultValue'> {
|
|
9
8
|
/**
|
|
10
9
|
* Default value
|
|
11
10
|
*/
|
|
12
|
-
defaultValue?: D | D[];
|
|
11
|
+
defaultValue?: T[D] | T[D][];
|
|
13
12
|
/**
|
|
14
13
|
* Get option label function
|
|
15
14
|
*/
|
|
@@ -17,7 +16,7 @@ export interface OptionGroupProps<T extends Record<string, any> = IdLabelDto, D
|
|
|
17
16
|
/**
|
|
18
17
|
* Id field, default is id
|
|
19
18
|
*/
|
|
20
|
-
idField
|
|
19
|
+
idField: T extends DataTypes.IdLabelItem ? D | undefined : D;
|
|
21
20
|
/**
|
|
22
21
|
* Label
|
|
23
22
|
*/
|
|
@@ -25,7 +24,7 @@ export interface OptionGroupProps<T extends Record<string, any> = IdLabelDto, D
|
|
|
25
24
|
/**
|
|
26
25
|
* Label field, default is label
|
|
27
26
|
*/
|
|
28
|
-
labelField
|
|
27
|
+
labelField: T extends DataTypes.IdLabelItem ? D | undefined : D;
|
|
29
28
|
/**
|
|
30
29
|
* Multiple choose item
|
|
31
30
|
*/
|
|
@@ -37,7 +36,7 @@ export interface OptionGroupProps<T extends Record<string, any> = IdLabelDto, D
|
|
|
37
36
|
/**
|
|
38
37
|
* On value change handler
|
|
39
38
|
*/
|
|
40
|
-
onValueChange?: (value: D | D[] | undefined) => void;
|
|
39
|
+
onValueChange?: (value: T[D] | T[D][] | undefined) => void;
|
|
41
40
|
/**
|
|
42
41
|
* Array of options.
|
|
43
42
|
*/
|
|
@@ -56,4 +55,4 @@ export interface OptionGroupProps<T extends Record<string, any> = IdLabelDto, D
|
|
|
56
55
|
* @param props Props
|
|
57
56
|
* @returns Component
|
|
58
57
|
*/
|
|
59
|
-
export declare function OptionGroup<T extends
|
|
58
|
+
export declare function OptionGroup<T extends {} = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: OptionGroupProps<T, D>): JSX.Element;
|
|
@@ -10,7 +10,7 @@ import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from './
|
|
|
10
10
|
/**
|
|
11
11
|
* ResponsibleContainer props
|
|
12
12
|
*/
|
|
13
|
-
export interface ResponsibleContainerProps<T extends {}, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate> extends Omit<DataGridExProps<T>, 'height' | 'itemKey' | 'loadData' | 'mRef' | 'onScroll' | 'onItemsRendered'> {
|
|
13
|
+
export interface ResponsibleContainerProps<T extends {}, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> extends Omit<DataGridExProps<T, D>, 'height' | 'itemKey' | 'loadData' | 'mRef' | 'onScroll' | 'onItemsRendered'> {
|
|
14
14
|
/**
|
|
15
15
|
* Height will be deducted
|
|
16
16
|
* @param height Current calcuated height
|
|
@@ -86,4 +86,4 @@ export interface ResponsibleContainerProps<T extends {}, F extends DataTypes.Bas
|
|
|
86
86
|
* @param props Props
|
|
87
87
|
* @returns Layout
|
|
88
88
|
*/
|
|
89
|
-
export declare function ResponsibleContainer<T extends {}, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ResponsibleContainerProps<T, F>): JSX.Element;
|
|
89
|
+
export declare function ResponsibleContainer<T extends {}, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: ResponsibleContainerProps<T, F, D>): JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataTypes } from '@etsoo/shared';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { ListChildComponentProps } from 'react-window';
|
|
3
4
|
import { ScrollerListProps } from '../components/ScrollerList';
|
|
@@ -33,7 +34,7 @@ export declare type ScrollerListExItemSize = ((index: number) => [number, number
|
|
|
33
34
|
/**
|
|
34
35
|
* Extended ScrollerList Props
|
|
35
36
|
*/
|
|
36
|
-
export interface ScrollerListExProps<T> extends Omit<ScrollerListProps<T>, 'itemRenderer' | 'itemSize'> {
|
|
37
|
+
export interface ScrollerListExProps<T extends {}, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> extends Omit<ScrollerListProps<T>, 'itemRenderer' | 'itemSize'> {
|
|
37
38
|
/**
|
|
38
39
|
* Alternating colors for odd/even rows
|
|
39
40
|
*/
|
|
@@ -41,7 +42,7 @@ export interface ScrollerListExProps<T> extends Omit<ScrollerListProps<T>, 'item
|
|
|
41
42
|
/**
|
|
42
43
|
* Id field
|
|
43
44
|
*/
|
|
44
|
-
idField?:
|
|
45
|
+
idField?: D;
|
|
45
46
|
/**
|
|
46
47
|
* Inner item renderer
|
|
47
48
|
*/
|
|
@@ -76,4 +77,4 @@ export interface ScrollerListExProps<T> extends Omit<ScrollerListProps<T>, 'item
|
|
|
76
77
|
* @param props Props
|
|
77
78
|
* @returns Component
|
|
78
79
|
*/
|
|
79
|
-
export declare function ScrollerListEx<T extends
|
|
80
|
+
export declare function ScrollerListEx<T extends {}, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: ScrollerListExProps<T, D>): JSX.Element;
|
package/lib/mu/ScrollerListEx.js
CHANGED
|
@@ -112,7 +112,7 @@ export function ScrollerListEx(props) {
|
|
|
112
112
|
return selected;
|
|
113
113
|
};
|
|
114
114
|
// Destruct
|
|
115
|
-
const { alternatingColors = [undefined, undefined], className, idField = 'id', innerItemRenderer, itemSize, itemKey = (index, data) => { var _a; return (_a = DataTypes.
|
|
115
|
+
const { alternatingColors = [undefined, undefined], className, idField = 'id', innerItemRenderer, itemSize, itemKey = (index, data) => { var _a; return (_a = DataTypes.getIdValue1(data, idField)) !== null && _a !== void 0 ? _a : index; }, itemRenderer = (itemProps) => {
|
|
116
116
|
const [itemHeight, space, margins] = calculateItemSize(itemProps.index);
|
|
117
117
|
return defaultItemRenderer({
|
|
118
118
|
itemHeight,
|
|
@@ -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 {} = 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/SelectEx.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface SelectExProps<T extends {}, D extends DataTypes.Keys<T> = DataT
|
|
|
12
12
|
/**
|
|
13
13
|
* Id field
|
|
14
14
|
*/
|
|
15
|
-
idField: D;
|
|
15
|
+
idField: T extends DataTypes.IdLabelItem ? D | undefined : D;
|
|
16
16
|
/**
|
|
17
17
|
* Item icon renderer
|
|
18
18
|
*/
|
|
@@ -20,7 +20,7 @@ export interface SelectExProps<T extends {}, D extends DataTypes.Keys<T> = DataT
|
|
|
20
20
|
/**
|
|
21
21
|
* Label field
|
|
22
22
|
*/
|
|
23
|
-
labelField: ((option: T) => string) | D;
|
|
23
|
+
labelField: ((option: T) => string) | (T extends DataTypes.IdLabelItem ? D | undefined : D);
|
|
24
24
|
/**
|
|
25
25
|
* Load data callback
|
|
26
26
|
*/
|
package/lib/mu/SelectEx.js
CHANGED
|
@@ -12,7 +12,7 @@ import { ReactUtils } from '../app/ReactUtils';
|
|
|
12
12
|
export function SelectEx(props) {
|
|
13
13
|
var _a;
|
|
14
14
|
// Destruct
|
|
15
|
-
const { defaultValue, idField, itemIconRenderer, label, labelField, loadData, onItemClick, onLoadData, multiple = false, name, options = [], search = false, autoAddBlankItem = search, value, onChange, fullWidth, ...rest } = props;
|
|
15
|
+
const { defaultValue, idField = 'id', itemIconRenderer, label, labelField = 'label', loadData, onItemClick, onLoadData, multiple = false, name, options = [], search = false, autoAddBlankItem = search, value, onChange, fullWidth, ...rest } = props;
|
|
16
16
|
// Options state
|
|
17
17
|
const [localOptions, setOptions] = React.useState(options);
|
|
18
18
|
const isMounted = React.useRef(true);
|
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 interface TableExProps<T extends
|
|
23
|
+
export interface TableExProps<T extends {}, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> extends TableProps, GridLoader<T> {
|
|
23
24
|
/**
|
|
24
25
|
* Alternating colors for odd/even rows
|
|
25
26
|
*/
|
|
@@ -35,7 +36,7 @@ export interface TableExProps<T extends Record<string, any>> extends TableProps,
|
|
|
35
36
|
/**
|
|
36
37
|
* Id field
|
|
37
38
|
*/
|
|
38
|
-
idField?:
|
|
39
|
+
idField?: D;
|
|
39
40
|
/**
|
|
40
41
|
* Max height
|
|
41
42
|
*/
|
|
@@ -62,4 +63,4 @@ export interface TableExProps<T extends Record<string, any>> extends TableProps,
|
|
|
62
63
|
* @param props Props
|
|
63
64
|
* @returns Component
|
|
64
65
|
*/
|
|
65
|
-
export declare function TableEx<T extends
|
|
66
|
+
export declare function TableEx<T extends {}, 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
|
@@ -15,4 +15,4 @@ export interface TiplistProps<T extends {}, D extends DataTypes.Keys<T>> extends
|
|
|
15
15
|
* @param props Props
|
|
16
16
|
* @returns Component
|
|
17
17
|
*/
|
|
18
|
-
export declare function Tiplist<T extends {}, D extends DataTypes.Keys<T>>(props: TiplistProps<T, D>): JSX.Element;
|
|
18
|
+
export declare function Tiplist<T extends {} = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: TiplistProps<T, D>): JSX.Element;
|
package/lib/mu/Tiplist.js
CHANGED
|
@@ -12,7 +12,7 @@ import { SearchField } from './SearchField';
|
|
|
12
12
|
*/
|
|
13
13
|
export function Tiplist(props) {
|
|
14
14
|
// Destruct
|
|
15
|
-
const { search = false, idField, idValue, inputAutoComplete = 'off', inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, label, loadData, defaultValue, value, name, readOnly, onChange, openOnFocus = true, sx = { minWidth: '180px' }, ...rest } = props;
|
|
15
|
+
const { search = false, idField = 'id', idValue, inputAutoComplete = 'off', inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, label, loadData, defaultValue, value, name, readOnly, onChange, openOnFocus = true, sx = { minWidth: '180px' }, ...rest } = props;
|
|
16
16
|
// Value input ref
|
|
17
17
|
const inputRef = React.createRef();
|
|
18
18
|
// Local value
|
|
@@ -20,7 +20,7 @@ export function Tiplist(props) {
|
|
|
20
20
|
if (localValue === undefined)
|
|
21
21
|
localValue = null;
|
|
22
22
|
// One time calculation for input's default value (uncontrolled)
|
|
23
|
-
const localIdValue = idValue !== null && idValue !== void 0 ? idValue : (localValue &&
|
|
23
|
+
const localIdValue = idValue !== null && idValue !== void 0 ? idValue : DataTypes.getValue(localValue, idField !== null && idField !== void 0 ? idField : 'id');
|
|
24
24
|
// Changable states
|
|
25
25
|
const [states, stateUpdate] = React.useReducer((currentState, newState) => {
|
|
26
26
|
return { ...currentState, ...newState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.77",
|
|
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.
|
|
54
|
+
"@etsoo/appscript": "^1.2.81",
|
|
55
55
|
"@etsoo/notificationbase": "^1.1.6",
|
|
56
|
-
"@etsoo/shared": "^1.1.
|
|
57
|
-
"@mui/icons-material": "^5.
|
|
58
|
-
"@mui/material": "^5.10.
|
|
56
|
+
"@etsoo/shared": "^1.1.47",
|
|
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",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataTypes } from '@etsoo/shared';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import {
|
|
3
4
|
Align,
|
|
@@ -25,8 +26,10 @@ export interface ScrollerGridItemRendererProps<T>
|
|
|
25
26
|
/**
|
|
26
27
|
* Scroller vertical grid props
|
|
27
28
|
*/
|
|
28
|
-
export interface ScrollerGridProps<
|
|
29
|
-
extends
|
|
29
|
+
export interface ScrollerGridProps<
|
|
30
|
+
T extends {},
|
|
31
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
32
|
+
> extends GridLoader<T>,
|
|
30
33
|
Omit<
|
|
31
34
|
VariableSizeGridProps<T>,
|
|
32
35
|
'children' | 'rowCount' | 'rowHeight' | 'ref'
|
|
@@ -54,7 +57,7 @@ export interface ScrollerGridProps<T>
|
|
|
54
57
|
* Id field
|
|
55
58
|
* @default id
|
|
56
59
|
*/
|
|
57
|
-
idField?:
|
|
60
|
+
idField?: D;
|
|
58
61
|
|
|
59
62
|
/**
|
|
60
63
|
* Item renderer
|
|
@@ -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 {}>(props: ScrollerListProps<T>) => {
|
|
104
102
|
// Destruct
|
|
105
103
|
const {
|
|
106
104
|
autoLoad = true,
|
package/src/mu/ComboBox.tsx
CHANGED
|
@@ -27,7 +27,7 @@ export interface ComboBoxProps<
|
|
|
27
27
|
/**
|
|
28
28
|
* Label field
|
|
29
29
|
*/
|
|
30
|
-
labelField: D;
|
|
30
|
+
labelField: T extends DataTypes.IdLabelItem ? D | undefined : D;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Load data callback
|
|
@@ -58,7 +58,7 @@ export function ComboBox<
|
|
|
58
58
|
const {
|
|
59
59
|
search = false,
|
|
60
60
|
autoAddBlankItem = search,
|
|
61
|
-
idField,
|
|
61
|
+
idField = 'id' as D,
|
|
62
62
|
idValue,
|
|
63
63
|
inputError,
|
|
64
64
|
inputHelperText,
|
|
@@ -68,7 +68,7 @@ export function ComboBox<
|
|
|
68
68
|
inputVariant,
|
|
69
69
|
defaultValue,
|
|
70
70
|
label,
|
|
71
|
-
labelField,
|
|
71
|
+
labelField = 'label' as D,
|
|
72
72
|
loadData,
|
|
73
73
|
onLoadData,
|
|
74
74
|
name,
|
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, Utils } from '@etsoo/shared';
|
|
3
3
|
import {
|
|
4
4
|
Box,
|
|
5
5
|
BoxProps,
|
|
@@ -30,9 +30,7 @@ import { MouseEventWithDataHandler } from './MUGlobal';
|
|
|
30
30
|
/**
|
|
31
31
|
* Footer item renderer props
|
|
32
32
|
*/
|
|
33
|
-
export interface DataGridExFooterItemRendererProps<
|
|
34
|
-
T extends Record<string, any>
|
|
35
|
-
> {
|
|
33
|
+
export interface DataGridExFooterItemRendererProps<T extends {}> {
|
|
36
34
|
column: GridColumn<T>;
|
|
37
35
|
index: number;
|
|
38
36
|
states: GridLoaderStates<T>;
|
|
@@ -43,9 +41,11 @@ export interface DataGridExFooterItemRendererProps<
|
|
|
43
41
|
/**
|
|
44
42
|
* Extended DataGrid with VariableSizeGrid props
|
|
45
43
|
*/
|
|
46
|
-
export interface DataGridExProps<
|
|
47
|
-
extends
|
|
48
|
-
|
|
44
|
+
export interface DataGridExProps<
|
|
45
|
+
T extends {},
|
|
46
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
47
|
+
> extends Omit<
|
|
48
|
+
ScrollerGridProps<T, D>,
|
|
49
49
|
'itemRenderer' | 'columnCount' | 'columnWidth' | 'width'
|
|
50
50
|
> {
|
|
51
51
|
/**
|
|
@@ -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 {},
|
|
215
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<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,
|
package/src/mu/OptionGroup.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IdLabelDto } from '@etsoo/appscript';
|
|
2
1
|
import { DataTypes, Utils } from '@etsoo/shared';
|
|
3
2
|
import {
|
|
4
3
|
Checkbox,
|
|
@@ -16,13 +15,13 @@ import React from 'react';
|
|
|
16
15
|
* OptionGroup props
|
|
17
16
|
*/
|
|
18
17
|
export interface OptionGroupProps<
|
|
19
|
-
T extends
|
|
20
|
-
D extends DataTypes.
|
|
18
|
+
T extends {} = DataTypes.IdLabelItem,
|
|
19
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
21
20
|
> extends Omit<FormControlProps<'fieldset'>, 'defaultValue'> {
|
|
22
21
|
/**
|
|
23
22
|
* Default value
|
|
24
23
|
*/
|
|
25
|
-
defaultValue?: D | D[];
|
|
24
|
+
defaultValue?: T[D] | T[D][];
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
27
|
* Get option label function
|
|
@@ -32,7 +31,7 @@ export interface OptionGroupProps<
|
|
|
32
31
|
/**
|
|
33
32
|
* Id field, default is id
|
|
34
33
|
*/
|
|
35
|
-
idField
|
|
34
|
+
idField: T extends DataTypes.IdLabelItem ? D | undefined : D;
|
|
36
35
|
|
|
37
36
|
/**
|
|
38
37
|
* Label
|
|
@@ -42,7 +41,7 @@ export interface OptionGroupProps<
|
|
|
42
41
|
/**
|
|
43
42
|
* Label field, default is label
|
|
44
43
|
*/
|
|
45
|
-
labelField
|
|
44
|
+
labelField: T extends DataTypes.IdLabelItem ? D | undefined : D;
|
|
46
45
|
|
|
47
46
|
/**
|
|
48
47
|
* Multiple choose item
|
|
@@ -57,7 +56,7 @@ export interface OptionGroupProps<
|
|
|
57
56
|
/**
|
|
58
57
|
* On value change handler
|
|
59
58
|
*/
|
|
60
|
-
onValueChange?: (value: D | D[] | undefined) => void;
|
|
59
|
+
onValueChange?: (value: T[D] | T[D][] | undefined) => void;
|
|
61
60
|
|
|
62
61
|
/**
|
|
63
62
|
* Array of options.
|
|
@@ -81,16 +80,16 @@ export interface OptionGroupProps<
|
|
|
81
80
|
* @returns Component
|
|
82
81
|
*/
|
|
83
82
|
export function OptionGroup<
|
|
84
|
-
T extends
|
|
85
|
-
D extends DataTypes.
|
|
83
|
+
T extends {} = DataTypes.IdLabelItem,
|
|
84
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
86
85
|
>(props: OptionGroupProps<T, D>) {
|
|
87
86
|
// Destruct
|
|
88
87
|
const {
|
|
89
88
|
getOptionLabel,
|
|
90
89
|
defaultValue,
|
|
91
|
-
idField = 'id',
|
|
90
|
+
idField = 'id' as D,
|
|
92
91
|
label,
|
|
93
|
-
labelField = 'label',
|
|
92
|
+
labelField = 'label' as D,
|
|
94
93
|
multiple = false,
|
|
95
94
|
name,
|
|
96
95
|
onValueChange,
|
|
@@ -103,10 +102,10 @@ export function OptionGroup<
|
|
|
103
102
|
|
|
104
103
|
// Get option value
|
|
105
104
|
// D type should be the source id type
|
|
106
|
-
const getOptionValue = (option: T): D | null => {
|
|
105
|
+
const getOptionValue = (option: T): T[D] | null => {
|
|
107
106
|
const value = DataTypes.getValue(option, idField);
|
|
108
107
|
if (value == null) return null;
|
|
109
|
-
return value as D;
|
|
108
|
+
return value as T[D];
|
|
110
109
|
};
|
|
111
110
|
|
|
112
111
|
// Checkbox values
|
|
@@ -142,7 +141,7 @@ export function OptionGroup<
|
|
|
142
141
|
onChange={(event) => {
|
|
143
142
|
if (firstOptionValue == null) return;
|
|
144
143
|
|
|
145
|
-
const typeValue = Utils.parseString
|
|
144
|
+
const typeValue = Utils.parseString(
|
|
146
145
|
event.target.value,
|
|
147
146
|
firstOptionValue
|
|
148
147
|
);
|
|
@@ -175,7 +174,7 @@ export function OptionGroup<
|
|
|
175
174
|
|
|
176
175
|
// Value, convert to string
|
|
177
176
|
// Will fail when type is number
|
|
178
|
-
const value = getOptionValue(option);
|
|
177
|
+
const value = getOptionValue(option) as unknown as React.Key;
|
|
179
178
|
|
|
180
179
|
return (
|
|
181
180
|
<FormControlLabel
|
|
@@ -197,7 +196,7 @@ export function OptionGroup<
|
|
|
197
196
|
value={values[0]}
|
|
198
197
|
onChange={(_event, value) => {
|
|
199
198
|
if (firstOptionValue == null) return;
|
|
200
|
-
const typeValue = Utils.parseString
|
|
199
|
+
const typeValue = Utils.parseString(value, firstOptionValue);
|
|
201
200
|
if (onValueChange) onValueChange(typeValue);
|
|
202
201
|
setValues([typeValue]);
|
|
203
202
|
}}
|
|
@@ -32,9 +32,10 @@ import { SearchBar } from './SearchBar';
|
|
|
32
32
|
*/
|
|
33
33
|
export interface ResponsibleContainerProps<
|
|
34
34
|
T extends {},
|
|
35
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
35
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
|
|
36
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
36
37
|
> extends Omit<
|
|
37
|
-
DataGridExProps<T>,
|
|
38
|
+
DataGridExProps<T, D>,
|
|
38
39
|
| 'height'
|
|
39
40
|
| 'itemKey'
|
|
40
41
|
| 'loadData'
|
|
@@ -163,8 +164,9 @@ function defaultContainerBoxSx(
|
|
|
163
164
|
*/
|
|
164
165
|
export function ResponsibleContainer<
|
|
165
166
|
T extends {},
|
|
166
|
-
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
|
|
167
|
-
>
|
|
167
|
+
F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
|
|
168
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
169
|
+
>(props: ResponsibleContainerProps<T, F, D>) {
|
|
168
170
|
// Destruct
|
|
169
171
|
const {
|
|
170
172
|
adjustHeight,
|
|
@@ -319,7 +321,7 @@ export function ResponsibleContainer<
|
|
|
319
321
|
|
|
320
322
|
return [
|
|
321
323
|
<Box className="ListBox" sx={{ height: heightLocal }}>
|
|
322
|
-
<ScrollerListEx<T>
|
|
324
|
+
<ScrollerListEx<T, D>
|
|
323
325
|
autoLoad={!hasFields}
|
|
324
326
|
height={heightLocal}
|
|
325
327
|
loadData={localLoadData}
|
|
@@ -117,8 +117,10 @@ export type ScrollerListExItemSize =
|
|
|
117
117
|
/**
|
|
118
118
|
* Extended ScrollerList Props
|
|
119
119
|
*/
|
|
120
|
-
export interface ScrollerListExProps<
|
|
121
|
-
|
|
120
|
+
export interface ScrollerListExProps<
|
|
121
|
+
T extends {},
|
|
122
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
123
|
+
> extends Omit<ScrollerListProps<T>, 'itemRenderer' | 'itemSize'> {
|
|
122
124
|
/**
|
|
123
125
|
* Alternating colors for odd/even rows
|
|
124
126
|
*/
|
|
@@ -127,7 +129,7 @@ export interface ScrollerListExProps<T>
|
|
|
127
129
|
/**
|
|
128
130
|
* Id field
|
|
129
131
|
*/
|
|
130
|
-
idField?:
|
|
132
|
+
idField?: D;
|
|
131
133
|
|
|
132
134
|
/**
|
|
133
135
|
* Inner item renderer
|
|
@@ -260,9 +262,10 @@ function defaultItemRenderer<T>({
|
|
|
260
262
|
* @param props Props
|
|
261
263
|
* @returns Component
|
|
262
264
|
*/
|
|
263
|
-
export function ScrollerListEx<
|
|
264
|
-
|
|
265
|
-
|
|
265
|
+
export function ScrollerListEx<
|
|
266
|
+
T extends {},
|
|
267
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
268
|
+
>(props: ScrollerListExProps<T, D>) {
|
|
266
269
|
// Selected item ref
|
|
267
270
|
const selectedItem = React.useRef<[HTMLDivElement, T]>();
|
|
268
271
|
|
|
@@ -295,11 +298,11 @@ export function ScrollerListEx<T extends Record<string, unknown>>(
|
|
|
295
298
|
const {
|
|
296
299
|
alternatingColors = [undefined, undefined],
|
|
297
300
|
className,
|
|
298
|
-
idField = 'id',
|
|
301
|
+
idField = 'id' as D,
|
|
299
302
|
innerItemRenderer,
|
|
300
303
|
itemSize,
|
|
301
304
|
itemKey = (index: number, data: T) =>
|
|
302
|
-
DataTypes.
|
|
305
|
+
DataTypes.getIdValue1(data, idField) ?? index,
|
|
303
306
|
itemRenderer = (itemProps) => {
|
|
304
307
|
const [itemHeight, space, margins] = calculateItemSize(
|
|
305
308
|
itemProps.index
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IdLabelDto } from '@etsoo/appscript';
|
|
2
1
|
import { DataTypes } from '@etsoo/shared';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import { MUGlobal } from './MUGlobal';
|
|
@@ -10,8 +9,8 @@ import { OptionGroup, OptionGroupProps } from './OptionGroup';
|
|
|
10
9
|
* @returns Component
|
|
11
10
|
*/
|
|
12
11
|
export function SearchOptionGroup<
|
|
13
|
-
T extends
|
|
14
|
-
D extends DataTypes.
|
|
12
|
+
T extends {} = DataTypes.IdLabelItem,
|
|
13
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
15
14
|
>(props: OptionGroupProps<T, D>) {
|
|
16
15
|
// Destruct
|
|
17
16
|
const {
|
package/src/mu/SelectBool.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Utils } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, Utils } from '@etsoo/shared';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import { globalApp } from '..';
|
|
5
4
|
import { SelectEx, SelectExProps } from './SelectEx';
|
|
@@ -8,7 +7,10 @@ import { SelectEx, SelectExProps } from './SelectEx';
|
|
|
8
7
|
* SelectBool props
|
|
9
8
|
*/
|
|
10
9
|
export interface SelectBoolProps
|
|
11
|
-
extends Omit<
|
|
10
|
+
extends Omit<
|
|
11
|
+
SelectExProps<DataTypes.IdLabelItem<string>>,
|
|
12
|
+
'options' | 'loadData'
|
|
13
|
+
> {}
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* SelectBool (yes/no)
|
|
@@ -20,7 +22,7 @@ export function SelectBool(props: SelectBoolProps) {
|
|
|
20
22
|
const { search = true, autoAddBlankItem = search, ...rest } = props;
|
|
21
23
|
|
|
22
24
|
// Options
|
|
23
|
-
const options:
|
|
25
|
+
const options: DataTypes.IdLabelItem<string>[] = [
|
|
24
26
|
{ id: 'false', label: globalApp.get('no')! },
|
|
25
27
|
{ id: 'true', label: globalApp.get('yes')! }
|
|
26
28
|
];
|
|
@@ -29,7 +31,7 @@ export function SelectBool(props: SelectBoolProps) {
|
|
|
29
31
|
|
|
30
32
|
// Layout
|
|
31
33
|
return (
|
|
32
|
-
<SelectEx<
|
|
34
|
+
<SelectEx<DataTypes.IdLabelItem<string>>
|
|
33
35
|
options={options}
|
|
34
36
|
search={search}
|
|
35
37
|
{...rest}
|
package/src/mu/SelectEx.tsx
CHANGED
|
@@ -30,7 +30,7 @@ export interface SelectExProps<
|
|
|
30
30
|
/**
|
|
31
31
|
* Id field
|
|
32
32
|
*/
|
|
33
|
-
idField: D;
|
|
33
|
+
idField: T extends DataTypes.IdLabelItem ? D | undefined : D;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Item icon renderer
|
|
@@ -40,7 +40,9 @@ export interface SelectExProps<
|
|
|
40
40
|
/**
|
|
41
41
|
* Label field
|
|
42
42
|
*/
|
|
43
|
-
labelField:
|
|
43
|
+
labelField:
|
|
44
|
+
| ((option: T) => string)
|
|
45
|
+
| (T extends DataTypes.IdLabelItem ? D | undefined : D);
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
48
|
* Load data callback
|
|
@@ -80,10 +82,10 @@ export function SelectEx<
|
|
|
80
82
|
// Destruct
|
|
81
83
|
const {
|
|
82
84
|
defaultValue,
|
|
83
|
-
idField,
|
|
85
|
+
idField = 'id' as D,
|
|
84
86
|
itemIconRenderer,
|
|
85
87
|
label,
|
|
86
|
-
labelField,
|
|
88
|
+
labelField = 'label' as D,
|
|
87
89
|
loadData,
|
|
88
90
|
onItemClick,
|
|
89
91
|
onLoadData,
|
package/src/mu/TableEx.tsx
CHANGED
|
@@ -47,8 +47,10 @@ export interface TableExMethodRef extends GridMethodRef {
|
|
|
47
47
|
/**
|
|
48
48
|
* Extended table props
|
|
49
49
|
*/
|
|
50
|
-
export interface TableExProps<
|
|
51
|
-
extends
|
|
50
|
+
export interface TableExProps<
|
|
51
|
+
T extends {},
|
|
52
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
53
|
+
> extends TableProps,
|
|
52
54
|
GridLoader<T> {
|
|
53
55
|
/**
|
|
54
56
|
* Alternating colors for odd/even rows
|
|
@@ -68,7 +70,7 @@ export interface TableExProps<T extends Record<string, any>>
|
|
|
68
70
|
/**
|
|
69
71
|
* Id field
|
|
70
72
|
*/
|
|
71
|
-
idField?:
|
|
73
|
+
idField?: D;
|
|
72
74
|
|
|
73
75
|
/**
|
|
74
76
|
* Max height
|
|
@@ -101,14 +103,13 @@ export interface TableExProps<T extends Record<string, any>>
|
|
|
101
103
|
* @param props Props
|
|
102
104
|
* @returns Component
|
|
103
105
|
*/
|
|
104
|
-
export function TableEx<
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
export function TableEx<
|
|
107
|
+
T extends {},
|
|
108
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
109
|
+
>(props: TableExProps<T, D>) {
|
|
107
110
|
// Theme
|
|
108
111
|
const theme = useTheme();
|
|
109
112
|
|
|
110
|
-
type keyType = string & keyof T;
|
|
111
|
-
|
|
112
113
|
// Destruct
|
|
113
114
|
const {
|
|
114
115
|
alternatingColors = [theme.palette.action.hover, undefined],
|
|
@@ -116,7 +117,7 @@ export function TableEx<T extends Record<string, unknown>>(
|
|
|
116
117
|
columns,
|
|
117
118
|
defaultOrderBy,
|
|
118
119
|
headerColors = [undefined, undefined],
|
|
119
|
-
idField = 'id' as
|
|
120
|
+
idField = 'id' as D,
|
|
120
121
|
loadBatchSize,
|
|
121
122
|
loadData,
|
|
122
123
|
maxHeight,
|
|
@@ -451,7 +452,10 @@ export function TableEx<T extends Record<string, unknown>>(
|
|
|
451
452
|
: false;
|
|
452
453
|
|
|
453
454
|
return (
|
|
454
|
-
<TableRow
|
|
455
|
+
<TableRow
|
|
456
|
+
key={rowId as unknown as React.Key}
|
|
457
|
+
selected={isItemSelected}
|
|
458
|
+
>
|
|
455
459
|
{selectable && (
|
|
456
460
|
<TableCell padding="checkbox">
|
|
457
461
|
{row && (
|
|
@@ -522,10 +526,7 @@ export function TableEx<T extends Record<string, unknown>>(
|
|
|
522
526
|
|
|
523
527
|
return (
|
|
524
528
|
<TableCell
|
|
525
|
-
key={
|
|
526
|
-
rowId.toString() +
|
|
527
|
-
columnIndex
|
|
528
|
-
}
|
|
529
|
+
key={`${rowId}${columnIndex}`}
|
|
529
530
|
{...cellProps}
|
|
530
531
|
>
|
|
531
532
|
{child}
|
package/src/mu/Tiplist.tsx
CHANGED
|
@@ -34,13 +34,14 @@ interface States<T extends {}> {
|
|
|
34
34
|
* @param props Props
|
|
35
35
|
* @returns Component
|
|
36
36
|
*/
|
|
37
|
-
export function Tiplist<
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
export function Tiplist<
|
|
38
|
+
T extends {} = DataTypes.IdLabelItem,
|
|
39
|
+
D extends DataTypes.Keys<T> = DataTypes.Keys<T>
|
|
40
|
+
>(props: TiplistProps<T, D>) {
|
|
40
41
|
// Destruct
|
|
41
42
|
const {
|
|
42
43
|
search = false,
|
|
43
|
-
idField,
|
|
44
|
+
idField = 'id' as D,
|
|
44
45
|
idValue,
|
|
45
46
|
inputAutoComplete = 'off',
|
|
46
47
|
inputError,
|
|
@@ -69,7 +70,8 @@ export function Tiplist<T extends {}, D extends DataTypes.Keys<T>>(
|
|
|
69
70
|
if (localValue === undefined) localValue = null;
|
|
70
71
|
|
|
71
72
|
// One time calculation for input's default value (uncontrolled)
|
|
72
|
-
const localIdValue =
|
|
73
|
+
const localIdValue =
|
|
74
|
+
idValue ?? DataTypes.getValue(localValue, idField ?? 'id');
|
|
73
75
|
|
|
74
76
|
// Changable states
|
|
75
77
|
const [states, stateUpdate] = React.useReducer(
|