@etsoo/react 1.5.77 → 1.5.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/lib/app/CommonApp.d.ts +2 -2
  2. package/lib/app/Labels.d.ts +1 -1
  3. package/lib/app/ServiceApp.d.ts +2 -2
  4. package/lib/components/GridColumn.d.ts +10 -10
  5. package/lib/components/GridLoader.d.ts +7 -8
  6. package/lib/components/ScrollerGrid.d.ts +5 -6
  7. package/lib/components/ScrollerList.d.ts +2 -2
  8. package/lib/mu/AutocompleteExtendedProps.d.ts +8 -6
  9. package/lib/mu/ComboBox.d.ts +9 -7
  10. package/lib/mu/DataGridEx.d.ts +5 -5
  11. package/lib/mu/DataGridRenderers.d.ts +1 -1
  12. package/lib/mu/DnDList.d.ts +2 -2
  13. package/lib/mu/ListMoreDisplay.d.ts +2 -2
  14. package/lib/mu/MUGlobal.d.ts +5 -5
  15. package/lib/mu/OptionGroup.d.ts +15 -11
  16. package/lib/mu/ResponsibleContainer.d.ts +5 -5
  17. package/lib/mu/ScrollerListEx.d.ts +10 -9
  18. package/lib/mu/SearchOptionGroup.d.ts +1 -1
  19. package/lib/mu/SelectEx.d.ts +15 -11
  20. package/lib/mu/TableEx.d.ts +9 -7
  21. package/lib/mu/Tiplist.d.ts +3 -3
  22. package/lib/mu/Tiplist.js +1 -3
  23. package/lib/mu/pages/CommonPageProps.d.ts +1 -1
  24. package/lib/mu/pages/DataGridPage.d.ts +1 -1
  25. package/lib/mu/pages/DataGridPageProps.d.ts +2 -2
  26. package/lib/mu/pages/FixedListPage.d.ts +1 -1
  27. package/lib/mu/pages/ListPage.d.ts +1 -1
  28. package/lib/mu/pages/ListPageProps.d.ts +1 -2
  29. package/lib/mu/pages/ResponsivePage.d.ts +1 -1
  30. package/lib/mu/pages/ResponsivePageProps.d.ts +2 -2
  31. package/lib/mu/pages/SearchPageProps.d.ts +2 -2
  32. package/lib/mu/pages/TablePage.d.ts +1 -1
  33. package/lib/mu/pages/TablePageProps.d.ts +1 -2
  34. package/lib/mu/pages/ViewPage.d.ts +5 -4
  35. package/lib/states/IState.d.ts +1 -1
  36. package/lib/uses/useCombinedRefs.d.ts +1 -1
  37. package/package.json +9 -9
  38. package/src/app/CommonApp.ts +2 -2
  39. package/src/app/Labels.ts +1 -1
  40. package/src/app/ServiceApp.ts +2 -2
  41. package/src/components/GridColumn.ts +10 -11
  42. package/src/components/GridLoader.ts +7 -7
  43. package/src/components/ScrollerGrid.tsx +64 -60
  44. package/src/components/ScrollerList.tsx +2 -2
  45. package/src/mu/AutocompleteExtendedProps.ts +13 -12
  46. package/src/mu/ComboBox.tsx +12 -11
  47. package/src/mu/DataGridEx.tsx +12 -12
  48. package/src/mu/DataGridRenderers.tsx +1 -1
  49. package/src/mu/DnDList.tsx +2 -2
  50. package/src/mu/ListMoreDisplay.tsx +2 -2
  51. package/src/mu/MUGlobal.ts +5 -5
  52. package/src/mu/OptionGroup.tsx +18 -15
  53. package/src/mu/ResponsibleContainer.tsx +12 -17
  54. package/src/mu/ScrollerListEx.tsx +18 -17
  55. package/src/mu/SearchOptionGroup.tsx +1 -1
  56. package/src/mu/SelectEx.tsx +18 -17
  57. package/src/mu/TableEx.tsx +51 -50
  58. package/src/mu/Tiplist.tsx +9 -8
  59. package/src/mu/pages/CommonPageProps.ts +1 -1
  60. package/src/mu/pages/DataGridPage.tsx +14 -10
  61. package/src/mu/pages/DataGridPageProps.ts +16 -13
  62. package/src/mu/pages/FixedListPage.tsx +1 -1
  63. package/src/mu/pages/ListPage.tsx +1 -1
  64. package/src/mu/pages/ListPageProps.ts +4 -3
  65. package/src/mu/pages/ResponsivePage.tsx +5 -4
  66. package/src/mu/pages/ResponsivePageProps.ts +9 -6
  67. package/src/mu/pages/SearchPageProps.ts +5 -3
  68. package/src/mu/pages/TablePage.tsx +1 -1
  69. package/src/mu/pages/TablePageProps.ts +4 -3
  70. package/src/mu/pages/ViewPage.tsx +8 -6
  71. package/src/states/IState.ts +1 -1
  72. package/src/states/UserState.ts +1 -1
  73. package/src/uses/useCombinedRefs.ts +3 -3
