@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
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { IdLabelDto } from '@etsoo/appscript';
3
2
  import { DataTypes } from '@etsoo/shared';
4
3
  import { OptionGroupProps } from './OptionGroup';
5
4
  /**
@@ -7,4 +6,4 @@ import { OptionGroupProps } from './OptionGroup';
7
6
  * @param props Props
8
7
  * @returns Component
9
8
  */
10
- export declare function SearchOptionGroup<T extends Record<string, any> = IdLabelDto, D extends DataTypes.IdType = string>(props: OptionGroupProps<T, D>): JSX.Element;
9
+ export declare function SearchOptionGroup<T extends object = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: OptionGroupProps<T, D>): JSX.Element;
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { IdLabelDto } from '@etsoo/appscript';
2
+ import { DataTypes } from '@etsoo/shared';
3
3
  import { SelectExProps } from './SelectEx';
4
4
  /**
5
5
  * SelectBool props
6
6
  */
7
- export interface SelectBoolProps extends Omit<SelectExProps<IdLabelDto<string>>, 'options' | 'loadData'> {
7
+ export interface SelectBoolProps extends Omit<SelectExProps<DataTypes.IdLabelItem<string>>, 'options' | 'loadData'> {
8
8
  }
9
9
  /**
10
10
  * SelectBool (yes/no)
@@ -18,5 +18,5 @@ export function SelectBool(props) {
18
18
  if (autoAddBlankItem)
19
19
  Utils.addBlankItem(options);
20
20
  // Layout
21
- return React.createElement(SelectEx, { options: options, search: search, ...rest });
21
+ return (React.createElement(SelectEx, { options: options, search: search, ...rest }));
22
22
  }
@@ -1,26 +1,18 @@
1
1
  import { SelectProps } from '@mui/material';
2
2
  import React from 'react';
3
- import { IdLabelDto } from '@etsoo/appscript';
3
+ import { DataTypes } from '@etsoo/shared';
4
4
  /**
5
5
  * Extended select component props
6
6
  */
7
- export interface SelectExProps<T extends {}> extends Omit<SelectProps, 'labelId' | 'input' | 'native'> {
7
+ export declare type SelectExProps<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> = Omit<SelectProps, 'labelId' | 'input' | 'native'> & {
8
8
  /**
9
9
  * Auto add blank item
10
10
  */
11
11
  autoAddBlankItem?: boolean;
12
- /**
13
- * Id field, default is id
14
- */
15
- idField?: string & keyof T;
16
12
  /**
17
13
  * Item icon renderer
18
14
  */
19
15
  itemIconRenderer?: (id: unknown) => React.ReactNode;
20
- /**
21
- * Label field, default is label
22
- */
23
- labelField?: ((option: T) => string) | (string & keyof T);
24
16
  /**
25
17
  * Load data callback
26
18
  */
@@ -41,10 +33,22 @@ export interface SelectExProps<T extends {}> extends Omit<SelectProps, 'labelId'
41
33
  * Is search case?
42
34
  */
43
35
  search?: boolean;
44
- }
36
+ } & (T extends {
37
+ id: DataTypes.IdType;
38
+ } ? {
39
+ idField?: D;
40
+ } : {
41
+ idField: D;
42
+ }) & (T extends {
43
+ label: string;
44
+ } ? {
45
+ labelField?: ((option: T) => string) | D;
46
+ } : {
47
+ labelField: ((option: T) => string) | D;
48
+ });
45
49
  /**
46
50
  * Extended select component
47
51
  * @param props Props
48
52
  * @returns Component
49
53
  */
50
- export declare function SelectEx<T extends {} = IdLabelDto>(props: SelectExProps<T>): JSX.Element;
54
+ export declare function SelectEx<T extends object = DataTypes.IdLabelItem, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: SelectExProps<T, D>): JSX.Element;
@@ -71,13 +71,13 @@ export function SelectEx(props) {
71
71
  };
72
72
  // Get option id
73
73
  const getId = (option) => {
74
- return Reflect.get(option, idField);
74
+ return option[idField];
75
75
  };
76
76
  // Get option label
77
77
  const getLabel = (option) => {
78
78
  return typeof labelField === 'function'
79
79
  ? labelField(option)
80
- : Reflect.get(option, labelField);
80
+ : new String(option[labelField]);
81
81
  };
82
82
  // Refs
83
83
  const divRef = React.useRef();
@@ -1,3 +1,4 @@
1
+ import { DataTypes } from '@etsoo/shared';
1
2
  import { TableProps } from '@mui/material';
2
3
  import React from 'react';
3
4
  import { GridColumn } from '../components/GridColumn';
