@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
@@ -10,10 +10,10 @@ import { ReactUtils } from '../app/ReactUtils';
10
10
  /**
11
11
  * ComboBox props
12
12
  */
13
- export interface ComboBoxProps<
14
- T extends {},
13
+ export type ComboBoxProps<
14
+ T extends object,
15
15
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
16
- > extends AutocompleteExtendedProps<T, D> {
16
+ > = AutocompleteExtendedProps<T, D> & {
17
17
  /**
18
18
  * Auto add blank item
19
19
  */
@@ -24,11 +24,6 @@ export interface ComboBoxProps<
24
24
  */
25
25
  dataReadonly?: boolean;
26
26
 
27
- /**
28
- * Label field
29
- */
30
- labelField: T extends DataTypes.IdLabelItem ? D | undefined : D;
31
-
32
27
  /**
33
28
  * Load data callback
34
29
  */
@@ -43,7 +38,13 @@ export interface ComboBoxProps<
43
38
  * Array of options.
44
39
  */
45
40
  options?: ReadonlyArray<T>;
46
- }
41
+ } & (T extends { label: string }
42
+ ? {
43
+ labelField?: D;
44
+ }
45
+ : {
46
+ labelField: D;
47
+ });
47
48
 
48
49
  /**
49
50
  * ComboBox
@@ -51,7 +52,7 @@ export interface ComboBoxProps<
51
52
  * @returns Component
52
53
  */
53
54
  export function ComboBox<
