@etsoo/react 1.7.94 → 1.7.96

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 (93) hide show
  1. package/README.md +2 -1
  2. package/__tests__/EventWatcher.tsx +21 -21
  3. package/__tests__/ReactUtils.ts +4 -4
  4. package/__tests__/tsconfig.json +17 -17
  5. package/babel.config.json +8 -8
  6. package/lib/app/CoreConstants.js +2 -2
  7. package/lib/app/EventWatcher.d.ts +1 -1
  8. package/lib/app/EventWatcher.js +3 -5
  9. package/lib/app/InputDialogProps.d.ts +2 -2
  10. package/lib/app/ReactUtils.d.ts +2 -2
  11. package/lib/app/ReactUtils.js +20 -19
  12. package/lib/components/DnDList.d.ts +3 -3
  13. package/lib/components/DnDList.js +4 -4
  14. package/lib/components/DynamicRouter.d.ts +2 -2
  15. package/lib/components/DynamicRouter.js +2 -2
  16. package/lib/components/GridColumn.d.ts +6 -6
  17. package/lib/components/GridColumn.js +7 -7
  18. package/lib/components/GridLoader.d.ts +4 -4
  19. package/lib/components/GridLoader.js +2 -2
  20. package/lib/components/GridMethodRef.d.ts +2 -2
  21. package/lib/components/ListItemReact.d.ts +2 -2
  22. package/lib/components/ScrollRestoration.js +3 -3
  23. package/lib/components/ScrollerGrid.d.ts +7 -12
  24. package/lib/components/ScrollerGrid.js +13 -17
  25. package/lib/components/ScrollerList.d.ts +6 -10
  26. package/lib/components/ScrollerList.js +15 -14
  27. package/lib/custom/CustomFieldReact.d.ts +1 -1
  28. package/lib/index.d.ts +32 -32
  29. package/lib/index.js +31 -31
  30. package/lib/notifier/Notifier.d.ts +5 -5
  31. package/lib/notifier/Notifier.js +7 -7
  32. package/lib/states/CultureState.d.ts +3 -3
  33. package/lib/states/CultureState.js +3 -3
  34. package/lib/states/IState.d.ts +2 -2
  35. package/lib/states/PageState.d.ts +2 -2
  36. package/lib/states/PageState.js +2 -3
  37. package/lib/states/State.d.ts +3 -3
  38. package/lib/states/State.js +2 -2
  39. package/lib/states/UserState.d.ts +2 -2
  40. package/lib/states/UserState.js +5 -5
  41. package/lib/uses/useAsyncState.d.ts +1 -1
  42. package/lib/uses/useAsyncState.js +1 -1
  43. package/lib/uses/useCombinedRefs.js +2 -2
  44. package/lib/uses/useDelayedExecutor.d.ts +1 -1
  45. package/lib/uses/useDelayedExecutor.js +2 -2
  46. package/lib/uses/useDimensions.d.ts +1 -1
  47. package/lib/uses/useDimensions.js +3 -3
  48. package/lib/uses/useParamsEx.d.ts +1 -1
  49. package/lib/uses/useParamsEx.js +2 -2
  50. package/lib/uses/useRefs.d.ts +2 -2
  51. package/lib/uses/useRefs.js +1 -1
  52. package/lib/uses/useSearchParamsEx.d.ts +1 -1
  53. package/lib/uses/useSearchParamsEx.js +3 -3
  54. package/lib/uses/useTimeout.js +2 -2
  55. package/lib/uses/useWindowScroll.js +3 -3
  56. package/lib/uses/useWindowSize.js +4 -5
  57. package/package.json +72 -74
  58. package/src/app/CoreConstants.ts +8 -8
  59. package/src/app/EventWatcher.ts +50 -52
  60. package/src/app/InputDialogProps.ts +16 -16
  61. package/src/app/ReactUtils.ts +206 -208
  62. package/src/components/DnDList.tsx +268 -283
  63. package/src/components/DynamicRouter.tsx +35 -35
  64. package/src/components/GridColumn.ts +201 -201
  65. package/src/components/GridLoader.ts +121 -121
  66. package/src/components/GridMethodRef.ts +26 -26
  67. package/src/components/ListItemReact.ts +2 -2
  68. package/src/components/ScrollRestoration.tsx +24 -24
  69. package/src/components/ScrollerGrid.tsx +428 -448
  70. package/src/components/ScrollerList.tsx +320 -332
  71. package/src/custom/CustomFieldReact.ts +12 -12
  72. package/src/index.ts +35 -35
  73. package/src/notifier/Notifier.ts +229 -240
  74. package/src/states/CultureState.ts +51 -52
  75. package/src/states/IState.ts +19 -19
  76. package/src/states/PageState.ts +63 -66
  77. package/src/states/State.tsx +47 -51
  78. package/src/states/UserState.ts +98 -98
  79. package/src/uses/useAsyncState.ts +37 -39
  80. package/src/uses/useCombinedRefs.ts +16 -16
  81. package/src/uses/useDelayedExecutor.ts +8 -8
  82. package/src/uses/useDimensions.ts +102 -103
  83. package/src/uses/useParamsEx.ts +6 -6
  84. package/src/uses/useRefs.ts +6 -6
  85. package/src/uses/useSearchParamsEx.ts +13 -13
  86. package/src/uses/useTimeout.ts +17 -17
  87. package/src/uses/useWindowScroll.ts +43 -43
  88. package/src/uses/useWindowSize.ts +46 -49
  89. package/tsconfig.json +17 -17
  90. package/.eslintignore +0 -3
  91. package/.eslintrc.json +0 -38
  92. package/.prettierignore +0 -5
  93. package/.prettierrc +0 -6