@@ -4,15 +4,15 @@ import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
4
4
  /**
5
5
  * Tiplist props
6
6
  */
7
- export interface TiplistProps<T extends {}, D extends DataTypes.Keys<T>> extends Omit<AutocompleteExtendedProps<T, D>, 'open'> {
7
+ export declare type TiplistProps<T extends object, D extends DataTypes.Keys<T>> = Omit<AutocompleteExtendedProps<T, D>, 'open'> & {
8
8
  /**
9
9
  * Load data callback
10
10
  */
11
11
  loadData: (keyword?: string, id?: T[D]) => PromiseLike<T[] | null | undefined>;
12
- }
12
+ };
13
13
  /**
14
14
  * Tiplist
15
15
  * @param props Props
16
16
  * @returns Component
17
17
  */
18
- export declare function Tiplist<T extends {} = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: TiplistProps<T, D>): JSX.Element;
18
+ export declare function Tiplist<T extends object = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: TiplistProps<T, D>): JSX.Element;
package/lib/mu/Tiplist.js CHANGED
@@ -17,10 +17,8 @@ export function Tiplist(props) {
17
17
  const inputRef = React.createRef();
18
18
  // Local value
19
19
  let localValue = value !== null && value !== void 0 ? value : defaultValue;
20
- if (localValue === undefined)
21
- localValue = null;
22
20
  // One time calculation for input's default value (uncontrolled)
23
- const localIdValue = idValue !== null && idValue !== void 0 ? idValue : DataTypes.getValue(localValue, idField !== null && idField !== void 0 ? idField : 'id');
21
+ const localIdValue = idValue !== null && idValue !== void 0 ? idValue : DataTypes.getValue(localValue, idField);
24
22
  // Changable states
25
23
  const [states, stateUpdate] = React.useReducer((currentState, newState) => {
26
24
  return { ...currentState, ...newState };
@@ -44,7 +44,7 @@ export interface CommonPageProps extends Omit<ContainerProps, 'id'> {
44
44
  /**
45
45
  * Paddings
46
46
  */
47
- paddings?: {};
47
+ paddings?: Record<string, string | number>;
48
48
  /**
49
49
  * Scroll container
50
50
  */
@@ -6,4 +6,4 @@ import { DataGridPageProps } from './DataGridPageProps';
6
6
  * @param props Props
7
7
  * @returns Component
8
8
  */
9
- export declare function DataGridPage<T, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: DataGridPageProps<T, F>): JSX.Element;
9
+ export declare function DataGridPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: DataGridPageProps<T, F, D>): JSX.Element;
@@ -4,7 +4,7 @@ import { SearchPageProps } from './SearchPageProps';
4
4
  /**
5
5
  * DataGrid page props
6
6
  */
7
- export interface DataGridPageProps<T, F extends DataTypes.BasicTemplate> extends SearchPageProps<T, F>, Omit<DataGridExProps<T>, 'loadData' | 'height'> {
7
+ export declare type DataGridPageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> = SearchPageProps<T, F> & Omit<DataGridExProps<T, D>, 'loadData' | 'height'> & {
8
8
  /**
9
9
  * Height will be deducted
10
10
  * @param height Current calcuated height
@@ -14,4 +14,4 @@ export interface DataGridPageProps<T, F extends DataTypes.BasicTemplate> extends
14
14
  * Grid height
15
15
  */
16
16
  height?: number;
17
- }
17
+ };
@@ -6,7 +6,7 @@ import { ListPageProps } from './ListPageProps';
6
6
  * @param props Props
7
7
  * @returns Component
8
8
  */
9
- export declare function FixedListPage<T extends {}, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ListPageProps<T, F> & {
9
+ export declare function FixedListPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ListPageProps<T, F> & {
10
10
  /**
11
11
  * Height will be deducted
12
12
  * @param height Current calcuated height
@@ -6,4 +6,4 @@ import { ListPageProps } from './ListPageProps';
6
6
  * @param props Props
7
7
  * @returns Component
8
8
  */
9
- export declare function ListPage<T extends {}, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ListPageProps<T, F>): JSX.Element;
9
+ export declare function ListPage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ListPageProps<T, F>): JSX.Element;
@@ -4,5 +4,4 @@ import { SearchPageProps } from './SearchPageProps';
4
4
  /**
5
5
  * List page props
6
6
  */
7
- export interface ListPageProps<T, F extends DataTypes.BasicTemplate> extends SearchPageProps<T, F>, Omit<ScrollerListExProps<T>, 'loadData'> {
8
- }
7
+ export declare type ListPageProps<T extends object, F extends DataTypes.BasicTemplate> = SearchPageProps<T, F> & Omit<ScrollerListExProps<T>, 'loadData'>;
@@ -6,4 +6,4 @@ import { ResponsePageProps } from './ResponsivePageProps';
6
6
  * @param props Props
7
7
  * @returns Component
8
8
  */
9
- export declare function ResponsivePage<T extends {}, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ResponsePageProps<T, F>): JSX.Element;
9
+ export declare function ResponsivePage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: ResponsePageProps<T, F, D>): JSX.Element;
@@ -7,7 +7,7 @@ import { DataGridPageProps } from './DataGridPageProps';
7
7
  /**
8
8
  * Response page props
9
9
  */
