@etsoo/react 1.5.78 → 1.5.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/lib/components/ScrollerGrid.d.ts +3 -3
  2. package/lib/mu/AutocompleteExtendedProps.d.ts +5 -7
  3. package/lib/mu/ComboBox.d.ts +8 -10
  4. package/lib/mu/DataGridEx.d.ts +3 -3
  5. package/lib/mu/ItemList.d.ts +6 -5
  6. package/lib/mu/ItemList.js +4 -12
  7. package/lib/mu/OptionGroup.d.ts +12 -16
  8. package/lib/mu/ResponsibleContainer.d.ts +3 -3
  9. package/lib/mu/ScrollerListEx.d.ts +3 -3
  10. package/lib/mu/SearchOptionGroup.d.ts +2 -2
  11. package/lib/mu/SelectBool.d.ts +2 -3
  12. package/lib/mu/SelectBool.js +1 -1
  13. package/lib/mu/SelectEx.d.ts +12 -16
  14. package/lib/mu/TableEx.d.ts +8 -10
  15. package/lib/mu/Tiplist.d.ts +2 -2
  16. package/lib/mu/pages/DataGridPage.d.ts +2 -2
  17. package/lib/mu/pages/DataGridPageProps.d.ts +2 -2
  18. package/lib/mu/pages/FixedListPage.d.ts +2 -2
  19. package/lib/mu/pages/ListPage.d.ts +2 -2
  20. package/lib/mu/pages/ListPageProps.d.ts +1 -1
  21. package/lib/mu/pages/ResponsivePage.d.ts +2 -2
  22. package/lib/mu/pages/ResponsivePageProps.d.ts +2 -2
  23. package/lib/mu/pages/TablePage.d.ts +2 -2
  24. package/lib/mu/pages/TablePageProps.d.ts +1 -1
  25. package/package.json +1 -1
  26. package/src/components/ScrollerGrid.tsx +3 -3
  27. package/src/mu/AutocompleteExtendedProps.ts +6 -7
  28. package/src/mu/ComboBox.tsx +20 -13
  29. package/src/mu/DataGridEx.tsx +3 -3
  30. package/src/mu/ItemList.tsx +28 -25
  31. package/src/mu/OptionGroup.tsx +26 -21
  32. package/src/mu/ResponsibleContainer.tsx +3 -3
  33. package/src/mu/ScrollerListEx.tsx +3 -3
  34. package/src/mu/SearchOptionGroup.tsx +11 -5
  35. package/src/mu/SelectBool.tsx +7 -14
  36. package/src/mu/SelectEx.tsx +25 -20
  37. package/src/mu/TableEx.tsx +9 -10
  38. package/src/mu/Tiplist.tsx +3 -3
  39. package/src/mu/pages/DataGridPage.tsx +2 -2
  40. package/src/mu/pages/DataGridPageProps.ts +2 -2
  41. package/src/mu/pages/FixedListPage.tsx +5 -4
  42. package/src/mu/pages/ListPage.tsx +5 -4
  43. package/src/mu/pages/ListPageProps.ts +3 -2
  44. package/src/mu/pages/ResponsivePage.tsx +2 -2
  45. package/src/mu/pages/ResponsivePageProps.ts +2 -2
  46. package/src/mu/pages/TablePage.tsx +5 -4
  47. package/src/mu/pages/TablePageProps.ts +3 -2
@@ -1,4 +1,10 @@
1
- import { DataTypes, Keyboard } from '@etsoo/shared';
1
+ import {
2
+ DataTypes,
3
+ IdDefaultType,
4
+ Keyboard,
5
+ LabelDefaultType,
6
+ ListType
7
+ } from '@etsoo/shared';
2
8
  import { Autocomplete, AutocompleteRenderInputParams } from '@mui/material';
3
9
  import React from 'react';
4
10
  import { Utils as SharedUtils } from '@etsoo/shared';
@@ -12,7 +18,8 @@ import { ReactUtils } from '../app/ReactUtils';
12
18
  */