@@ -1,5 +1,5 @@
1
- import { QueryPagingData } from '@etsoo/appscript';
2
- import { DataTypes, DomUtils } from '@etsoo/shared';
1
+ import { QueryPagingData } from "@etsoo/appscript";
2
+ import { DataTypes, DomUtils } from "@etsoo/shared";
3
3
 
4
4
  /**
5
5
  * Grid size
@@ -12,8 +12,8 @@ export type GridSize = number | ((input: number) => number);
12
12
  * @param input Input
13
13
  */
14
14
  export const GridSizeGet = (size: GridSize, input: number) => {
15
- if (typeof size === 'function') return size(input);
16
- return size;
15
+ if (typeof size === "function") return size(input);
16
+ return size;
17
17
  };
18
18
 
19
19
  /**
@@ -27,14 +27,14 @@ export type GridData = FormData | DataTypes.StringRecord;
27
27
  * @returns Json data
28
28
  */
29
29
  export function GridDataGet<F extends DataTypes.BasicTemplate>(
30
- props: GridLoadDataProps,
31
- template?: F
30
+ props: GridLoadDataProps,
31
+ template?: F
32
32
  ): GridJsonData & DataTypes.BasicTemplateType<F> {
33
- // Destruct
34
- const { data, ...rest } = props;
33
+ // Destruct
34
+ const { data, ...rest } = props;
35
35
 
36
- // DomUtils.dataAs(data, template);
37
- return { ...GridDataGetData(data, template), ...rest };
36
+ // DomUtils.dataAs(data, template);
37
+ return { ...GridDataGetData(data, template), ...rest };
38
38
  }
39
39
 
40
40
  /**
@@ -43,144 +43,144 @@ export function GridDataGet<F extends DataTypes.BasicTemplate>(
43
43
  * @returns Json data
44
44
  */
45
45
  export function GridDataGetData<F extends DataTypes.BasicTemplate>(
46
- data?: GridData,
47
- template?: F
46
+ data?: GridData,
47
+ template?: F
48
48
  ): DataTypes.BasicTemplateType<F> {
49
- // Clear form empty value
50
- if (data instanceof FormData) {
51
- DomUtils.clearFormData(data);
52
- }
49
+ // Clear form empty value
50
+ if (data instanceof FormData) {
51
+ DomUtils.clearFormData(data);
52
+ }
53
53
 
54
- // Conditions
55
- const conditions: DataTypes.BasicTemplateType<F> =
56
- data == null ? {} : DomUtils.dataAs(data, template ?? {}, true); // Set keepSource to true to hold form data, even they are invisible from the conditions
54
+ // Conditions
55
+ const conditions: DataTypes.BasicTemplateType<F> =
56
+ data == null ? {} : DomUtils.dataAs(data, template ?? {}, true); // Set keepSource to true to hold form data, even they are invisible from the conditions
57
57
 
58
- return conditions;
58
+ return conditions;
59
59
  }
60
60
 
61
61
  /**
62
62
  * Grid Json data
63
63
  */
64
- export type GridJsonData = Omit<GridLoadDataProps, 'data'>;
64
+ export type GridJsonData = Omit<GridLoadDataProps, "data">;
65
65
 
66
66
  /**
67
67
  * Grid data load props
68
68
  */
69
69
  export type GridLoadDataProps = {
70
- /**
71
- * Query paging data
72
- */
73
- queryPaging: QueryPagingData;
74
-
75
- /**
76
- * Data related
77
- */
78
- data?: GridData;
70
+ /**
71
+ * Query paging data
72
+ */
73
+ queryPaging: QueryPagingData;
74
+
75
+ /**
76
+ * Data related
77
+ */
78
+ data?: GridData;
79
79
  };
80
80
 
81
81
  /**
82
82
  * Grid data load partial props
83
83
  */
