@etsoo/react 1.5.74 → 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 +3 -3
- package/lib/mu/ComboBox.d.ts +4 -4
- package/lib/mu/ComboBox.js +6 -6
- 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/SelectBool.js +1 -1
- package/lib/mu/SelectEx.d.ts +7 -7
- package/lib/mu/SelectEx.js +2 -2
- package/lib/mu/TableEx.d.ts +4 -3
- package/lib/mu/TableEx.js +1 -2
- package/lib/mu/Tiplist.d.ts +3 -4
- package/lib/mu/Tiplist.js +4 -4
- package/package.json +8 -8
- package/src/components/ScrollerGrid.tsx +6 -3
- package/src/components/ScrollerList.tsx +1 -3
- package/src/mu/AutocompleteExtendedProps.ts +6 -4
- package/src/mu/ComboBox.tsx +18 -15
- package/src/mu/DataGridEx.tsx +13 -12
- package/src/mu/MUGlobal.ts +1 -6
- 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 +13 -5
- package/src/mu/SelectEx.tsx +19 -13
- package/src/mu/TableEx.tsx +15 -14
- package/src/mu/Tiplist.tsx +15 -13
|
@@ -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 {};
|
|
@@ -4,15 +4,15 @@ import { ChangeEventHandler } from 'react';
|
|
|
4
4
|
/**
|
|
5
5
|
* Autocomplete extended props
|
|
6
6
|
*/
|
|
7
|
-
export interface AutocompleteExtendedProps<T extends
|
|
7
|
+
export interface AutocompleteExtendedProps<T extends {}, D extends DataTypes.Keys<T>> extends Omit<AutocompleteProps<T, undefined, false, false>, 'renderInput' | 'options'> {
|
|
8
8
|
/**
|
|
9
9
|
* Id field, default is id
|
|
10
10
|
*/
|
|
11
|
-
idField
|
|
11
|
+
idField: T extends DataTypes.IdLabelItem ? D | undefined : D;
|
|
12
12
|
/**
|
|
13
13
|
* Id value
|
|
14
14
|
*/
|
|
15
|
-
idValue?:
|
|
15
|
+
idValue?: T[D];
|
|
16
16
|
/**
|
|
17
17
|
* Autocomplete for the input
|
|
18
18
|
*/
|
package/lib/mu/ComboBox.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { DataTypes } from '@etsoo/shared';
|
|
3
3
|
import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
|
|
4
4
|
/**
|
|
5
5
|
* ComboBox props
|
|
6
6
|
*/
|
|
7
|
-
export interface ComboBoxProps<T extends {}> extends AutocompleteExtendedProps<T> {
|
|
7
|
+
export interface ComboBoxProps<T extends {}, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> extends AutocompleteExtendedProps<T, D> {
|
|
8
8
|
/**
|
|
9
9
|
* Auto add blank item
|
|
10
10
|
*/
|
|
@@ -16,7 +16,7 @@ export interface ComboBoxProps<T extends {}> extends AutocompleteExtendedProps<T
|
|
|
16
16
|
/**
|
|
17
17
|
* Label field
|
|
18
18
|
*/
|
|
19
|
-
labelField
|
|
19
|
+
labelField: T extends DataTypes.IdLabelItem ? D | undefined : D;
|
|
20
20
|
/**
|
|
21
21
|
* Load data callback
|
|
22
22
|
*/
|
|
@@ -35,4 +35,4 @@ export interface ComboBoxProps<T extends {}> extends AutocompleteExtendedProps<T
|
|
|
35
35
|
* @param props Props
|
|
36
36
|
* @returns Component
|
|
37
37
|
*/
|
|
38
|
-
export declare function ComboBox<T extends {} =
|
|
38
|
+
export declare function ComboBox<T extends {} = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: ComboBoxProps<T, D>): JSX.Element;
|
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 = '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) =>
|
|
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
|
|
@@ -27,7 +27,7 @@ export function ComboBox(props) {
|
|
|
27
27
|
}, [JSON.stringify(options), propertyWay]);
|
|
28
28
|
// Local default value
|
|
29
29
|
let localValue = idValue != null
|
|
30
|
-
? localOptions.find((o) =>
|
|
30
|
+
? localOptions.find((o) => o[idField] === idValue)
|
|
31
31
|
: defaultValue !== null && defaultValue !== void 0 ? defaultValue : value;
|
|
32
32
|
if (localValue === undefined)
|
|
33
33
|
localValue = null;
|
|
@@ -36,7 +36,7 @@ export function ComboBox(props) {
|
|
|
36
36
|
const [stateValue, setStateValue] = React.useState(null);
|
|
37
37
|
// Current id value
|
|
38
38
|
// One time calculation for input's default value (uncontrolled)
|
|
39
|
-
const localIdValue = stateValue &&
|
|
39
|
+
const localIdValue = stateValue && stateValue[idField];
|
|
40
40
|
React.useEffect(() => {
|
|
41
41
|
if (localValue != null)
|
|
42
42
|
setStateValue(localValue);
|
|
@@ -68,7 +68,7 @@ export function ComboBox(props) {
|
|
|
68
68
|
const input = inputRef.current;
|
|
69
69
|
if (input) {
|
|
70
70
|
// Update value
|
|
71
|
-
const newValue = value != null ? `${
|
|
71
|
+
const newValue = value != null ? `${value[idField]}` : '';
|
|
72
72
|
if (newValue !== input.value) {
|
|
73
73
|
// Different value, trigger change event
|
|
74
74
|
ReactUtils.triggerChange(input, newValue, false);
|
|
@@ -97,8 +97,8 @@ export function ComboBox(props) {
|
|
|
97
97
|
}, []);
|
|
98
98
|
// Layout
|
|
99
99
|
return (React.createElement("div", null,
|
|
100
|
-
React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: localIdValue !== null && localIdValue !== void 0 ? localIdValue : ''
|
|
101
|
-
React.createElement(Autocomplete, { value: stateValue, getOptionLabel: getOptionLabel, isOptionEqualToValue: (option, value) =>
|
|
100
|
+
React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: `${localIdValue !== null && localIdValue !== void 0 ? localIdValue : ''}`, readOnly: true, onChange: inputOnChange }),
|
|
101
|
+
React.createElement(Autocomplete, { value: stateValue, getOptionLabel: getOptionLabel, isOptionEqualToValue: (option, value) => option[idField] === value[idField], onChange: (event, value, reason, details) => {
|
|
102
102
|
// Set value
|
|
103
103
|
setInputValue(value);
|
|
104
104
|
// Custom
|
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/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,26 @@
|
|
|
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 interface SelectExProps<T extends {}> extends Omit<SelectProps, 'labelId' | 'input' | 'native'> {
|
|
7
|
+
export interface SelectExProps<T extends {}, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> extends Omit<SelectProps, 'labelId' | 'input' | 'native'> {
|
|
8
8
|
/**
|
|
9
9
|
* Auto add blank item
|
|
10
10
|
*/
|
|
11
11
|
autoAddBlankItem?: boolean;
|
|
12
12
|
/**
|
|
13
|
-
* Id field
|
|
13
|
+
* Id field
|
|
14
14
|
*/
|
|
15
|
-
idField
|
|
15
|
+
idField: T extends DataTypes.IdLabelItem ? D | undefined : D;
|
|
16
16
|
/**
|
|
17
17
|
* Item icon renderer
|
|
18
18
|
*/
|
|
19
19
|
itemIconRenderer?: (id: unknown) => React.ReactNode;
|
|
20
20
|
/**
|
|
21
|
-
* Label field
|
|
21
|
+
* Label field
|
|
22
22
|
*/
|
|
23
|
-
labelField
|
|
23
|
+
labelField: ((option: T) => string) | (T extends DataTypes.IdLabelItem ? D | undefined : D);
|
|
24
24
|
/**
|
|
25
25
|
* Load data callback
|
|
26
26
|
*/
|
|
@@ -47,4 +47,4 @@ export interface SelectExProps<T extends {}> extends Omit<SelectProps, 'labelId'
|
|
|
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 {} = 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 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
|
@@ -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 interface TiplistProps<T extends {}
|
|
7
|
+
export interface TiplistProps<T extends {}, D extends DataTypes.Keys<T>> extends Omit<AutocompleteExtendedProps<T, D>, 'open'> {
|
|
9
8
|
/**
|
|
10
9
|
* Load data callback
|
|
11
10
|
*/
|
|
12
|
-
loadData: (keyword?: string, id?:
|
|
11
|
+
loadData: (keyword?: string, id?: T[D]) => PromiseLike<T[] | null | undefined>;
|
|
13
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 {} = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: TiplistProps<T, D>): JSX.Element;
|
package/lib/mu/Tiplist.js
CHANGED
|
@@ -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 };
|
|
@@ -31,7 +31,7 @@ export function Tiplist(props) {
|
|
|
31
31
|
value: null
|
|
32
32
|
});
|
|
33
33
|
// Input value
|
|
34
|
-
const inputValue = React.useMemo(() => states.value &&
|
|
34
|
+
const inputValue = React.useMemo(() => states.value && states.value[idField], [states.value]);
|
|
35
35
|
React.useEffect(() => {
|
|
36
36
|
if (localValue != null)
|
|
37
37
|
stateUpdate({ value: localValue });
|
|
@@ -128,7 +128,7 @@ export function Tiplist(props) {
|
|
|
128
128
|
}, []);
|
|
129
129
|
// Layout
|
|
130
130
|
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 : ''
|
|
131
|
+
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
132
|
React.createElement(Autocomplete, { filterOptions: (options, _state) => options, value: states.value, options: states.options, onChange: (event, value, reason, details) => {
|
|
133
133
|
// Set value
|
|
134
134
|
setInputValue(value);
|
|
@@ -150,7 +150,7 @@ export function Tiplist(props) {
|
|
|
150
150
|
if (loading)
|
|
151
151
|
loadDataDirect(undefined, states.value == null
|
|
152
152
|
? undefined
|
|
153
|
-
:
|
|
153
|
+
: states.value[idField]);
|
|
154
154
|
}, onClose: () => {
|
|
155
155
|
stateUpdate({
|
|
156
156
|
open: false,
|
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",
|
|
@@ -75,14 +75,14 @@
|
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@babel/cli": "^7.18.10",
|
|
78
|
-
"@babel/core": "^7.18.
|
|
78
|
+
"@babel/core": "^7.18.13",
|
|
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
82
|
"@types/jest": "^28.1.7",
|
|
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.34.0",
|
|
85
|
+
"@typescript-eslint/parser": "^5.34.0",
|
|
86
86
|
"eslint": "^8.22.0",
|
|
87
87
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
88
88
|
"eslint-plugin-import": "^2.26.0",
|
|
@@ -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,
|
|
@@ -5,20 +5,22 @@ import { ChangeEventHandler } from 'react';
|
|
|
5
5
|
/**
|
|
6
6
|
* Autocomplete extended props
|
|
7
7
|
*/
|
|
8
|
-
export interface AutocompleteExtendedProps<
|
|
9
|
-
extends
|
|
8
|
+
export interface AutocompleteExtendedProps<
|
|
9
|
+
T extends {},
|
|
10
|
+
D extends DataTypes.Keys<T>
|
|
11
|
+
> extends Omit<
|
|
10
12
|
AutocompleteProps<T, undefined, false, false>,
|
|
11
13
|
'renderInput' | 'options'
|
|
12
14
|
> {
|
|
13
15
|
/**
|
|
14
16
|
* Id field, default is id
|
|
15
17
|
*/
|
|
16
|
-
idField
|
|
18
|
+
idField: T extends DataTypes.IdLabelItem ? D | undefined : D;
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Id value
|
|
20
22
|
*/
|
|
21
|
-
idValue?:
|
|
23
|
+
idValue?: T[D];
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* Autocomplete for the input
|