13
19
  export type ComboBoxProps<
14
20
  T extends object,
15
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
21
+ D extends DataTypes.Keys<T>,
22
+ L extends DataTypes.Keys<T, string>
16
23
  > = AutocompleteExtendedProps<T, D> & {
17
24
  /**
18
25
  * Auto add blank item
@@ -24,6 +31,11 @@ export type ComboBoxProps<
24
31
  */
25
32
  dataReadonly?: boolean;
26
33
 
34
+ /**
35
+ * Label field
36
+ */
37
+ labelField?: L;
38
+
27
39
  /**
28
40
  * Load data callback
29
41
  */
@@ -38,13 +50,7 @@ export type ComboBoxProps<
38
50
  * Array of options.
39
51
  */
40
52
  options?: ReadonlyArray<T>;
41
- } & (T extends { label: string }
42
- ? {
43
- labelField?: D;
44
- }
45
- : {
46
- labelField: D;
47
- });
53
+ };
48
54
 
49
55
  /**
50
56
  * ComboBox
@@ -52,9 +58,10 @@ export type ComboBoxProps<
52
58
  * @returns Component
53
59
  */
54
60
  export function ComboBox<
55
- T extends object = DataTypes.IdLabelItem,
56
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
57
- >(props: ComboBoxProps<T, D>) {
61
+ T extends object = ListType,
62
+ D extends DataTypes.Keys<T> = IdDefaultType<T>,
63
+ L extends DataTypes.Keys<T, string> = LabelDefaultType<T>
64
+ >(props: ComboBoxProps<T, D, L>) {
58
65
  // Destruct
59
66
  const {
60
67
  search = false,
@@ -69,7 +76,7 @@ export function ComboBox<
69
76
  inputVariant,
70
77
  defaultValue,
71
78
  label,
72
- labelField = 'label' as D,
79
+ labelField = 'label' as L,
73
80
  loadData,
74
81
  onLoadData,
75
82
  name,
@@ -1,5 +1,5 @@
1
1
  import { css } from '@emotion/css';
2
- import { DataTypes, Utils } from '@etsoo/shared';
2
+ import { DataTypes, IdDefaultType, Utils } from '@etsoo/shared';
3
3
  import {
4
4
  Box,
5
5
  BoxProps,
@@ -43,7 +43,7 @@ export type DataGridExFooterItemRendererProps<T extends object> = {
43
43
  */
44
44
  export type DataGridExProps<
45
45
  T extends object,
46
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
46
+ D extends DataTypes.Keys<T>
47
47
  > = Omit<
48
48
  ScrollerGridProps<T, D>,
49
49
  'itemRenderer' | 'columnCount' | 'columnWidth' | 'width'
@@ -212,7 +212,7 @@ export function DataGridExCalColumns<T>(columns: GridColumn<T>[]) {
212
212
  */
213
213
  export function DataGridEx<
214
214
  T extends object,
215
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
215
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
216
216
  >(props: DataGridExProps<T, D>) {
217
217
  // Theme
218
218
  const theme = useTheme();
@@ -3,17 +3,26 @@ import {
3
3
  Dialog,
4
4
  DialogTitle,
5
5
  List,
6
- ListItem,
7
6
  ListItemText,
8
7
  DialogContent,
9
- Button
8
+ Button,
9
+ ListItemButton
10
10
  } from '@mui/material';
11
- import { DataTypes } from '@etsoo/shared';
11
+ import {
12
+ DataTypes,
13
+ IdDefaultType,
14
+ LabelDefaultType,
15
+ ListType
16
+ } from '@etsoo/shared';
12
17
 
13
18
  /**
14
19
  * Item list properties
15
20
  */
16
- export interface ItemListProps<T extends Record<string, unknown>> {
21
+ export interface ItemListProps<
22
+ T extends object,
23
+ D extends DataTypes.Keys<T>,
24
+ L extends DataTypes.Keys<T, string>
25
+ > {
17
26
  /**
18
27
  * Style class name
19
28
  */
@@ -22,12 +31,12 @@ export interface ItemListProps<T extends Record<string, unknown>> {
22
31
  /**
23
32
  * Id field name
24
33
  */
25
- idField?: string & keyof T;
34
+ idField?: D;
26
35
 
27
36
  /**
28
37
  * Label field name or callback
29
38
  */
30
- labelField?: (string & keyof T) | ((item: T) => string);
39
+ labelField?: L | ((item: T) => string);
31
40
 
32
41
  /**
33
42
  * Button icon
@@ -47,7 +56,7 @@ export interface ItemListProps<T extends Record<string, unknown>> {
47
56
  /**
48
57
  * Current selected language
49
58
  */
50
- selectedValue?: string;
59
+ selectedValue?: T[D];
51
60
 
52
61
  /**
53
62
  * Button size
@@ -75,15 +84,17 @@ export interface ItemListProps<T extends Record<string, unknown>> {
75
84
  * @param props Properties
76
85
  */
77
86
  export function ItemList<
78
- T extends Record<string, unknown> = Record<string, unknown>
79
- >(props: ItemListProps<T>) {
87
+ T extends object = ListType,
88
+ D extends DataTypes.Keys<T> = IdDefaultType<T>,
89
+ L extends DataTypes.Keys<T, string> = LabelDefaultType<T>
90
+ >(props: ItemListProps<T, D, L>) {
80
91
  // properties destructure
81
92
  const {
82
93
  className,
83
94
  color = 'primary',
84
95
  items,
85
- idField = 'id',
86
- labelField = 'label',
96
+ idField = 'id' as D,
97
+ labelField = 'label' as L,
87
98
  icon,
88
99
  onClose,
89
100
  selectedValue,
@@ -92,13 +103,6 @@ export function ItemList<
92
103
  variant = 'outlined'
93
104
  } = props;
94
105
 
95
- // Get id
96
- const getId = (item: T): string | number => {
97
- const id = item[idField];
98
- if (typeof id === 'number') return id;
99
- return DataTypes.convert(id, 'string') ?? '';
100
- };
101
-
102
106
  // Get label
103
107
  const getLabel = (item: T): string => {
104
108
  if (typeof labelField === 'function') {
@@ -113,7 +117,7 @@ export function ItemList<
113
117
 
114
118
  // Default state
115
119
  const defaultItem =
116
- items.find((item) => getId(item) === selectedValue) ?? items[0];
120
+ items.find((item) => item[idField] === selectedValue) ?? items[0];
117
121
 
118
122
  // Current item
119
123
  const [currentItem, setCurrentItem] = React.useState(defaultItem);
@@ -179,18 +183,17 @@ export function ItemList<
179
183
  <DialogContent>
180
184
  <List>
181
185
  {items.map((item) => {
182
- const id = getId(item);
186
+ const id = item[idField];
183
187
  return (
184
- <ListItem
185
- button
186
- key={id}
187
- disabled={id === getId(currentItem)}
188
+ <ListItemButton
189
+ key={id as unknown as React.Key}
190
+ disabled={id === currentItem[idField]}
188
191
  onClick={() => closeItemHandler(item)}
189
192
  >
190
193
  <ListItemText>
191
194
  {getLabel(item)}
192
195
  </ListItemText>
193
- </ListItem>
196
+ </ListItemButton>
194
197
  );
195
198
  })}
196
199
  </List>
@@ -1,4 +1,10 @@
1
- import { DataTypes, Utils } from '@etsoo/shared';
1
+ import {
2
+ DataTypes,
3
+ IdDefaultType,
4
+ LabelDefaultType,
5
+ ListType,
6
+ Utils
7
+ } from '@etsoo/shared';
2
8
  import {
3
9
  Checkbox,
4
10
  FormControl,
@@ -15,8 +21,9 @@ import React from 'react';
15
21
  * OptionGroup props
16
22
  */
17
23
  export type OptionGroupProps<
18
- T extends object = DataTypes.IdLabelItem,
19
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
24
+ T extends object,
25
+ D extends DataTypes.Keys<T>,
26
+ L extends DataTypes.Keys<T, string>
20
27
  > = Omit<FormControlProps<'fieldset'>, 'defaultValue'> & {
21
28
  /**
22
29
  * Default value
@@ -28,11 +35,21 @@ export type OptionGroupProps<
28
35
  */
29
36
  getOptionLabel?: (option: T) => string;
30
37
 
38
+ /**
39
+ * Id field
40
+ */
41
+ idField?: D;
42
+
31
43
  /**
32
44
  * Label
33
45
  */
34
46
  label?: string;
35
47
 
48
+ /**
49
+ * Label field
50
+ */
51
+ labelField?: L;
52
+
36
53
  /**
37
54
  * Multiple choose item
38
55
  */
@@ -62,20 +79,7 @@ export type OptionGroupProps<
62
79
  * Display group of elements in a compact row
63
80
  */
64
81
  row?: boolean;
65
- } & (T extends { id: DataTypes.IdType }
66
- ? {
67
- idField?: D;
68
- }
69
- : {
70
- idField: D;
71
- }) &
72
- (T extends { label: string }
73
- ? {
74
- labelField?: D;
75
- }
76
- : {
77
- labelField: D;
78
- });
82
+ };
79
83
 
80
84
  /**
81
85
  * OptionGroup
@@ -83,16 +87,17 @@ export type OptionGroupProps<
83
87
  * @returns Component
84
88
  */
85
89
  export function OptionGroup<
86
- T extends object = DataTypes.IdLabelItem,
87
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
88
- >(props: OptionGroupProps<T, D>) {
90
+ T extends object = ListType,
91
+ D extends DataTypes.Keys<T> = IdDefaultType<T>,
92
+ L extends DataTypes.Keys<T, string> = LabelDefaultType<T>
93
+ >(props: OptionGroupProps<T, D, L>) {
89
94
  // Destruct
90
95
  const {
91
96
  getOptionLabel,
92
97
  defaultValue,
93
98
  idField = 'id' as D,
94
99
  label,
95
- labelField = 'label' as D,
100
+ labelField = 'label' as L,
96
101
  multiple = false,
97
102
  name,
98
103
  onValueChange,
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, IdDefaultType } from '@etsoo/shared';
2
2
  import { Box, Stack, SxProps, Theme } from '@mui/material';
3
3
  import React from 'react';
4
4
  import { ListChildComponentProps } from 'react-window';
@@ -33,7 +33,7 @@ import { SearchBar } from './SearchBar';
33
33
  export type ResponsibleContainerProps<
34
34
  T extends object,
35
35
  F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
36
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
36
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
37
37
  > = Omit<
38
38
  DataGridExProps<T, D>,
39
39
  'height' | 'itemKey' | 'loadData' | 'mRef' | 'onScroll' | 'onItemsRendered'
@@ -160,7 +160,7 @@ function defaultContainerBoxSx(
160
160
  export function ResponsibleContainer<
161
161
  T extends object,
162
162
  F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
163
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
163
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
164
164
  >(props: ResponsibleContainerProps<T, F, D>) {
165
165
  // Destruct
166
166
  const {
@@ -1,5 +1,5 @@
1
1
  import { css } from '@emotion/css';
2
- import { DataTypes, Utils } from '@etsoo/shared';
2
+ import { DataTypes, IdDefaultType, Utils } from '@etsoo/shared';
3
3
  import { useTheme } from '@mui/material';
4
4
  import React from 'react';
5
5
  import { ListChildComponentProps } from 'react-window';
@@ -119,7 +119,7 @@ export type ScrollerListExItemSize =
119
119
  */
120
120
  export type ScrollerListExProps<
121
121
  T extends object,
122
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
122
+ D extends DataTypes.Keys<T>
123
123
  > = Omit<ScrollerListProps<T>, 'itemRenderer' | 'itemSize'> & {
124
124
  /**
125
125
  * Alternating colors for odd/even rows
@@ -265,7 +265,7 @@ function defaultItemRenderer<T>({
265
265
  */
266
266
  export function ScrollerListEx<
267
267
  T extends object,
268
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
268
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
269
269
  >(props: ScrollerListExProps<T, D>) {
270
270
  // Selected item ref
271
271
  const selectedItem = React.useRef<[HTMLDivElement, T]>();
@@ -1,4 +1,9 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import {
2
+ DataTypes,
3
+ IdDefaultType,
4
+ LabelDefaultType,
5
+ ListType
6
+ } from '@etsoo/shared';
2
7
  import React from 'react';
3
8
  import { MUGlobal } from './MUGlobal';
4
9
  import { OptionGroup, OptionGroupProps } from './OptionGroup';
@@ -9,9 +14,10 @@ import { OptionGroup, OptionGroupProps } from './OptionGroup';
9
14
  * @returns Component
10
15
  */
11
16
  export function SearchOptionGroup<
12
- T extends object = DataTypes.IdLabelItem,
13
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
14
- >(props: OptionGroupProps<T, D>) {
17
+ T extends object = ListType,
18
+ D extends DataTypes.Keys<T> = IdDefaultType<T>,
19
+ L extends DataTypes.Keys<T, string> = LabelDefaultType<T>
20
+ >(props: OptionGroupProps<T, D, L>) {
15
21
  // Destruct
16
22
  const {
17
23
  row = true,
@@ -21,5 +27,5 @@ export function SearchOptionGroup<
21
27
  } = props;
22
28
 
23
29
  // Layout
24
- return <OptionGroup<T, D> row={row} size={size} sx={sx} {...rest} />;
30
+ return <OptionGroup<T, D, L> row={row} size={size} sx={sx} {...rest} />;
25
31
  }
@@ -1,4 +1,4 @@
1
- import { DataTypes, Utils } from '@etsoo/shared';
1
+ import { ListType1, Utils } from '@etsoo/shared';
2
2
  import React from 'react';
3
3
  import { globalApp } from '..';
4
4
  import { SelectEx, SelectExProps } from './SelectEx';
@@ -6,11 +6,10 @@ import { SelectEx, SelectExProps } from './SelectEx';
6
6
  /**
7
7
  * SelectBool props
8
8
  */
9
- export interface SelectBoolProps
10
- extends Omit<
11
- SelectExProps<DataTypes.IdLabelItem<string>>,
12
- 'options' | 'loadData'
13
- > {}
9
+ export type SelectBoolProps = Omit<
10
+ SelectExProps<ListType1>,
11
+ 'options' | 'loadData'
12
+ >;
14
13
 
15
14
  /**
16
15
  * SelectBool (yes/no)
@@ -22,7 +21,7 @@ export function SelectBool(props: SelectBoolProps) {
22
21
  const { search = true, autoAddBlankItem = search, ...rest } = props;
23
22
 
24
23
  // Options
25
- const options: DataTypes.IdLabelItem<string>[] = [
24
+ const options: ListType1[] = [
26
25
  { id: 'false', label: globalApp.get('no')! },
27
26
  { id: 'true', label: globalApp.get('yes')! }
28
27
  ];
@@ -30,11 +29,5 @@ export function SelectBool(props: SelectBoolProps) {
30
29
  if (autoAddBlankItem) Utils.addBlankItem(options);
31
30
 
32
31
  // Layout
33
- return (
34
- <SelectEx<DataTypes.IdLabelItem<string>>
35
- options={options}
36
- search={search}
37
- {...rest}
38
- />
39
- );
32
+ return <SelectEx<ListType1> options={options} search={search} {...rest} />;
40
33
  }
@@ -12,7 +12,13 @@ import {
12
12
  import React from 'react';
13
13
  import { MUGlobal } from './MUGlobal';
14
14
  import { ListItemRightIcon } from './ListItemRightIcon';
15
- import { DataTypes, Utils } from '@etsoo/shared';
15
+ import {
16
+ DataTypes,
17
+ IdDefaultType,
18
+ LabelDefaultType,
19
+ ListType,
20
+ Utils
21
+ } from '@etsoo/shared';
16
22
  import { ReactUtils } from '../app/ReactUtils';
17
23
 
18
24
  /**
@@ -20,18 +26,29 @@ import { ReactUtils } from '../app/ReactUtils';
20
26
  */
21
27
  export type SelectExProps<
22
28
  T extends object,
23
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
29
+ D extends DataTypes.Keys<T> = IdDefaultType<T>,
30
+ L extends DataTypes.Keys<T, string> = LabelDefaultType<T>
24
31
  > = Omit<SelectProps, 'labelId' | 'input' | 'native'> & {
25
32
  /**
26
33
  * Auto add blank item
27
34
  */
28
35
  autoAddBlankItem?: boolean;
29
36
 
37
+ /**
38
+ * Id field
39
+ */
40
+ idField?: D;
41
+
30
42
  /**
31
43
  * Item icon renderer
32
44
  */
33
45
  itemIconRenderer?: (id: unknown) => React.ReactNode;
34
46
 
47
+ /**
48
+ * Label field
49
+ */
50
+ labelField?: L | ((option: T) => string);
51
+
35
52
  /**
36
53
  * Load data callback
37
54
  */
@@ -56,20 +73,7 @@ export type SelectExProps<
56
73
  * Is search case?
57
74
  */
58
75
  search?: boolean;
59
- } & (T extends { id: DataTypes.IdType }
60
- ? {
61
- idField?: D;
62
- }
63
- : {
64
- idField: D;
65
- }) &
66
- (T extends { label: string }
67
- ? {
68
- labelField?: ((option: T) => string) | D;
69
- }
70
- : {
71
- labelField: ((option: T) => string) | D;
72
- });
76
+ };
73
77
 
74
78
  /**
75
79
  * Extended select component
@@ -77,16 +81,17 @@ export type SelectExProps<
77
81
  * @returns Component
78
82
  */
79
83
  export function SelectEx<
80
- T extends object = DataTypes.IdLabelItem,
81
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
82
- >(props: SelectExProps<T, D>) {
84
+ T extends object = ListType,
85
+ D extends DataTypes.Keys<T> = IdDefaultType<T>,
86
+ L extends DataTypes.Keys<T, string> = LabelDefaultType<T>
87
+ >(props: SelectExProps<T, D, L>) {
83
88
  // Destruct
84
89
  const {
85
90
  defaultValue,
86
91
  idField = 'id' as D,
87
92
  itemIconRenderer,
88
93
  label,
89
- labelField = 'label' as D,
94
+ labelField = 'label' as L,
90
95
  loadData,
91
96
  onItemClick,
92
97
  onLoadData,
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, IdDefaultType } from '@etsoo/shared';
2
2
  import {
3
3
  Checkbox,
4
4
  Paper,
@@ -49,7 +49,7 @@ export interface TableExMethodRef extends GridMethodRef {
49
49
  */
50
50
  export type TableExProps<
51
51
  T extends object,
52
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
52
+ D extends DataTypes.Keys<T>
53
53
  > = TableProps &
54
54
  GridLoader<T> & {
55
55
  /**
@@ -67,6 +67,11 @@ export type TableExProps<
67
67
  */
68
68
  headerColors?: [string?, string?];
69
69
 
70
+ /**
71
+ * Id field
72
+ */
73
+ idField?: D;
74
+
70
75
  /**
71
76
  * Max height
72
77
  */
@@ -91,13 +96,7 @@ export type TableExProps<
91
96
  * Header and bottom height
92
97
  */
93
98
  otherHeight?: number;
94
- } & (T extends { id: DataTypes.IdType }
95
- ? {
96
- idField?: D;
97
- }
98
- : {
99
- idField: D;
100
- });
99
+ };
101
100
 
102
101
  /**
103
102
  * Extended Table
@@ -106,7 +105,7 @@ export type TableExProps<
106
105
  */
107
106
  export function TableEx<
108
107
  T extends object,
109
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
108
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
110
109
  >(props: TableExProps<T, D>) {
111
110
  // Theme
112
111
  const theme = useTheme();
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, IdDefaultType, ListType } from '@etsoo/shared';
2
2
  import { Autocomplete, AutocompleteRenderInputParams } from '@mui/material';
3
3
  import React from 'react';
4
4
  import { ReactUtils } from '../app/ReactUtils';
@@ -37,8 +37,8 @@ interface States<T extends object> {
37
37
  * @returns Component
38
38
  */
39
39
  export function Tiplist<
40
- T extends object = DataTypes.IdLabelItem,
41
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
40
+ T extends object = ListType,
41
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
42
42
  >(props: TiplistProps<T, D>) {
43
43
  // Destruct
44
44
  const {
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, IdDefaultType } from '@etsoo/shared';
2
2
  import { Box, Stack } from '@mui/material';
3
3
  import React from 'react';
4
4
  import { GridDataGet, GridLoadDataProps } from '../../components/GridLoader';
@@ -26,7 +26,7 @@ interface LocalStates {
26
26
  export function DataGridPage<
27
27
  T extends object,
28
28
  F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
29
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
29
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
30
30
  >(props: DataGridPageProps<T, F, D>) {
31
31
  // Destruct
32
32
  const {
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, IdDefaultType } from '@etsoo/shared';
2
2
  import { DataGridExProps } from '../DataGridEx';
3
3
  import { SearchPageProps } from './SearchPageProps';
4
4
 
@@ -8,7 +8,7 @@ import { SearchPageProps } from './SearchPageProps';
8
8
  export type DataGridPageProps<
9
9
  T extends object,
10
10
  F extends DataTypes.BasicTemplate,
11
- D extends DataTypes.Keys<T> = DataTypes.Keys<T>
11
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
12
12
  > = SearchPageProps<T, F> &
13
13
  Omit<DataGridExProps<T, D>, 'loadData' | 'height'> & {
14
14
  /**
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, IdDefaultType } from '@etsoo/shared';
2
2
  import { Box, Stack } from '@mui/material';
3
3
  import React from 'react';
4
4
  import { GridDataGet, GridLoadDataProps } from '../../components/GridLoader';
@@ -18,9 +18,10 @@ import { ListPageProps } from './ListPageProps';
18
18
  */
19
19
  export function FixedListPage<
20
20
  T extends object,
21
- F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
21
+ F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
22
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
22
23
  >(
23
- props: ListPageProps<T, F> & {
24
+ props: ListPageProps<T, F, D> & {
24
25
  /**
25
26
  * Height will be deducted
26
27
  * @param height Current calcuated height
@@ -99,7 +100,7 @@ export function FixedListPage<
99
100
  height: height + 'px'
100
101
  }}
101
102
  >
102
- <ScrollerListEx<T>
103
+ <ScrollerListEx<T, D>
103
104
  autoLoad={false}
104
105
  height={height}
105
106
  loadData={localLoadData}
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, IdDefaultType } from '@etsoo/shared';
2
2
  import { Box, Stack } from '@mui/material';
3
3
  import React from 'react';
4
4
  import { GridDataGet, GridLoadDataProps } from '../../components/GridLoader';
@@ -17,8 +17,9 @@ import { ListPageProps } from './ListPageProps';
17
17
  */
18
18
  export function ListPage<
19
19
  T extends object,
20
- F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
21
- >(props: ListPageProps<T, F>) {
20
+ F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
21
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
22
+ >(props: ListPageProps<T, F, D>) {
22
23
  // Destruct
23
24
  const {
24
25
  fields,
@@ -74,7 +75,7 @@ export function ListPage<
74
75
  >
75
76
  <SearchBar fields={fields} onSubmit={onSubmit} />
76
77
  </Box>
77
- <ScrollerListEx<T>
78
+ <ScrollerListEx<T, D>
78
79
  autoLoad={false}
79
80
  loadData={localLoadData}
80
81
  mRef={refs}