@etsoo/react 1.8.11 → 1.8.13

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.
@@ -39,15 +39,16 @@ export declare function GridDataGetData<const T>(data?: GridData, template?: T,
39
39
  /**
40
40
  * Grid Json data
41
41
  */
42
- export type GridJsonData = Omit<GridLoadDataProps, "data">;
43
- /**
44
- * Grid data load props
45
- */
46
- export type GridLoadDataProps = {
42
+ export type GridJsonData = {
47
43
  /**
48
44
  * Query paging data
49
45
  */
50
46
  queryPaging: QueryPagingData;
47
+ };
48
+ /**
49
+ * Grid data load props
50
+ */
51
+ export type GridLoadDataProps = GridJsonData & {
51
52
  /**
52
53
  * Data related
53
54
  */
@@ -69,7 +70,7 @@ export type GridLoadDataPartialProps = {
69
70
  /**
70
71
  * Grid data loader
71
72
  */
72
- export interface GridLoader<T extends object> {
73
+ export type GridLoader<T extends object, P extends GridJsonData = GridLoadDataProps> = {
73
74
  /**
74
75
  * Auto load data, otherwise call reset
75
76
  * @default true
@@ -86,7 +87,7 @@ export interface GridLoader<T extends object> {
86
87
  /**
87
88
  * Load data
88
89
  */
89
- loadData: (props: GridLoadDataProps, lastItem?: T) => PromiseLike<T[] | null | undefined>;
90
+ loadData: (props: P, lastItem?: T) => PromiseLike<T[] | null | undefined>;
90
91
  /**
91
92
  * Handler for init load
92
93
  * @param ref Ref
@@ -103,7 +104,7 @@ export interface GridLoader<T extends object> {
103
104
  * Threshold at which to pre-fetch data; default is half of loadBatchSize
104
105
  */
105
106
  threshold?: number | undefined;
106
- }
107
+ };
107
108
  type GridLoaderProps<T> = {
108
109
  /**
109
110
  * Auto load data, otherwise call reset
@@ -21,7 +21,7 @@ export type ScrollerGridItemRendererProps<T> = Omit<GridChildComponentProps<T>,
21
21
  /**
22
22
  * Scroller vertical grid props
23
23
  */
24
- export interface ScrollerGridProps<T extends object> extends GridLoader<T>, Omit<VariableSizeGridProps<T>, "children" | "rowCount" | "rowHeight"> {
24
+ export type ScrollerGridProps<T extends object> = GridLoader<T> & Omit<VariableSizeGridProps<T>, "children" | "rowCount" | "rowHeight"> & {
25
25
  /**
26
26
  * Footer renderer
27
27
  */
@@ -50,7 +50,7 @@ export interface ScrollerGridProps<T extends object> extends GridLoader<T>, Omit
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
  */
@@ -6,7 +6,7 @@ import { GridMethodRef } from "./GridMethodRef";
6
6
  /**
7
7
  * Scroller vertical list props
8
8
  */
9
- export interface ScrollerListProps<T extends object> extends GridLoader<T>, Omit<ListProps<T>, "outerRef" | "height" | "width" | "children" | "itemCount"> {
9
+ export type ScrollerListProps<T extends object> = GridLoader<T> & Omit<ListProps<T>, "outerRef" | "height" | "width" | "children" | "itemCount"> & {
10
10
  /**
11
11
  * Methods ref
12
12
  */
@@ -35,7 +35,7 @@ export interface ScrollerListProps<T extends object> extends GridLoader<T>, Omit
35
35
  * Item size, a function indicates its a variable size list
36
36
  */
37
37
  itemSize: ((index: number) => number) | number;
38
- }
38
+ };
39
39
  /**
40
40
  * Scroller list ref
41
41
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.8.11",
3
+ "version": "1.8.13",
4
4
  "description": "TypeScript ReactJs UI Independent Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -81,17 +81,17 @@ export function GridDataGetData<const T>(
81
81
  /**
82
82
  * Grid Json data
83
83
  */
84
- export type GridJsonData = Omit<GridLoadDataProps, "data">;
85
-
86
- /**
87
- * Grid data load props
88
- */
89
- export type GridLoadDataProps = {
84
+ export type GridJsonData = {
90
85
  /**
91
86
  * Query paging data
92
87
  */
93
88
  queryPaging: QueryPagingData;
89
+ };
94
90
 
91
+ /**
92
+ * Grid data load props
93
+ */
94
+ export type GridLoadDataProps = GridJsonData & {
95
95
  /**
96
96
  * Data related
97
97
  */
@@ -116,7 +116,10 @@ export type GridLoadDataPartialProps = {
116
116
  /**
117
117
  * Grid data loader
118
118
  */
119
- export interface GridLoader<T extends object> {
119
+ export type GridLoader<
120
+ T extends object,
121
+ P extends GridJsonData = GridLoadDataProps
122
+ > = {
120
123
  /**
121
124
  * Auto load data, otherwise call reset
122
125
  * @default true
@@ -136,10 +139,7 @@ export interface GridLoader<T extends object> {
136
139
  /**
137
140
  * Load data
138
141
  */
139
- loadData: (
140
- props: GridLoadDataProps,
141
- lastItem?: T
142
- ) => PromiseLike<T[] | null | undefined>;
142
+ loadData: (props: P, lastItem?: T) => PromiseLike<T[] | null | undefined>;
143
143
 
144
144
  /**
145
145
  * Handler for init load
@@ -161,7 +161,7 @@ export interface GridLoader<T extends object> {
161
161
  * Threshold at which to pre-fetch data; default is half of loadBatchSize
162
162
  */
163
163
  threshold?: number | undefined;
164
- }
164
+ };
165
165
 
166
166
  type GridLoaderProps<T> = {
167
167
  /**
@@ -44,44 +44,48 @@ export type ScrollerGridItemRendererProps<T> = Omit<
44
44
  /**
45
45
  * Scroller vertical grid props
46
46
  */
47
- export interface ScrollerGridProps<T extends object>
48
- extends GridLoader<T>,
49
- Omit<VariableSizeGridProps<T>, "children" | "rowCount" | "rowHeight"> {
50
- /**
51
- * Footer renderer
52
- */
53
- footerRenderer?: (rows: T[], states: GridLoaderStates<T>) => React.ReactNode;
54
-
55
- /**
56
- * Header renderer
57
- */
58
- headerRenderer?: (states: GridLoaderStates<T>) => React.ReactNode;
59
-
60
- /**
61
- * Id field
62
- */
63
- idField?: DataTypes.Keys<T>;
64
-
65
- /**
66
- * Item renderer
67
- */
68
- itemRenderer: (props: ScrollerGridItemRendererProps<T>) => React.ReactElement;
69
-
70
- /**
71
- * Methods
72
- */
73
- mRef?: React.Ref<ScrollerGridForwardRef<T>>;
74
-
75
- /**
76
- * On items select change
77
- */
78
- onSelectChange?: (selectedItems: T[]) => void;
79
-
80
- /**
81
- * Returns the height of the specified row.
82
- */
83
- rowHeight?: ((index: number) => number) | number;
84
- }
47
+ export type ScrollerGridProps<T extends object> = GridLoader<T> &
48
+ Omit<VariableSizeGridProps<T>, "children" | "rowCount" | "rowHeight"> & {
49
+ /**
50
+ * Footer renderer
51
+ */
52
+ footerRenderer?: (
53
+ rows: T[],
54
+ states: GridLoaderStates<T>
55
+ ) => React.ReactNode;
56
+
57
+ /**
58
+ * Header renderer
59
+ */
60
+ headerRenderer?: (states: GridLoaderStates<T>) => React.ReactNode;
61
+
62
+ /**
63
+ * Id field
64
+ */
65
+ idField?: DataTypes.Keys<T>;
66
+
67
+ /**
68
+ * Item renderer
69
+ */
70
+ itemRenderer: (
71
+ props: ScrollerGridItemRendererProps<T>
72
+ ) => React.ReactElement;
73
+
74
+ /**
75
+ * Methods
76
+ */
77
+ mRef?: React.Ref<ScrollerGridForwardRef<T>>;
78
+
79
+ /**
80
+ * On items select change
81
+ */
82
+ onSelectChange?: (selectedItems: T[]) => void;
83
+
84
+ /**
85
+ * Returns the height of the specified row.
86
+ */
87
+ rowHeight?: ((index: number) => number) | number;
88
+ };
85
89
 
86
90
  /**
87
91
  * Scroller grid forward ref
@@ -21,47 +21,46 @@ import { GridMethodRef } from "./GridMethodRef";
21
21
  /**
22
22
  * Scroller vertical list props
23
23
  */
24
- export interface ScrollerListProps<T extends object>
25
- extends GridLoader<T>,
26
- Omit<
27
- ListProps<T>,
28
- "outerRef" | "height" | "width" | "children" | "itemCount" // Exclude these props, shoud be exisited otherwise will be failed
29
- > {
30
- /**
31
- * Methods ref
32
- */
33
- mRef?: React.Ref<ScrollerListForwardRef<T>>;
34
-
35
- /**
36
- * Outer div ref
37
- */
38
- oRef?: React.Ref<HTMLDivElement>;
39
-
40
- /**
41
- * Height of the list
42
- */
43
- height?: number;
44
-
45
- /**
46
- * Width of the list
47
- */
48
- width?: number | string;
49
-
50
- /**
51
- * Id field
52
- */
53
- idField?: DataTypes.Keys<T>;
54
-
55
- /**
56
- * Item renderer
57
- */
58
- itemRenderer: (props: ListChildComponentProps<T>) => React.ReactElement;
59
-
60
- /**
61
- * Item size, a function indicates its a variable size list
62
- */
63
- itemSize: ((index: number) => number) | number;
64
- }
24
+ export type ScrollerListProps<T extends object> = GridLoader<T> &
25
+ Omit<
26
+ ListProps<T>,
27
+ "outerRef" | "height" | "width" | "children" | "itemCount" // Exclude these props, shoud be exisited otherwise will be failed
28
+ > & {
29
+ /**
30
+ * Methods ref
31
+ */
32
+ mRef?: React.Ref<ScrollerListForwardRef<T>>;
33
+
34
+ /**
35
+ * Outer div ref
36
+ */
37
+ oRef?: React.Ref<HTMLDivElement>;
38
+
39
+ /**
40
+ * Height of the list
41
+ */
42
+ height?: number;
43
+
44
+ /**
45
+ * Width of the list
46
+ */
47
+ width?: number | string;
48
+
49
+ /**
50
+ * Id field
51
+ */
52
+ idField?: DataTypes.Keys<T>;
53
+
54
+ /**
55
+ * Item renderer
56
+ */
57
+ itemRenderer: (props: ListChildComponentProps<T>) => React.ReactElement;
58
+
59
+ /**
60
+ * Item size, a function indicates its a variable size list
61
+ */
62
+ itemSize: ((index: number) => number) | number;
63
+ };
65
64
 
66
65
  /**
67
66
  * Scroller list ref