10
- export interface ResponsePageProps<T, F extends DataTypes.BasicTemplate> extends Omit<DataGridPageProps<T, F>, 'mRef' | 'itemKey' | 'onScroll' | 'onItemsRendered'> {
10
+ export declare type ResponsePageProps<T extends object, F extends DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> = Omit<DataGridPageProps<T, F, D>, 'mRef' | 'itemKey' | 'onScroll' | 'onItemsRendered'> & {
11
11
  /**
12
12
  * Min width to show Datagrid
13
13
  */
@@ -36,4 +36,4 @@ export interface ResponsePageProps<T, F extends DataTypes.BasicTemplate> extends
36
36
  * Quick action for double click or click under mobile
37
37
  */
38
38
  quickAction?: (data: T) => void;
39
- }
39
+ };
@@ -5,7 +5,7 @@ import { CommonPageProps } from './CommonPageProps';
5
5
  /**
6
6
  * Search page props
7
7
  */
8
- export interface SearchPageProps<T, F extends DataTypes.BasicTemplate> extends Omit<GridLoader<T>, 'loadData'> {
8
+ export declare type SearchPageProps<T extends object, F extends DataTypes.BasicTemplate> = Omit<GridLoader<T>, 'loadData'> & {
9
9
  /**
10
10
  * Search fields
11
11
  */
@@ -27,4 +27,4 @@ export interface SearchPageProps<T, F extends DataTypes.BasicTemplate> extends O
27
27
  * @default 100
28
28
  */
29
29
  sizeReadyMiliseconds?: number;
30
- }
30
+ };
@@ -6,4 +6,4 @@ import { TablePageProps } from './TablePageProps';
6
6
  * @param props Props
7
7
  * @returns Component
8
8
  */
9
- export declare function TablePage<T extends {}, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: TablePageProps<T, F>): JSX.Element;
9
+ export declare function TablePage<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: TablePageProps<T, F>): JSX.Element;
@@ -4,5 +4,4 @@ import { SearchPageProps } from './SearchPageProps';
4
4
  /**
5
5
  * Table page props
6
6
  */
7
- export interface TablePageProps<T, F extends DataTypes.BasicTemplate> extends SearchPageProps<T, F>, Omit<TableExProps<T>, 'loadData'> {
8
- }
7
+ export declare type TablePageProps<T extends object, F extends DataTypes.BasicTemplate> = SearchPageProps<T, F> & Omit<TableExProps<T>, 'loadData'>;
@@ -1,3 +1,4 @@
1
+ import { DataTypes } from '@etsoo/shared';
1
2
  import { GridProps } from '@mui/material';
2
3
  import React from 'react';
3
4
  import { GridColumnRenderProps, GridDataType } from '../../components/GridColumn';
@@ -5,7 +6,7 @@ import { CommonPageProps } from './CommonPageProps';
5
6
  /**
6
7
  * View page display field
7
8
  */
