@etsoo/react 1.5.77 → 1.5.80

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 (83) hide show
  1. package/__tests__/mu/ComboBox.tsx +30 -0
  2. package/__tests__/mu/NotifierMUTests.tsx +1 -1
  3. package/__tests__/mu/SelectEx.tsx +26 -0
  4. package/lib/app/CommonApp.d.ts +2 -2
  5. package/lib/app/Labels.d.ts +1 -1
  6. package/lib/app/ServiceApp.d.ts +2 -2
  7. package/lib/components/GridColumn.d.ts +10 -10
  8. package/lib/components/GridLoader.d.ts +7 -8
  9. package/lib/components/ScrollerGrid.d.ts +6 -7
  10. package/lib/components/ScrollerList.d.ts +2 -2
  11. package/lib/mu/AutocompleteExtendedProps.d.ts +4 -4
  12. package/lib/mu/ComboBox.d.ts +5 -5
  13. package/lib/mu/DataGridEx.d.ts +6 -6
  14. package/lib/mu/DataGridRenderers.d.ts +1 -1
  15. package/lib/mu/DnDList.d.ts +2 -2
  16. package/lib/mu/ItemList.d.ts +6 -5
  17. package/lib/mu/ItemList.js +4 -12
  18. package/lib/mu/ListMoreDisplay.d.ts +2 -2
  19. package/lib/mu/MUGlobal.d.ts +5 -5
  20. package/lib/mu/OptionGroup.d.ts +8 -8
  21. package/lib/mu/ResponsibleContainer.d.ts +6 -6
  22. package/lib/mu/ScrollerListEx.d.ts +11 -10
  23. package/lib/mu/SearchOptionGroup.d.ts +2 -2
  24. package/lib/mu/SelectBool.d.ts +2 -3
  25. package/lib/mu/SelectBool.js +1 -1
  26. package/lib/mu/SelectEx.d.ts +8 -8
  27. package/lib/mu/SelectEx.js +3 -3
  28. package/lib/mu/TableEx.d.ts +4 -4
  29. package/lib/mu/Tiplist.d.ts +4 -4
  30. package/lib/mu/Tiplist.js +1 -3
  31. package/lib/mu/pages/CommonPageProps.d.ts +1 -1
  32. package/lib/mu/pages/DataGridPage.d.ts +2 -2
  33. package/lib/mu/pages/DataGridPageProps.d.ts +3 -3
  34. package/lib/mu/pages/FixedListPage.d.ts +2 -2
  35. package/lib/mu/pages/ListPage.d.ts +2 -2
  36. package/lib/mu/pages/ListPageProps.d.ts +1 -2
  37. package/lib/mu/pages/ResponsivePage.d.ts +2 -2
  38. package/lib/mu/pages/ResponsivePageProps.d.ts +3 -3
  39. package/lib/mu/pages/SearchPageProps.d.ts +2 -2
  40. package/lib/mu/pages/TablePage.d.ts +2 -2
  41. package/lib/mu/pages/TablePageProps.d.ts +1 -2
  42. package/lib/mu/pages/ViewPage.d.ts +5 -4
  43. package/lib/states/IState.d.ts +1 -1
  44. package/lib/uses/useCombinedRefs.d.ts +1 -1
  45. package/package.json +12 -12
  46. package/src/app/CommonApp.ts +2 -2
  47. package/src/app/Labels.ts +1 -1
  48. package/src/app/ServiceApp.ts +2 -2
  49. package/src/components/GridColumn.ts +10 -11
  50. package/src/components/GridLoader.ts +7 -7
  51. package/src/components/ScrollerGrid.tsx +66 -62
  52. package/src/components/ScrollerList.tsx +2 -2
  53. package/src/mu/AutocompleteExtendedProps.ts +9 -9
  54. package/src/mu/ComboBox.tsx +20 -12
  55. package/src/mu/DataGridEx.tsx +15 -15
  56. package/src/mu/DataGridRenderers.tsx +1 -1
  57. package/src/mu/DnDList.tsx +2 -2
  58. package/src/mu/ItemList.tsx +28 -25
  59. package/src/mu/ListMoreDisplay.tsx +2 -2
  60. package/src/mu/MUGlobal.ts +5 -5
  61. package/src/mu/OptionGroup.tsx +22 -14
  62. package/src/mu/ResponsibleContainer.tsx +15 -20
  63. package/src/mu/ScrollerListEx.tsx +21 -20
  64. package/src/mu/SearchOptionGroup.tsx +11 -5
  65. package/src/mu/SelectBool.tsx +7 -14
  66. package/src/mu/SelectEx.tsx +25 -19
  67. package/src/mu/TableEx.tsx +53 -53
  68. package/src/mu/Tiplist.tsx +11 -10
  69. package/src/mu/pages/CommonPageProps.ts +1 -1
  70. package/src/mu/pages/DataGridPage.tsx +15 -11
  71. package/src/mu/pages/DataGridPageProps.ts +17 -14
  72. package/src/mu/pages/FixedListPage.tsx +6 -5
  73. package/src/mu/pages/ListPage.tsx +6 -5
  74. package/src/mu/pages/ListPageProps.ts +5 -3
  75. package/src/mu/pages/ResponsivePage.tsx +6 -5
  76. package/src/mu/pages/ResponsivePageProps.ts +10 -7
  77. package/src/mu/pages/SearchPageProps.ts +5 -3
  78. package/src/mu/pages/TablePage.tsx +6 -5
  79. package/src/mu/pages/TablePageProps.ts +5 -3
  80. package/src/mu/pages/ViewPage.tsx +8 -6
  81. package/src/states/IState.ts +1 -1
  82. package/src/states/UserState.ts +1 -1
  83. package/src/uses/useCombinedRefs.ts +3 -3