84
84
  export type GridLoadDataPartialProps = {
85
- /**
86
- * Query paging data
87
- */
88
- queryPaging?: Partial<QueryPagingData>;
89
-
90
- /**
91
- * Data related
92
- */
93
- data?: GridData;
85
+ /**
86
+ * Query paging data
87
+ */
88
+ queryPaging?: Partial<QueryPagingData>;
89
+
90
+ /**
91
+ * Data related
92
+ */
93
+ data?: GridData;
94
94
  };
95
95
 
96
96
  /**
97
97
  * Grid data loader
98
98
  */
99
99
  export interface GridLoader<T extends object> {
100
- /**
101
- * Auto load data, otherwise call reset
102
- * @default true
103
- */
104
- autoLoad?: boolean;
105
-
106
- /**
107
- * Default order by
108
- */
109
- defaultOrderBy?: string;
110
-
111
- /**
112
- * Batch size when load data, default will be calcuated with height and itemSize
113
- */
114
- loadBatchSize?: GridSize;
115
-
116
- /**
117
- * Load data
118
- */
119
- loadData: (props: GridLoadDataProps) => PromiseLike<T[] | null | undefined>;
120
-
121
- /**
122
- * Handler for init load
123
- * @param ref Ref
124
- * @returns Result
125
- */
126
- onInitLoad?: (
127
- ref: any
128
- ) => [T[], GridLoaderPartialStates<T>?] | null | undefined;
129
-
130
- /**
131
- * Handler for updating rows
132
- * @param rows Rows
133
- * @param state State
134
- */
135
- onUpdateRows?: (rows: T[], state: GridLoaderStates<T>) => void;
136
-
137
- /**
138
- * Threshold at which to pre-fetch data; default is half of loadBatchSize
139
- */
140
- threshold?: number | undefined;
100
+ /**
101
+ * Auto load data, otherwise call reset
102
+ * @default true
103
+ */
104
+ autoLoad?: boolean;
105
+
106
+ /**
107
+ * Default order by
108
+ */
109
+ defaultOrderBy?: Record<string, boolean>;
110
+
111
+ /**
112
+ * Batch size when load data, default will be calcuated with height and itemSize
113
+ */
114
+ loadBatchSize?: GridSize;
115
+
116
+ /**
117
+ * Load data
118
+ */
119
+ loadData: (props: GridLoadDataProps) => PromiseLike<T[] | null | undefined>;
120
+
121
+ /**
122
+ * Handler for init load
123
+ * @param ref Ref
124
+ * @returns Result
125
+ */
126
+ onInitLoad?: (
127
+ ref: any
128
+ ) => [T[], GridLoaderPartialStates<T>?] | null | undefined;
129
+
130
+ /**
131
+ * Handler for updating rows
132
+ * @param rows Rows
133
+ * @param state State
134
+ */
135
+ onUpdateRows?: (rows: T[], state: GridLoaderStates<T>) => void;
136
+
137
+ /**
138
+ * Threshold at which to pre-fetch data; default is half of loadBatchSize
139
+ */
140
+ threshold?: number | undefined;
141
141
  }
142
142
 
143
143
  type GridLoaderProps<T> = {
144
- /**
145
- * Auto load data, otherwise call reset
146
- * @default true
147
- */
148
- autoLoad: boolean;
149
-
150
- /**
151
- * Last loaded items
152
- */
153
- lastLoadedItems?: number;
154
-
155
- /**
156
- * All loaded items count
157
- */
158
- loadedItems: number;
159
-
160
- /**
161
- * Has next page?
162
- */
163
- hasNextPage: boolean;
164
-
165
- /**
166
- * Is next page loading?
167
- */
168
- isNextPageLoading: boolean;
169
-
170
- /**
171
- * Is mounted
172
- */
173
- isMounted?: boolean;
174
-
175
- /**
176
- * Selected items of id
177
- */
178
- selectedItems: T[];
179
-
180
- /**
181
- * Id cache
182
- */
183
- idCache: Record<any, null>;
144
+ /**
145
+ * Auto load data, otherwise call reset
146
+ * @default true
147
+ */
148
+ autoLoad: boolean;
149
+
150
+ /**
151
+ * Last loaded items
152
+ */
153
+ lastLoadedItems?: number;
154
+
155
+ /**
156
+ * All loaded items count
157
+ */
158
+ loadedItems: number;
159
+
160
+ /**
161
+ * Has next page?
162
+ */
163
+ hasNextPage: boolean;
164
+
165
+ /**
166
+ * Is next page loading?
167
+ */
168
+ isNextPageLoading: boolean;
169
+
170
+ /**
171
+ * Is mounted
172
+ */
173
+ isMounted?: boolean;
174
+
175
+ /**
176
+ * Selected items of id
177
+ */
178
+ selectedItems: T[];
179
+
180
+ /**
181
+ * Id cache
182
+ */
183
+ idCache: Record<any, null>;
184
184
  };