8
- export interface ViewPageField<T extends {}> extends GridProps {
9
+ export interface ViewPageField<T extends object> extends GridProps {
9
10
  /**
10
11
  * Data field
11
12
  */
@@ -27,11 +28,11 @@ export interface ViewPageField<T extends {}> extends GridProps {
27
28
  */
28
29
  renderProps?: GridColumnRenderProps;
29
30
  }
30
- declare type ViewPageFieldType<T> = (string & keyof T) | [string & keyof T, GridDataType, GridColumnRenderProps?] | ViewPageField<T>;
31
+ declare type ViewPageFieldType<T extends object> = (string & keyof T) | [string & keyof T, GridDataType, GridColumnRenderProps?] | ViewPageField<T>;
31
32
  /**
32
33
  * View page props
33
34
  */
34
- export interface ViewPageProps<T extends {}> extends Omit<CommonPageProps, 'children'> {
35
+ export interface ViewPageProps<T extends DataTypes.StringRecord> extends Omit<CommonPageProps, 'children'> {
35
36
  /**
36
37
  * Actions
37
38
  */
@@ -61,5 +62,5 @@ export interface ViewPageProps<T extends {}> extends Omit<CommonPageProps, 'chil
61
62
  * View page
62
63
  * @param props Props
63
64
  */
64
- export declare function ViewPage<T extends {}>(props: ViewPageProps<T>): JSX.Element;
65
+ export declare function ViewPage<T extends DataTypes.StringRecord>(props: ViewPageProps<T>): JSX.Element;
65
66
  export {};
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  /**
4
4
  * State UI creator
5
5
  */
6
- export interface IUICreator<S extends IState, A extends IAction, P = {}> {
6
+ export interface IUICreator<S extends IState, A extends IAction, P = object> {
7
7
  (state: S, dispatch: React.Dispatch<A>, props: P): React.ReactElement;
8
8
  }
9
9
  /**
@@ -4,4 +4,4 @@
4
4
  * @param refs Refs
5
5
  * @returns Callback
6
6
  */
7
- export default function useCombinedRefs(...refs: (React.Ref<unknown> | undefined)[]): (target: unknown) => void;
7
+ export default function useCombinedRefs<T>(...refs: (React.Ref<T> | undefined)[]): (target: T | null) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.5.77",
3
+ "version": "1.5.78",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -51,9 +51,9 @@
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.81",
55
- "@etsoo/notificationbase": "^1.1.6",
56
- "@etsoo/shared": "^1.1.47",
54
+ "@etsoo/appscript": "^1.2.82",
55
+ "@etsoo/notificationbase": "^1.1.7",
56
+ "@etsoo/shared": "^1.1.48",
57
57
  "@mui/icons-material": "^5.10.2",
58
58
  "@mui/material": "^5.10.2",
59
59
  "@types/pica": "^9.0.1",
@@ -79,18 +79,18 @@
79
79
  "@babel/plugin-transform-runtime": "^7.18.10",
80
80
  "@babel/preset-env": "^7.18.10",
81
81
  "@babel/runtime-corejs3": "^7.18.9",
82
- "@types/jest": "^28.1.7",
82
+ "@types/jest": "^28.1.8",
83
83
  "@types/react-test-renderer": "^18.0.0",
84
- "@typescript-eslint/eslint-plugin": "^5.34.0",
85
- "@typescript-eslint/parser": "^5.34.0",
84
+ "@typescript-eslint/eslint-plugin": "^5.35.1",
85
+ "@typescript-eslint/parser": "^5.35.1",
86
86
  "eslint": "^8.22.0",
87
87
  "eslint-config-airbnb-base": "^15.0.0",
88
88
  "eslint-plugin-import": "^2.26.0",
89
- "eslint-plugin-react": "^7.30.1",
89
+ "eslint-plugin-react": "^7.31.0",
90
90
  "jest": "^28.1.3",
91
91
  "jest-environment-jsdom": "^28.1.3",
92
92
  "react-test-renderer": "^18.2.0",
93
93
  "ts-jest": "^28.0.8",
94
- "typescript": "^4.7.4"
94
+ "typescript": "^4.8.2"
95
95
  }
96
96
  }
@@ -57,7 +57,7 @@ export abstract class CommonApp<
57
57
  * Refresh token
58
58
  * @param props Props
59
59
  */
60
- override async refreshToken<D = RefreshTokenRQ>(
60
+ override async refreshToken<D extends object = RefreshTokenRQ>(
61
61
  props?: RefreshTokenProps<D>
62
62
  ) {
63
63
  // Destruct
@@ -206,7 +206,7 @@ export abstract class CommonApp<
206
206
  * @param showLoading Show loading bar or not
207
207
  * @returns Result
208
208
  */
209
- override async tryLogin<D = RefreshTokenRQ>(
209
+ override async tryLogin<D extends object = RefreshTokenRQ>(
210
210
  data?: D,
211
211
  showLoading?: boolean
212
212
  ) {
package/src/app/Labels.ts CHANGED
@@ -67,7 +67,7 @@ export namespace Labels {
67
67
  * @param reference Key reference
68
68
  */
69
69
  export const setLabels = (
70
- labels: {},
70
+ labels: DataTypes.StringRecord,
71
71
  reference: setLabelsReference = {}
72
72
  ) => {
73
73
  Utils.setLabels(CommonPage, labels, reference.commonPage);
@@ -101,7 +101,7 @@ export class ServiceApp<
101
101
  * Refresh token
102
102
  * @param props Props
103
103
  */
104
- override async refreshToken<D = RefreshTokenRQ>(
104
+ override async refreshToken<D extends object = RefreshTokenRQ>(
105
105
  props?: RefreshTokenProps<D>
106
106
  ) {
107
107
  // Destruct
@@ -305,7 +305,7 @@ export class ServiceApp<
305
305
  * @param showLoading Show loading bar or not
306
306
  * @returns Result
307
307
  */
308
- override async tryLogin<D extends {} = {}>(
308
+ override async tryLogin<D extends object = {}>(
309
309
  data?: D,
310
310
  showLoading?: boolean
311
311
  ) {
@@ -40,7 +40,7 @@ export type GridCellValueType = string | number | Date | boolean | undefined;
40
40
  /**
41
41
  * Grid cell formatter props
42
42
  */
43
- export interface GridCellFormatterProps<T> {
43
+ export type GridCellFormatterProps<T> = {
44
44
  /**
45
45
  * Current data
46
46
  */
@@ -60,13 +60,12 @@ export interface GridCellFormatterProps<T> {
60
60
  * Column index
61
61
  */
62
62
  columnIndex: number;
63
- }
63
+ };
64
64
 
65
65
  /**
66
66
  * Grid cell renderer props
67
67
  */
68
- export interface GridCellRendererProps<T, P = any>
69
- extends GridCellFormatterProps<T> {
68
+ export type GridCellRendererProps<T, P = any> = GridCellFormatterProps<T> & {
70
69
  /**
71
70
  * Cell props
72
71
  */
@@ -91,12 +90,12 @@ export interface GridCellRendererProps<T, P = any>
91
90
  * Render props
92
91
  */
93
92
  renderProps?: GridColumnRenderProps;
94
- }
93
+ };
95
94
 
96
95
  /**
97
96
  * Grid header cell renderer props
98
97
  */
99
- export interface GridHeaderCellRendererProps<T, P = any> {
98
+ export type GridHeaderCellRendererProps<T, P = any> = {
100
99
  /**
101
100
  * Cell props
102
101
  */
@@ -116,12 +115,12 @@ export interface GridHeaderCellRendererProps<T, P = any> {
116
115
  * States
117
116
  */
118
117
  states: GridLoaderStates<T>;
119
- }
118
+ };
120
119
 
121
120
  /**
122
121
  * Grid column render props
123
122
  */
124
- export interface GridColumnRenderProps {
123
+ export type GridColumnRenderProps = {
125
124
  /**
126
125
  * Culture, like zh-CN
127
126
  */
@@ -151,12 +150,12 @@ export interface GridColumnRenderProps {
151
150
  * Additional data
152
151
  */
153
152
  readonly data?: Readonly<Record<string, any>>;
154
- }
153
+ };
155
154
 
156
155
  /**
157
156
  * Grid column
158
157
  */
159
- export interface GridColumn<T> {
158
+ export type GridColumn<T> = {
160
159
  /**
161
160
  * The column identifier. It's used to map with row data
162
161
  */
@@ -219,4 +218,4 @@ export interface GridColumn<T> {
219
218
  headerCellRenderer?: (
220
219
  props: GridHeaderCellRendererProps<T>
221
220
  ) => React.ReactNode;
222
- }
221
+ };
@@ -48,12 +48,12 @@ export function GridDataGet<F extends DataTypes.BasicTemplate>(
48
48
  /**
49
49
  * Grid Json data
50
50
  */
51
- export interface GridJsonData extends Omit<GridLoadDataProps, 'data'> {}
51
+ export type GridJsonData = Omit<GridLoadDataProps, 'data'>;
52
52
 
53
53
  /**
54
54
  * Grid data load props
55
55
  */
56
- export interface GridLoadDataProps {
56
+ export type GridLoadDataProps = {
57
57
  /**
58
58
  * Current page
59
59
  */
@@ -78,12 +78,12 @@ export interface GridLoadDataProps {
78
78
  * Data related
79
79
  */
80
80
  data?: GridData;
81
- }
81
+ };
82
82
 
83
83
  /**
84
84
  * Grid data loader
85
85
  */
86
- export interface GridLoader<T> {
86
+ export type GridLoader<T extends object> = {
87
87
  /**
88
88
  * Auto load data, otherwise call reset
89
89
  * @default true
@@ -109,12 +109,12 @@ export interface GridLoader<T> {
109
109
  * Threshold at which to pre-fetch data; default is half of loadBatchSize
110
110
  */
111
111
  threshold?: number | undefined;
112
- }
112
+ };
113
113
 
114
114
  /**
115
115
  * Grid loader states
116
116
  */
117
- export interface GridLoaderStates<T> extends GridLoadDataProps {
117
+ export type GridLoaderStates<T> = GridLoadDataProps & {
118
118
  /**
119
119
  * Auto load data, otherwise call reset
120
120
  * @default true
@@ -150,4 +150,4 @@ export interface GridLoaderStates<T> extends GridLoadDataProps {
150
150
  * Selected items of id
151
151
  */
152
152
  selectedItems: T[];
153
- }
153
+ };
@@ -10,8 +10,10 @@ import {
10
10
  import { GridMethodRef } from '../mu/GridMethodRef';
11
11
  import { GridLoadDataProps, GridLoader, GridLoaderStates } from './GridLoader';
12
12
 
13
- export interface ScrollerGridItemRendererProps<T>
14
- extends Omit<GridChildComponentProps<T>, 'data'> {
13
+ export type ScrollerGridItemRendererProps<T> = Omit<
14
+ GridChildComponentProps<T>,
15
+ 'data'
16
+ > & {
15
17
  /**
16
18
  * Selected items
17
19
  */
@@ -21,66 +23,65 @@ export interface ScrollerGridItemRendererProps<T>
21
23
  * Data
22
24
  */
23
25
  data?: T;
24
- }
26
+ };
25
27
 
26
28
  /**
27
29
  * Scroller vertical grid props
28
30
  */
29
- export interface ScrollerGridProps<
30
- T extends {},
31
+ export type ScrollerGridProps<
32
+ T extends object,
31
33
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
32
- > extends GridLoader<T>,
33
- Omit<
34
- VariableSizeGridProps<T>,
35
- 'children' | 'rowCount' | 'rowHeight' | 'ref'
36
- > {
37
- /**
38
- * Default order by asc
39
- * @default true
40
- */
41
- defaultOrderByAsc?: boolean;
42
-
43
- /**
44
- * Footer renderer
45
- */
46
- footerRenderer?: (
47
- rows: T[],
48
- states: GridLoaderStates<T>
49
- ) => React.ReactNode;
50
-
51
- /**
52
- * Header renderer
53
- */
54
- headerRenderer?: (states: GridLoaderStates<T>) => React.ReactNode;
55
-
56
- /**
57
- * Id field
58
- * @default id
59
- */
60
- idField?: D;
61
-
62
- /**
63
- * Item renderer
64
- */
65
- itemRenderer: (
66
- props: ScrollerGridItemRendererProps<T>
67
- ) => React.ReactElement;
68
-
69
- /**
70
- * Methods
71
- */
72
- mRef?: React.Ref<ScrollerGridForwardRef>;
73
-
74
- /**
75
- * On items select change
76
- */
77
- onSelectChange?: (selectedItems: T[]) => void;
78
-
79
- /**
80
- * Returns the height of the specified row.
81
- */
82
- rowHeight?: ((index: number) => number) | number;
83
- }
34
+ > = GridLoader<T> &
35
+ Omit<
36
+ VariableSizeGridProps<T>,
37
+ 'children' | 'rowCount' | 'rowHeight' | 'ref'
38
+ > & {
39
+ /**
40
+ * Default order by asc
41
+ * @default true
42
+ */
43
+ defaultOrderByAsc?: boolean;
44
+
45
+ /**
46
+ * Footer renderer
47
+ */
48
+ footerRenderer?: (
49
+ rows: T[],
50
+ states: GridLoaderStates<T>
51
+ ) => React.ReactNode;
52
+
53
+ /**
54
+ * Header renderer
55
+ */
56
+ headerRenderer?: (states: GridLoaderStates<T>) => React.ReactNode;
57
+
58
+ /**
59
+ * Id field
60
+ */
61
+ idField?: D;
62
+
63
+ /**
64
+ * Item renderer
65
+ */
66
+ itemRenderer: (
67
+ props: ScrollerGridItemRendererProps<T>
68
+ ) => React.ReactElement;
69
+
70
+ /**
71
+ * Methods
72
+ */
73
+ mRef?: React.Ref<ScrollerGridForwardRef>;
74
+
75
+ /**
76
+ * On items select change
77
+ */
78
+ onSelectChange?: (selectedItems: T[]) => void;
79
+
80
+ /**
81
+ * Returns the height of the specified row.
82
+ */
83
+ rowHeight?: ((index: number) => number) | number;
84
+ };
84
85
 
85
86
  /**
86
87
  * Scroller grid forward ref
@@ -146,8 +147,11 @@ export interface ScrollerGridForwardRef extends GridMethodRef {
146
147
  * @param props Props
147
148
  * @returns Component
148
149
  */
149
- export const ScrollerGrid = <T extends Record<string, unknown>>(
150
- props: ScrollerGridProps<T>
150
+ export const ScrollerGrid = <
151
+ T extends object,
152
+ D extends DataTypes.Keys<T> = DataTypes.Keys<T>
153
+ >(
154
+ props: ScrollerGridProps<T, D>
151
155
  ) => {
152
156
  // Destruct
153
157
  const {
@@ -157,7 +161,7 @@ export const ScrollerGrid = <T extends Record<string, unknown>>(
157
161
  footerRenderer,
158
162
  headerRenderer,
159
163
  itemRenderer,
160
- idField = 'id',
164
+ idField = 'id' as D,
161
165
  loadBatchSize,
162
166
  loadData,
163
167
  mRef,
@@ -20,7 +20,7 @@ import {
20
20
  /**
21
21
  * Scroller vertical list props
22
22
  */
23
- export interface ScrollerListProps<T>
23
+ export interface ScrollerListProps<T extends object>
24
24
  extends GridLoader<T>,
25
25
  Omit<
26
26
  ListProps<T>,
@@ -98,7 +98,7 @@ const calculateBatchSize = (
98
98
  * @param props Props
99
99
  * @returns Component
100
100
  */
101
- export const ScrollerList = <T extends {}>(props: ScrollerListProps<T>) => {
101
+ export const ScrollerList = <T extends object>(props: ScrollerListProps<T>) => {
102
102
  // Destruct
103
103
  const {
104
104
  autoLoad = true,
@@ -5,18 +5,13 @@ import { ChangeEventHandler } from 'react';
5
5
  /**
6
6
  * Autocomplete extended props
7
7
  */
8
- export interface AutocompleteExtendedProps<
9
- T extends {},
8
+ export type AutocompleteExtendedProps<
9
+ T extends object,
10
10
  D extends DataTypes.Keys<T>
11
- > extends Omit<
12
- AutocompleteProps<T, undefined, false, false>,
13
- 'renderInput' | 'options'
14
- > {
15
- /**
16
- * Id field, default is id
17
- */
18
- idField: T extends DataTypes.IdLabelItem ? D | undefined : D;
19
-
11
+ > = Omit<
12
+ AutocompleteProps<T, undefined, false, false>,
13
+ 'renderInput' | 'options'
14
+ > & {
20
15
  /**
21
16
  * Id value
22
17
  */
@@ -80,4 +75,10 @@ export interface AutocompleteExtendedProps<
80
75
  * Is search field?
81
76
  */
82
77
  search?: boolean;
83
- }
78
+ } & (T extends { id: DataTypes.IdType }
79
+ ? {
80
+ idField?: D;
81
+ }
82
+ : {
83
+ idField: D;
84
+ });