@etsoo/react 1.5.75 → 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 (80) 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 +7 -7
  7. package/lib/components/ScrollerList.d.ts +2 -2
  8. package/lib/mu/AutocompleteExtendedProps.d.ts +9 -7
  9. package/lib/mu/ComboBox.d.ts +10 -8
  10. package/lib/mu/ComboBox.js +6 -6
  11. package/lib/mu/DataGridEx.d.ts +6 -5
  12. package/lib/mu/DataGridRenderers.d.ts +1 -1
  13. package/lib/mu/DnDList.d.ts +2 -2
  14. package/lib/mu/ListMoreDisplay.d.ts +2 -2
  15. package/lib/mu/MUGlobal.d.ts +5 -5
  16. package/lib/mu/OptionGroup.d.ts +17 -14
  17. package/lib/mu/ResponsibleContainer.d.ts +5 -5
  18. package/lib/mu/ScrollerListEx.d.ts +11 -9
  19. package/lib/mu/ScrollerListEx.js +1 -1
  20. package/lib/mu/SearchOptionGroup.d.ts +1 -2
  21. package/lib/mu/SelectBool.d.ts +2 -2
  22. package/lib/mu/SelectBool.js +1 -1
  23. package/lib/mu/SelectEx.d.ts +16 -12
  24. package/lib/mu/SelectEx.js +2 -2
  25. package/lib/mu/TableEx.d.ts +10 -7
  26. package/lib/mu/TableEx.js +1 -2
  27. package/lib/mu/Tiplist.d.ts +4 -5
  28. package/lib/mu/Tiplist.js +4 -6
  29. package/lib/mu/pages/CommonPageProps.d.ts +1 -1
  30. package/lib/mu/pages/DataGridPage.d.ts +1 -1
  31. package/lib/mu/pages/DataGridPageProps.d.ts +2 -2
  32. package/lib/mu/pages/FixedListPage.d.ts +1 -1
  33. package/lib/mu/pages/ListPage.d.ts +1 -1
  34. package/lib/mu/pages/ListPageProps.d.ts +1 -2
  35. package/lib/mu/pages/ResponsivePage.d.ts +1 -1
  36. package/lib/mu/pages/ResponsivePageProps.d.ts +2 -2
  37. package/lib/mu/pages/SearchPageProps.d.ts +2 -2
  38. package/lib/mu/pages/TablePage.d.ts +1 -1
  39. package/lib/mu/pages/TablePageProps.d.ts +1 -2
  40. package/lib/mu/pages/ViewPage.d.ts +5 -4
  41. package/lib/states/IState.d.ts +1 -1
  42. package/lib/uses/useCombinedRefs.d.ts +1 -1
  43. package/package.json +11 -11
  44. package/src/app/CommonApp.ts +2 -2
  45. package/src/app/Labels.ts +1 -1
  46. package/src/app/ServiceApp.ts +2 -2
  47. package/src/components/GridColumn.ts +10 -11
  48. package/src/components/GridLoader.ts +7 -7
  49. package/src/components/ScrollerGrid.tsx +66 -59
  50. package/src/components/ScrollerList.tsx +2 -4
  51. package/src/mu/AutocompleteExtendedProps.ts +15 -12
  52. package/src/mu/ComboBox.tsx +25 -21
  53. package/src/mu/DataGridEx.tsx +19 -18
  54. package/src/mu/DataGridRenderers.tsx +1 -1
  55. package/src/mu/DnDList.tsx +2 -2
  56. package/src/mu/ListMoreDisplay.tsx +2 -2
  57. package/src/mu/MUGlobal.ts +5 -5
  58. package/src/mu/OptionGroup.tsx +29 -27
  59. package/src/mu/ResponsibleContainer.tsx +18 -21
  60. package/src/mu/ScrollerListEx.tsx +24 -20
  61. package/src/mu/SearchOptionGroup.tsx +2 -3
  62. package/src/mu/SelectBool.tsx +13 -5
  63. package/src/mu/SelectEx.tsx +27 -20
  64. package/src/mu/TableEx.tsx +61 -59
  65. package/src/mu/Tiplist.tsx +20 -17
  66. package/src/mu/pages/CommonPageProps.ts +1 -1
  67. package/src/mu/pages/DataGridPage.tsx +14 -10
  68. package/src/mu/pages/DataGridPageProps.ts +16 -13
  69. package/src/mu/pages/FixedListPage.tsx +1 -1
  70. package/src/mu/pages/ListPage.tsx +1 -1
  71. package/src/mu/pages/ListPageProps.ts +4 -3
  72. package/src/mu/pages/ResponsivePage.tsx +5 -4
  73. package/src/mu/pages/ResponsivePageProps.ts +9 -6
  74. package/src/mu/pages/SearchPageProps.ts +5 -3
  75. package/src/mu/pages/TablePage.tsx +1 -1
  76. package/src/mu/pages/TablePageProps.ts +4 -3
  77. package/src/mu/pages/ViewPage.tsx +8 -6
  78. package/src/states/IState.ts +1 -1
  79. package/src/states/UserState.ts +1 -1
  80. package/src/uses/useCombinedRefs.ts +3 -3