54
- T extends {} = DataTypes.IdLabelItem,
55
+ T extends object = DataTypes.IdLabelItem,
55
56
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
56
57
  >(props: ComboBoxProps<T, D>) {
57
58
  // Destruct
@@ -194,7 +195,7 @@ export function ComboBox<
194
195
  onChange={inputOnChange}
195
196
  />
196
197
  {/* Previous input will reset first with "disableClearable = false", next input trigger change works */}
197
- <Autocomplete
198
+ <Autocomplete<T, undefined, false, false>
198
199
  value={stateValue}
199
200
  getOptionLabel={getOptionLabel}
200
201
  isOptionEqualToValue={(option: T, value: T) =>
@@ -30,24 +30,24 @@ import { MouseEventWithDataHandler } from './MUGlobal';
30
30
  /**
31
31
  * Footer item renderer props
32
32
  */
33
- export interface DataGridExFooterItemRendererProps<T extends {}> {
33
+ export type DataGridExFooterItemRendererProps<T extends object> = {
34
34
  column: GridColumn<T>;
35
35
  index: number;
36
36
  states: GridLoaderStates<T>;
37
37
  cellProps: any;
38
38
  checkable: boolean;
39
- }
39
+ };
40
40
 
41
41
  /**
42
42
  * Extended DataGrid with VariableSizeGrid props
43
43
  */
44
- export interface DataGridExProps<
45
- T extends {},
44
+ export type DataGridExProps<
45
+ T extends object,
46
46
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
47
- > extends Omit<
48
- ScrollerGridProps<T, D>,
49
- 'itemRenderer' | 'columnCount' | 'columnWidth' | 'width'
50
- > {
47
+ > = Omit<
48
+ ScrollerGridProps<T, D>,
49
+ 'itemRenderer' | 'columnCount' | 'columnWidth' | 'width'
50
+ > & {
51
51
  /**
52
52
  * Alternating colors for odd/even rows
53
53
  */
@@ -124,7 +124,7 @@ export interface DataGridExProps<
124
124
  * Width
125
125
  */
126
126
  width?: number;
127
- }
127
+ };
128
128
 
129
129
  // Borders
130
130
  const boldBorder = '2px solid rgba(224, 224, 224, 1)';
@@ -211,7 +211,7 @@ export function DataGridExCalColumns<T>(columns: GridColumn<T>[]) {
211
211
  * @returns Component
212
212
  */
213
213
  export function DataGridEx<
214
- T extends {},
214
+ T extends object,
215
215
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
216
216
  >(props: DataGridExProps<T, D>) {
217
217
  // Theme
@@ -443,7 +443,7 @@ export function DataGridEx<
443
443
  };
444
444
 
445
445
  // Reset
446
- const reset = (add: {}) => {
446
+ const reset = (add: object) => {
447
447
  refs.current.ref?.reset(add);
448
448
  };
449
449
 
@@ -633,7 +633,7 @@ export function DataGridEx<
633
633
  : undefined;
634
634
 
635
635
  return (
636
- <ScrollerGrid<T>
636
+ <ScrollerGrid<T, D>
637
637
  className={Utils.mergeClasses(
638
638
  'DataGridEx-Body',
639
639
  'DataGridEx-CustomBar',
@@ -117,7 +117,7 @@ export namespace DataGridRenderers {
117
117
  * @param location Renderer location (column index)
118
118
  * @returns Component
119
119
  */
120
- export function defaultFooterItemRenderer<T>(
120
+ export function defaultFooterItemRenderer<T extends object>(
121
121
  _rows: T[],
122
122
  { index, states, checkable }: DataGridExFooterItemRendererProps<T>,
123
123
  location: number = 0
@@ -79,7 +79,7 @@ export const DnDItemStyle = (
79
79
  /**
80
80
  * DnD list forward ref
81
81
  */
82
- export interface DnDListRef<D extends {}> {
82
+ export interface DnDListRef<D extends object> {
83
83
  /**
84
84
  * Add item
85
85
  * @param item New item
@@ -109,7 +109,7 @@ export interface DnDListRef<D extends {}> {
109
109
  /**
110
110
  * DnD sortable list properties
111
111
  */
112
- export interface DnDListPros<D extends {}, K extends DataTypes.Keys<D>> {
112
+ export interface DnDListPros<D extends object, K extends DataTypes.Keys<D>> {
113
113
  /**
114
114
  * Get list item style callback
115
115
  */
@@ -22,7 +22,7 @@ import { LoadingButton } from './LoadingButton';
22
22
  * ListMoreDisplay props
23
23
  */
24
24
  export interface ListMoreDisplayProps<
25
- T,
25
+ T extends object,
26
26
  F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
27
27
  > extends Omit<CardProps, 'children'>,
28
28
  GridLoader<T> {
@@ -63,7 +63,7 @@ type states<T> = {
63
63
  * @returns Component
64
64
  */
65
65
  export function ListMoreDisplay<
66
- T extends {},
66
+ T extends object,
67
67
  F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
68
68
  >(props: ListMoreDisplayProps<T, F>) {
69
69
  // Destruct
@@ -92,7 +92,7 @@ export class MUGlobal {
92
92
  * @param input Input object
93
93
  * @returns Updated object
94
94
  */
95
- static half(input: {}) {
95
+ static half(input: object) {
96
96
  const newObj = { ...input };
97
97
  Object.entries(newObj).forEach(([key, value]) => {
98
98
  if (typeof value === 'number') {
@@ -107,7 +107,7 @@ export class MUGlobal {
107
107
  * @param input Input object
108
108
  * @returns Updated object
109
109
  */
110
- static reverse(input: {}) {
110
+ static reverse(input: object) {
111
111
  const newObj = { ...input };
112
112
  Object.entries(newObj).forEach(([key, value]) => {
113
113
  if (typeof value === 'number') {
@@ -124,7 +124,7 @@ export class MUGlobal {
124
124
  * @param field Specific field
125
125
  * @returns Updated object
126
126
  */
127
- static increase(input: {}, adjust: number | {}, field?: string) {
127
+ static increase(input: object, adjust: number | object, field?: string) {
128
128
  const newObj = { ...input };
129
129
  Object.entries(newObj).forEach(([key, value]) => {
130
130
  if (typeof value === 'number') {
@@ -152,7 +152,7 @@ export class MUGlobal {
152
152
  */
153
153
  static adjustWithTheme(
154
154
  size: number,
155
- adjust: {},
155
+ adjust: object,
156
156
  updateFunc: (value: number) => string
157
157
  ) {
158
158
  const newObj = { ...adjust };
@@ -185,7 +185,7 @@ export class MUGlobal {
185
185
  * @param theme Theme
186
186
  * @returns Result
187
187
  */
188
- static getSpace(spaces: {}, theme: Theme) {
188
+ static getSpace(spaces: object, theme: Theme) {
189
189
  const start = this.breakpoints.length - 1;
190
190
  for (let i = start; i >= 0; i--) {
191
191
  const key = this.breakpoints[i];
@@ -14,10 +14,10 @@ import React from 'react';
14
14
  /**
15
15
  * OptionGroup props
16
16
  */
17
- export interface OptionGroupProps<
18
- T extends {} = DataTypes.IdLabelItem,
17
+ export type OptionGroupProps<
18
+ T extends object = DataTypes.IdLabelItem,
19
19
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
20
- > extends Omit<FormControlProps<'fieldset'>, 'defaultValue'> {
20
+ > = Omit<FormControlProps<'fieldset'>, 'defaultValue'> & {
21
21
  /**
22
22
  * Default value
23
23
  */
@@ -28,21 +28,11 @@ export interface OptionGroupProps<
28
28
  */
29
29
  getOptionLabel?: (option: T) => string;
30
30
 
31
- /**
32
- * Id field, default is id
33
- */
34
- idField: T extends DataTypes.IdLabelItem ? D | undefined : D;
35
-
36
31
  /**
37
32
  * Label
38
33
  */
39
34
  label?: string;
40
35
 
41
- /**
42
- * Label field, default is label
43
- */
44
- labelField: T extends DataTypes.IdLabelItem ? D | undefined : D;
45
-
46
36
  /**
47
37
  * Multiple choose item
48
38
  */
@@ -72,7 +62,20 @@ export interface OptionGroupProps<
72
62
  * Display group of elements in a compact row
73
63
  */
74
64
  row?: boolean;
75
- }
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
+ });
76
79
 
77
80
  /**
78
81
  * OptionGroup
@@ -80,7 +83,7 @@ export interface OptionGroupProps<
80
83
  * @returns Component
81
84
  */
82
85
  export function OptionGroup<
83
- T extends {} = DataTypes.IdLabelItem,
86
+ T extends object = DataTypes.IdLabelItem,
84
87
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
85
88
  >(props: OptionGroupProps<T, D>) {
86
89
  // Destruct
@@ -30,19 +30,14 @@ import { SearchBar } from './SearchBar';
30
30
  /**
31
31
  * ResponsibleContainer props
32
32
  */
33
- export interface ResponsibleContainerProps<
34
- T extends {},
33
+ export type ResponsibleContainerProps<
34
+ T extends object,
35
35
  F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
36
36
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
37
- > extends Omit<
38
- DataGridExProps<T, D>,
39
- | 'height'
40
- | 'itemKey'
41
- | 'loadData'
42
- | 'mRef'
43
- | 'onScroll'
44
- | 'onItemsRendered'
45
- > {
37
+ > = Omit<
38
+ DataGridExProps<T, D>,
39
+ 'height' | 'itemKey' | 'loadData' | 'mRef' | 'onScroll' | 'onItemsRendered'
40
+ > & {
46
41
  /**
47
42
  * Height will be deducted
48
43
  * @param height Current calcuated height
@@ -58,7 +53,7 @@ export interface ResponsibleContainerProps<
58
53
  * Container box SX (dataGrid determines the case)
59
54
  */
60
55
  containerBoxSx?: (
61
- paddings: {},
56
+ paddings: Record<string, string | number>,
62
57
  hasFields: boolean,
63
58
  dataGrid?: boolean
64
59
  ) => SxProps<Theme>;
@@ -120,7 +115,7 @@ export interface ResponsibleContainerProps<
120
115
  /**
121
116
  * Paddings
122
117
  */
123
- paddings?: {};
118
+ paddings?: Record<string, string | number>;
124
119
 
125
120
  /**
126
121
  * Pull to refresh data
@@ -136,7 +131,7 @@ export interface ResponsibleContainerProps<
136
131
  * Size ready to read miliseconds span
137
132
  */
138
133
  sizeReadyMiliseconds?: number;
139
- }
134
+ };
140
135
 
141
136
  interface LocalRefs {
142
137
  rect?: DOMRect;
@@ -145,7 +140,7 @@ interface LocalRefs {
145
140
  }
146
141
 
147
142
  function defaultContainerBoxSx(
148
- paddings: {},
143
+ paddings: object,
149
144
  hasField: boolean,
150
145
  _dataGrid?: boolean
151
146
  ): SxProps<Theme> {
@@ -163,7 +158,7 @@ function defaultContainerBoxSx(
163
158
  * @returns Layout
164
159
  */
165
160
  export function ResponsibleContainer<
166
- T extends {},
161
+ T extends object,
167
162
  F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
168
163
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
169
164
  >(props: ResponsibleContainerProps<T, F, D>) {
@@ -288,7 +283,7 @@ export function ResponsibleContainer<
288
283
 
289
284
  return [
290
285
  <Box className="DataGridBox">
291
- <DataGridEx<T>
286
+ <DataGridEx<T, D>
292
287
  autoLoad={!hasFields}
293
288
  height={heightLocal}
294
289
  width={rect.width}
@@ -47,7 +47,7 @@ const createGridStyle = (
47
47
  };
48
48
 
49
49
  // Default margin
50
- const defaultMargin = (margin: {}, isNarrow?: boolean) => {
50
+ const defaultMargin = (margin: object, isNarrow?: boolean) => {
51
51
  const half = MUGlobal.half(margin);
52
52
 
53
53
  if (isNarrow == null) {
@@ -100,7 +100,7 @@ export interface ScrollerListExInnerItemRendererProps<T>
100
100
  /**
101
101
  * Default margins
102
102
  */
103
- margins: {};
103
+ margins: object;
104
104
  }
105
105
 
106
106
  /**
@@ -110,27 +110,22 @@ export interface ScrollerListExInnerItemRendererProps<T>
110
110
  * 3. Dynamic calculation
111
111
  */
112
112
  export type ScrollerListExItemSize =
113
- | ((index: number) => [number, number] | [number, number, {}])
113
+ | ((index: number) => [number, number] | [number, number, object])
114
114
  | [number, number]
115
- | [number, {}, boolean?];
115
+ | [number, object, boolean?];
116
116
 
117
117
  /**
118
118
  * Extended ScrollerList Props
119
119
  */
120
- export interface ScrollerListExProps<
121
- T extends {},
120
+ export type ScrollerListExProps<
121
+ T extends object,
122
122
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
123
- > extends Omit<ScrollerListProps<T>, 'itemRenderer' | 'itemSize'> {
123
+ > = Omit<ScrollerListProps<T>, 'itemRenderer' | 'itemSize'> & {
124
124
  /**
125
125
  * Alternating colors for odd/even rows
126
126
  */
127
127
  alternatingColors?: [string?, string?];
128
128
 
129
- /**
130
- * Id field
131
- */
132
- idField?: D;
133
-
134
129
  /**
135
130
  * Inner item renderer
136
131
  */
@@ -143,6 +138,12 @@ export interface ScrollerListExProps<
143
138
  */
144
139
  itemRenderer?: (props: ListChildComponentProps<T>) => React.ReactElement;
145
140
 
141
+ /**
142
+ * Id field
143
+ * Failed: D extends { id: DataTypes.IdType } ? { idField?: D } : { idField: D }
144
+ */
145
+ idField?: D;
146
+
146
147
  /**
147
148
  * Item size, a function indicates its a variable size list
148
149
  */
@@ -167,7 +168,7 @@ export interface ScrollerListExProps<
167
168
  * Selected color
168
169
  */
169
170
  selectedColor?: string;
170
- }
171
+ };
171
172
 
172
173
  interface defaultItemRendererProps<T> extends ListChildComponentProps<T> {
173
174
  /**
@@ -205,7 +206,7 @@ interface defaultItemRendererProps<T> extends ListChildComponentProps<T> {
205
206
  /**
206
207
  * Default margins
207
208
  */
208
- margins: {};
209
+ margins: object;
209
210
 
210
211
  /**
211
212
  * Item selected
@@ -263,7 +264,7 @@ function defaultItemRenderer<T>({
263
264
  * @returns Component
264
265
  */
265
266
  export function ScrollerListEx<
266
- T extends {},
267
+ T extends object,
267
268
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
268
269
  >(props: ScrollerListExProps<T, D>) {
269
270
  // Selected item ref
@@ -331,7 +332,7 @@ export function ScrollerListEx<
331
332
 
332
333
  // Cache calculation
333
334
  const itemSizeResult = React.useMemo(():
334
- | [number, number, {}]
335
+ | [number, number, object]
335
336
  | undefined => {
336
337
  if (typeof itemSize === 'function') return undefined;
337
338
  const [size, spaces, isNarrow] = itemSize;
@@ -350,7 +351,7 @@ export function ScrollerListEx<
350
351
  }, [itemSize]);
351
352
 
352
353
  // Calculate size
353
- const calculateItemSize = (index: number): [number, number, {}] => {
354
+ const calculateItemSize = (index: number): [number, number, object] => {
354
355
  // Callback function
355
356
  if (typeof itemSize === 'function') {
356
357
  const result = itemSize(index);
@@ -9,7 +9,7 @@ import { OptionGroup, OptionGroupProps } from './OptionGroup';
9
9
  * @returns Component
10
10
  */
11
11
  export function SearchOptionGroup<
12
- T extends {} = DataTypes.IdLabelItem,
12
+ T extends object = DataTypes.IdLabelItem,
13
13
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
14
14
  >(props: OptionGroupProps<T, D>) {
15
15
  // Destruct
@@ -18,32 +18,20 @@ import { ReactUtils } from '../app/ReactUtils';
18
18
  /**
19
19
  * Extended select component props
20
20
  */
21
- export interface SelectExProps<
22
- T extends {},
21
+ export type SelectExProps<
22
+ T extends object,
23
23
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
24
- > extends Omit<SelectProps, 'labelId' | 'input' | 'native'> {
24
+ > = Omit<SelectProps, 'labelId' | 'input' | 'native'> & {
25
25
  /**
26
26
  * Auto add blank item
27
27
  */
28
28
  autoAddBlankItem?: boolean;
29
29
 
30
- /**
31
- * Id field
32
- */
33
- idField: T extends DataTypes.IdLabelItem ? D | undefined : D;
34
-
35
30
  /**
36
31
  * Item icon renderer
37
32
  */
38
33
  itemIconRenderer?: (id: unknown) => React.ReactNode;
39
34
 
40
- /**
41
- * Label field
42
- */
43
- labelField:
44
- | ((option: T) => string)
45
- | (T extends DataTypes.IdLabelItem ? D | undefined : D);
46
-
47
35
  /**
48
36
  * Load data callback
49
37
  */
@@ -68,7 +56,20 @@ export interface SelectExProps<
68
56
  * Is search case?
69
57
  */
70
58
  search?: boolean;
71
- }
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
+ });
72
73
 
73
74
  /**
74
75
  * Extended select component
@@ -76,7 +77,7 @@ export interface SelectExProps<
76
77
  * @returns Component
77
78
  */
78
79
  export function SelectEx<
79
- T extends {} = DataTypes.IdLabelItem,
80
+ T extends object = DataTypes.IdLabelItem,
80
81
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
81
82
  >(props: SelectExProps<T, D>) {
82
83
  // Destruct
@@ -47,56 +47,57 @@ export interface TableExMethodRef extends GridMethodRef {
47
47
  /**
48
48
  * Extended table props
49
49
  */
50
- export interface TableExProps<
51
- T extends {},
50
+ export type TableExProps<
51
+ T extends object,
52
52
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
53
- > extends TableProps,
54
- GridLoader<T> {
55
- /**
56
- * Alternating colors for odd/even rows
57
- */
58
- alternatingColors?: [string?, string?];
59
-
60
- /**
61
- * Columns
62
- */
63
- columns: GridColumn<T>[];
64
-
65
- /**
66
- * Header cells background color and font color
67
- */
68
- headerColors?: [string?, string?];
69
-
70
- /**
71
- * Id field
72
- */
73
- idField?: D;
74
-
75
- /**
76
- * Max height
77
- */
78
- maxHeight?: number;
79
-
80
- /**
81
- * Methods
82
- */
83
- mRef?: React.Ref<TableExMethodRef>;
84
-
85
- /**
86
- * On items select change
87
- */
88
- onSelectChange?: (selectedItems: T[]) => void;
89
-
90
- /**
91
- * Row height
92
- */
93
- rowHeight?: number;
94
-
95
- /**
96
- * Header and bottom height
97
- */
98
- otherHeight?: number;
99
- }
53
+ > = TableProps &
54
+ GridLoader<T> & {
55
+ /**
56
+ * Alternating colors for odd/even rows
57
+ */
58
+ alternatingColors?: [string?, string?];
59
+
60
+ /**
61
+ * Columns
62
+ */
63
+ columns: GridColumn<T>[];
64
+
65
+ /**
66
+ * Header cells background color and font color
67
+ */
68
+ headerColors?: [string?, string?];
69
+
70
+ /**
71
+ * Max height
72
+ */
73
+ maxHeight?: number;
74
+
75
+ /**
76
+ * Methods
77
+ */
78
+ mRef?: React.Ref<TableExMethodRef>;
79
+
80
+ /**
81
+ * On items select change
82
+ */
83
+ onSelectChange?: (selectedItems: T[]) => void;
84
+
85
+ /**
86
+ * Row height
87
+ */
88
+ rowHeight?: number;
89
+
90
+ /**
91
+ * Header and bottom height
92
+ */
93
+ otherHeight?: number;
94
+ } & (T extends { id: DataTypes.IdType }
95
+ ? {
96
+ idField?: D;
97
+ }
98
+ : {
99
+ idField: D;
100
+ });
100
101
 
101
102
  /**
102
103
  * Extended Table
@@ -104,7 +105,7 @@ export interface TableExProps<
104
105
  * @returns Component
105
106
  */
106
107
  export function TableEx<
107
- T extends {},
108
+ T extends object,
108
109
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
109
110
  >(props: TableExProps<T, D>) {
110
111
  // Theme