@etsoo/react 1.5.77 → 1.5.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/mu/ComboBox.tsx +30 -0
- package/__tests__/mu/NotifierMUTests.tsx +1 -1
- package/__tests__/mu/SelectEx.tsx +26 -0
- package/lib/app/CommonApp.d.ts +2 -2
- package/lib/app/Labels.d.ts +1 -1
- package/lib/app/ServiceApp.d.ts +2 -2
- package/lib/components/GridColumn.d.ts +10 -10
- package/lib/components/GridLoader.d.ts +7 -8
- package/lib/components/ScrollerGrid.d.ts +6 -7
- package/lib/components/ScrollerList.d.ts +2 -2
- package/lib/mu/AutocompleteExtendedProps.d.ts +4 -4
- package/lib/mu/ComboBox.d.ts +5 -5
- package/lib/mu/DataGridEx.d.ts +6 -6
- package/lib/mu/DataGridRenderers.d.ts +1 -1
- package/lib/mu/DnDList.d.ts +2 -2
- package/lib/mu/ItemList.d.ts +6 -5
- package/lib/mu/ItemList.js +4 -12
- package/lib/mu/ListMoreDisplay.d.ts +2 -2
- package/lib/mu/MUGlobal.d.ts +5 -5
- package/lib/mu/OptionGroup.d.ts +8 -8
- package/lib/mu/ResponsibleContainer.d.ts +6 -6
- package/lib/mu/ScrollerListEx.d.ts +11 -10
- package/lib/mu/SearchOptionGroup.d.ts +2 -2
- package/lib/mu/SelectBool.d.ts +2 -3
- package/lib/mu/SelectBool.js +1 -1
- package/lib/mu/SelectEx.d.ts +8 -8
- package/lib/mu/SelectEx.js +3 -3
- package/lib/mu/TableEx.d.ts +4 -4
- package/lib/mu/Tiplist.d.ts +4 -4
- package/lib/mu/Tiplist.js +1 -3
- package/lib/mu/pages/CommonPageProps.d.ts +1 -1
- package/lib/mu/pages/DataGridPage.d.ts +2 -2
- package/lib/mu/pages/DataGridPageProps.d.ts +3 -3
- package/lib/mu/pages/FixedListPage.d.ts +2 -2
- package/lib/mu/pages/ListPage.d.ts +2 -2
- package/lib/mu/pages/ListPageProps.d.ts +1 -2
- package/lib/mu/pages/ResponsivePage.d.ts +2 -2
- package/lib/mu/pages/ResponsivePageProps.d.ts +3 -3
- package/lib/mu/pages/SearchPageProps.d.ts +2 -2
- package/lib/mu/pages/TablePage.d.ts +2 -2
- package/lib/mu/pages/TablePageProps.d.ts +1 -2
- package/lib/mu/pages/ViewPage.d.ts +5 -4
- package/lib/states/IState.d.ts +1 -1
- package/lib/uses/useCombinedRefs.d.ts +1 -1
- package/package.json +12 -12
- package/src/app/CommonApp.ts +2 -2
- package/src/app/Labels.ts +1 -1
- package/src/app/ServiceApp.ts +2 -2
- package/src/components/GridColumn.ts +10 -11
- package/src/components/GridLoader.ts +7 -7
- package/src/components/ScrollerGrid.tsx +66 -62
- package/src/components/ScrollerList.tsx +2 -2
- package/src/mu/AutocompleteExtendedProps.ts +9 -9
- package/src/mu/ComboBox.tsx +20 -12
- package/src/mu/DataGridEx.tsx +15 -15
- package/src/mu/DataGridRenderers.tsx +1 -1
- package/src/mu/DnDList.tsx +2 -2
- package/src/mu/ItemList.tsx +28 -25
- package/src/mu/ListMoreDisplay.tsx +2 -2
- package/src/mu/MUGlobal.ts +5 -5
- package/src/mu/OptionGroup.tsx +22 -14
- package/src/mu/ResponsibleContainer.tsx +15 -20
- package/src/mu/ScrollerListEx.tsx +21 -20
- package/src/mu/SearchOptionGroup.tsx +11 -5
- package/src/mu/SelectBool.tsx +7 -14
- package/src/mu/SelectEx.tsx +25 -19
- package/src/mu/TableEx.tsx +53 -53
- package/src/mu/Tiplist.tsx +11 -10
- package/src/mu/pages/CommonPageProps.ts +1 -1
- package/src/mu/pages/DataGridPage.tsx +15 -11
- package/src/mu/pages/DataGridPageProps.ts +17 -14
- package/src/mu/pages/FixedListPage.tsx +6 -5
- package/src/mu/pages/ListPage.tsx +6 -5
- package/src/mu/pages/ListPageProps.ts +5 -3
- package/src/mu/pages/ResponsivePage.tsx +6 -5
- package/src/mu/pages/ResponsivePageProps.ts +10 -7
- package/src/mu/pages/SearchPageProps.ts +5 -3
- package/src/mu/pages/TablePage.tsx +6 -5
- package/src/mu/pages/TablePageProps.ts +5 -3
- package/src/mu/pages/ViewPage.tsx +8 -6
- package/src/states/IState.ts +1 -1
- package/src/states/UserState.ts +1 -1
- package/src/uses/useCombinedRefs.ts +3 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComboBox } from '../../src';
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
+
|
|
6
|
+
it('Render ComboBox', async () => {
|
|
7
|
+
// Arrange
|
|
8
|
+
type T = { id: number; name: string };
|
|
9
|
+
const options: T[] = [
|
|
10
|
+
{ id: 1, name: 'Name 1' },
|
|
11
|
+
{ id: 2, name: 'Name 2' }
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
render(
|
|
15
|
+
<ComboBox<T>
|
|
16
|
+
name="Test"
|
|
17
|
+
options={options}
|
|
18
|
+
labelField="name"
|
|
19
|
+
label="Test"
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
// Act, click the list
|
|
24
|
+
const clicked = fireEvent.click(screen.getByRole('button'));
|
|
25
|
+
expect(clicked).toBeTruthy();
|
|
26
|
+
|
|
27
|
+
// Get list item
|
|
28
|
+
const item = screen.getByText('Name 1');
|
|
29
|
+
expect(item.nodeName).toBe('LI');
|
|
30
|
+
});
|
|
@@ -14,7 +14,7 @@ root.append(container);
|
|
|
14
14
|
|
|
15
15
|
// The state provider
|
|
16
16
|
const Provider = NotifierMU.setup();
|
|
17
|
-
const reactRoot = createRoot(container);
|
|
17
|
+
const reactRoot = createRoot(container);
|
|
18
18
|
|
|
19
19
|
act(() => {
|
|
20
20
|
// Concorrent renderer needs act block
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SelectEx } from '../../src';
|
|
3
|
+
import { findByText, fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
+
|
|
6
|
+
it('Render SelectEx', async () => {
|
|
7
|
+
// Arrange
|
|
8
|
+
type T = { id: number; name: string };
|
|
9
|
+
const options: T[] = [
|
|
10
|
+
{ id: 1, name: 'Name 1' },
|
|
11
|
+
{ id: 2, name: 'Name 2' }
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
// Render component
|
|
15
|
+
const { baseElement } = render(
|
|
16
|
+
<SelectEx<T> options={options} name="test" search labelField="name" />
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
// Act, click to show the list
|
|
20
|
+
const button = screen.getByRole('button');
|
|
21
|
+
fireEvent.mouseDown(button); // Not click
|
|
22
|
+
|
|
23
|
+
// Get list item
|
|
24
|
+
const item = await findByText(baseElement, 'Name 2');
|
|
25
|
+
expect(item.nodeName).toBe('SPAN');
|
|
26
|
+
});
|
package/lib/app/CommonApp.d.ts
CHANGED
|
@@ -28,12 +28,12 @@ export declare abstract class CommonApp<U extends IUser = IUser, P extends IPage
|
|
|
28
28
|
* Refresh token
|
|
29
29
|
* @param props Props
|
|
30
30
|
*/
|
|
31
|
-
refreshToken<D = RefreshTokenRQ>(props?: RefreshTokenProps<D>): Promise<boolean>;
|
|
31
|
+
refreshToken<D extends object = RefreshTokenRQ>(props?: RefreshTokenProps<D>): Promise<boolean>;
|
|
32
32
|
/**
|
|
33
33
|
* Try login
|
|
34
34
|
* @param data Additional data
|
|
35
35
|
* @param showLoading Show loading bar or not
|
|
36
36
|
* @returns Result
|
|
37
37
|
*/
|
|
38
|
-
tryLogin<D = RefreshTokenRQ>(data?: D, showLoading?: boolean): Promise<boolean>;
|
|
38
|
+
tryLogin<D extends object = RefreshTokenRQ>(data?: D, showLoading?: boolean): Promise<boolean>;
|
|
39
39
|
}
|
package/lib/app/Labels.d.ts
CHANGED
|
@@ -61,5 +61,5 @@ export declare namespace Labels {
|
|
|
61
61
|
* @param labels Labels
|
|
62
62
|
* @param reference Key reference
|
|
63
63
|
*/
|
|
64
|
-
const setLabels: (labels:
|
|
64
|
+
const setLabels: (labels: DataTypes.StringRecord, reference?: setLabelsReference) => void;
|
|
65
65
|
}
|
package/lib/app/ServiceApp.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
45
45
|
* Refresh token
|
|
46
46
|
* @param props Props
|
|
47
47
|
*/
|
|
48
|
-
refreshToken<D = RefreshTokenRQ>(props?: RefreshTokenProps<D>): Promise<boolean>;
|
|
48
|
+
refreshToken<D extends object = RefreshTokenRQ>(props?: RefreshTokenProps<D>): Promise<boolean>;
|
|
49
49
|
/**
|
|
50
50
|
* Service decrypt message
|
|
51
51
|
* @param messageEncrypted Encrypted message
|
|
@@ -67,7 +67,7 @@ export declare class ServiceApp<U extends IServiceUser = IServiceUser, P extends
|
|
|
67
67
|
* @param showLoading Show loading bar or not
|
|
68
68
|
* @returns Result
|
|
69
69
|
*/
|
|
70
|
-
tryLogin<D extends
|
|
70
|
+
tryLogin<D extends object = {}>(data?: D, showLoading?: boolean): Promise<boolean>;
|
|
71
71
|
/**
|
|
72
72
|
* User login extended
|
|
73
73
|
* @param user Core system user
|
|
@@ -23,7 +23,7 @@ export declare type GridCellValueType = string | number | Date | boolean | undef
|
|
|
23
23
|
/**
|
|
24
24
|
* Grid cell formatter props
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export declare type GridCellFormatterProps<T> = {
|
|
27
27
|
/**
|
|
28
28
|
* Current data
|
|
29
29
|
*/
|
|
@@ -40,11 +40,11 @@ export interface GridCellFormatterProps<T> {
|
|
|
40
40
|
* Column index
|
|
41
41
|
*/
|
|
42
42
|
columnIndex: number;
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
44
|
/**
|
|
45
45
|
* Grid cell renderer props
|
|
46
46
|
*/
|
|
47
|
-
export
|
|
47
|
+
export declare type GridCellRendererProps<T, P = any> = GridCellFormatterProps<T> & {
|
|
48
48
|
/**
|
|
49
49
|
* Cell props
|
|
50
50
|
*/
|
|
@@ -65,11 +65,11 @@ export interface GridCellRendererProps<T, P = any> extends GridCellFormatterProp
|
|
|
65
65
|
* Render props
|
|
66
66
|
*/
|
|
67
67
|
renderProps?: GridColumnRenderProps;
|
|
68
|
-
}
|
|
68
|
+
};
|
|
69
69
|
/**
|
|
70
70
|
* Grid header cell renderer props
|
|
71
71
|
*/
|
|
72
|
-
export
|
|
72
|
+
export declare type GridHeaderCellRendererProps<T, P = any> = {
|
|
73
73
|
/**
|
|
74
74
|
* Cell props
|
|
75
75
|
*/
|
|
@@ -86,11 +86,11 @@ export interface GridHeaderCellRendererProps<T, P = any> {
|
|
|
86
86
|
* States
|
|
87
87
|
*/
|
|
88
88
|
states: GridLoaderStates<T>;
|
|
89
|
-
}
|
|
89
|
+
};
|
|
90
90
|
/**
|
|
91
91
|
* Grid column render props
|
|
92
92
|
*/
|
|
93
|
-
export
|
|
93
|
+
export declare type GridColumnRenderProps = {
|
|
94
94
|
/**
|
|
95
95
|
* Culture, like zh-CN
|
|
96
96
|
*/
|
|
@@ -115,11 +115,11 @@ export interface GridColumnRenderProps {
|
|
|
115
115
|
* Additional data
|
|
116
116
|
*/
|
|
117
117
|
readonly data?: Readonly<Record<string, any>>;
|
|
118
|
-
}
|
|
118
|
+
};
|
|
119
119
|
/**
|
|
120
120
|
* Grid column
|
|
121
121
|
*/
|
|
122
|
-
export
|
|
122
|
+
export declare type GridColumn<T> = {
|
|
123
123
|
/**
|
|
124
124
|
* The column identifier. It's used to map with row data
|
|
125
125
|
*/
|
|
@@ -169,4 +169,4 @@ export interface GridColumn<T> {
|
|
|
169
169
|
* Header cell renderer
|
|
170
170
|
*/
|
|
171
171
|
headerCellRenderer?: (props: GridHeaderCellRendererProps<T>) => React.ReactNode;
|
|
172
|
-
}
|
|
172
|
+
};
|
|
@@ -22,12 +22,11 @@ export declare function GridDataGet<F extends DataTypes.BasicTemplate>(props: Gr
|
|
|
22
22
|
/**
|
|
23
23
|
* Grid Json data
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
26
|
-
}
|
|
25
|
+
export declare type GridJsonData = Omit<GridLoadDataProps, 'data'>;
|
|
27
26
|
/**
|
|
28
27
|
* Grid data load props
|
|
29
28
|
*/
|
|
30
|
-
export
|
|
29
|
+
export declare type GridLoadDataProps = {
|
|
31
30
|
/**
|
|
32
31
|
* Current page
|
|
33
32
|
*/
|
|
@@ -48,11 +47,11 @@ export interface GridLoadDataProps {
|
|
|
48
47
|
* Data related
|
|
49
48
|
*/
|
|
50
49
|
data?: GridData;
|
|
51
|
-
}
|
|
50
|
+
};
|
|
52
51
|
/**
|
|
53
52
|
* Grid data loader
|
|
54
53
|
*/
|
|
55
|
-
export
|
|
54
|
+
export declare type GridLoader<T extends object> = {
|
|
56
55
|
/**
|
|
57
56
|
* Auto load data, otherwise call reset
|
|
58
57
|
* @default true
|
|
@@ -74,11 +73,11 @@ export interface GridLoader<T> {
|
|
|
74
73
|
* Threshold at which to pre-fetch data; default is half of loadBatchSize
|
|
75
74
|
*/
|
|
76
75
|
threshold?: number | undefined;
|
|
77
|
-
}
|
|
76
|
+
};
|
|
78
77
|
/**
|
|
79
78
|
* Grid loader states
|
|
80
79
|
*/
|
|
81
|
-
export
|
|
80
|
+
export declare type GridLoaderStates<T> = GridLoadDataProps & {
|
|
82
81
|
/**
|
|
83
82
|
* Auto load data, otherwise call reset
|
|
84
83
|
* @default true
|
|
@@ -108,4 +107,4 @@ export interface GridLoaderStates<T> extends GridLoadDataProps {
|
|
|
108
107
|
* Selected items of id
|
|
109
108
|
*/
|
|
110
109
|
selectedItems: T[];
|
|
111
|
-
}
|
|
110
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Align, GridChildComponentProps, VariableSizeGridProps } from 'react-window';
|
|
4
4
|
import { GridMethodRef } from '../mu/GridMethodRef';
|
|
5
5
|
import { GridLoader, GridLoaderStates } from './GridLoader';
|
|
6
|
-
export
|
|
6
|
+
export declare type ScrollerGridItemRendererProps<T> = Omit<GridChildComponentProps<T>, 'data'> & {
|
|
7
7
|
/**
|
|
8
8
|
* Selected items
|
|
9
9
|
*/
|
|
@@ -12,11 +12,11 @@ export interface ScrollerGridItemRendererProps<T> extends Omit<GridChildComponen
|
|
|
12
12
|
* Data
|
|
13
13
|
*/
|
|
14
14
|
data?: T;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
/**
|
|
17
17
|
* Scroller vertical grid props
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export declare type ScrollerGridProps<T extends object, D extends DataTypes.Keys<T>> = GridLoader<T> & Omit<VariableSizeGridProps<T>, 'children' | 'rowCount' | 'rowHeight' | 'ref'> & {
|
|
20
20
|
/**
|
|
21
21
|
* Default order by asc
|
|
22
22
|
* @default true
|
|
@@ -32,7 +32,6 @@ export interface ScrollerGridProps<T extends {}, D extends DataTypes.Keys<T> = D
|
|
|
32
32
|
headerRenderer?: (states: GridLoaderStates<T>) => React.ReactNode;
|
|
33
33
|
/**
|
|
34
34
|
* Id field
|
|
35
|
-
* @default id
|
|
36
35
|
*/
|
|
37
36
|
idField?: D;
|
|
38
37
|
/**
|
|
@@ -51,7 +50,7 @@ export interface ScrollerGridProps<T extends {}, D extends DataTypes.Keys<T> = D
|
|
|
51
50
|
* Returns the height of the specified row.
|
|
52
51
|
*/
|
|
53
52
|
rowHeight?: ((index: number) => number) | number;
|
|
54
|
-
}
|
|
53
|
+
};
|
|
55
54
|
/**
|
|
56
55
|
* Scroller grid forward ref
|
|
57
56
|
*/
|
|
@@ -110,4 +109,4 @@ export interface ScrollerGridForwardRef extends GridMethodRef {
|
|
|
110
109
|
* @param props Props
|
|
111
110
|
* @returns Component
|
|
112
111
|
*/
|
|
113
|
-
export declare const ScrollerGrid: <T extends
|
|
112
|
+
export declare const ScrollerGrid: <T extends object, D extends DataTypes.Keys<T, string | number> = IdDefaultType<T>>(props: ScrollerGridProps<T, D>) => JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { GridLoader } from './GridLoader';
|
|
|
5
5
|
/**
|
|
6
6
|
* Scroller vertical list props
|
|
7
7
|
*/
|
|
8
|
-
export interface ScrollerListProps<T> extends GridLoader<T>, Omit<ListProps<T>, 'ref' | 'outerRef' | 'height' | 'width' | 'children' | 'itemCount'> {
|
|
8
|
+
export interface ScrollerListProps<T extends object> extends GridLoader<T>, Omit<ListProps<T>, 'ref' | 'outerRef' | 'height' | 'width' | 'children' | 'itemCount'> {
|
|
9
9
|
/**
|
|
10
10
|
* Default order by asc/desc
|
|
11
11
|
*/
|
|
@@ -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 object>(props: ScrollerListProps<T>) => JSX.Element;
|
|
63
63
|
export {};
|
|
@@ -4,11 +4,11 @@ import { ChangeEventHandler } from 'react';
|
|
|
4
4
|
/**
|
|
5
5
|
* Autocomplete extended props
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export declare type AutocompleteExtendedProps<T extends object, D extends DataTypes.Keys<T>> = Omit<AutocompleteProps<T, undefined, false, false>, 'renderInput' | 'options'> & {
|
|
8
8
|
/**
|
|
9
|
-
* Id field
|
|
9
|
+
* Id field
|
|
10
10
|
*/
|
|
11
|
-
idField
|
|
11
|
+
idField?: D;
|
|
12
12
|
/**
|
|
13
13
|
* Id value
|
|
14
14
|
*/
|
|
@@ -61,4 +61,4 @@ export interface AutocompleteExtendedProps<T extends {}, D extends DataTypes.Key
|
|
|
61
61
|
* Is search field?
|
|
62
62
|
*/
|
|
63
63
|
search?: boolean;
|
|
64
|
-
}
|
|
64
|
+
};
|
package/lib/mu/ComboBox.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { DataTypes, IdDefaultType, LabelDefaultType, ListType } from '@etsoo/shared';
|
|
3
3
|
import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
|
|
4
4
|
/**
|
|
5
5
|
* ComboBox props
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export declare type ComboBoxProps<T extends object, D extends DataTypes.Keys<T>, L extends DataTypes.Keys<T, string>> = AutocompleteExtendedProps<T, D> & {
|
|
8
8
|
/**
|
|
9
9
|
* Auto add blank item
|
|
10
10
|
*/
|
|
@@ -16,7 +16,7 @@ export interface ComboBoxProps<T extends {}, D extends DataTypes.Keys<T> = DataT
|
|
|
16
16
|
/**
|
|
17
17
|
* Label field
|
|
18
18
|
*/
|
|
19
|
-
labelField
|
|
19
|
+
labelField?: L;
|
|
20
20
|
/**
|
|
21
21
|
* Load data callback
|
|
22
22
|
*/
|
|
@@ -29,10 +29,10 @@ export interface ComboBoxProps<T extends {}, D extends DataTypes.Keys<T> = DataT
|
|
|
29
29
|
* Array of options.
|
|
30
30
|
*/
|
|
31
31
|
options?: ReadonlyArray<T>;
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
33
|
/**
|
|
34
34
|
* ComboBox
|
|
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 object = ListType, D extends DataTypes.Keys<T> = IdDefaultType<T>, L extends DataTypes.Keys<T, string> = LabelDefaultType<T>>(props: ComboBoxProps<T, D, L>): JSX.Element;
|
package/lib/mu/DataGridEx.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { GridColumn } from '../components/GridColumn';
|
|
4
4
|
import { GridLoaderStates } from '../components/GridLoader';
|
|
@@ -7,17 +7,17 @@ import { MouseEventWithDataHandler } from './MUGlobal';
|
|
|
7
7
|
/**
|
|
8
8
|
* Footer item renderer props
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export declare type DataGridExFooterItemRendererProps<T extends object> = {
|
|
11
11
|
column: GridColumn<T>;
|
|
12
12
|
index: number;
|
|
13
13
|
states: GridLoaderStates<T>;
|
|
14
14
|
cellProps: any;
|
|
15
15
|
checkable: boolean;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
/**
|
|
18
18
|
* Extended DataGrid with VariableSizeGrid props
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
20
|
+
export declare type DataGridExProps<T extends object, D extends DataTypes.Keys<T>> = Omit<ScrollerGridProps<T, D>, 'itemRenderer' | 'columnCount' | 'columnWidth' | 'width'> & {
|
|
21
21
|
/**
|
|
22
22
|
* Alternating colors for odd/even rows
|
|
23
23
|
*/
|
|
@@ -78,7 +78,7 @@ export interface DataGridExProps<T extends {}, D extends DataTypes.Keys<T> = Dat
|
|
|
78
78
|
* Width
|
|
79
79
|
*/
|
|
80
80
|
width?: number;
|
|
81
|
-
}
|
|
81
|
+
};
|
|
82
82
|
/**
|
|
83
83
|
* Extended datagrid columns calculation
|
|
84
84
|
* @param columns
|
|
@@ -93,4 +93,4 @@ export declare function DataGridExCalColumns<T>(columns: GridColumn<T>[]): {
|
|
|
93
93
|
* @param props Props
|
|
94
94
|
* @returns Component
|
|
95
95
|
*/
|
|
96
|
-
export declare function DataGridEx<T extends
|
|
96
|
+
export declare function DataGridEx<T extends object, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: DataGridExProps<T, D>): JSX.Element;
|
|
@@ -18,5 +18,5 @@ export declare namespace DataGridRenderers {
|
|
|
18
18
|
* @param location Renderer location (column index)
|
|
19
19
|
* @returns Component
|
|
20
20
|
*/
|
|
21
|
-
function defaultFooterItemRenderer<T>(_rows: T[], { index, states, checkable }: DataGridExFooterItemRendererProps<T>, location?: number): string | undefined;
|
|
21
|
+
function defaultFooterItemRenderer<T extends object>(_rows: T[], { index, states, checkable }: DataGridExFooterItemRendererProps<T>, location?: number): string | undefined;
|
|
22
22
|
}
|
package/lib/mu/DnDList.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare const DnDItemStyle: (index: number, isDragging: boolean, theme: T
|
|
|
17
17
|
/**
|
|
18
18
|
* DnD list forward ref
|
|
19
19
|
*/
|
|
20
|
-
export interface DnDListRef<D extends
|
|
20
|
+
export interface DnDListRef<D extends object> {
|
|
21
21
|
/**
|
|
22
22
|
* Add item
|
|
23
23
|
* @param item New item
|
|
@@ -43,7 +43,7 @@ export interface DnDListRef<D extends {}> {
|
|
|
43
43
|
/**
|
|
44
44
|
* DnD sortable list properties
|
|
45
45
|
*/
|
|
46
|
-
export interface DnDListPros<D extends
|
|
46
|
+
export interface DnDListPros<D extends object, K extends DataTypes.Keys<D>> {
|
|
47
47
|
/**
|
|
48
48
|
* Get list item style callback
|
|
49
49
|
*/
|
package/lib/mu/ItemList.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { DataTypes, IdDefaultType, LabelDefaultType, ListType } from '@etsoo/shared';
|
|
2
3
|
/**
|
|
3
4
|
* Item list properties
|
|
4
5
|
*/
|
|
5
|
-
export interface ItemListProps<T extends
|
|
6
|
+
export interface ItemListProps<T extends object, D extends DataTypes.Keys<T>, L extends DataTypes.Keys<T, string>> {
|
|
6
7
|
/**
|
|
7
8
|
* Style class name
|
|
8
9
|
*/
|
|
@@ -10,11 +11,11 @@ export interface ItemListProps<T extends Record<string, unknown>> {
|
|
|
10
11
|
/**
|
|
11
12
|
* Id field name
|
|
12
13
|
*/
|
|
13
|
-
idField?:
|
|
14
|
+
idField?: D;
|
|
14
15
|
/**
|
|
15
16
|
* Label field name or callback
|
|
16
17
|
*/
|
|
17
|
-
labelField?:
|
|
18
|
+
labelField?: L | ((item: T) => string);
|
|
18
19
|
/**
|
|
19
20
|
* Button icon
|
|
20
21
|
*/
|
|
@@ -30,7 +31,7 @@ export interface ItemListProps<T extends Record<string, unknown>> {
|
|
|
30
31
|
/**
|
|
31
32
|
* Current selected language
|
|
32
33
|
*/
|
|
33
|
-
selectedValue?:
|
|
34
|
+
selectedValue?: T[D];
|
|
34
35
|
/**
|
|
35
36
|
* Button size
|
|
36
37
|
*/
|
|
@@ -52,4 +53,4 @@ export interface ItemListProps<T extends Record<string, unknown>> {
|
|
|
52
53
|
* Item list component
|
|
53
54
|
* @param props Properties
|
|
54
55
|
*/
|
|
55
|
-
export declare function ItemList<T extends
|
|
56
|
+
export declare function ItemList<T extends object = ListType, D extends DataTypes.Keys<T> = IdDefaultType<T>, L extends DataTypes.Keys<T, string> = LabelDefaultType<T>>(props: ItemListProps<T, D, L>): JSX.Element;
|
package/lib/mu/ItemList.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Dialog, DialogTitle, List,
|
|
2
|
+
import { Dialog, DialogTitle, List, ListItemText, DialogContent, Button, ListItemButton } from '@mui/material';
|
|
3
3
|
import { DataTypes } from '@etsoo/shared';
|
|
4
4
|
/**
|
|
5
5
|
* Item list component
|
|
@@ -9,14 +9,6 @@ export function ItemList(props) {
|
|
|
9
9
|
var _a;
|
|
10
10
|
// properties destructure
|
|
11
11
|
const { className, color = 'primary', items, idField = 'id', labelField = 'label', icon, onClose, selectedValue, size = 'medium', title, variant = 'outlined' } = props;
|
|
12
|
-
// Get id
|
|
13
|
-
const getId = (item) => {
|
|
14
|
-
var _a;
|
|
15
|
-
const id = item[idField];
|
|
16
|
-
if (typeof id === 'number')
|
|
17
|
-
return id;
|
|
18
|
-
return (_a = DataTypes.convert(id, 'string')) !== null && _a !== void 0 ? _a : '';
|
|
19
|
-
};
|
|
20
12
|
// Get label
|
|
21
13
|
const getLabel = (item) => {
|
|
22
14
|
var _a;
|
|
@@ -30,7 +22,7 @@ export function ItemList(props) {
|
|
|
30
22
|
// Dialog open or not state
|
|
31
23
|
const [open, setOpen] = React.useState(false);
|
|
32
24
|
// Default state
|
|
33
|
-
const defaultItem = (_a = items.find((item) =>
|
|
25
|
+
const defaultItem = (_a = items.find((item) => item[idField] === selectedValue)) !== null && _a !== void 0 ? _a : items[0];
|
|
34
26
|
// Current item
|
|
35
27
|
const [currentItem, setCurrentItem] = React.useState(defaultItem);
|
|
36
28
|
// Click handler
|
|
@@ -70,8 +62,8 @@ export function ItemList(props) {
|
|
|
70
62
|
React.createElement(DialogTitle, { sx: { minWidth: '200px' }, id: "dialog-title" }, title || ''),
|
|
71
63
|
React.createElement(DialogContent, null,
|
|
72
64
|
React.createElement(List, null, items.map((item) => {
|
|
73
|
-
const id =
|
|
74
|
-
return (React.createElement(
|
|
65
|
+
const id = item[idField];
|
|
66
|
+
return (React.createElement(ListItemButton, { key: id, disabled: id === currentItem[idField], onClick: () => closeItemHandler(item) },
|
|
75
67
|
React.createElement(ListItemText, null, getLabel(item))));
|
|
76
68
|
}))))));
|
|
77
69
|
}
|
|
@@ -5,7 +5,7 @@ import { GridData, GridLoader } from '../components/GridLoader';
|
|
|
5
5
|
/**
|
|
6
6
|
* ListMoreDisplay props
|
|
7
7
|
*/
|
|
8
|
-
export interface ListMoreDisplayProps<T, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate> extends Omit<CardProps, 'children'>, GridLoader<T> {
|
|
8
|
+
export interface ListMoreDisplayProps<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate> extends Omit<CardProps, 'children'>, GridLoader<T> {
|
|
9
9
|
/**
|
|
10
10
|
* Children to display the list
|
|
11
11
|
*/
|
|
@@ -32,4 +32,4 @@ export interface ListMoreDisplayProps<T, F extends DataTypes.BasicTemplate = Dat
|
|
|
32
32
|
* @param props Props
|
|
33
33
|
* @returns Component
|
|
34
34
|
*/
|
|
35
|
-
export declare function ListMoreDisplay<T extends
|
|
35
|
+
export declare function ListMoreDisplay<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ListMoreDisplayProps<T, F>): JSX.Element;
|
package/lib/mu/MUGlobal.d.ts
CHANGED
|
@@ -55,13 +55,13 @@ export declare class MUGlobal {
|
|
|
55
55
|
* @param input Input object
|
|
56
56
|
* @returns Updated object
|
|
57
57
|
*/
|
|
58
|
-
static half(input:
|
|
58
|
+
static half(input: object): {};
|
|
59
59
|
/**
|
|
60
60
|
* Reverse object number properties, like 5 to -5
|
|
61
61
|
* @param input Input object
|
|
62
62
|
* @returns Updated object
|
|
63
63
|
*/
|
|
64
|
-
static reverse(input:
|
|
64
|
+
static reverse(input: object): {};
|
|
65
65
|
/**
|
|
66
66
|
* Update object number properties with adjustment
|
|
67
67
|
* @param input Input object
|
|
@@ -69,7 +69,7 @@ export declare class MUGlobal {
|
|
|
69
69
|
* @param field Specific field
|
|
70
70
|
* @returns Updated object
|
|
71
71
|
*/
|
|
72
|
-
static increase(input:
|
|
72
|
+
static increase(input: object, adjust: number | object, field?: string): {};
|
|
73
73
|
/**
|
|
74
74
|
* Adjust size with theme update
|
|
75
75
|
* @param size Base size
|
|
@@ -77,7 +77,7 @@ export declare class MUGlobal {
|
|
|
77
77
|
* @param updateFunc Theme update function
|
|
78
78
|
* @returns Updated object
|
|
79
79
|
*/
|
|
80
|
-
static adjustWithTheme(size: number, adjust:
|
|
80
|
+
static adjustWithTheme(size: number, adjust: object, updateFunc: (value: number) => string): {};
|
|
81
81
|
/**
|
|
82
82
|
* Break points defined
|
|
83
83
|
*/
|
|
@@ -91,7 +91,7 @@ export declare class MUGlobal {
|
|
|
91
91
|
* @param theme Theme
|
|
92
92
|
* @returns Result
|
|
93
93
|
*/
|
|
94
|
-
static getSpace(spaces:
|
|
94
|
+
static getSpace(spaces: object, theme: Theme): number;
|
|
95
95
|
/**
|
|
96
96
|
* Update object number properties with theme
|
|
97
97
|
* @param input Input object
|
package/lib/mu/OptionGroup.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { DataTypes, IdDefaultType, LabelDefaultType, ListType } from '@etsoo/shared';
|
|
3
3
|
import { FormControlProps } from '@mui/material';
|
|
4
4
|
/**
|
|
5
5
|
* OptionGroup props
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export declare type OptionGroupProps<T extends object, D extends DataTypes.Keys<T>, L extends DataTypes.Keys<T, string>> = Omit<FormControlProps<'fieldset'>, 'defaultValue'> & {
|
|
8
8
|
/**
|
|
9
9
|
* Default value
|
|
10
10
|
*/
|
|
@@ -14,17 +14,17 @@ export interface OptionGroupProps<T extends {} = DataTypes.IdLabelItem, D extend
|
|
|
14
14
|
*/
|
|
15
15
|
getOptionLabel?: (option: T) => string;
|
|
16
16
|
/**
|
|
17
|
-
* Id field
|
|
17
|
+
* Id field
|
|
18
18
|
*/
|
|
19
|
-
idField
|
|
19
|
+
idField?: D;
|
|
20
20
|
/**
|
|
21
21
|
* Label
|
|
22
22
|
*/
|
|
23
23
|
label?: string;
|
|
24
24
|
/**
|
|
25
|
-
* Label field
|
|
25
|
+
* Label field
|
|
26
26
|
*/
|
|
27
|
-
labelField
|
|
27
|
+
labelField?: L;
|
|
28
28
|
/**
|
|
29
29
|
* Multiple choose item
|
|
30
30
|
*/
|
|
@@ -49,10 +49,10 @@ export interface OptionGroupProps<T extends {} = DataTypes.IdLabelItem, D extend
|
|
|
49
49
|
* Display group of elements in a compact row
|
|
50
50
|
*/
|
|
51
51
|
row?: boolean;
|
|
52
|
-
}
|
|
52
|
+
};
|
|
53
53
|
/**
|
|
54
54
|
* OptionGroup
|
|
55
55
|
* @param props Props
|
|
56
56
|
* @returns Component
|
|
57
57
|
*/
|
|
58
|
-
export declare function OptionGroup<T extends
|
|
58
|
+
export declare function OptionGroup<T extends object = ListType, D extends DataTypes.Keys<T> = IdDefaultType<T>, L extends DataTypes.Keys<T, string> = LabelDefaultType<T>>(props: OptionGroupProps<T, D, L>): JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
1
|
+
import { DataTypes, IdDefaultType } from '@etsoo/shared';
|
|
2
2
|
import { SxProps, Theme } from '@mui/material';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { ListChildComponentProps } from 'react-window';
|
|
@@ -10,7 +10,7 @@ import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from './
|
|
|
10
10
|
/**
|
|
11
11
|
* ResponsibleContainer props
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export declare type ResponsibleContainerProps<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>> = 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
|
|
@@ -23,7 +23,7 @@ export interface ResponsibleContainerProps<T extends {}, F extends DataTypes.Bas
|
|
|
23
23
|
/**
|
|
24
24
|
* Container box SX (dataGrid determines the case)
|
|
25
25
|
*/
|
|
26
|
-
containerBoxSx?: (paddings:
|
|
26
|
+
containerBoxSx?: (paddings: Record<string, string | number>, hasFields: boolean, dataGrid?: boolean) => SxProps<Theme>;
|
|
27
27
|
/**
|
|
28
28
|
* Min width to show Datagrid
|
|
29
29
|
*/
|
|
@@ -67,7 +67,7 @@ export interface ResponsibleContainerProps<T extends {}, F extends DataTypes.Bas
|
|
|
67
67
|
/**
|
|
68
68
|
* Paddings
|
|
69
69
|
*/
|
|
70
|
-
paddings?:
|
|
70
|
+
paddings?: Record<string, string | number>;
|
|
71
71
|
/**
|
|
72
72
|
* Pull to refresh data
|
|
73
73
|
*/
|
|
@@ -80,10 +80,10 @@ export interface ResponsibleContainerProps<T extends {}, F extends DataTypes.Bas
|
|
|
80
80
|
* Size ready to read miliseconds span
|
|
81
81
|
*/
|
|
82
82
|
sizeReadyMiliseconds?: number;
|
|
83
|
-
}
|
|
83
|
+
};
|
|
84
84
|
/**
|
|
85
85
|
* Responsible container
|
|
86
86
|
* @param props Props
|
|
87
87
|
* @returns Layout
|
|
88
88
|
*/
|
|
89
|
-
export declare function ResponsibleContainer<T extends
|
|
89
|
+
export declare function ResponsibleContainer<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = IdDefaultType<T>>(props: ResponsibleContainerProps<T, F, D>): JSX.Element;
|