@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,8 +10,10 @@ import { SearchField } from './SearchField';
10
10
  /**
11
11
  * Tiplist props
12
12
  */
13
- export interface TiplistProps<T extends {}, D extends DataTypes.Keys<T>>
14
- extends Omit<AutocompleteExtendedProps<T, D>, 'open'> {
13
+ export type TiplistProps<T extends object, D extends DataTypes.Keys<T>> = Omit<
14
+ AutocompleteExtendedProps<T, D>,
15
+ 'open'
16
+ > & {
15
17
  /**
16
18
  * Load data callback
17
19
  */
@@ -19,10 +21,10 @@ export interface TiplistProps<T extends {}, D extends DataTypes.Keys<T>>
19
21
  keyword?: string,
20
22
  id?: T[D]
21
23
  ) => PromiseLike<T[] | null | undefined>;
22
- }
24
+ };
23
25
 
24
26
  // Multiple states
25
- interface States<T extends {}> {
27
+ interface States<T extends object> {
26
28
  open: boolean;
27
29
  options: T[];
28
30
  value?: T | null;
@@ -35,7 +37,7 @@ interface States<T extends {}> {
35
37
  * @returns Component
36
38
  */
37
39
  export function Tiplist<
38
- T extends {} = DataTypes.IdLabelItem,
40
+ T extends object = DataTypes.IdLabelItem,
39
41
  D extends DataTypes.Keys<T> = DataTypes.Keys<T>
40
42
  >(props: TiplistProps<T, D>) {
41
43
  // Destruct
@@ -67,11 +69,10 @@ export function Tiplist<
67
69
 
68
70
  // Local value
69
71
  let localValue = value ?? defaultValue;
70
- if (localValue === undefined) localValue = null;
71
72
 
72
73
  // One time calculation for input's default value (uncontrolled)
73
74
  const localIdValue =
74
- idValue ?? DataTypes.getValue(localValue, idField ?? 'id');
75
+ idValue ?? DataTypes.getValue(localValue, idField as any);
75
76
 
76
77
  // Changable states
77
78
  const [states, stateUpdate] = React.useReducer(
@@ -218,7 +219,7 @@ export function Tiplist<
218
219
  onChange={inputOnChange}
219
220
  />
220
221
  {/* Previous input will reset first with "disableClearable = false", next input trigger change works */}
221
- <Autocomplete
222
+ <Autocomplete<T, undefined, false, false>
222
223
  filterOptions={(options, _state) => options}
223
224
  value={states.value}
224
225
  options={states.options}
@@ -52,7 +52,7 @@ export interface CommonPageProps extends Omit<ContainerProps, 'id'> {
52
52
  /**
53
53
  * Paddings
54
54
  */
55
- paddings?: {};
55
+ paddings?: Record<string, string | number>;
56
56
 
57
57
  /**
58
58
  * Scroll container
@@ -5,7 +5,7 @@ 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> = DataTypes.Keys<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}
@@ -5,17 +5,20 @@ import { SearchPageProps } from './SearchPageProps';
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> = DataTypes.Keys<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
+ };
@@ -17,7 +17,7 @@ import { ListPageProps } from './ListPageProps';
17
17
  * @returns Component
18
18
  */
19
19
  export function FixedListPage<
20
- T extends {},
20
+ T extends object,
21
21
  F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
22
22
  >(
23
23
  props: ListPageProps<T, F> & {
@@ -16,7 +16,7 @@ import { ListPageProps } from './ListPageProps';
16
16
  * @returns Component
17
17
  */
18
18
  export function ListPage<
19
- T extends {},
19
+ T extends object,
20
20
  F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
21
21
  >(props: ListPageProps<T, F>) {
22
22
  // Destruct
@@ -5,6 +5,7 @@ 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
+ > = SearchPageProps<T, F> & Omit<ScrollerListExProps<T>, 'loadData'>;
@@ -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> = DataTypes.Keys<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
@@ -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> = DataTypes.Keys<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
+ };
@@ -16,7 +16,7 @@ import { TablePageProps } from './TablePageProps';
16
16
  * @returns Component
17
17
  */
18
18
  export function TablePage<
19
- T extends {},
19
+ T extends object,
20
20
  F extends DataTypes.BasicTemplate = DataTypes.BasicTemplate
21
21
  >(props: TablePageProps<T, F>) {
22
22
  // Destruct
@@ -5,6 +5,7 @@ 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
+ > = SearchPageProps<T, F> & Omit<TableExProps<T>, '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