@@ -1,11 +1,11 @@
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';
5
5
  import { ScrollerGridForwardRef } from '../../components/ScrollerGrid';
6
6
  import useCombinedRefs from '../../uses/useCombinedRefs';
7
7
  import { useDimensions } from '../../uses/useDimensions';
8
- import { DataGridEx } from '../DataGridEx';
8
+ import { DataGridEx, DataGridExProps } from '../DataGridEx';
9
9
  import { MUGlobal } from '../MUGlobal';
10
10
  import { SearchBar } from '../SearchBar';
11
11
  import { CommonPage } from './CommonPage';
@@ -24,9 +24,10 @@ interface LocalStates {
24
24
  * @returns Component
25
25
  */
26
26
  export function DataGridPage<
27
- T,
28
- F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
29
- >(props: DataGridPageProps<T, F>) {
27
+ T extends object,
28
+ F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
29
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
30
+ >(props: DataGridPageProps<T, F, D>) {
30
31
  // Destruct
31
32
  const {
32
33
  adjustHeight,
@@ -52,11 +53,14 @@ export function DataGridPage<
52
53
  }
53
54
  );
54
55
 
55
- const refs = useCombinedRefs(mRef, (ref: ScrollerGridForwardRef) => {
56
- if (ref == null) return;
57
- states.ref = ref;
58
- //setStates({ ref });
59
- });
56
+ const refs = useCombinedRefs<ScrollerGridForwardRef>(
57
+ mRef,
58
+ (ref: ScrollerGridForwardRef | null) => {
59
+ if (ref == null) return;
60
+ states.ref = ref;
61
+ //setStates({ ref });
62
+ }
63
+ );
60
64
 
61
65
  // On submit callback
62
66
  const onSubmit = (data: FormData, _reset: boolean) => {
@@ -95,7 +99,7 @@ export function DataGridPage<
95
99
  if (gridHeight == null) return;
96
100
 
97
101
  return (
98
- <DataGridEx<T>
102
+ <DataGridEx<T, D>
99
103
  autoLoad={false}
100
104
  height={gridHeight}
101
105
  loadData={localLoadData}
@@ -1,21 +1,24 @@
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
 
5
5
  /**
6
6
  * DataGrid page props
7
7
  */
8
- export interface DataGridPageProps<T, F extends DataTypes.BasicTemplate>
9
- extends SearchPageProps<T, F>,
10
- Omit<DataGridExProps<T>, 'loadData' | 'height'> {
11
- /**
12
- * Height will be deducted
13
- * @param height Current calcuated height
14
- */
15
- adjustHeight?: (height: number) => number;
8
+ export type DataGridPageProps<
9
+ T extends object,
10
+ F extends DataTypes.BasicTemplate,
11
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
12
+ > = SearchPageProps<T, F> &
13
+ Omit<DataGridExProps<T, D>, 'loadData' | 'height'> & {
14
+ /**
15
+ * Height will be deducted
16
+ * @param height Current calcuated height
17
+ */
18
+ adjustHeight?: (height: number) => number;
16
19
 
17
- /**
18
- * Grid height
19
- */
20
- height?: number;
21
- }
20
+ /**
21
+ * Grid height
22
+ */
23
+ height?: number;
24
+ };
@@ -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,10 +17,11 @@ import { ListPageProps } from './ListPageProps';
17
17
  * @returns Component
18
18
  */
19
19
  export function FixedListPage<
20
- T extends {},
21
- F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
20
+ T extends object,
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';
@@ -16,9 +16,10 @@ import { ListPageProps } from './ListPageProps';
16
16
  * @returns Component
17
17
  */
18
18
  export function ListPage<
19
- T extends {},
20
- F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
21
- >(props: ListPageProps<T, F>) {
19
+ T extends object,
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}
@@ -5,6 +5,8 @@ import { SearchPageProps } from './SearchPageProps';
5
5
  /**
6
6
  * List page props
7
7
  */
8
- export interface ListPageProps<T, F extends DataTypes.BasicTemplate>
9
- extends SearchPageProps<T, F>,
10
- Omit<ScrollerListExProps<T>, 'loadData'> {}
8
+ export type ListPageProps<
9
+ T extends object,
10
+ F extends DataTypes.BasicTemplate,
11
+ D extends DataTypes.Keys<T>
12
+ > = SearchPageProps<T, F> & Omit<ScrollerListExProps<T, D>, 'loadData'>;
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, IdDefaultType } from '@etsoo/shared';
2
2
  import React from 'react';
3
3
  import { MUGlobal } from '../MUGlobal';
4
4
  import { ResponsibleContainer } from '../ResponsibleContainer';
@@ -11,9 +11,10 @@ import { ResponsePageProps } from './ResponsivePageProps';
11
11
  * @returns Component
12
12
  */
13
13
  export function ResponsivePage<
14
- T extends {},
15
- F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
16
- >(props: ResponsePageProps<T, F>) {
14
+ T extends object,
15
+ F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
16
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
17
+ >(props: ResponsePageProps<T, F, D>) {
17
18
  // Destruct
18
19
  const { pageProps = {}, ...rest } = props;
19
20
 
@@ -32,7 +33,7 @@ export function ResponsivePage<
32
33
  scrollContainer={scrollContainer}
33
34
  fabColumnDirection={direction}
34
35
  >
35
- <ResponsibleContainer<T, F>
36
+ <ResponsibleContainer<T, F, D>
36
37
  paddings={paddings}
37
38
  containerBoxSx={(paddings, hasField, _dataGrid) => {
38
39
  // Half
@@ -1,4 +1,4 @@
1
- import { DataTypes } from '@etsoo/shared';
1
+ import { DataTypes, IdDefaultType } from '@etsoo/shared';
2
2
  import { ListChildComponentProps } from 'react-window';
3
3
  import { GridMethodRef } from '../GridMethodRef';
4
4
  import {
@@ -10,11 +10,14 @@ import { DataGridPageProps } from './DataGridPageProps';
10
10
  /**
11
11
  * Response page props
12
12
  */
13
- export interface ResponsePageProps<T, F extends DataTypes.BasicTemplate>
14
- extends Omit<
15
- DataGridPageProps<T, F>,
16
- 'mRef' | 'itemKey' | 'onScroll' | 'onItemsRendered'
17
- > {
13
+ export type ResponsePageProps<
14
+ T extends object,
15
+ F extends DataTypes.BasicTemplate,
16
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
17
+ > = Omit<
18
+ DataGridPageProps<T, F, D>,
19
+ 'mRef' | 'itemKey' | 'onScroll' | 'onItemsRendered'
20
+ > & {
18
21
  /**
19
22
  * Min width to show Datagrid
20
23
  */
@@ -51,4 +54,4 @@ export interface ResponsePageProps<T, F extends DataTypes.BasicTemplate>
51
54
  * Quick action for double click or click under mobile
52
55
  */
53
56
  quickAction?: (data: T) => void;
54
- }
57
+ };
@@ -5,8 +5,10 @@ import { CommonPageProps } from './CommonPageProps';
5
5
  /**
6
6
  * Search page props
7
7
  */
8
- export interface SearchPageProps<T, F extends DataTypes.BasicTemplate>
9
- extends Omit<GridLoader<T>, 'loadData'> {
8
+ export type SearchPageProps<
9
+ T extends object,
10
+ F extends DataTypes.BasicTemplate
11
+ > = Omit<GridLoader<T>, 'loadData'> & {
10
12
  /**
11
13
  * Search fields
12
14
  */
@@ -34,4 +36,4 @@ export interface SearchPageProps<T, F extends DataTypes.BasicTemplate>
34
36
  * @default 100
35
37
  */
36
38
  sizeReadyMiliseconds?: number;
37
- }
39
+ };
@@ -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';
@@ -16,9 +16,10 @@ import { TablePageProps } from './TablePageProps';
16
16
  * @returns Component
17
17
  */
18
18
  export function TablePage<
19
- T extends {},
20
- F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
21
- >(props: TablePageProps<T, F>) {
19
+ T extends object,
20
+ F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate,
21
+ D extends DataTypes.Keys<T> = IdDefaultType<T>
22
+ >(props: TablePageProps<T, F, D>) {
22
23
  // Destruct
23
24
  const {
24
25
  columns,
@@ -88,7 +89,7 @@ export function TablePage<
88
89
  if (!isNaN(paddingBottom)) maxHeight -= paddingBottom;
89
90
 
90
91
  return (
91
- <TableEx<T>
92
+ <TableEx<T, D>
92
93
  autoLoad={false}
93
94
  columns={columns}
94
95
  loadData={localLoadData}
@@ -5,6 +5,8 @@ import { SearchPageProps } from './SearchPageProps';
5
5
  /**
6
6
  * Table page props
7
7
  */
8
- export interface TablePageProps<T, F extends DataTypes.BasicTemplate>
9
- extends SearchPageProps<T, F>,
10
- Omit<TableExProps<T>, 'loadData'> {}
8
+ export type TablePageProps<
9
+ T extends object,
10
+ F extends DataTypes.BasicTemplate,
11
+ D extends DataTypes.Keys<T>
12
+ > = SearchPageProps<T, F> & Omit<TableExProps<T, D>, 'loadData'>;
@@ -1,4 +1,4 @@
1
- import { Utils } from '@etsoo/shared';
1
+ import { DataTypes, Utils } from '@etsoo/shared';
2
2
  import {
3
3
  Grid,
4
4
  GridProps,
@@ -22,7 +22,7 @@ import { CommonPageProps } from './CommonPageProps';
22
22
  /**
23
23
  * View page display field
24
24
  */
25
- export interface ViewPageField<T extends {}> extends GridProps {
25
+ export interface ViewPageField<T extends object> extends GridProps {
26
26
  /**
27
27
  * Data field
28
28
  */
@@ -49,7 +49,7 @@ export interface ViewPageField<T extends {}> extends GridProps {
49
49
  renderProps?: GridColumnRenderProps;
50
50
  }
51
51
 
52
- type ViewPageFieldType<T> =
52
+ type ViewPageFieldType<T extends object> =
53
53
  | (string & keyof T)
54
54
  | [string & keyof T, GridDataType, GridColumnRenderProps?]
55
55
  | ViewPageField<T>;
@@ -57,7 +57,7 @@ type ViewPageFieldType<T> =
57
57
  /**
58
58
  * View page props
59
59
  */
60
- export interface ViewPageProps<T extends {}>
60
+ export interface ViewPageProps<T extends DataTypes.StringRecord>
61
61
  extends Omit<CommonPageProps, 'children'> {
62
62
  /**
63
63
  * Actions
@@ -101,7 +101,7 @@ function formatItemData(fieldData: unknown): string | undefined {
101
101
  return `${fieldData}`;
102
102
  }
103
103
 
104
- function getItemField<T>(
104
+ function getItemField<T extends object>(
105
105
  field: ViewPageFieldType<T>,
106
106
  data: T
107
107
  ): [React.ReactNode, React.ReactNode, GridProps] {
@@ -163,7 +163,9 @@ function getItemField<T>(
163
163
  * View page
164
164
  * @param props Props
165
165
  */
166
- export function ViewPage<T extends {}>(props: ViewPageProps<T>) {
166
+ export function ViewPage<T extends DataTypes.StringRecord>(
167
+ props: ViewPageProps<T>
168
+ ) {
167
169
  // Destruct
168
170
  const {
169
171
  actions,
@@ -4,7 +4,7 @@ import React, { ReactNode } from 'react';
4
4
  /**
5
5
  * State UI creator
6
6
  */
7
- export interface IUICreator<S extends IState, A extends IAction, P = {}> {
7
+ export interface IUICreator<S extends IState, A extends IAction, P = object> {
8
8
  (state: S, dispatch: React.Dispatch<A>, props: P): React.ReactElement;
9
9
  }
10
10
 
@@ -122,7 +122,7 @@ export class UserState<D extends IUser> {
122
122
  this.provider = provider;
123
123
  }
124
124
 
125
- private getChangedFields(input: {}, init: {}) {
125
+ private getChangedFields(input: object, init: object) {
126
126
  return Utils.objectUpdated(input, init, [
127
127
  'authorized',
128
128
  'seconds',
@@ -3,10 +3,10 @@
3
3
  * @param refs Refs
4
4
  * @returns Callback
5
5
  */
6
- export default function useCombinedRefs(
7
- ...refs: (React.Ref<unknown> | undefined)[]
6
+ export default function useCombinedRefs<T>(
7
+ ...refs: (React.Ref<T> | undefined)[]
8
8
  ) {
9
- return (target: unknown) => {
9
+ return (target: T | null) => {
10
10
  // Ignore null reference
11
11
  if (target == null) return;
12
12