185
185
 
186
186
  /**
@@ -192,4 +192,4 @@ export type GridLoaderStates<T> = GridLoadDataProps & GridLoaderProps<T>;
192
192
  * Grid loader states
193
193
  */
194
194
  export type GridLoaderPartialStates<T> = GridLoadDataPartialProps &
195
- Partial<GridLoaderProps<T>>;
195
+ Partial<GridLoaderProps<T>>;
@@ -1,36 +1,36 @@
1
- import { Align } from 'react-window';
2
- import { GridLoaderPartialStates } from './GridLoader';
1
+ import { Align } from "react-window";
2
+ import { GridLoaderPartialStates } from "./GridLoader";
3
3
 
4
4
  /**
5
5
  * Grid method ref
6
6
  */
7
7
  export interface GridMethodRef<T> {
8
- /**
9
- * Delete item at the index
10
- * @param index Index
11
- */
12
- delete(index: number): T | undefined;
8
+ /**
9
+ * Delete item at the index
10
+ * @param index Index
11
+ */
12
+ delete(index: number): T | undefined;
13
13
 
14
- /**
15
- * Insert the item at start
16
- * @param item Item
17
- * @param start Start position
18
- */
19
- insert(item: T, start: number): void;
14
+ /**
15
+ * Insert the item at start
16
+ * @param item Item
17
+ * @param start Start position
18
+ */
19
+ insert(item: T, start: number): void;
20
20
 
21
- /**
22
- * Reset
23
- * @param add Additional data
24
- */
25
- reset(add?: GridLoaderPartialStates<T>): void;
21
+ /**
22
+ * Reset
23
+ * @param add Additional data
24
+ */
25
+ reset(add?: GridLoaderPartialStates<T>): void;
26
26
 
27
- /**
28
- * Scroll to the specified offset (scrollTop or scrollLeft, depending on the direction prop).
29
- */
30
- scrollToRef(scrollOffset: number): void;
27
+ /**
28
+ * Scroll to the specified offset (scrollTop or scrollLeft, depending on the direction prop).
29
+ */
30
+ scrollToRef(scrollOffset: number): void;
31
31
 
32
- /**
33
- * Scroll to the specified item.
34
- */
35
- scrollToItemRef(index: number, align?: Align): void;
32
+ /**
33
+ * Scroll to the specified item.
34
+ */
35
+ scrollToItemRef(index: number, align?: Align): void;
36
36
  }
@@ -1,5 +1,5 @@
1
- import { ListItem } from '@etsoo/appscript';
2
- import React from 'react';
1
+ import { ListItem } from "@etsoo/appscript";
2
+ import React from "react";
3
3
 
4
4
  /**
5
5
  * React list item
@@ -1,6 +1,6 @@
1
- import React from 'react';
2
- import { useLocation } from 'react-router-dom';
3
- import { IScrollPos, useWindowScroll } from '../uses/useWindowScroll';
1
+ import React from "react";
2
+ import { useLocation } from "react-router-dom";
3
+ import { IScrollPos, useWindowScroll } from "../uses/useWindowScroll";
4
4
 
5
5
  const urls: Record<string, IScrollPos | undefined> = {};
6
6
 
@@ -8,30 +8,30 @@ const urls: Record<string, IScrollPos | undefined> = {};
8
8
  * Scroll restoration
9
9
  */
10
10
  export function ScrollRestoration() {
11
- // Location key
12
- const { key } = useLocation();
11
+ // Location key
12
+ const { key } = useLocation();
13
13
 
14
- // Mounted
15
- const mounted = React.useRef(false);
14
+ // Mounted
15
+ const mounted = React.useRef(false);
16
16
 
17
- // Detect scroll
18
- const data = useWindowScroll();
19
- if (mounted.current) {
20
- urls[key] = data;
21
- }
17
+ // Detect scroll
18
+ const data = useWindowScroll();
19
+ if (mounted.current) {
20
+ urls[key] = data;
21
+ }
22
22
 
23
- // Setup
24
- React.useEffect(() => {
25
- const pos = urls[key];
26
- if (pos) {
27
- window.scrollTo(pos.x, pos.y);
28
- }
23
+ // Setup
24
+ React.useEffect(() => {
25
+ const pos = urls[key];
26
+ if (pos) {
27
+ window.scrollTo(pos.x, pos.y);
28
+ }
29
29
 
30
- mounted.current = true;
31
- return () => {
32
- mounted.current = false;
33
- };
34
- }, [key]);
30
+ mounted.current = true;
31
+ return () => {
32
+ mounted.current = false;
33
+ };
34
+ }, [key]);
35
35
 
36
- return <React.Fragment />;
36
+ return <React.Fragment />;
37
37
  }