@@ -19,7 +20,7 @@ export interface TableExMethodRef extends GridMethodRef {
19
20
  /**
20
21
  * Extended table props
21
22
  */
22
- export interface TableExProps<T extends Record<string, any>> extends TableProps, GridLoader<T> {
23
+ export declare type TableExProps<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>> = TableProps & GridLoader<T> & {
23
24
  /**
24
25
  * Alternating colors for odd/even rows
25
26
  */
@@ -32,10 +33,6 @@ export interface TableExProps<T extends Record<string, any>> extends TableProps,
32
33
  * Header cells background color and font color
33
34
  */
34
35
  headerColors?: [string?, string?];
35
- /**
36
- * Id field
37
- */
38
- idField?: string & keyof T;
39
36
  /**
40
37
  * Max height
41
38
  */
@@ -56,10 +53,16 @@ export interface TableExProps<T extends Record<string, any>> extends TableProps,
56
53
  * Header and bottom height
57
54
  */
58
55
  otherHeight?: number;
59
- }
56
+ } & (T extends {
57
+ id: DataTypes.IdType;
58
+ } ? {
59
+ idField?: D;
60
+ } : {
61
+ idField: D;
62
+ });
60
63
  /**
61
64
  * Extended Table
62
65
  * @param props Props
63
66
  * @returns Component
64
67
  */
65
- export declare function TableEx<T extends Record<string, unknown>>(props: TableExProps<T>): JSX.Element;
68
+ export declare function TableEx<T extends object, D extends DataTypes.Keys<T> = DataTypes.Keys<T>>(props: TableExProps<T, D>): JSX.Element;
package/lib/mu/TableEx.js CHANGED
@@ -259,8 +259,7 @@ export function TableEx(props) {
259
259
  columnIndex,
260
260
  cellProps
261
261
  })) : (React.createElement(React.Fragment, null, "\u00A0"));
262
- return (React.createElement(TableCell, { key: rowId.toString() +
263
- columnIndex, ...cellProps }, child));
262
+ return (React.createElement(TableCell, { key: `${rowId}${columnIndex}`, ...cellProps }, child));
264
263
  })));
265
264
  })))),
266
265
  React.createElement(TablePagination, { component: "div", showFirstButton: true, count: totalRows, rowsPerPage: batchSize, page: currentPage, onPageChange: handleChangePage, onRowsPerPageChange: handleChangeRowsPerPage, rowsPerPageOptions: [
@@ -1,19 +1,18 @@
1
1
  /// <reference types="react" />
2
- import { IdLabelDto } from '@etsoo/appscript';
3
2
  import { DataTypes } from '@etsoo/shared';
4
3
  import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
5
4
  /**
6
5
  * Tiplist props
7
6
  */
8
- export interface TiplistProps<T extends {}> extends Omit<AutocompleteExtendedProps<T>, 'open'> {
7
+ export declare type TiplistProps<T extends object, D extends DataTypes.Keys<T>> = Omit<AutocompleteExtendedProps<T, D>, 'open'> & {
9
8
  /**
10
9
  * Load data callback
11
10
  */
12
- loadData: (keyword?: string, id?: DataTypes.IdType) => PromiseLike<T[] | null | undefined>;
13
- }
11
+ loadData: (keyword?: string, id?: T[D]) => PromiseLike<T[] | null | undefined>;
12
+ };
14
13
  /**
15
14
  * Tiplist
16
15
  * @param props Props
17
16
  * @returns Component
18
17
  */
19
- export declare function Tiplist<T extends {} = IdLabelDto>(props: TiplistProps<T>): 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 : (localValue && Reflect.get(localValue, idField));
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 };
@@ -31,7 +29,7 @@ export function Tiplist(props) {
31
29
  value: null
32
30
  });
33
31
  // Input value
34
- const inputValue = React.useMemo(() => states.value && Reflect.get(states.value, idField), [states.value]);
32
+ const inputValue = React.useMemo(() => states.value && states.value[idField], [states.value]);
35
33
  React.useEffect(() => {
36
34
  if (localValue != null)
37
35
  stateUpdate({ value: localValue });
@@ -128,7 +126,7 @@ export function Tiplist(props) {
128
126
  }, []);
129
127
  // Layout
130
128
  return (React.createElement("div", null,
131
- React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: inputValue !== null && inputValue !== void 0 ? inputValue : '', readOnly: true, onChange: inputOnChange }),
129
+ React.createElement("input", { ref: inputRef, "data-reset": "true", type: "text", style: { display: 'none' }, name: name, value: `${inputValue !== null && inputValue !== void 0 ? inputValue : ''}`, readOnly: true, onChange: inputOnChange }),
132
130
  React.createElement(Autocomplete, { filterOptions: (options, _state) => options, value: states.value, options: states.options, onChange: (event, value, reason, details) => {
133
131
  // Set value
134
132
  setInputValue(value);
@@ -150,7 +148,7 @@ export function Tiplist(props) {
150
148
  if (loading)
151
149
  loadDataDirect(undefined, states.value == null
152
150
  ? undefined
153
- : Reflect.get(states.value, idField));
151
+ : states.value[idField]);
154
152
  }, onClose: () => {
155
153
  stateUpdate({
156
154
  open: false,
@@ -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.75",
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,11 +51,11 @@
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.78",
55
- "@etsoo/notificationbase": "^1.1.6",
56
- "@etsoo/shared": "^1.1.45",
57
- "@mui/icons-material": "^5.8.4",
58
- "@mui/material": "^5.10.1",
54
+ "@etsoo/appscript": "^1.2.82",
55
+ "@etsoo/notificationbase": "^1.1.7",
56
+ "@etsoo/shared": "^1.1.48",
57
+ "@mui/icons-material": "^5.10.2",
58
+ "@mui/material": "^5.10.2",
59
59
  "@types/pica": "^9.0.1",
60
60
  "@types/pulltorefreshjs": "^0.1.5",
61
61
  "@types/react": "^18.0.17",
@@ -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
+ };