@@ -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
  }
@@ -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: {}, reference?: setLabelsReference) => void;
64
+ const setLabels: (labels: DataTypes.StringRecord, reference?: setLabelsReference) => void;
65
65
  }
@@ -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 {} = {}>(data?: D, showLoading?: boolean): Promise<boolean>;
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 interface GridCellFormatterProps<T> {
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 interface GridCellRendererProps<T, P = any> extends GridCellFormatterProps<T> {
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 interface GridHeaderCellRendererProps<T, P = any> {
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 interface GridColumnRenderProps {
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 interface GridColumn<T> {
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 interface GridJsonData extends Omit<GridLoadDataProps, 'data'> {
26
- }
25
+ export declare type GridJsonData = Omit<GridLoadDataProps, 'data'>;
27
26
  /**
28
27
  * Grid data load props
29
28
  */
30
- export interface GridLoadDataProps {
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 interface GridLoader<T> {
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 interface GridLoaderStates<T> extends GridLoadDataProps {
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,8 +1,9 @@
1
+ import { DataTypes } from '@etsoo/shared';
1
2
  import React from 'react';
2
3
  import { Align, GridChildComponentProps, VariableSizeGridProps } from 'react-window';
3
4
  import { GridMethodRef } from '../mu/GridMethodRef';
4
5
  import { GridLoader, GridLoaderStates } from './GridLoader';
5
- export interface ScrollerGridItemRendererProps<T> extends Omit<GridChildComponentProps<T>, 'data'> {
6
+ export declare type ScrollerGridItemRendererProps<T> = Omit<GridChildComponentProps<T>, 'data'> & {
6
7
  /**
7
8
  * Selected items
8
9
  */
@@ -11,11 +12,11 @@ export interface ScrollerGridItemRendererProps<T> extends Omit<GridChildComponen
11
12
  * Data
12
13
  */
13
14
  data?: T;
14
- }
15
+ };
15
16
  /**
16
17
  * Scroller vertical grid props
17
18
  */
18
- export interface ScrollerGridProps<T> extends GridLoader<T>, Omit<VariableSizeGridProps<T>, 'children' | 'rowCount' | 'rowHeight' | 'ref'> {
19
+ export declare type ScrollerGridProps<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> = GridLoader<T> & Omit<VariableSizeGridProps<T>, 'children' | 'rowCount' | 'rowHeight' | 'ref'> & {
19
20
  /**
20
21
  * Default order by asc
21
22
  * @default true
@@ -31,9 +32,8 @@ export interface ScrollerGridProps<T> extends GridLoader<T>, Omit<VariableSizeGr
31
32
  headerRenderer?: (states: GridLoaderStates<T>) => React.ReactNode;
32
33
  /**
33
34
  * Id field
34
- * @default id
35
35
  */
36
- idField?: string & keyof T;
36
+ idField?: D;
37
37
  /**
38
38
  * Item renderer
39
39
  */
@@ -50,7 +50,7 @@ export interface ScrollerGridProps<T> extends GridLoader<T>, Omit<VariableSizeGr
50
50
  * Returns the height of the specified row.
51
51
  */
52
52
  rowHeight?: ((index: number) => number) | number;
53
- }
53
+ };
54
54
  /**
55
55
  * Scroller grid forward ref
56
56
  */
@@ -109,4 +109,4 @@ export interface ScrollerGridForwardRef extends GridMethodRef {
109
109
  * @param props Props
110
110
  * @returns Component
111
111
  */
112
- export declare const ScrollerGrid: <T extends Record<string, unknown>>(props: ScrollerGridProps<T>) => JSX.Element;
112
+ export declare const ScrollerGrid: <T extends object, D extends DataTypes.Keys<T, string | number> = DataTypes.Keys<T, string | number>>(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 Record<string, any>>(props: ScrollerListProps<T>) => JSX.Element;
62
+ export declare const ScrollerList: <T extends object>(props: ScrollerListProps<T>) => JSX.Element;
63
63
  export {};
@@ -4,15 +4,11 @@ import { ChangeEventHandler } from 'react';
4
4
  /**
5
5
  * Autocomplete extended props
6
6
  */
7
- export interface AutocompleteExtendedProps<T extends Record<string, unknown>> extends Omit<AutocompleteProps<T, undefined, false, false>, 'renderInput' | 'options'> {
8
- /**
9
- * Id field, default is id
10
- */
11
- idField?: string & keyof T;
7
+ export declare type AutocompleteExtendedProps<T extends object, D extends DataTypes.Keys<T>> = Omit<AutocompleteProps<T, undefined, false, false>, 'renderInput' | 'options'> & {
12
8
  /**
13
9
  * Id value
14
10
  */
15
- idValue?: DataTypes.IdType;
11
+ idValue?: T[D];
16
12
  /**
17
13
  * Autocomplete for the input
18
14
  */
@@ -61,4 +57,10 @@ export interface AutocompleteExtendedProps<T extends Record<string, unknown>> ex
61
57
  * Is search field?
62
58
  */
63
59
  search?: boolean;
64
- }
60
+ } & (T extends {
61
+ id: DataTypes.IdType;
62
+ } ? {
63
+ idField?: D;
64
+ } : {
65
+ idField: D;
66
+ });
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { IdLabelDto } from '@etsoo/appscript';
2
+ import { DataTypes } from '@etsoo/shared';
3
3
  import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
4
4
  /**
5
5
  * ComboBox props
6
6
  */
7
- export interface ComboBoxProps<T extends {}> extends AutocompleteExtendedProps<T> {
7
+ export declare type ComboBoxProps<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> = AutocompleteExtendedProps<T, D> & {
8
8
  /**
9
9
  * Auto add blank item
10
10
  */
@@ -13,10 +13,6 @@ export interface ComboBoxProps<T extends {}> extends AutocompleteExtendedProps<T
13
13
  * Data readonly
14
14
  */
15
15
  dataReadonly?: boolean;
16
- /**
17
- * Label field
18
- */
19
- labelField?: string & keyof T;
20
16
  /**
21
17
  * Load data callback
22
18
  */
@@ -29,10 +25,16 @@ export interface ComboBoxProps<T extends {}> extends AutocompleteExtendedProps<T
29
25
  * Array of options.
30
26
  */
31
27
  options?: ReadonlyArray<T>;
32
- }
28
+ } & (T extends {
29
+ label: string;
30
+ } ? {
31
+ labelField?: D;
32
+ } : {
33
+ labelField: D;
34
+ });
33
35
  /**
34
36
  * ComboBox
35
37
  * @param props Props
36
38
  * @returns Component
37
39
  */
38
- export declare function ComboBox<T extends {} = IdLabelDto>(props: ComboBoxProps<T>): JSX.Element;
40
+ export declare function ComboBox<T extends object = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: ComboBoxProps<T, D>): JSX.Element;
@@ -12,7 +12,7 @@ import { ReactUtils } from '../app/ReactUtils';
12
12
  */
13
13
  export function ComboBox(props) {
14
14
  // Destruct
15
- const { search = false, autoAddBlankItem = search, idField = 'id', idValue, inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, defaultValue, label, labelField = 'label', loadData, onLoadData, name, inputAutoComplete = 'off', options, dataReadonly = true, readOnly, onChange, openOnFocus = true, value, getOptionLabel = (option) => String(Reflect.get(option, labelField)), sx = { minWidth: '150px' }, ...rest } = props;
15
+ const { search = false, autoAddBlankItem = search, idField = 'id', idValue, inputError, inputHelperText, inputMargin, inputOnChange, inputRequired, inputVariant, defaultValue, label, labelField = 'label', loadData, onLoadData, name, inputAutoComplete = 'off', options, dataReadonly = true, readOnly, onChange, openOnFocus = true, value, getOptionLabel = (option) => `${option[labelField]}`, sx = { minWidth: '150px' }, ...rest } = props;
16
16
  // Value input ref
17
17
  const inputRef = React.createRef();
18
18
  // Options state
@@ -27,7 +27,7 @@ export function ComboBox(props) {
27
27
  }, [JSON.stringify(options), propertyWay]);
28
28
  // Local default value
29
29
  let localValue = idValue != null
30
- ? localOptions.find((o) => Reflect.get(o, idField) === idValue)
30
+ ? localOptions.find((o) => o[idField] === idValue)
31
31
  : defaultValue !== null && defaultValue !== void 0 ? defaultValue : value;
32
32
  if (localValue === undefined)
33
33
  localValue = null;
@@ -36,7 +36,7 @@ export function ComboBox(props) {
36
36
  const [stateValue, setStateValue] = React.useState(null);
37
37
  // Current id value
38
38
  // One time calculation for input's default value (uncontrolled)
39
- const localIdValue = stateValue && Reflect.get(stateValue, idField);
39
+ const localIdValue = stateValue && stateValue[idField];
40
40
  React.useEffect(() => {
41
41
  if (localValue != null)
42
42
  setStateValue(localValue);
@@ -68,7 +68,7 @@ export function ComboBox(props) {
68
68
  const input = inputRef.current;
69
69
  if (input) {
70
70
  // Update value
71
- const newValue = value != null ? `${Reflect.get(value, idField)}` : '';
71
+ const newValue = value != null ? `${value[idField]}` : '';
72
72
  if (newValue !== input.value) {
73
73
  // Different value, trigger change event
74
74
  ReactUtils.triggerChange(input, newValue, false);
@@ -97,8 +97,8 @@ export function ComboBox(props) {
97
97
  }, []);
98
98
  // Layout
99
99
  return (React.createElement("div", null,
100
- React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: localIdValue !== null && localIdValue !== void 0 ? localIdValue : '', readOnly: true, onChange: inputOnChange }),
101
- React.createElement(Autocomplete, { value: stateValue, getOptionLabel: getOptionLabel, isOptionEqualToValue: (option, value) => Reflect.get(option, idField) === Reflect.get(value, idField), onChange: (event, value, reason, details) => {
100
+ React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: `${localIdValue !== null && localIdValue !== void 0 ? localIdValue : ''}`, readOnly: true, onChange: inputOnChange }),
101
+ React.createElement(Autocomplete, { value: stateValue, getOptionLabel: getOptionLabel, isOptionEqualToValue: (option, value) => option[idField] === value[idField], onChange: (event, value, reason, details) => {
102
102
  // Set value
103
103
  setInputValue(value);
104
104
  // Custom
@@ -1,3 +1,4 @@
1
+ import { DataTypes } from '@etsoo/shared';
1
2
  import React from 'react';
2
3
  import { GridColumn } from '../components/GridColumn';
3
4
  import { GridLoaderStates } from '../components/GridLoader';
@@ -6,17 +7,17 @@ import { MouseEventWithDataHandler } from './MUGlobal';
6
7
  /**
7
8
  * Footer item renderer props
8
9
  */
9
- export interface DataGridExFooterItemRendererProps<T extends Record<string, any>> {
10
+ export declare type DataGridExFooterItemRendererProps<T extends object> = {
10
11
  column: GridColumn<T>;
11
12
  index: number;
12
13
  states: GridLoaderStates<T>;
13
14
  cellProps: any;
14
15
  checkable: boolean;
15
- }
16
+ };
16
17
  /**
17
18
  * Extended DataGrid with VariableSizeGrid props
18
19
  */
19
- export interface DataGridExProps<T extends Record<string, any>> extends Omit<ScrollerGridProps<T>, 'itemRenderer' | 'columnCount' | 'columnWidth' | 'width'> {
20
+ export declare type DataGridExProps<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> = Omit<ScrollerGridProps<T, D>, 'itemRenderer' | 'columnCount' | 'columnWidth' | 'width'> & {
20
21
  /**
21
22
  * Alternating colors for odd/even rows
22
23
  */
@@ -77,7 +78,7 @@ export interface DataGridExProps<T extends Record<string, any>> extends Omit<Scr
77
78
  * Width
78
79
  */
79
80
  width?: number;
80
- }
81
+ };
81
82
  /**
82
83
  * Extended datagrid columns calculation
83
84
  * @param columns
@@ -92,4 +93,4 @@ export declare function DataGridExCalColumns<T>(columns: GridColumn<T>[]): {
92
93
  * @param props Props
93
94
  * @returns Component
94
95
  */
95
- export declare function DataGridEx<T extends Record<string, any>>(props: DataGridExProps<T>): JSX.Element;
96
+ export declare function DataGridEx<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<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
  }
@@ -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 {}, K extends DataTypes.Keys<D>> {
46
+ export interface DnDListPros<D extends object, K extends DataTypes.Keys<D>> {
47
47
  /**
48
48
  * Get list item style callback
49
49
  */
@@ -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 {}, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ListMoreDisplayProps<T, F>): JSX.Element;
35
+ export declare function ListMoreDisplay<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ListMoreDisplayProps<T, F>): JSX.Element;
@@ -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: {}, adjust: number | {}, field?: string): {};
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: {}, updateFunc: (value: number) => string): {};
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: {}, theme: Theme): number;
94
+ static getSpace(spaces: object, theme: Theme): number;
95
95
  /**
96
96
  * Update object number properties with theme
97
97
  * @param input Input object
@@ -1,31 +1,22 @@
1
1
  /// <reference types="react" />
2
- import { IdLabelDto } from '@etsoo/appscript';
3
2
  import { DataTypes } from '@etsoo/shared';
4
3
  import { FormControlProps } from '@mui/material';
5
4
  /**
6
5
  * OptionGroup props
7
6
  */
8
- export interface OptionGroupProps<T extends Record<string, any> = IdLabelDto, D extends DataTypes.IdType = string> extends Omit<FormControlProps<'fieldset'>, 'defaultValue'> {
7
+ export declare type OptionGroupProps<T extends object = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> = Omit<FormControlProps<'fieldset'>, 'defaultValue'> & {
9
8
  /**
10
9
  * Default value
11
10
  */
12
- defaultValue?: D | D[];
11
+ defaultValue?: T[D] | T[D][];
13
12
  /**
14
13
  * Get option label function
15
14
  */
16
15
  getOptionLabel?: (option: T) => string;
17
- /**
18
- * Id field, default is id
19
- */
20
- idField?: string & keyof T;
21
16
  /**
22
17
  * Label
23
18
  */
24
19
  label?: string;
25
- /**
26
- * Label field, default is label
27
- */
28
- labelField?: string & keyof T;
29
20
  /**
30
21
  * Multiple choose item
31
22
  */
@@ -37,7 +28,7 @@ export interface OptionGroupProps<T extends Record<string, any> = IdLabelDto, D
37
28
  /**
38
29
  * On value change handler
39
30
  */
40
- onValueChange?: (value: D | D[] | undefined) => void;
31
+ onValueChange?: (value: T[D] | T[D][] | undefined) => void;
41
32
  /**
42
33
  * Array of options.
43
34
  */
@@ -50,10 +41,22 @@ export interface OptionGroupProps<T extends Record<string, any> = IdLabelDto, D
50
41
  * Display group of elements in a compact row
51
42
  */
52
43
  row?: boolean;
53
- }
44
+ } & (T extends {
45
+ id: DataTypes.IdType;
46
+ } ? {
47
+ idField?: D;
48
+ } : {
49
+ idField: D;
50
+ }) & (T extends {
51
+ label: string;
52
+ } ? {
53
+ labelField?: D;
54
+ } : {
55
+ labelField: D;
56
+ });
54
57
  /**
55
58
  * OptionGroup
56
59
  * @param props Props
57
60
  * @returns Component
58
61
  */
59
- export declare function OptionGroup<T extends Record<string, unknown> = IdLabelDto, D extends DataTypes.IdType = string>(props: OptionGroupProps<T, D>): JSX.Element;
62
+ export declare function OptionGroup<T extends object = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: OptionGroupProps<T, D>): JSX.Element;
@@ -10,7 +10,7 @@ import { ScrollerListExInnerItemRendererProps, ScrollerListExItemSize } from './
10
10
  /**
11
11
  * ResponsibleContainer props
12
12
  */
13
- export interface ResponsibleContainerProps<T extends {}, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate> extends Omit<DataGridExProps<T>, 'height' | 'itemKey' | 'loadData' | 'mRef' | 'onScroll' | 'onItemsRendered'> {
13
+ export declare type ResponsibleContainerProps<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = DataTypes.Keys<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: {}, hasFields: boolean, dataGrid?: boolean) => SxProps<Theme>;
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 {}, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate>(props: ResponsibleContainerProps<T, F>): JSX.Element;
89
+ export declare function ResponsibleContainer<T extends object, F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: ResponsibleContainerProps<T, F, D>): JSX.Element;
@@ -1,3 +1,4 @@
1
+ import { DataTypes } from '@etsoo/shared';
1
2
  import React from 'react';
2
3
  import { ListChildComponentProps } from 'react-window';
3
4
  import { ScrollerListProps } from '../components/ScrollerList';
@@ -21,7 +22,7 @@ export interface ScrollerListExInnerItemRendererProps<T> extends ListChildCompon
21
22
  /**
22
23
  * Default margins
23
24
  */
24
- margins: {};
25
+ margins: object;
25
26
  }
26
27
  /**
27
28
  * Extended ScrollerList ItemSize type
@@ -29,19 +30,15 @@ export interface ScrollerListExInnerItemRendererProps<T> extends ListChildCompon
29
30
  * 2. Static sets
30
31
  * 3. Dynamic calculation
31
32
  */
32
- export declare type ScrollerListExItemSize = ((index: number) => [number, number] | [number, number, {}]) | [number, number] | [number, {}, boolean?];
33
+ export declare type ScrollerListExItemSize = ((index: number) => [number, number] | [number, number, object]) | [number, number] | [number, object, boolean?];
33
34
  /**
34
35
  * Extended ScrollerList Props
35
36
  */
36
- export interface ScrollerListExProps<T> extends Omit<ScrollerListProps<T>, 'itemRenderer' | 'itemSize'> {
37
+ export declare type ScrollerListExProps<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> = Omit<ScrollerListProps<T>, 'itemRenderer' | 'itemSize'> & {
37
38
  /**
38
39
  * Alternating colors for odd/even rows
39
40
  */
40
41
  alternatingColors?: [string?, string?];
41
- /**
42
- * Id field
43
- */
44
- idField?: string & keyof T;
45
42
  /**
46
43
  * Inner item renderer
47
44
  */
@@ -50,6 +47,11 @@ export interface ScrollerListExProps<T> extends Omit<ScrollerListProps<T>, 'item
50
47
  * Item renderer
51
48
  */
52
49
  itemRenderer?: (props: ListChildComponentProps<T>) => React.ReactElement;
50
+ /**
51
+ * Id field
52
+ * Failed: D extends { id: DataTypes.IdType } ? { idField?: D } : { idField: D }
53
+ */
54
+ idField?: D;
53
55
  /**
54
56
  * Item size, a function indicates its a variable size list
55
57
  */
@@ -70,10 +72,10 @@ export interface ScrollerListExProps<T> extends Omit<ScrollerListProps<T>, 'item
70
72
  * Selected color
71
73
  */
72
74
  selectedColor?: string;
73
- }
75
+ };
74
76
  /**
75
77
  * Extended ScrollerList
76
78
  * @param props Props
77
79
  * @returns Component
78
80
  */
79
- export declare function ScrollerListEx<T extends Record<string, unknown>>(props: ScrollerListExProps<T>): JSX.Element;
81
+ export declare function ScrollerListEx<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: ScrollerListExProps<T, D>): JSX.Element;
@@ -112,7 +112,7 @@ export function ScrollerListEx(props) {
112
112
  return selected;
113
113
  };
114
114
  // Destruct
115
- const { alternatingColors = [undefined, undefined], className, idField = 'id', innerItemRenderer, itemSize, itemKey = (index, data) => { var _a; return (_a = DataTypes.getValue(data, idField)) !== null && _a !== void 0 ? _a : index; }, itemRenderer = (itemProps) => {
115
+ const { alternatingColors = [undefined, undefined], className, idField = 'id', innerItemRenderer, itemSize, itemKey = (index, data) => { var _a; return (_a = DataTypes.getIdValue1(data, idField)) !== null && _a !== void 0 ? _a : index; }, itemRenderer = (itemProps) => {
116
116
  const [itemHeight, space, margins] = calculateItemSize(itemProps.index);
117
117
  return defaultItemRenderer({
118
118
  itemHeight,